Speculative Decoding in Practice: Speeding Up LLM Inference with a Draft Model
This article explains how speculative decoding reduces the number of full target-model passes during LLM inference. It covers the draft-and-verify workflow, how acceptance rate determines the speedup, what a draft model needs to get right, and how dynamic draft depth works. It also reports benchmark results from an 8-GPU setup with a 32k-token context, describes a layer-by-layer approach to finding bottlenecks, and outlines the deployment practices that make the method reliable in production.
1. Background: Why Token-by-Token Decoding Is Slow
Autoregressive decoding generates one token per step. Each step requires a full forward pass of the target model, which reads large amounts of model weights and KV cache. At small batch sizes, the time per step is mainly limited by memory bandwidth, and most compute units sit idle. As a result, faster generation often depends less on adding compute and more on reducing how many times the target model must run.
Speculative decoding separates generation from verification. A lightweight draft model proposes several candidate tokens at once. The target model then checks all of them in a single forward pass. As long as the candidates are accepted, one target-model pass produces multiple output tokens.
2. How Speculative Decoding Works
A typical speculative decoding iteration has three steps:
- The draft model autoregressively generates a candidate sequence of length k from the current context.
- The target model concatenates the original context with the candidate sequence and computes a probability distribution for each position in one forward pass.
- The system compares each candidate token with the target distribution, from left to right. At the first rejected position, it resamples from a corrected distribution and discards all candidates after that position.
With a standard rejection sampling implementation, the output distribution matches the distribution obtained by sampling token by token directly from the target model. In theory, the method does not change output quality.
Speedup depends on the acceptance rate. Let α be the probability that a single candidate token is accepted, and assume positions are independent of each other. With a draft length of k, the expected number of tokens produced per iteration is:
E = (1 − α^(k+1)) / (1 − α)
For example, with α = 0.8 and k = 4, E ≈ 3.36. This means one target-model verification advances about 3.4 tokens on average. In real workloads, the acceptance rate varies with content type and sampling parameters, so measure it on real traffic rather than relying only on the theoretical value.
3. How the Draft and Target Models Work Together
The draft model has two key constraints.
First, its vocabulary and tokenization must match those of the target model. Otherwise, the token IDs proposed by the draft cannot be verified directly by the target model, and the whole process fails.
Second, the draft model must balance speed and prediction quality. A model that is too small has a low acceptance rate, so verification overhead cancels out the gain. A model that is too large turns the draft stage into the bottleneck. Some approaches let the draft model reuse part of the target model’s intermediate representations. This gives predictions closer to the target distribution at a lower cost.
4. Dynamic Path Selection
A fixed draft length rarely suits all content. Highly repetitive, structured text, such as templated documents, code completion, and tabular data, usually has a high acceptance rate and works well with longer drafts. Open-ended, highly random content has a lower acceptance rate, and long drafts waste a lot of computation.
Dynamic path selection adjusts draft depth or the number of branches in real time. It uses context entropy, a measure of how predictable the content is, and the recent acceptance rate. The following is an illustrative policy function. The thresholds are for demonstration only, and real values should be determined through load testing.
def choose_draft_depth(recent_accept_rate: float,context_entropy: float,max_depth: int = 6) -> int:# Low entropy and high recent acceptance rate: propose as many candidates as possibleif context_entropy < 2.0 and recent_accept_rate > 0.7:return max_depth# Moderate acceptance rate: halve the depth to reduce wasted verificationif recent_accept_rate > 0.5:return max(1, max_depth // 2)# Low acceptance rate: fall back to near token-by-token generationreturn 1
The core idea is to let draft depth follow the characteristics of the content. Each decision is cheap, and the policy avoids continuous waste of compute in low-acceptance scenarios.
5. Benchmark Results and Interpretation
The test environment in this article is as follows. The target model is a large language model deployed on 8 identical GPUs with tensor parallelism (TP=8). The input context is about 32k tokens, and the content is highly predictable, meaning it has a low-entropy context.
Table 1: Decoding performance in the 8-GPU test
| Metric | Native autoregressive decoding | Speculative decoding | Relative change |
|---|---|---|---|
| Single-concurrency decoding speed | About 84.5 tokens/s (back-calculated from the reported 3.41x ratio) | 288.2 tokens/s | About 3.41x |
| Total throughput at 64 concurrency | About 420.1 tokens/s (back-calculated from the reported 44.9% ratio) | 608.71 tokens/s | 44.9% increase |
The baseline values are back-calculated from the reported ratios. They are not independent measurements.
The two sets of data show how the benefit of speculative decoding changes with concurrency.
At single concurrency, GPU compute utilization is low. The extra computation during verification barely uses additional resources, so the benefit is most visible.
At 64 concurrency, batching already uses compute efficiently. The extra candidate and verification computation takes part of the available resources, so the gain shrinks. Total throughput still increases by 44.9%, which shows the method remains valuable under high concurrency. The gain, however, is clearly smaller than at single concurrency.
These numbers apply only to the specific model, hardware, context length, and content distribution described here. They should not be extrapolated to other environments.
6. Locating Performance Bottlenecks Layer by Layer
Optimization starts with knowing which layer the bottleneck sits in. Check the following four layers in order.
Model layer: Focus on the acceptance rate, how well the draft distribution matches the target distribution, and whether the draft model’s precision and size are appropriate.
Runtime layer: Focus on scheduling, batch composition, and KV cache allocation and reclamation. Speculative decoding produces a variable number of tokens per step, so the runtime must handle inconsistent sequence lengths correctly.
Software layer: Focus on operator implementation, kernel fusion, and communication overhead between GPUs. As the tensor parallel size grows, the share of communication time usually increases.
Hardware layer: Focus on memory bandwidth, memory capacity, and inter-GPU interconnect bandwidth. The draft model’s weights and the extra KV cache increase memory usage. When memory is tight, batch sizes may have to shrink.
Two principles guide troubleshooting. First, establish a baseline with native decoding. Second, change only one variable at a time and observe its effect on the metrics. Key metrics include the acceptance rate, average tokens produced per step, time to first token, single-concurrency speed, and total throughput.
7. Engineering Deployment: Designing for Reuse
For speculative decoding to run in production, its parameters and workflow should be codified rather than tuned by hand. A reusable deployment usually includes the following elements.
- Configuration as code: Model paths, the draft model, parallel size, and the draft depth policy all go into configuration files. This makes version control and rollback easier.
- Environment pre-checks: Before startup, check the GPU count, memory headroom, and driver and runtime versions. This catches environment problems before the service starts.
- Health monitoring: Continuously track the acceptance rate and throughput. If the acceptance rate stays below a threshold for a sustained period, switch back to native decoding automatically.
- Fallback switch: Keep the ability to disable speculative decoding with one action. This lets you restore the baseline service quickly during troubleshooting.
The following is an illustrative configuration draft. The field names only show the structure. Actual fields should follow the documentation for the runtime you use.
target_model: /models/targetdraft_model: /models/draftparallel:tensor_parallel_size: 8decoding:mode: speculativemax_draft_tokens: 6adaptive_depth: truefallback:enable: truemin_accept_rate: 0.35monitor:metrics: [accept_rate, tokens_per_step, ttft, throughput]
8. Limits and Risks
Speculative decoding does not speed up every workload. Before adopting it, be clear about the following limits.
- Acceptance rate determines the gain. When content is highly random or the sampling temperature is high, the acceptance rate drops. The gain may then disappear or turn into a slowdown.
- Memory cost increases. The draft model’s weights and the extra cache consume memory. This may limit maximum concurrency or context length.
- Performance depends on the environment. Hardware model, GPU interconnect, batch composition, and context length all affect results. Validate with load tests on your own workloads.
- Operational complexity rises. An additional model must be deployed, upgraded, and monitored. Assess whether your team can maintain it.
9. Summary
Speculative decoding reduces the number of target-model passes by having a draft model propose tokens and the target model verify them. Its speedup depends on the acceptance rate, the draft cost, and the hardware’s concurrency state. In practice, locate bottlenecks layer by layer, use dynamic policies to match content characteristics, and rely on configuration management and fallback mechanisms for stability. In the 8-GPU test cited here, single-concurrency speed was about 3.41 times that of native decoding, and total throughput at 64 concurrency rose 44.9%. These results show that the method delivers meaningful gains across concurrency levels, but the exact figures need to be verified in your own environment.
