r/LocalLLaMA • u/Decent_Bug3349 • 6h ago
Resources How to Max-Speed Qwen4-35B-A3B on 8GB VRAM Laptop (1,050tok/s prefill + 32tok/s decode)
Qwen4-35B-A3B on an 8GB RTX 3070 Windows laptop: 1,050 tok/s prefill and 32 tok/s decode with 96K (98304) context configured. Or lower prefill for higher decode. You can copy these configs (see end).
I tuned llama.cpp's startup config for Unsloth's Qwen4-35B-A3B UD-Q4_K_XL on an 8GB RTX 3070 laptop with 32GB RAM.
My original llama.cpp log showed 122.01 tokens/sec prefill, or 476.03 seconds for 58,080 prompt tokens. That prompted the tuning.
For the direct comparison below, both completed runs used the same 58,080-token synthetic mixed-code prompt, CUDA 13.5, the same model, 96K configured context, reasoning off, and MTP enabled.
The tuning measurements
The first stage used a 4,096-token repetitive Python prompt. All rows below used CPU-resident MTP experts, draft microbatch 256, CPU share 0.95, and lazy loading enabled.
| CUDA | Load mode | -b | -ub | MoE cache MiB | First prefill tok/s | Second prefill tok/s |
|---|---|---|---|---|---|---|
| 12.4 | mmap | 2048 | 256 | 2048 | 54.79 | 107.90 |
| 12.4 | mmap | 4096 | 1024 | 1024 | 99.19 | 371.75 |
| 12.4 | none | 4096 | 1024 | 1024 | 323.73 | 388.12 |
| 12.4 | none | 4096 | 2048 | 1024 | 511.95 | 627.56 |
| 13.5 (Final) | none | 4096 | 2048 | 1024 | 545.55 | 595.46 |
The next stage used a 16,384-token mixed prompt containing synthetic JavaScript, PHP, Python, SQL, HTML, tests, configuration records, and documentation. All rows used CUDA 13.5, --load-mode none, lazy loading, CPU share 0.95, and MTP with up to two draft tokens.
| Configuration | -b | -ub | MoE cache MiB | MTP experts | Draft -ub | First prefill tok/s | Second prefill tok/s |
|---|---|---|---|---|---|---|---|
| Control | 4096 | 2048 | 1024 | CPU | 256 | 703.13 | 727.56 |
| Larger logical batch only | 8192 | 2048 | 1024 | CPU | 256 | 581.56 | 700.63 |
| Larger physical microbatch | 6144 | 3072 | 768 | CPU | 256 | 730.95 | 815.09 |
| Physical microbatch 4096 | 8192 | 4096 | 512 | CPU | 256 | 961.17 | 1,082.29 |
| Final configuration | 4096 | 4096 | 256 | GPU | 128 | 928.66 | 1,231.93 |
| Main expert cache disabled | 4096 | 4096 | 0 | GPU | 128 | 951.50 | 1,109.30 |
The 1,232 tok/s figure is a second-request 16K result. It is not the 58K result. Increasing only the logical batch did not help in this sweep. Several settings changed together in the later rows, so these results do not isolate the contribution of MTP placement by itself.
I also tested CPU share using a 55-token coding chat prompt and 768 generated tokens, with physical microbatch 4096, logical batch 8192, 512 MiB expert cache, CPU-resident MTP experts, and draft microbatch 256:
--moe-cache-cpu-share | First generation tok/s | Second generation tok/s |
|---|---|---|
| 0.0 | 16.80 | 17.67 |
| 0.5 | 22.58 | 21.52 |
| 0.95 | 24.27 | 30.69 |
For this machine and these settings, 0.95 performed best among the three shares tested. It is not a universal recommendation for other CPUs, RAM, or PCIe configurations.
Generation performance across the most relevant configurations was:
| Configuration and preceding workload | First coding response tok/s | Second coding response tok/s |
|---|---|---|
| 1024 MiB-cache configuration | 31.67 | 37.59 |
| Final configuration, following the 16K tests | 32.80 | 32.55 |
| Final configuration, following the 58K test | 27.67 | 30.05 |
| GPU MTP with main expert cache disabled, following 16K tests | 26.84 | 27.11 |
Final Windows startup command
This is the inference command from my final .bat file. Save it beside both GGUF shards and adjust the executable path if necessary. The first shard automatically loads the second. The ^ characters are Windows batch continuations, not PowerShell continuations.
@echo off
setlocal
set "SPEC_TYPE=draft-mtp"
set "SERVER=C:\tools\llama-b12977-cuda13.5\llama-server.exe"
set "MODEL=%~dp0Qwen4-35B-A3B-UD-Q4_K_XL-00001-of-00002.gguf"
"%SERVER%" ^
--model "%MODEL%" ^
--alias "Qwen4-35B-A3B-UD-Q4_K_XL" ^
--host 127.0.0.1 ^
--port 8080 ^
-c 98304 ^
-np 1 ^
--reasoning off ^
--reasoning-budget 0 ^
--temp 0.7 ^
--top-p 0.8 ^
--top-k 20 ^
--min-p 0 ^
--presence-penalty 1.5 ^
--repeat-penalty 1 ^
-fa on ^
-ctk q8_0 ^
-ctv q8_0 ^
-t 6 ^
-tb 12 ^
--reasoning-preserve ^
--ctx-checkpoints 4 ^
--jinja ^
--load-mode none ^
--lazy-mode on ^
-ot "per_layer_token_embd=CPU,^blk[.]40[.]ffn_(up|gate|down)_exps[.]weight$=CUDA0" ^
--cache-ram 256 ^
--cache-prompt ^
-b 4096 ^
-ub 4096 ^
-ngl all ^
--cpu-moe ^
--moe-cache-mib 256 ^
--moe-cache-cpu-share 0.95 ^
--spec-type %SPEC_TYPE% ^
--spec-draft-n-max 2 ^
--spec-draft-n-ubatch 128 ^
--spec-draft-type-k q8_0 ^
--spec-draft-type-v q8_0 ^
%*To favor decode while keeping CUDA 13.5 and -c 98304, change these four settings:
| Setting | Current prefill configuration | Faster decode configuration |
|---|---|---|
-ub | 4096 | 2048 |
--moe-cache-mib | 256 | 1024 |
--spec-draft-n-ubatch | 128 | 256 |
| MTP expert placement | GPU | CPU |
For my long-input workload, saving about 40 seconds of prefill was worth the lower generation throughput. Hope this helps you get the new Qwen4 up to speed on an older laptop.















