Speculative Decoding for Faster Local LLM Inference: Principles and Practice
Speculative decoding can speed up local large language model inference by letting a small draft model propose candidate tokens and having the target model verify them in one forward pass. This article explains why the decode stage is often limited by memory bandwidth and data movement, how speculative decoding can preserve the target model’s output distribution, and what determines real-world gains, including average acceptance length, draft-model quality, batching, concurrency, and hardware constraints.
1. The Local LLM Inference Bottleneck: It Is Not Just About Compute
Large language model inference can usually be divided into two stages: prefill and decode.
During the prefill stage, the model processes the user prompt as a whole. It builds the attention state required for generation and writes the key-value cache. This stage often processes many tokens at once, has high computational density, and is more sensitive to compute capacity.
The slower part of local inference usually happens in the decode stage. When the model starts generating the answer token by token, each step produces only one new token. To generate the next token, the GPU must read model weights, read the historical key-value cache, perform one forward pass, and then write the new key-value state back to the cache. This loop repeats until generation finishes.
The problem is that large model weights can be tens or even hundreds of gigabytes. Every generated token may involve large-scale weight reads and cache movement. When compute units are not the only bottleneck, memory bandwidth and data movement efficiency become critical constraints. As a result, the common issue in local inference is not that the model “cannot compute fast enough,” but that it must repeatedly move the same data for every step.
This is why speculative decoding has attracted attention. Its goal is not to further compress the model or replace the GPU. Instead, it changes how tokens are generated: a smaller, faster model handles the easier part of the work first, and the larger model verifies the result in one pass.
2. The Basic Idea of Speculative Decoding: A Small Model Drafts, a Large Model Verifies
The core idea of speculative decoding is simple: first let a small and fast model generate several candidate tokens, then let the target large model verify those candidates with one forward pass.
If the candidate tokens match the probability distribution of the target model under the current context, they can be accepted directly. If one candidate does not match, generation stops at that position, and the target model produces a corrected token.
Here is a simple example.
User input:
The cat
The draft model may quickly predict:
sat on my lap
Instead of generating every token one by one, the target model performs one verification pass over these candidates. If the target model considers “sat,” “on,” and “my” reasonable in this context, those tokens can be accepted. If the third position does not match the target model’s distribution, the remaining candidates are discarded, and the target model generates the correct token instead.
This changes the generation process. Work that previously required multiple autoregressive steps may now advance several positions with one verification pass. The draft model is small, so generating candidates is usually much cheaper than repeatedly reading the full weights and cache of the large model.
In some public demonstrations, this approach can increase single-request generation speed to nearly four times the original speed in certain scenarios. Even when concurrent requests increase, it may still provide about a two-times throughput improvement under specific workloads and high acceptance rates. However, these gains depend on draft-model quality, task type, hardware bandwidth, batching strategy, and concurrency level. They are not guaranteed in every case.
3. Why Speculative Decoding Does Not Reduce Output Quality
A common concern is whether a draft model that guesses tokens first will affect the final answer.
With a correct implementation, speculative decoding does not change the final output distribution of the target model. The draft model only proposes candidates. Whether a candidate is accepted is decided by the target model. In other words, the draft model mainly affects speed, while the target model determines the final result.
There are two common verification approaches.
1. Greedy decoding
If the target model uses greedy decoding, a draft token can be accepted as long as it is the highest-probability token under the target model in the current context. If a draft token is not the target model’s preferred choice at that position, correction begins from that position.
2. Sampling decoding
If the target model uses stochastic decoding methods such as temperature sampling or top-k sampling, verification must ensure that the final output still follows the target model’s original sampling distribution. In engineering practice, this is usually handled through acceptance probability and corrected sampling, so that the final result remains consistent with what the target model would generate independently.
Speculative decoding is therefore a form of generation-path optimization, not model replacement. The draft model may come from a smaller same-family model, a lightweight approximate model, a distilled model, a state-tracking mechanism, or another fast candidate generator. However, it should not be treated as the author of the final answer.
4. The Key Metric: Average Acceptance Length Determines the Speedup
Speculative decoding may look like a free speedup, but the core metric that determines the actual benefit is average acceptance length: the average number of draft tokens accepted by the target model per verification round.
Suppose the draft model proposes four candidate tokens.
- If the target model accepts zero tokens, the draft effort is almost useless and may even add overhead.
- If it accepts two tokens, the large model can advance multiple positions with one forward pass, and benefits begin to appear.
- If it accepts all four tokens, the draft hit rate is high, and the speedup is usually obvious.
- If the draft model itself is too slow or the acceptance rate is too low, overall latency may increase instead.
Therefore, speculative decoding is not simply a matter of “the more draft tokens, the better.” Increasing the number of draft tokens expands the potential acceptance space, but it also increases draft-model overhead and may lead to more invalid verification work.
In actual deployment, it is necessary to balance draft length, draft-model speed, target-model verification cost, and task predictability.
A simplified way to understand the trade-off is:
- Effective gain is approximately the number of tokens advanced per verification step.
- Total cost is approximately the draft generation cost plus the target-model verification cost plus the fallback correction cost.
Stable speedup occurs when the average acceptance length is high, the draft cost is low, and the target-model verification cost is sufficiently worthwhile compared with the draft cost.
5. How to Choose a Draft Model: Same Vocabulary, Lightweight, and Predictable
The choice of draft model directly affects whether speculative decoding is effective. Several dimensions should be considered.
1. Use the same or compatible vocabulary
The draft model and the target model should ideally use the same or compatible tokenization method. If their token boundaries differ too much, candidate tokens may be difficult for the target model to verify, and the acceptance rate will drop significantly.
2. The draft model must be lightweight enough
The draft model must be faster than the target model. If the draft model itself is computationally expensive, its cost can offset the benefits of target-model verification.
Common approaches include using a smaller same-family model, a distilled model, a lightweight proxy model, or a low-cost candidate generator built from historical context.
3. The acceptance rate must be high enough
The draft model does not need to be excellent at generation in general, but it must be good at predicting the target model’s likely output.
Acceptance rates are often easier to improve in tasks such as code completion, structured text generation, fixed templates, repetitive tasks, and long-form continuation. In highly creative writing, complex reasoning, and open-ended dialogue, candidate tokens may be rejected more often.
4. The draft model should match the target model’s style
If the draft model and the target model differ significantly in tone, formatting habits, or terminology, draft candidates may be rejected frequently.
In practice, it is often better to choose a candidate generator that was trained from the same source, distilled from the same model, or strongly aligned with the target model.
6. A Simplified Flow: From Drafting to Verification
The following pseudocode illustrates the basic execution logic of speculative decoding:
context = promptoutput = []while not finished:draft_tokens = draft_model.propose(context, k)target_logits = target_model.forward(context + draft_tokens)accepted = []for token, logits in zip(draft_tokens, target_logits):if can_accept(logits, token):accepted.append(token)else:breakif len(accepted) == 0:fallback_token = target_model.sample_from_current_logits()accepted.append(fallback_token)output.extend(accepted)context = context + acceptedif len(output) >= max_new_tokens:break
There are three key points in this flow:
- The draft model quickly proposes candidate tokens.
- The target model verifies whether the candidates are acceptable with one forward pass.
- Once a rejection occurs, the remaining draft tokens are discarded, and the target model generates a corrected token.
In real engineering implementations, additional issues must be handled, including cache consistency, batch concatenation, sequence-length limits, concurrent request isolation, sampling parameter propagation, and failure fallback. If implemented incorrectly, even a theoretically lossless speculative decoding setup may degrade quality because of cache errors, position-encoding errors, or batching mistakes.
7. How Batching and Concurrency Change the Picture
In a single-request scenario, the benefits of speculative decoding are usually easier to observe. Each generation step may be affected by weight reads and cache movement. By verifying multiple candidate tokens at once, the target model can advance several positions and reduce the number of forward passes, thereby lowering single-request latency.
In high-concurrency serving environments, the situation becomes more complex. The target model can already batch multiple requests together, which partially amortizes the cost of reading model weights. In this case, the marginal benefit of speculative decoding may depend on:
- The number of concurrent requests.
- The generation length of each request.
- The computational cost of the draft model.
- The batching efficiency of the target model.
- Whether memory bandwidth is saturated.
- Whether the average acceptance length is stable.
- Whether long-tail requests slow down the entire batch.
Under high concurrency, if the draft model is too heavy or the acceptance rate drops, the system may incur additional computational burden. On the other hand, if the draft model has a high hit rate, is lightweight enough, and is scheduled properly with batching, speculative decoding can still improve overall throughput.
Therefore, local single-user inference and online concurrent inference should not blindly use the same settings. In practice, load testing is needed to observe changes in latency, throughput, memory usage, and acceptance rate under different conditions.
8. When Speculative Decoding Is Most Effective
Speculative decoding does not always provide a speedup. It is more suitable for the following situations.
1. The target model is large, and memory bandwidth is the main bottleneck
If the model is small, or the hardware has sufficient bandwidth, the benefit from draft verification may be limited.
2. The output has high predictability
Speculative decoding often works better for tasks such as code completion, template generation, structured summaries, fixed-format conversion, and long-form continuation. These tasks usually have higher draft acceptance rates.
3. Single-request latency is sensitive
If users care about generation speed after the first token, speculative decoding may provide a noticeable improvement.
4. The draft model is highly aligned with the target model
A smaller same-family model, a distilled model, or a candidate generator trained through alignment with the target model is more likely to achieve a high acceptance rate.
The following cases are less suitable or require careful evaluation:
- The draft model is not fast enough.
- The draft model differs too much from the target model in style.
- The task requires substantial complex reasoning, and candidates are frequently rejected.
- Concurrency is extremely high and batching already makes full use of the hardware.
- Memory capacity is insufficient, and additional draft state creates memory pressure.
- The output stability requirement is very strict, and cache and sampling consistency must be carefully verified.
9. Common Misconceptions
Misconception 1: The smaller the draft model, the better
The draft model should be lightweight, but if it is too small, the acceptance rate may become too low. If the draft model guesses incorrectly too often, the target model must keep correcting it, and overall performance may decline.
Misconception 2: The more draft tokens, the better
Increasing draft length does not linearly increase benefits. A longer draft creates more potential acceptance opportunities, but it also increases invalid computation and cache overhead.
Misconception 3: Speculative decoding changes model capability
A correctly implemented speculative decoding system mainly changes the generation path, not the final output distribution of the target model. However, errors in sampling, caching, or batching during implementation can still affect results, so rigorous testing is necessary.
Misconception 4: Enabling it always makes inference faster
Speculative decoding depends on acceptance rate, hardware bottlenecks, and workload patterns. If the target model is clearly compute-bound, or the draft model does not match the target model, the speedup may be limited.
Misconception 5: Only end-to-end speed matters
When optimizing with speculative decoding, it is not enough to observe only the speed perceived by users. It is also important to monitor average acceptance length, draft-model overhead, fallback rate, cache hit rate, batching efficiency, and tail latency.
10. Performance Evaluation Suggestions
If you want to evaluate whether speculative decoding is suitable for a local inference scenario, at least the following metrics should be observed.
1. Per-token generation latency
This measures the response speed of the decode stage on a per-token basis.
2. Time to first token
This measures the cost of the prefill stage and initial waiting time. It is usually less directly related to speculative decoding, but it still affects the overall user experience.
3. Tokens generated per second
This measures throughput capability.
4. Average acceptance length
This helps judge the quality of the draft model. If it remains low over time, the draft model or candidate strategy may need adjustment.
5. Draft-model overhead ratio
If the draft stage consumes too much time, the overall benefit may be offset even when the acceptance rate is not low.
6. Batching throughput and tail latency
In high-concurrency scenarios, both average throughput and long-tail request latency should be monitored.
7. Memory usage and cache behavior
Speculative decoding may introduce additional state. It is important to ensure that it does not squeeze the cache space required by the target model.
11. Conclusion
Speculative decoding provides a way to optimize local LLM inference speed without changing model parameters or requiring a stronger GPU. Its essence is to let a small and fast draft model propose candidate tokens first, then let the target model verify them in one pass. If the acceptance rate is high enough, the large model can advance more tokens with fewer forward passes, improving the efficiency of the decode stage.
However, speculative decoding is not a simple “acceleration switch.” Its effectiveness depends on draft-model quality, acceptance rate, draft length, target-model size, hardware bandwidth, concurrency strategy, and engineering implementation details.
For developers, a more reasonable approach is to treat speculative decoding as an observable, tunable, and load-testable inference optimization method. Start by establishing a clear performance baseline, then use metrics such as average acceptance length, latency, throughput, and memory usage to evaluate the real benefit. Only when the draft model, target model, workload, and hardware environment are well matched can speculative decoding deliver stable value.
