Speculative Decoding for Local LLM Inference: Accelerating Generation with Draft Models
This article explains why local LLM decoding can be slow even when the GPU is not fully utilized, how speculative decoding uses a small draft model and batched verification by the target model to reduce forward passes, and what to consider when choosing draft models, managing KV cache, batching, measuring acceptance length, and tuning for latency or throughput.
When running large models locally, many teams encounter a counterintuitive phenomenon: the GPU is not fully utilized, yet generation speed remains limited. On the same machine, with the same target model and the same prompt, output still emerges token by token. The problem is often not raw compute capacity, but the data movement pattern of autoregressive decoding. Speculative decoding offers an acceleration path that does not require replacing the GPU or further compressing the main model: a small, fast draft model first “guesses” several tokens, and the target model then verifies them in a batch. This article covers the principles, workflow, tuning, and engineering implementation.
Why the Decode Phase Is Slow: Memory Bandwidth Beyond Compute
LLM inference is typically divided into two phases: prefill and decode. In prefill, the model processes user input in a batch, computes attention for many tokens in parallel, and builds the KV cache; this phase is usually more compute-intensive. Once decoding begins, the model generates one token at a time. To generate the next token, it must read model weights and the existing KV cache, then write new key-value data. The next step repeats the process.
When model weights reach tens of GB or more, every generated token involves moving a large amount of weights and cache data. At this point, the key factor limiting speed is often not how many compute units the GPU has, but memory bandwidth, cache access efficiency, and data movement overhead. Especially in single-request, small-batch scenarios, compute unit utilization may be low, and decode speed is directly constrained by memory bandwidth.
Speculative decoding targets exactly this problem by reducing the number of target model forward passes. It does not change the target model architecture, nor does it require the main model to be quantized. Instead, it assigns some of the “easy-to-predict” work to a smaller, faster draft model, allowing the target model to verify multiple candidate tokens at once and advance more positions at the same weight-read cost.
The Core Flow: Draft First, Then Verify in a Batch
Suppose the user input is “The cat.” The draft model might propose consecutive candidates such as “sat on my lap.” The target model then checks the probability distribution of these candidate tokens in a single forward pass. If the first two tokens meet the target model’s acceptance conditions, they are accepted directly. The third token is rejected, subsequent candidates are discarded, and the target model generates a correction token. Work that would have required multiple target model rounds can potentially be compressed into one verification round.
A simplified pseudocode flow is as follows:
function speculative_decode(prompt, target, draft, K, max_tokens):tokens = tokenize(prompt)Initialize KV caches for target and draftoutput = []while output has not reached max_tokens:candidates = draft.generate(tokens, K) # Draft model proposes K candidateslogits = target.verify(tokens, candidates) # Target model verifies in one forward passaccepted = []for i in range(K):p = target.prob(logits[i], candidates[i])q = draft.prob(candidates[i])if accept(p, q):accepted.append(candidates[i])else:breakif accepted is not empty:output.extend(accepted)tokens.extend(accepted)Commit KV cache for accepted tokenselse:correction_token = target.sample(logits[0])output.append(correction_token)tokens.append(correction_token)Commit KV cache for the correction tokenif end token encountered: breakreturn output
In sampling scenarios, a common acceptance criterion can be written as min(1, p/q), where p is the target model probability and q is the draft model probability; under certain conditions, this keeps the output distribution consistent with the target model. For greedy decoding, one can also directly compare the candidate choices of the target and draft models. The more critical engineering requirement is that the target model must verify multiple candidate positions in parallel in one forward pass and correctly commit the KV cache after accepting a prefix. Once a rejection occurs, it must roll back the cache state corresponding to subsequent candidates, and then the target model samples a correction token at the rejection point.
This mechanism is not “free” under all conditions. The speedup depends on the average acceptance length, meaning how many draft tokens the target model accepts per round on average. If the draft predicts four tokens at a time and three are accepted, one target model computation effectively advances multiple positions. If acceptance length is very low, the draft model’s computation and cache management overhead can instead worsen end-to-end latency.
Choosing a Draft Model: Small Is Not the Only Criterion
The choice of draft model directly affects acceptance length and extra overhead. In practice, consider the following:
- Consistent vocabulary and tokenization: The draft model and target model should ideally use the same or highly compatible vocabulary and tokenization rules; otherwise, candidate tokens cannot map directly, and the verification flow becomes complicated.
- Distribution close to the target model: The draft model does not have to come from the same source, but the closer its output distribution is to the target model, the higher the acceptance length usually is. When domains do not match, a seemingly smaller draft model may produce a lower acceptance rate.
- Sufficiently low inference cost: The draft model must be small, have few layers, and have low single-pass latency to amortize the target model’s verification cost. If the draft model itself is slow, the available speedup is consumed.
- Support for quantization and low-resource deployment: Local environments have limited GPU memory, so the draft model can be deployed at lower precision, but the impact of precision changes on acceptance length must be evaluated.
- Dynamic windows are more robust than fixed windows: The number of tokens proposed per draft round, often denoted K, should not remain fixed. If K is too small, the reduction in target model verification rounds is limited; if K is too large, waste after rejection increases. It can be adjusted dynamically based on recent acceptance length.
Public technical demonstrations have shown that in some tests, this combination can increase single-request generation speed to nearly 4x the original. As concurrent requests increase, it can still deliver about 2x throughput improvement. However, such numbers depend on the model combination, hardware, batch size, prompt distribution, and sampling parameters, and should not be treated as fixed promises. The truly transferable metrics are acceptance length, the proportion of draft overhead, and end-to-end P50/P99 latency.
Concurrency and Batching: Throughput Gains Are Not Proportional to Single-Request Latency
Speculative decoding more easily demonstrates latency benefits in single-request, low-concurrency scenarios: the target model verifies multiple candidates in one forward pass, reducing the number of weight reads. In high-concurrency scenarios, however, inference systems usually amortize weight-read costs through batching, and the target model itself already achieves relatively high throughput. At that point, the extra computation, cache usage, and scheduling overhead introduced by the draft model are amplified, and the throughput improvement ratio may be lower than single-request demonstration data.
Engineering implementation needs to distinguish two goals: optimizing single-request latency or optimizing overall throughput. The former should focus on acceptance length and draft overhead; the latter should focus on the number of draft tokens within a batch, KV cache memory usage, scheduling fairness, and rollback cost after rejection. It is advisable to decouple draft model and target model scheduling so that the draft phase does not block target model batching. At the same time, establish monitoring for acceptance length, rejection rate, draft time, verification time, and cache rollback count.
Quality and Tuning: Measure Acceptance Length Before Claiming Speedups
The correctness of speculative decoding depends on the acceptance criterion and cache commit logic. If sampling parameters are inconsistent—for example, if the target and draft models use different temperature, top-p, or penalty terms—acceptance rates may become abnormal or output quality may deviate. Before launch, three types of evaluation should be performed: first, output quality regression, comparing performance on a fixed evaluation set before and after enabling speculative decoding; second, acceptance length distribution, grouped by task type, prompt length, and temperature; third, end-to-end performance, recording the time spent in prefill, drafting, verification, correction, and cache management separately.
During tuning, start with a smaller draft window and dynamically expand or shrink it based on acceptance length. For long-context, high-temperature, open-ended generation tasks, acceptance length is usually more volatile, so speedup expectations should be lowered. Draft model domain adaptation is also important: acceptance length may differ significantly across workloads such as code, customer service, and summarization. Ultimately, speculative decoding should be treated as a monitorable, rollback-capable inference optimization method, not as a one-time replacement for the main model.
Conclusion
The value of speculative decoding lies in changing how tokens are generated: a small draft model proposes candidates, and the target model verifies them in a batch, reducing the number of target model forward passes without replacing the GPU or compressing the main model. Its upper bound is determined by average acceptance length, and its lower bound is determined by draft overhead and engineering implementation. For local LLM inference, choosing draft models appropriately, managing KV cache, distinguishing latency and throughput goals, and establishing quality and performance monitoring are what turn “draft-model acceleration” into a stable, usable engineering capability.
