Speculative Decoding: Speed Up Local LLM Inference with Draft Models Without Upgrading Your GPU
When you run large language models locally, hardware is fixed and the model is already chosen, yet generation speed is often still disappointing. This article explains speculative decoding, a technique that accelerates inference by having a small draft model propose candidate tokens and the target model verify them in parallel. It covers why local inference is frequently bottlenecked by memory bandwidth rather than raw compute, how speculative decoding preserves output quality through greedy and sampling verification, how to choose a compatible draft model, and the key engineering concerns around KV cache management, candidate length, and sampling. Readers will also learn which metrics matter, how to combine the technique with quantization and caching, and how to follow a practical implementation path.
Local deployment of large language models often hits a familiar problem: the hardware is fixed, the model is already chosen, but generation speed is still unsatisfactory. When you need token-by-token streaming output, real-time conversation, or batch processing of long documents, the waiting time clearly hurts the experience. If you cannot upgrade the GPU and do not want to compress the model any further, is there still a way to speed up inference?
The answer is usually not to add more compute, but to change the way tokens are generated. Speculative decoding is one approach that has drawn considerable attention in local inference optimization. A smaller draft model first proposes candidate tokens, and the target model then verifies them in parallel, improving generation efficiency while preserving output quality.
Where the bottleneck in local LLM inference actually is
LLM inference typically involves two main stages: prefill and decode. During the prefill stage, the model processes the entire input prompt, computes attention in parallel, and builds the KV Cache that later steps will rely on. This stage often deals with long inputs, concentrates computation, and is largely limited by raw compute power.
Once decoding begins, the situation changes: the model can generate only one token at a time, then waits before generating the next one.
The crux of the problem lies here. For every token generated, the inference system has to read the model parameters and the accumulated KV Cache, then write the newly generated keys and values back into the cache. For a model with billions of parameters, especially when the weights reach tens of gigabytes or more, producing a single token is not a simple “calculate once.” It comes with a large amount of memory movement. At this point, the GPU’s compute capability is not necessarily the bottleneck; what truly limits speed is memory bandwidth and data transfer efficiency.
You can think of it this way: the model is not unable to compute, but on every step it has to move a large amount of “existing knowledge” next to the compute units before processing one tiny increment. When only one token is generated per step, the actual utilization of the compute units may be low. As a result, the focus of local inference optimization should not be solely on peak compute. Instead, it should look at how to reduce wasted data movement and increase the number of useful tokens produced by each computation step.
The core idea of speculative decoding: draft first, then verify
The central idea of speculative decoding can be summed up in one sentence: let a small model quickly write several candidates, and let the large model check them all at once.
The concrete flow is as follows:
- The target model generates subsequent content based on the current context.
- The draft model, running faster, predicts several candidate tokens in sequence.
- Instead of generating tokens one by one, the target model runs a single forward pass over these candidate tokens together with the context.
- Based on the target model’s predicted distribution at the corresponding positions, the inference system accepts or rejects the candidate tokens.
- If some candidates are accepted, they are written directly into the final output; if a token is rejected at some position, the candidates after it are discarded, and the target model regenerates that position.
In this mechanism, the draft model does not determine final quality. It only proposes “possible answers.” Whether they are ultimately adopted is decided by the target model’s verification. Speculative decoding is therefore not simply a matter of replacing a large model with a small one, but a collaborative inference structure.
Why speculative decoding can speed things up
The speedup from speculative decoding does not come from simply reducing the amount of computation, but from increasing the degree of parallelism in the generation stage.
Traditional autoregressive decoding is serial: generate the first token, feed it into the second step; generate the second token, feed it into the third step. Every step has to re-access the weights and the cache. Speculative decoding, by contrast, batches several candidate tokens together and lets the target model verify multiple positions in a single pass. This brings several benefits:
- Higher reuse of memory reads: one read of the model weights and cache can check multiple candidate positions.
- Higher GPU parallelism: multiple token positions form a parallel computation dimension, putting otherwise idle compute resources to use.
- Lower scheduling overhead: fewer per-token loops mean less framework-level overhead.
- Shorter perceived latency: when the draft model’s acceptance rate is high, a single iteration can produce multiple final tokens.
It can be simplified as:
Traditional approach: one forward pass, one token output.
Speculative approach: one draft generation of K candidates, then one target verification, potentially outputting 1 to K+1 tokens.
The gains from speculative decoding therefore depend heavily on two variables: the speed at which the draft model proposes candidates, and the proportion of candidates the target model accepts. If the draft model is too small, the acceptance rate may be low; if it is too large, its own overhead may cancel out the benefit. In engineering practice, people usually choose a draft model that is smaller than the target model but has a distribution reasonably close to it.
How output quality stays intact
Many people worry that, since the draft model is weaker than the target model, it might degrade the final answer. By design, speculative decoding does not let the draft model replace the target model’s output. The target model verifies each draft position, and the verification logic generally falls into two categories: greedy and sampling.
In a greedy decoding scenario, the target model compares its prediction at the current position with the draft token. If they match, the token is accepted; if they do not match, a token is resampled from the target model’s prediction at that position.
In a random sampling scenario, the more common approach is to use a modified acceptance algorithm. The basic idea is this: the draft model proposes a candidate distribution, the target model provides the true distribution, and the system accepts a draft token with a certain probability. If it is rejected, a token is sampled from a corrected distribution so that the overall output distribution stays as close as possible to what the target model would produce through direct sampling. This is why speculative decoding can preserve generation quality in theory, rather than simply trading it away for speed.
Illustrative pseudocode:
def speculative_decode(target_model, draft_model, context, k):cache_target = target_model.build_cache(context)cache_draft = draft_model.build_cache(context)output = []while not finished:draft_tokens = draft_model.propose(cache_draft, k)logits = target_model.forward_with_context(cache_target, draft_tokens)accepted_tokens = []for i, token in enumerate(draft_tokens):if accept(target_model, logits[i], token):accepted_tokens.append(token)else:corrected = sample_from_target(logits[i])accepted_tokens.append(corrected)breakoutput.extend(accepted_tokens)update_caches(accepted_tokens)return output
This pseudocode expresses the general idea, not any specific implementation. A real implementation also involves details such as cache rolling, position-encoding alignment, random-number-state management, and consistent temperature settings.
How to choose a draft model
Choosing the draft model is the key to putting speculative decoding into practice. A suitable draft model should generally meet the following conditions:
- Compatible vocabulary or tokenization: the tokens the draft model produces must map onto the context the target model can understand. If the tokenization schemes do not match, misalignment will occur during verification.
- Close to the main model’s domain: if the target model is a code model, the draft model should ideally also have a tendency toward code generation; if the target model leans toward Chinese conversation, the draft model should have a similar language distribution.
- Clearly lower inference cost: the draft model must have fewer parameters and be lighter to compute in order to provide a speed advantage.
- High enough acceptance rate: the draft model does not have to be perfect, but it needs to keep a high agreement rate with the target model on common contexts.
- Controllable memory footprint: in local deployment, the draft model must not crowd out the target model’s KV Cache space.
In practice, you can choose a draft model from a smaller model in the same series, a distilled model, or a quantized lightweight model. If the target model and the draft model come from different families, you need to pay particular attention to tokenization consistency and the degree of semantic alignment.
Key details in engineering implementation
Speculative decoding does not yield benefits immediately just because you connect a small model. Several details need attention during implementation.
First, cache management. Both the target model and the draft model need to maintain their own KV Caches. When a draft is partially accepted or rejected, the cache must be rolled back or truncated in sync; otherwise subsequent generation will suffer from context confusion.
Second, candidate length settings. If the candidate length is too small, the gains are limited; if it is too large, the acceptance rate drops and the target model verifies more useless positions. It is common to adjust the candidate length dynamically based on the acceptance rate, or to set different upper bounds for different business scenarios.
Third, temperature and sampling strategy. If the main model uses sampling strategies such as temperature, top-k, or top-p, the draft model should keep a similar strategy. Otherwise the gap between the draft and target distributions becomes too large, and the acceptance rate will drop noticeably.
Fourth, concurrency effects. In a single-request local scenario, speculative decoding more easily delivers latency benefits. But in high-concurrency serving, the target model may already improve throughput through batched requests, so the marginal benefit of speculative decoding changes. If the system bottleneck has shifted to compute resources or scheduling, the draft model may add extra overhead.
Fifth, prompt length. If the input prompt is very long, the proportion taken up by the prefill stage increases, and the speedup from the decode stage gets diluted. In this case, you need to combine approaches such as prefix caching and cache reuse for a more complete optimization.
Which metrics to focus on when evaluating the gains
When evaluating speculative decoding, you should not look at a single theoretical multiplier, but measure it against a specific scenario.
Common metrics include:
- Average time per token: measures whether single-step latency drops.
- Tokens output per second: measures overall generation throughput.
- Average number of accepted tokens: reflects the consistency between the draft model and the target model.
- Time to first token: measures how long the user waits before output begins.
- Memory footprint: indicates whether the draft model creates additional resource pressure.
- Concurrent throughput: indicates whether there is still a benefit in multi-request scenarios.
- Long-context stability: indicates whether cache rollback and position management are correct.
If the average accepted length is low, it means the draft model’s candidates are frequently rejected, and continuing to increase the number of candidates may not pay off. A more sensible approach is to first optimize the draft model, then adjust the candidate length or sampling strategy.
How speculative decoding relates to other optimization techniques
Speculative decoding is not an isolated technique; it usually needs to be used together with other inference optimizations.
- Quantization: reduces the amount of weight data read and improves memory-bandwidth utilization; combined with speculative decoding, it helps further increase speed.
- KV Cache optimization: includes cache quantization, paged management, and windowing, which reduce the pressure of cache movement.
- Continuous batching: in multi-request serving scenarios, dynamically batching requests can raise GPU utilization.
- Prefix caching: for shared system prompts or multi-turn conversations, it can reuse prefill results and cut down repeated computation.
- Graph optimization and operator fusion: reduces scheduling overhead and makes parallel verification more efficient.
Local inference optimization should therefore not pursue a single trick, but evaluate speculative decoding as part of the overall inference pipeline.
Applicability boundaries and common misconceptions
Speculative decoding does not necessarily make every scenario faster. Be cautious in the following situations:
- The draft model and the main model differ too much in distribution, resulting in a very low acceptance rate.
- The draft model’s inference cost is too high, cancelling out the gains from parallel verification.
- The system is already compute-bound, so increasing parallelism does not translate into throughput.
- Memory is insufficient to hold the target model, the draft model, and the cache at the same time.
- The task is extremely sensitive to the output distribution, requiring strict evaluation of whether the verification algorithm is correct.
A common misconception is that “there is guaranteed to be a speedup as long as there is a draft model.” In fact, the essence of speculative decoding is to convert serial decoding into parallel verification, and benefits appear only when the acceptance rate is high enough and the verification cost is low enough.
A practical path for local inference
For developers who want to improve the LLM inference experience in a local environment, the following steps can serve as a reference:
- Identify the bottleneck: first determine whether the current system is limited by compute, by bandwidth, or by concurrency scheduling. If single-request generation speed is clearly below the theoretical compute value, speculative decoding is usually worth trying.
- Choose the draft model: prioritize a model that is tokenization-compatible, smaller, and stylistically similar to the target model.
- Build the verification logic: make sure the accept and reject flow is correct and that the cache can be rolled back accurately.
- Set the candidate length: start from a smaller value and adjust gradually, watching for changes in acceptance rate and latency.
- Set up a metrics dashboard: record time per token, accepted length, memory footprint, and concurrent performance.
- Combine with other optimizations: stack quantization, cache reuse, batching optimizations, and so on based on available resources.
Overall, speculative decoding offers a very important idea: with local hardware unchanged, it improves the effective output gained from each memory read by changing how token generation is organized. It does not depend on a larger GPU, nor does it necessarily require a larger model. Through smarter inference scheduling, it lets existing hardware operate at higher efficiency.
To summarize, the speed bottleneck in local LLM inference is often not just insufficient compute, but the serial memory-access pattern of the generation stage that leads to underused resources. Through “quick proposal, parallel verification, and on-demand rollback,” draft models and speculative decoding turn traditional token-by-token generation into a more parallel computation. While preserving the target model’s final output quality, it can lower single-request latency, raise throughput, and make local LLM inference more usable. For developers, the key to speculative decoding lies not only in introducing a draft model, but in understanding the balance among acceptance rate, cache consistency, sampling strategy, and concurrency scenarios. Only by handling these engineering details well can you make large-model inference genuinely faster, more stable, and more economical without upgrading your GPU.
