Speculative Decoding: Why Acceleration Sometimes Slows Down Inference and How to Engineer It Effectively
This article explains why speculative decoding (and multi-token prediction) can speed up some inference workloads while slowing others down. It breaks down the draft-then-verify mechanism, shows how the acceptance rate governs the real speedup, and explains why a low acceptance rate can turn "optimization" into a net slowdown. It also covers performance characteristics on unified-memory hardware, the efficiency differences between dense and Mixture-of-Experts (MoE) models, a task-by-task evaluation methodology, and practical tuning guidelines so you can decide when to enable the technique and when to turn it off.
Introduction: When an “Acceleration Technique” Actually Slows Down Inference
As open-source large models iterate quickly, a class of inference-acceleration techniques known as speculative decoding (or multi-token prediction, MTP) has been widely integrated into mainstream inference frameworks. Its core promise is attractive: without sacrificing output quality, it produces multiple tokens in a single forward pass by “guessing first, verifying later,” thereby increasing decoding throughput.
In real engineering work, however, many developers have observed a counterintuitive phenomenon. After enabling speculative decoding, some tasks genuinely speed up, while others not only fail to improve but actually get slower, with end-to-end latency even rising. This is not an implementation bug; it is a consequence of the technique’s inherent applicability boundaries. Setting aside any specific product context, this article frames the problem as a general engineering question: under what conditions is speculative decoding effective, under what conditions does it fail, and how can it be evaluated and tuned scientifically?
1. How Speculative Decoding Works
At its core, speculative decoding is a two-phase collaboration between “draft” and “verify”:
- Draft phase: A lightweight draft source (which can be a small model, an extra prediction head, or the model’s own next-token prediction capability) cheaply generates several candidate tokens in sequence.
- Verification phase: The main model runs a single parallel forward pass over the candidate sequence, confirming at once which positions are acceptable.
- Corrective sampling: If a token is rejected partway through, a token is resampled from that position and all subsequent draft tokens are discarded, guaranteeing that the output distribution is strictly identical to independent decoding by the main model.
Illustrative code:
# Core speculative decoding loop (simplified illustration, not a specific framework implementation)def speculative_decode(draft, target, prefix, gamma=3):output = list(prefix)while not finished(output):# 1. Draft source proposes gamma candidate tokens at oncedraft_tokens = draft.propose(output, num=gamma)# 2. Target model verifies the candidate sequence in parallellogits = target.forward(output + draft_tokens)# 3. Accept/reject each positionaccepted = accept_or_reject(logits, draft_tokens)output.extend(accepted)# 4. Resample at the first rejected position, add one tokenif len(accepted) < gamma:output.append(resample_at(logits, len(accepted)))return output
The key point is that the draft phase adds almost no compute. What truly determines the payoff is how many draft tokens the verification phase can confirm in a single pass.
2. Acceptance Rate: The Core Variable Behind the Real Speedup
Let α be the independent probability that a token at each draft position is accepted (the acceptance rate), and let each round speculate at most γ tokens. The expected number of tokens produced per verification step is approximately:
E[tokens per step] = (1 - α^(γ+1)) / (1 - α)
This formula reveals two engineering intuitions:
- When α is high (say, above 0.8), a single verification pass confirms multiple tokens and the speedup is significant.
- When α is low (say, 0.5–0.6), drafts are frequently rejected, most of the parallel compute in the verification phase is wasted, and the expected output degrades to nearly 1.
More importantly, the acceptance rate is strongly correlated with task type. The following is a set of illustrative data used only to show the trend (not measured results from any specific product):
| Task type | Illustrative acceptance rate α | Relative speedup |
|---|---|---|
| Code generation | ~0.76 | 1.1x–1.2x |
| Retrieval-augmented QA | ~0.80 | ≈1.0x |
| Mathematical reasoning | ~0.61 | <1.0x |
| Creative writing | ~0.58 | noticeably slower |
The pattern is clear: tasks with more deterministic, more predictable generation (code, retrieval QA) accept drafts more readily; high-divergence tasks such as long-chain reasoning or open-ended writing see the draft diverge from the main model more often, and the speedup collapses accordingly.
3. Why a Low Acceptance Rate Makes It “Slower the More You Optimize”
Many developers are puzzled: even if every draft is rejected, isn’t the worst case simply “a wasted round, back to square one”? Why the net slowdown? There are three reasons:
- Overhead of the verification phase: Even when drafts are rejected, the main model still runs a parallel forward pass over the draft sequence. Compared to single-token decoding, this forward pass processes a longer sequence, with higher attention and KV-cache read/write costs—an expense that cannot be recovered.
- Cost of corrective sampling and scheduling: Every rejection triggers resampling, state rollback, and cache trimming. In naive implementations, these are serial, non-trivial extra operations.
- Imbalance in memory access and batching utilization: Parallel verification changes the memory-access pattern. If the hardware cannot fully exploit the longer sequence, you fall into the awkward situation of “no compute saved, more memory traffic incurred.”
So the payoff of speculative decoding is not monotonically positive; it is a function determined jointly by α, γ, and verification overhead. When α drops below a certain threshold, the net gain turns negative—this is exactly the root of “enabling it makes things slower.”
4. Performance Characteristics on Unified-Memory Architecture
On devices that use a unified memory architecture (where the CPU and accelerator share the same physical memory), speculative decoding’s behavior is further shaped by architectural traits:
- Unified memory reduces the cost of copying data between the processor and video memory, making memory bandwidth rather than compute the main bottleneck in the decoding phase.
- In this bandwidth-bound scenario, the main model’s decoding speed is often dictated by weight-read bandwidth. If speculative decoding can confirm multiple tokens at once, it amortizes the cost of each weight read, so the payoff in high-acceptance scenarios is amplified.
- Conversely, a low acceptance rate means weights are read repeatedly while producing little, wasting bandwidth heavily and making the slowdown more pronounced.
A practical observation is that on such architectures, sparse-activation models (such as Mixture-of-Experts) are often more efficient than dense models with an equivalent number of active parameters—because each token needs to read only a subset of expert weights, the weight-read volume drops significantly and decoding stays closer to the bandwidth ceiling. In a bandwidth-constrained environment, this is a decisive advantage.
5. Efficiency Differences Between Dense and MoE Models
Mixture-of-Experts (MoE) models use a routing mechanism so that each token activates only a subset of the expert networks, approaching the capability of a large model with a smaller “active parameter count.” At the inference level, this has two direct consequences:
- Lower weight-read volume during decoding: especially friendly to bandwidth-constrained unified-memory devices.
- More complex coupling with speculative decoding: if the draft source and the target model exhibit inconsistent routing behavior, the acceptance rate drops further and requires targeted tuning.
Therefore, when choosing an inference approach, you should not look at total parameter count alone, but consider jointly: active parameter count, the target hardware’s bandwidth/compute ratio, and whether speculative decoding is layered on top. Together, these three factors determine actual throughput.
6. How to Evaluate Speculative Decoding Scientifically
The key to avoiding “just turning it on by feel” is to build a per-task, comparable evaluation process:
- Fix a baseline: First measure decoding speed and end-to-end latency for each task category with speculation off (γ=0).
- Sweep γ values: Measure separately for γ=1,2,3,4, observe how the speedup curve varies with draft length, and find the optimum.
- Track acceptance rate per task: Record α separately for categories such as code, reasoning, writing, and QA to identify strong and weak scenarios.
- Align on end-to-end latency: A gain in decoding speed does not equal a gain in user experience; always look at end-to-end latency together, and avoid fixating on token/s while ignoring scheduling and sampling overhead.
- Average over multiple runs: Variance is large across different input distributions, so repeat measurements and report both the median and the variance.
A reusable minimal evaluation skeleton:
results = {}for task in ["coding", "reasoning", "writing", "qa"]:base = bench(model, task, gamma=0) # Baselinefor g in [1, 2, 3, 4]:spec = bench(model, task, gamma=g) # Speculative decodingresults[(task, g)] = {"speedup": spec.decode_tps / base.decode_tps,"latency_ratio": spec.latency / base.latency,"accept_rate": spec.accept_rate,}# Count it as a net gain only when both speedup and latency_ratio improve
7. Engineering Practice Recommendations
To use speculative decoding well, you can follow these principles:
- Toggle dynamically by task: enable it for high-determinism tasks such as code and retrieval QA; disable it or lower γ for low-acceptance tasks such as long-chain reasoning and open-ended writing.
- Tune the draft source: prefer a draft distribution that closely matches the target model; the higher the acceptance rate, the steadier the speedup.
- Match hardware characteristics: on bandwidth-constrained unified-memory devices, prioritize high acceptance and consider sparse-activation models to reduce weight-read volume.
- Use end-to-end latency as the yardstick: don’t fixate only on token throughput; users perceive overall response time.
- Establish regression evaluation: rerun per-task evaluation after any model or framework upgrade to prevent “optimizations” from introducing hidden slowdowns.
Conclusion
Speculative decoding is not a “free lunch”; it is an acceleration technique with clearly defined applicability boundaries. Its real payoff is determined jointly by the acceptance rate, draft length, verification overhead, and hardware architecture. Understanding this mechanism and building a scientific, per-task evaluation are what let speculative decoding deliver value in the right scenarios—rather than causing the confusion of “the more you optimize, the slower it gets.”
