Optimizing local large language models on constrained hardware usually feels like a game of diminishing returns. When working with an 8GB VRAM setup, conventional wisdom points toward shrinking the model or buying a new GPU. However, systematic testing on the Qwen4-35B-A3B model (35B total parameters, 3B activated per token) running via llama.cpp (CUDA build) on an RTX 3070 Ti with 32GB of RAM proves otherwise. By carefully tuning speculative decoding and stacking minor configuration changes, generation speed rose from a baseline of 26.6 tok/s to 30.43 tok/s—a 14.4% improvement—without purchasing new hardware or reducing model size.
Every condition was evaluated using the same reasoning problem: counting numbers from 1 to 200 that are not divisible by 3, 5, or 7 (with a correct answer of 92). Generation speed is the average of three runs of 200-token generation at temperature 0, isolating speed as the sole variable.
Phase 1: Baseline and Initial Parameter Adjustments
In the first phase, the ggml-org Q4_K_M was used as the main model. Changing one setting at a time yielded the following generation speeds:
| Condition | Description | Generation (tok/s) |
|---|---|---|
| A | Baseline, no MTP | 26.46 |
| C1 | MTP (n-max 1) | 28.30 |
| B | MTP (n-max 2) | 28.02 |
| C4 | MTP (n-max 4) | 20.59 |
| D | MoE experts moved to GPU (without -cmoe) | 5.16 |
| D2 | MoE experts to GPU, with cache | 7.30 |
| E | KV cache quantized to q8_0 | 24.24 |
| F8 | 8 threads | 25.92 |
| F16 | 16 threads | 25.31 |
In this phase, MTP (multi-token prediction, serving as the speculative-decoding draft mechanism) successfully lifted performance when predicting a single token, but performance dropped rapidly as the prediction length increased.
Phase 2: Quantization Swaps and Detailed Tuning
Phase 2 shifted the main model to the Unsloth build (UD-Q4_K_M), then tested how it behaved with MTP at different prediction lengths:
| Condition | Description | Generation (tok/s) | Change vs Reference |
|---|---|---|---|
| U0 | UD-Q4_K_M alone | 24.42 | vs A, -7.7% |
| U1 | UD-Q4_K_M + MTP (n-max 1) | 29.24 | vs C1, +3.3% |
| N2 | U1 with n-max 2 | 25.77 | vs U1, -11.9% |
| N3 | U1 with n-max 3 | 23.93 | vs U1, -18.2% |
The Quantization Reversal
Head-to-head alone, UD-Q4_K_M achieves 24.42 tok/s, losing to the ggml baseline of 26.46 tok/s by -7.7%. However, when paired with MTP, UD + MTP reaches 29.24 tok/s, beating ggml + MTP (28.30 tok/s) by +3.3%.
The acceptance rates hint at why this occurs: UD + MTP registers an acceptance rate of 0.90, while ggml + MTP sits at 0.91, which is nearly identical. With equal acceptance, the number of tokens pulled per main-model pass is the same. The performance gap therefore stems from the main model's per-token cost: the UD build is slower alone due to a higher per-pass cost, meaning it gains relatively more when MTP extracts several tokens out of a single pass. While the exact mechanism cannot be proven from numbers alone, this is the most consistent explanation, and the measured conclusion stands either way.
For long-prompt processing, UD + MTP yields 297.88 tok/s versus ggml + MTP's 301.94 tok/s (nearly tied at -1.3%), and both successfully output the correct answer of 92. Consequently, there is no context-free answer to which quantization is fastest: use UD with MTP, but use ggml without MTP.
Acceptance Rates and the Danger of Over-Prediction
The acceptance rate—defined as the share of the draft model's predicted tokens that the main model accepts—dictates the practical limits of speculative decoding.
| Setting | Acceptance Rate | Generation Speed |
|---|---|---|
| n-max 1 | 0.90 to 0.93 | 29.24 tok/s (U1) |
| n-max 2 | 0.76 | 25.77 tok/s (N2) |
| n-max 3 | 0.55 | 23.93 tok/s (N3) |
| n-max 4 | 0.38 | 20.59 tok/s (C4) |
Raising n-max (the parameter determining how many tokens the draft predicts ahead) from 1 to 2 drops the acceptance rate from 0.90 to 0.76. At n-max 3 it falls to 0.55, and at n-max 4 it plummets to 0.38. Wrong predictions waste the compute spent on them, and this collapse in acceptance outweighs the benefit of predicting more tokens. As a result, speed falls as n-max rises: n-max 2 is -11.9% and n-max 3 is -18.2% against n-max 1's 29.24 tok/s.
There is one exception: n-max 3 yielded the fastest long-prompt processing of all conditions at 322.33 tok/s. Therefore, n-max 1 remains ideal for generation-heavy use, while n-max 3 is viable for long-prompt reading only.
Phase 3: Stacking Small Wins
Phase 3 successfully stacked three independent optimizations onto U1 (29.24 tok/s), each contributing roughly +3% on its own:
- Enabling flash attention (
-faon): 30.12 tok/s (+3.0%). - Updating llama.cpp from b12973 to b12977: 30.28 tok/s (+3.6%).
- Changing the MTP draft from ggml Q4_K_M to Unsloth Q8_0: 30.18 tok/s (+3.2%), which simultaneously pushed the acceptance rate to 0.93, the highest of all conditions.
Combining all three into the COMBO configuration achieved 30.43 tok/s (+4.1% vs U1). While the individual gains do not strictly add up linearly, the final throughput remains unreachable if any of the three components is missing.
The final configuration consists of the main model Unsloth UD-Q4_K_M, the draft Unsloth MTP Q8_0 at n-max 1, running on llama.cpp b12977 with -fa on and -ngl all -cmoe --fit on. Long-prompt processing for the COMBO setup reaches 300.93 tok/s (+1.0% vs U1) while still returning the correct answer of 92. This setup was also confirmed to run alongside other local models, though performance drops when system resources are shared.
The Honest Failures
Not every experimental change yielded a performance boost. Several adjustments that seemed promising in theory resulted in clear regressions:
- Moving MoE experts to the GPU: This was the largest failure, dropping generation speed to 5.16 tok/s—about one-fifth of the baseline. Moving the routed expert weights of the Mixture-of-Experts model into the 8GB VRAM left only 0.7 GB of free RAM, causing the system to enter memory thrashing. Condition D2 with cache reached only 7.30 tok/s. The rule that putting weights on the GPU increases speed only holds true when sufficient memory headroom exists.
-
KV cache quantization: Quantizing the KV cache to
q8_0resulted in 24.24 tok/s, representing an 8.4% degradation compared to the 26.46 baseline. - Thread counts: Adjusting thread counts degraded performance. Running 8 threads yielded 25.92 tok/s (-2.0%), and 16 threads yielded 25.31 tok/s (-4.3%). The default thread count was already optimal.
Breakdown and Conclusion
The total 14.4% performance leap from 26.6 to 30.43 tok/s breaks down into specific contributors: the initial introduction of MTP added +7.0%, the UD quantization swap combined with MTP added +3.3%, and the three stacked small wins contributed +4.1%. There was never a single massive jump. Furthermore, every change that "should" have been faster in theory—such as raising n-max above 1—failed because the acceptance rate collapsed.
On an 8GB-class setup, execution speed is decided not by brute-force model reduction, but by tuning the speculative-decoding acceptance rate and stacking compatible settings. Before investing in a new GPU, set n-max to 1 and measure your acceptance rate. The empirical data frequently points in the exact opposite direction of intuition.
Top comments (0)