Speculative Decoding Explained: How Draft Models Accelerate LLM Inference
Speculative decoding uses a small draft model to propose tokens that a larger target model verifies in parallel. This article explains why the approach can accelerate memory-bound decoding, how acceptance length affects performance, and what to consider when selecting a draft model, managing concurrency, and deploying without changing the target model’s output distribution.
Introduction: Same GPU, Different Inference Speeds
Imagine running two inference workloads on the same machine, using the same large language model and prompt. One finishes its response while the other is still generating tokens. In the scenario described here, the faster approach delivers nearly four times the generation speed for a single request and roughly twice the overall throughput as concurrency increases.
The difference is neither a hardware upgrade nor model quantization. It comes from changing how tokens are generated through speculative decoding, a technique built around a much smaller draft model.
Major LLM inference frameworks have increasingly added support for this approach, moving it from research into practical optimization for local inference and cloud deployments. Its actual benefits depend on the model pair and workload; the speedups above should not be treated as universal expectations.
This article explains the underlying mechanism, the factors that determine performance, and the engineering considerations involved in deployment.
1. Understanding the Bottleneck: Prefill vs. Decode
To understand why speculative decoding works, it helps to distinguish the two main stages of LLM inference: prefill and decode.
Prefill: Parallel Computation
When a user submits a prompt, the model processes the input tokens, computes attention, and builds the KV cache.
Because this stage handles hundreds or thousands of tokens together, its matrix operations offer substantial parallelism. GPU compute units can be used efficiently, so prefill is often primarily compute-bound.
Decode: Sequential Generation
During conventional autoregressive decoding, the model generates one token at a time. Each step involves:
- Reading model weights from GPU memory.
- Reading the existing KV cache.
- Running a forward pass and writing the new key and value data to the cache.
A 7-billion-parameter model can require well over 10 GB for its weights, depending on the numerical format. Larger models may require tens or hundreds of gigabytes.
For low-concurrency decoding, repeatedly accessing these weights creates substantial memory traffic. GPU memory bandwidth, rather than raw arithmetic capacity, often becomes the limiting factor. Much of the GPU’s compute capacity can remain underused.
That imbalance is the opportunity speculative decoding aims to exploit.
2. The Core Idea: A Small Model Proposes, a Large Model Verifies
If a target-model forward pass already incurs the cost of accessing its weights, can that pass verify several candidate tokens instead of advancing by only one?
Speculative decoding uses a small model to make inexpensive predictions, then lets the larger model evaluate those predictions together.
How the Process Works
The process has two main steps:
- Draft generation: The draft model generates several candidate tokens sequentially at relatively low cost.
- Parallel verification: The target model evaluates the candidate sequence in a single forward pass. An acceptance procedure checks candidates in order, retains an accepted prefix, and stops at the first rejection. The remaining draft tokens are discarded, and a correction token is sampled using the target model’s distribution and the rejection-sampling procedure.
For example, suppose the draft model proposes five tokens after a prompt. If the first three are accepted but the fourth is rejected, the system keeps the first three, discards the remaining draft candidates, and produces a correction token.
One target-model verification pass has therefore advanced the output by several positions that would otherwise require separate decoding steps.
Why the Trade-Off Can Pay Off
The costs are asymmetric:
- A draft model may have only a small fraction of the target model’s parameters, making several draft-generation steps cheaper than additional target-model passes.
- Verifying a short candidate sequence adds computation and KV-cache work, but allows the target model to process multiple positions together.
The technique is beneficial when the progress made during each verification round outweighs the added cost of drafting and verification. A sufficiently accurate, inexpensive draft model is therefore essential.
3. The Key Performance Metric: Average Acceptance Length
Speculative decoding adds work, so acceleration is not automatic. A central metric is average acceptance length: the average number of draft tokens accepted per verification round.
How Acceptance Length Affects Speed
Suppose the draft model proposes five tokens per round:
- If four are accepted on average, a target-model pass can advance the output by roughly five positions when the additional target-generated token is included.
- If candidates are frequently rejected early, the system makes little progress per round. Draft generation then becomes overhead and may make inference slower than ordinary decoding.
Acceptance length must therefore be considered alongside the time spent generating and verifying each draft.
What Affects Acceptance Length?
Alignment between draft and target distributions
The closer the two models’ predictions are, the more useful the drafts tend to be. Smaller models from the same family are often a practical starting point. In the standard shared-token setup described here, the models need matching vocabularies and tokenization.
Task type
More predictable workloads, such as code completion, structured output, and some factual question-answering tasks, can produce higher acceptance rates. Open-ended creative writing may be less predictable.
Sampling temperature
Lower-temperature generation is generally more deterministic and can make draft predictions easier to accept. The result still depends on how closely the models’ distributions align.
Number of draft tokens
Longer drafts create more opportunities to advance, but later candidates are useful only if the preceding candidates are accepted. Beyond a certain point, additional draft steps cost more than they save. Three to five candidate tokens is a practical starting range discussed here, not a universally optimal setting.
4. Engineering Considerations
Choosing a Draft Model
Start with a smaller model from the same family as the target model, checking that tokenization and vocabulary are compatible.
If no suitable smaller model is available, possible alternatives include:
- A distilled version of the target model.
- A lightweight model fine-tuned on outputs from the target model.
Draft-model latency matters as much as predictive accuracy. A larger draft model may improve acceptance while consuming enough time to cancel out the benefit.
The goal is not to maximize draft accuracy in isolation, but to find the best balance between drafting cost and accepted progress.
Single-Request Latency vs. Concurrent Throughput
Speculative decoding often offers its largest gains at low concurrency, when ordinary decoding leaves GPU compute capacity underused. This is the setting in which speedups approaching the introductory fourfold example may occur.
As concurrency increases, batching can use more of the GPU’s compute resources. Decoding may become less bandwidth-bound and more compute-bound, reducing the spare capacity available for speculative verification.
Throughput gains can therefore narrow, and they are not guaranteed at every load level. Production systems should evaluate whether to enable speculative decoding based on current concurrency and measured performance.
Preserving Output Quality
A correctly implemented speculative sampling algorithm uses rejection sampling to preserve the target model’s output distribution.
The draft model proposes candidates; it does not replace the target model as the authority over the output distribution. This distinguishes exact speculative decoding from potentially lossy techniques such as quantization or distillation used to replace the serving model.
Distributional equivalence does not mean every run must produce the same text. It means sampling follows the same distribution as the target model under the corresponding decoding settings.
Local and Cloud Deployment
For local inference, a supporting framework may expose assistant-model settings that let developers specify the draft model and candidate-token count. Configuration details depend on the framework.
For cloud deployments, inference services can be orchestrated on a container platform, with logging, monitoring, and alerts used to track:
- Average acceptance length.
- End-to-end latency.
- Throughput.
- Performance at different concurrency levels.
These measurements can guide adjustments to draft length and decisions about when to enable or disable speculative decoding.
Cloud inference and compute services, including relevant Baidu AI Cloud offerings, can form part of such a deployment. Support for a particular configuration and its regional availability should be checked in the official documentation rather than assumed.
5. Conclusion
Speculative decoding trades inexpensive draft-model predictions for more productive target-model verification passes. By evaluating multiple candidate tokens together, it can use compute capacity that would otherwise remain idle during memory-bound decoding.
With an exact implementation, it does not require changing the target model’s weights or sacrificing its output distribution. However, performance depends on more than prediction alignment alone: draft-model latency, verification cost, candidate length, and concurrency all affect the outcome.
Successful deployment starts with understanding the different bottlenecks in prefill and decode, measuring average acceptance length, and choosing a draft model that is both fast and well aligned with the target. Combined with techniques such as continuous batching and KV-cache optimization, speculative decoding is becoming an important tool for improving LLM inference efficiency on existing hardware.
