Speculative Decoding: How Draft Models Accelerate Large Language Model Inference
This article explains speculative decoding, a technique that speeds up large language model (LLM) inference without changing model weights or sacrificing output quality. It starts by clarifying why the decode phase is bottlenecked by memory bandwidth rather than raw compute, then introduces the core idea of using a small, fast draft model to propose candidate tokens and a large, accurate target model to verify them in a single pass. The article covers how rejection sampling preserves the exact output distribution, the key metric of average acceptance length, the tradeoffs of draft length, the main drafting strategies, and practical guidance for deploying speculative decoding in inference frameworks. Readers will come away with a clear, engineering-oriented understanding of how the technique delivers faster inference on existing hardware.
1. The Performance Bottleneck of Token-by-Token Generation
LLM inference is usually divided into two phases: prefill and decode. After a user submits a prompt, the model processes the entire input in parallel during the prefill phase, computing attention and building the key-value cache (KV Cache). Because a large number of tokens are handled at once, this phase is primarily bound by compute (throughput).
The situation changes once generation enters the decode phase. Here, the model can only produce one token at a time: it reads the weights and existing KV Cache → computes → writes the new key and value → then repeats the same process for the next token. A single model may hold tens or even hundreds of gigabytes of weights, and generating each token requires moving that massive amount of data from memory into the compute units. At this point the bottleneck is often no longer compute, but memory bandwidth and data movement speed. This is a classic memory-bound process.
Understanding this point is key: during the decode phase, the compute units sit largely idle, and what actually slows things down is repeatedly moving the full set of weights. This also explains why simply upgrading a GPU’s raw compute does not necessarily yield a linear speedup, whereas optimizing the way tokens are generated can deliver far greater gains.
2. The Core Idea of Speculative Decoding
Speculative decoding starts from a simple observation: not every token is equally hard to predict. If a “small and fast” model can guess the easy-to-predict parts first, and a “large and accurate” target model then focuses on verifying them, a single forward pass through the target model can advance multiple positions at once.
- Draft model: small and fast, responsible for predicting several candidate tokens in a row;
- Target model: high precision and large in size, responsible for verifying the draft’s correctness in one pass.
For example, given the input “The cat”, a draft model might predict “sat on my lap” in sequence. The target model then uses a single forward pass to check the probability distributions at all of these candidate positions at once. If the first two tokens match the target model’s distribution, they are accepted directly; if the third is rejected, all candidates after it are discarded too, and the target model fills in a corrected token. Work that would otherwise require three or four rounds on the target model is compressed into a single verification round.
The key point is this: the cost of having the draft model generate candidates is far lower than the cost of the target model repeatedly reading the full set of weights. So even when occasional mistakes require a rollback, as long as the average gain is positive, overall throughput improves. This is the principle behind achieving faster inference without swapping out hardware.
3. How Correctness Is Guaranteed
Speculative decoding is not “approximation” or “cutting corners.” Through a mechanism called rejection sampling, the final output distribution is exactly the same as that of the target model. The intuition can be expressed with the following pseudocode:
# draft: draft model target: target modelprefix = generated prefixfor x_i in draft.propose(prefix): # the draft model proposes candidatesp = target.probs(x_i, prefix) # target model's probability at the candidate positionq = draft.probs(x_i, prefix) # probability given by the draft model itselfif uniform(0, 1) <= min(1.0, p / q):accept(x_i) # accept this tokenprefix = append(prefix, x_i)else:# rejection: resample a token from the adjusted distribution as a correctiony = sample(adjusted_distribution)prefix = append(prefix, y)break # end this verification roundelse:# when all tokens are accepted, the target model can sample one extra tokenprefix = append(prefix, target.sample(prefix))
This means the output distribution is mathematically equivalent, in expectation, to decoding token by token directly with the target model. The speedup comes from running the large model fewer times, not from sacrificing generation quality. This is what fundamentally sets speculative decoding apart from lossy compression approaches such as quantization and pruning.
4. The Key Metric: Average Acceptance Length
The core metric for measuring the speedup is the average acceptance length, meaning the average number of draft tokens the target model accepts per verification round.
- If the draft predicts 4 tokens at once and 3 of them are accepted, that is equivalent to advancing multiple positions with a single large-model computation;
- The longer the acceptance length, the higher the theoretical speedup, but the overhead of draft generation and verification also grows.
At an engineering level, this can be roughly understood as: actual speedup ≈ average acceptance length / (1 + the ratio of draft cost to target cost). This relationship shows that more drafts are not always better. There is an “optimal draft length” that is strongly tied to the task content.
5. More Drafts Do Not Necessarily Mean Faster
A common misconception is that “longer drafts are always better.” In reality, increasing the draft length introduces costs on two fronts:
- The draft model itself has to generate more tokens, so cumulative time increases;
- Once a position is rejected, all subsequent drafts are discarded, so the longer the draft, the greater the waste.
When the model faces high-entropy, high-uncertainty content (for example, open-ended creative writing or highly random dialogue), the acceptance rate drops noticeably, and an overly long draft ends up slowing things down overall. For this reason, draft length usually needs to be adjusted dynamically according to the task, or exposed as a configurable parameter, rather than kept fixed.
6. Different Forms of Drafting Strategies
The source of a “draft” is not limited to a separate small model. The industry has developed several implementation approaches, each with its own tradeoffs:
- Independent draft model: choose a smaller model that shares the target model’s vocabulary and has a similar structure. High distribution alignment typically leads to a better acceptance rate;
- Self-speculation: reuse the target model’s shallow-layer computations or skipped layers to generate drafts, requiring no extra model;
- Multi-head prediction: add extra prediction heads to the model to produce several candidate tokens in parallel;
- Retrieval / n-gram-based drafting: retrieve high-frequency fragments from the context or external corpora as candidates, which suits templated, highly repetitive scenarios.
These strategies differ significantly in hardware footprint, memory overhead, and acceptance rate, so the choice should be based on the actual deployment conditions and business workload.
7. Recommendations for Engineering Deployment
When integrating speculative decoding into an inference framework, focus on the following points:
- Draft model selection: share the same vocabulary and tokenizer as the target model wherever possible to reduce probability-conversion error and improve the acceptance rate;
- Dynamic draft length: adjust it adaptively based on the task and real-time acceptance rate, so that a fixed long draft does not drag things down in difficult scenarios;
- Batching and concurrency: in high-concurrency scenarios, the gains from speculative decoding are diluted, so you need to balance throughput against per-request latency;
- Metrics monitoring: bring the average acceptance length and actual speedup into your monitoring and alerting system, continuously observe performance under different workloads, and tune parameters in a timely manner.
It is worth emphasizing that speculative decoding neither changes the model weights nor compresses the model size, so it does not harm the final generation quality. What it optimizes is “the way tokens are generated,” turning many memory-bound serial small steps into a few batched verification steps. Combined with common cloud capabilities such as containerized deployment, logging services, and monitoring and alerting, teams can more smoothly gain inference speedups on their existing hardware, without additional hardware investment.
Conclusion
The core insight of speculative decoding is simple yet profound: since guessing one token at a time is too slow, let a small model batch-guess first and a large model verify all at once. It does not depend on new hardware, and it does not sacrifice generation quality, making it one of the most practical techniques for speeding up LLM inference today. Once you truly understand these three points, the average acceptance length, the draft-length tradeoff, and the correctness guarantee, you can apply this technique correctly and effectively in a real system.
