Speculative Decoding: How to Speed Up Local LLM Inference Without More GPU Compute
Local LLM inference is usually bottlenecked by memory bandwidth during the decode phase, not by raw GPU compute, which is why simply compressing the model or upgrading hardware often fails to move the needle. Speculative decoding attacks the problem differently: a small draft model proposes several candidate tokens, and the target model verifies them all in a single forward pass, trading cheap drafting work for expensive repeated weight transfers. This article covers where local inference actually loses time (prefill vs. decode), how speculative decoding works and why it leaves output quality unchanged, the average acceptance length metric that determines whether it pays off, a reference pseudocode implementation, and the practical tradeoffs around draft model choice, latency versus throughput, and monitoring.
1. Where local LLM inference actually breaks down
When deploying a model locally or in a private environment, the first instinct is often “we don’t have enough GPU compute,” followed by aggressive quantization or a hardware upgrade. In practice, generation speed is far more often limited by memory bandwidth than by the number of compute units. Understanding this starts with the two phases of a single inference call.
Prefill
Once the user submits a prompt, the model processes the entire input at once, computing attention and building the KV cache. This phase ingests many tokens in parallel and is compute-intensive, so it is primarily bound by FLOPS. For long prompts it is usually fast.
Decode
Almost all of the pain lives here. During decode, the model produces one token at a time. To generate the next token, the GPU must:
- Read the full model weights and the existing KV cache from GPU memory;
- Run one forward pass;
- Write the newly produced keys and values back into the cache;
- Repeat the entire cycle for the next token.
A model’s weights can easily run to tens or even hundreds of gigabytes, and every single token requires moving all of that data again. What limits throughput here is memory bandwidth and data-movement efficiency, not compute units. This is the root cause of local inference feeling like it is “typing itself out one letter at a time”: the compute units sit idle while the memory bus runs flat out.
2. Speculative decoding: a small model drafts, the large model grades
Speculative decoding rests on a simple insight: if a forward pass of the target model is expensive, can one such pass confirm multiple tokens instead of one?
The answer is to add a much smaller draft model. The loop works as follows:
- The draft model proposes several candidate tokens (for example, four);
- The target model runs one forward pass over the existing sequence plus those candidates, yielding the true probability distribution at each position;
- The candidates are verified one by one: tokens that match the target distribution are accepted outright, and once the first rejection happens, all subsequent drafts are discarded;
- The rejected position is filled by resampling a “correction token” from the target model’s distribution.
An analogy: a passage that previously took three or four rounds of target-model generation may now be confirmed in a single verification pass. The more accurate the draft model, the more tokens each target forward pass advances, and the larger the payoff.
One important guarantee: output quality does not change. Every accepted token is checked against the target model’s probability distribution, so the effective sampling distribution is identical to the original model. Acceleration changes how results are produced, not what the results are.
3. The metric that decides success: average acceptance length
Speculative decoding can look like a free lunch, but the gains are not automatic. The decisive metric is average acceptance length — the average number of draft tokens the target model accepts per round.
- If the draft model proposes four tokens and three are accepted, one target forward pass advances multiple positions at once, which is a clear win;
- If the draft model guesses wrong frequently, the target model spends its time rejecting and correcting, and the extra drafting and verification overhead can slow generation down overall.
In other words, speculative decoding trades cheap draft computation for expensive repeated weight movement. Whether the trade is worth it depends on the relative cost of the two sides. Smaller and more accurate draft models make it more attractive; a large mismatch between draft and target quality makes it a net loss.
4. Illustrative implementation
The pseudocode below describes the core speculative decoding loop and shows how the pieces fit together:
def speculative_decode(target_model, draft_model, prompt,num_draft=4, max_new_tokens=256):output = promptgenerated = []while len(generated) < max_new_tokens:# 1. The draft model generates num_draft candidate tokensdraft_tokens = draft_model.generate(output, num_tokens=num_draft)# 2. The target model runs a single forward pass over# "existing sequence + draft tokens" to obtain the true# probability distribution at each positiontarget_probs = target_model.forward(output + draft_tokens)# 3. Verify position by position and accumulate accepted tokensaccepted = []for i, tok in enumerate(draft_tokens):if accept(tok, target_probs[i]):accepted.append(tok)else:# 4. At the first rejected position, sample a correction# token from the target model and stopaccepted.append(target_model.sample(target_probs[i]))breakoutput += acceptedgenerated += acceptedif has_eos(accepted):breakreturn output
As the code shows, one round of drafting plus one target forward pass can produce multiple settled tokens. Whenever the average acceptance length exceeds 1, the result is a net speedup over token-by-token generation.
5. Key tradeoffs in production
Choosing a draft model
Draft models are usually drawn from the same family as the target model — typically a smaller variant — because their probability distributions are closer, which raises the acceptance rate. Approaches that avoid a separate draft model exist as well, such as n-gram or early-layer predictions based on the target model itself, but pairing the target with a small, fast draft model remains the common practice.
Single-request latency and concurrent throughput are different problems
- For single requests at low load, the decode-phase bandwidth bottleneck is most pronounced, and speculative decoding can often raise generation speed to several times the original rate;
- Under high concurrency and high load, the system is already close to compute saturation, so the throughput gains from speculative decoding shrink somewhat, though they are usually still meaningful.
Decide up front which problem you are solving: latency sensitivity for individual requests, or aggregate throughput.
Fitting into an existing inference stack
Speculative decoding is gradually being adopted by mainstream inference frameworks as an optional capability. On the deployment side, whether you build your own inference service or use a cloud platform, it is worth doing the following:
- Include the draft model alongside the target model in deployment and monitoring;
- Continuously observe average acceptance length — it is the first signal of whether acceleration is actually working;
- Use general capabilities such as log collection and monitoring alerts to track latency and throughput across different load levels, and tune parameters like draft length dynamically.
For teams that want to run these capabilities in their own environment, general-purpose deployment, monitoring, and operations features offered by cloud platforms such as Baidu AI Cloud can serve as one foundation for hosting the inference service.
6. Summary
The value of speculative decoding is that it sidesteps the old path of “swap in a better GPU, pile on more compute” and instead looks for efficiency in how tokens are generated: a lightweight draft model drafts, the target model grades everything in one pass, and what used to require multiple target forward passes collapses into a single verification.
Output quality stays the same, yet in bandwidth-constrained local inference the technique can deliver several-fold gains in single-request speed along with meaningful throughput improvements. For developers, the practical takeaway is to understand average acceptance length as the core metric, configure the draft model and draft length sensibly, and keep tuning against a solid deployment and monitoring setup — that is what makes local LLM inference both fast and accurate.
