Speculative Decoding: Speeding Up LLM Inference Without Upgrading Your GPU
This article explains why large language model (LLM) generation often hits a bottleneck even when the GPU is not fully utilized, and how speculative decoding addresses it. It breaks down the two phases of inference—prefill and decode—and shows why the decode phase is limited by memory bandwidth rather than raw compute. You will learn how a small draft model proposes candidate tokens while the target model verifies them in a single parallel forward pass, why this remains lossless, and how acceptance length determines the actual speedup. It also covers where draft models come from, how batch size and the speculation length K affect results, and the engineering trade-offs to weigh before enabling it.
Introduction: No new hardware, so where does the speed come from?
When you run a large language model locally or in the cloud, a common puzzle appears: the GPU’s compute is not even maxed out, yet generation speed seems stuck at a bottleneck. To understand why, you need to look at the basic structure of LLM inference. Speculative decoding is one acceleration approach designed for exactly this bottleneck. It does not change the quality of the model’s output, and it does not depend on hardware upgrades. Instead, it changes the way tokens are generated so that each expensive computation step “gets more done at once.” In the right scenarios, single-request generation speed can improve by close to several times, and concurrent load testing often shows a noticeable gain in throughput.
1. Why LLMs always seem to “load themselves one token at a time”
A complete model inference run typically has two phases, and their performance characteristics are completely different.
The prefill phase handles the user’s input. The model reads the entire prompt at once, computes attention in parallel, and builds the KV cache (the key-value cache). Because it processes a large number of tokens in one go, this step is compute-intensive and is primarily bounded by compute power.
The decode phase generates the answer one token at a time. Here the model can produce only a single token per step, and the process repeats:
- To generate the next token, the GPU must read the model’s entire set of weights and the existing KV cache from memory into the compute units;
- it performs one computation;
- it writes the newly produced key-value data back into the cache.
This is where the problem lies. A model can easily be tens or even hundreds of GB, and generating each token means “moving” that massive set of weights around again. In this phase, how many compute units the GPU has is no longer the only deciding factor. Memory bandwidth and data movement speed directly limit generation speed. In other words, the decode phase is memory-bandwidth-intensive. The expensive compute sits largely idle, turning the process into an inefficient loop of “loading itself one token at a time.”
2. The core idea of speculative decoding: run the compute at full capacity once
The key insight behind speculative decoding is this: since the cost of a single forward pass is almost fixed, you might as well have it verify several tokens at once. The approach introduces a very small, very fast draft model:
- The draft model does the “guessing”: it predicts several candidate tokens in a row, at a cost far lower than the target model;
- The target model does the “verifying”: it runs a single parallel forward pass over these candidates to check whether they match its own probability distribution.
Here is an intuitive example. The input is “The cat,” and the draft model might predict “sat on my lap” in one shot. The target model does not generate token by token. Instead, it checks all of these candidates with a single forward pass: if the leading candidates match the target model’s distribution, they are accepted directly; at the first mismatch, it discards that position and every candidate after it, then samples a corrected token at that spot.
So progress that once took the target model three or four rounds to advance can now be compressed into one round of verification. The draft model is small, and the cost of generating candidates is far lower than the cost of the target model repeatedly reading its full weights. The speedup comes from exactly this.
It is worth emphasizing that speculative decoding uses an acceptance mechanism with randomized correction to guarantee that the final output distribution is identical to that of the target model. In other words, this is lossless acceleration: it gets faster, but the answer quality is still governed by the same target model and is not degraded by “taking a shortcut.”
3. Illustrative pseudocode: one speculative decoding loop
The pseudocode below is only meant to illustrate the flow. It is not the interface of any specific product:
def speculative_decode(draft, target, prompt, K=4, max_len=256):output = list(prompt)while len(output) < max_len:# 1. The draft model autoregressively predicts K candidate tokenscandidates = draft.generate(output, K)# 2. The target model verifies all candidates with a single parallel forward passlogits = target.forward(output + candidates)# 3. From left to right, accept the tokens that match the target distributionaccepted = 0for i in range(K):if accept(candidates[i], logits[i]):accepted += 1else:break# 4. Emit the accepted tokens, then sample one corrected token at the first rejectionoutput.extend(candidates[:accepted])output.append(resample(logits[accepted]))return output
The key is step 2: no matter how many candidates are being verified, the target model performs only one forward pass, and that is exactly where the time is saved.
4. The real deciding factor: acceptance length
Speculative decoding is not an automatic “free lunch.” The core metric that determines its payoff is called acceptance length—how many draft tokens the target model accepts on average per round.
- If the draft model predicts 4 tokens in one shot and 3 of them are accepted, that is equivalent to advancing 3 or more positions with a single target-model computation, a significant gain;
- If the draft model guesses wrong frequently, the target model has to keep rejecting and correcting, and the extra draft computation and verification overhead can actually slow things down overall—even producing a “negative optimization.”
Therefore, the draft model must be small enough and fast enough, while still being sufficiently “in tune” with the target model. This is a trade-off that has to be balanced: too weak and the acceptance rate is low; too strong and its own overhead is too high.
5. Where draft models come from: a few common strategies
Industry practice is not limited to “just find a separate small model.” Common approaches include:
- Independent small model: choose a small-parameter model from the same family as the target model, with a matching vocabulary, for relatively stable prediction quality;
- Self-speculation: use the large model’s own shallow layers or an early-exit mechanism to produce drafts, avoiding the need to maintain two sets of weights;
- Retrieval-based speculation: look up repeated segments directly from the prompt context as candidates, which is especially well suited to code completion, text rewriting, and other copy-heavy scenarios.
Which strategy you choose depends on your model architecture, hardware conditions, and the characteristics of your business workload.
6. Engineering considerations and applicability boundaries
The effectiveness of speculative decoding depends heavily on the scenario. A few points to watch when putting it into practice:
- Impact of batch size: with small batches, decode is in the memory-bandwidth-bound region, and speculative decoding delivers its biggest gains; when the concurrent batch is large and compute is fully fed, the system becomes compute-intensive, and the speedup narrows noticeably.
- Tuning the speculation length K: too small and you waste verification capacity; too large and the drafts become increasingly error-prone the further they go. Tune it dynamically or empirically based on the actual acceptance rate.
- End-to-end cost: account for both the draft model’s memory footprint and compute overhead, and confirm the overall result is a net gain rather than robbing one place to pay another.
- Workload fit: highly repetitive, highly predictable tasks (such as structured output, code, and formatted text) tend to have higher acceptance rates and are more worth enabling.
This kind of acceleration approach is gradually being absorbed by mainstream inference frameworks and is increasingly showing up as an option in enterprise-grade LLM inference platforms. Taking Baidu AI Cloud’s related inference services as an example, when engineering teams evaluate optimizations like this, they typically weigh business concurrency characteristics, model scale, and hardware bandwidth together, then decide on the speculation length and draft strategy—rather than switching it on blindly.
Conclusion
The essence of speculative decoding is to reuse idle compute in the memory-bandwidth-bound decode phase by “verifying multiple tokens at once.” It does not change the model and does not require a new GPU, yet under the right workload it can deliver a meaningful improvement in speed and throughput. Understand the core metric of acceptance length, match the draft model to your business scenario, and you can turn this “speed dividend” into real gains.
