Speculative Decoding: Get Several Times Faster LLM Inference Without a New GPU
This article explains speculative decoding, a technique that can speed up large language model inference by several times in some scenarios without changing the GPU or further compressing the model. It looks at why LLM decoding is bottlenecked by memory bandwidth rather than raw compute, how the draft-then-verify approach works, and why it preserves the target model's output distribution exactly through an acceptance/rejection sampling algorithm rather than approximating it. It also covers average acceptance length as the real measure of speedup, the main strategies for producing drafts, and when the technique pays off versus when it needs caution.
Same machine, same model, same prompt — on one side the answer is already finished, while on the other it is still squeezing out one character at a time. This “typing at a snail’s pace” experience is almost universal for anyone running a large model locally for the first time. Surprisingly, without swapping the GPU or further compressing the model, simply changing the way tokens are generated can, in some scenarios, multiply single-request generation speed several times over. This technique is called Speculative Decoding, and it is now being adopted by mainstream inference frameworks, making it an unavoidable topic when deploying large models on-premises.
Why a Large Model Always Seems to “Load Itself” One Token at a Time
To understand the value of speculative decoding, you first need to see the two phases of large-model inference.
Prefill phase: After the user submits a prompt, the model processes the entire input at once, computing the attention relationships between all tokens and building the KV Cache (key-value cache). This phase handles a large volume of tokens in a single pass and is compute-intensive, mainly constrained by GPU compute, so it is usually fast.
Decode phase: This is where the slowdown actually happens. Once generation begins, the model can produce only one token per round. To generate the next token, the GPU must first read all model weights and the existing KV Cache from memory, and after computing, write the new key-value data back into the cache. Then, to generate the token after that, the same transfer process must be repeated in full again.
That is exactly where the problem lies. A model that is tens or even hundreds of gigabytes in size has to shuttle its massive weights back and forth between memory and the compute units for every single token it generates. At this point, what determines speed is often no longer how many compute cores the GPU has, but rather memory bandwidth — how fast data can be moved directly limits how fast tokens can be produced. Even with plenty of compute, the GPU can sit idle because it cannot be “fed” fast enough. This is a classic memory-bound problem.
The Core Idea of Speculative Decoding: Guess First, Verify Later
The idea behind a draft model is intuitive: hand off some of the easily predictable work to a smaller, faster model.
Imagine the user inputs the prompt “The cat.” A very small draft model can guess several candidate tokens in a row — “satin my lap.” Afterward, the target large model does not need to run once for each candidate; instead, it validates them all together with a single forward pass: any token that matches the target model’s probability distribution is accepted directly, and as soon as a token is rejected, that token and everything after it are discarded, and the target model generates the correct replacement token itself.
As an analogy, the old approach was for the target model to run three or four rounds, producing one token per round; the new approach is to first let an “intern” draft the answer, then have an “expert” stamp or revise it in a single batch review. Because the draft model is tiny, the cost of guessing wrong is far smaller than the cost of making the large model repeatedly shuttle its full set of weights. The industry usually summarizes it this way: the assistant model proposes candidates first, and the main model validates them all in a single forward pass.
The Key Premise: Why the Output Doesn’t “Change Flavor” After Speeding Up
Many people worry: if a small model does some of the “ghostwriting,” will it lower generation quality? The most elegant part of speculative decoding is precisely that — mathematically, it guarantees that the final output distribution is exactly identical to sampling directly from the target model, not an approximation.
At its core is an acceptance/rejection sampling algorithm. For each candidate token proposed by the draft model, a decision to accept is made based on the ratio of the target model’s probability to the draft model’s probability; when a token is rejected, a new token is resampled from the corrected distribution derived from the difference between the two. This mechanism ensures that the probability distribution of the output sequence is strictly equal to what you would get from sampling the target model on its own. In other words, speculative decoding is a “free speedup”: the results don’t change, it’s just faster. Understanding this point is the key to grasping the value of the technique, and it is what sets it apart from general model distillation or quantization — those methods alter the model itself, whereas speculative decoding does not modify a single weight.
Here is a schematic of the execution logic (pseudocode, for illustrating the flow only):
def speculative_decode(draft_model, target_model, prefix, gamma):# 1. The draft model proposes gamma candidate tokens in a rowcandidates, draft_probs = draft_model.propose(prefix, gamma)# 2. A single target-model forward pass yields the full probability distribution at each positiontarget_logits = target_model.forward(prefix, candidates)# 3. Verify each candidate one by one, keeping it according to the acceptance probabilityaccepted = 0for i in range(gamma):p = target_dist(target_logits, i) # target model distributionq = draft_probs[i] # draft model distributionif uniform(0, 1) <= min(1, p(x_i) / q(x_i)):accepted += 1 # accept this candidateelse:# Reject: resample from the corrected (p - q)+ distribution and end this roundreturn prefix + candidates[:accepted] + resample(p, q)# All accepted: sample one extra token to preserve distribution correctnessreturn prefix + candidates + target_model.sample_next(target_logits, gamma)
Average Acceptance Length: The Real Measure of Speedup
Speculative decoding may look like a “free lunch,” but the speedup factor is not fixed. The metric that truly determines its effectiveness is called average acceptance length — the average number of draft tokens the target model accepts per round.
- If the draft model guesses 4 tokens at once and 3 of them are accepted by the target model, that is equivalent to advancing 3 positions with a single large-model computation, a significant gain.
- Conversely, if the draft model guesses wrong frequently, and the target model must keep rejecting and correcting — or even “starting over” every round — then you pay the verification cost without gaining effective progress. The speedup ratio may approach 1, or the extra overhead may even make things slightly slower.
Here is a counterintuitive conclusion: writing more drafts does not necessarily make it faster. Setting the draft length too aggressively causes the acceptance rate to drop, which drags down overall throughput. In practice, therefore, you need to tune the number of draft tokens (the gamma in the pseudocode above) for the specific model and task.
Where Do the Drafts Come From: A Few Mainstream Strategies
A draft model doesn’t have to be “just find another small model”; other common approaches include:
- Independent draft model: Use a smaller model with the same vocabulary and style but fewer layers as the assistant. This is the most direct approach with stable results, but it requires maintaining an extra model.
- Self-speculation: Instead of introducing an external model, let the target model quickly produce drafts itself by skipping layers or exiting early, saving memory usage.
- N-gram / prompt lookup: For tasks with a lot of repetition, such as code completion or summarization and rewriting, directly retrieve and copy likely continuation snippets from the existing context as candidates — at almost zero extra cost, with clear benefits in scenarios where the hit rate is high.
When choosing, you should weigh the memory budget of the deployment environment, the predictability of the task, and the maintenance complexity.
When It Works, and When to Be Cautious
Speculative decoding is not a master key, and its speedup effect depends heavily on the scenario:
- Suitable: Generation tasks (dialogue, writing, code completion), scenarios where the draft and target distributions are similar, and large models with an obvious memory bottleneck. In these cases, the acceptance rate is often high, yielding several times the speedup.
- Requires caution: When the draft model’s style differs too much from the target model and the acceptance rate is too low, the gains get offset by verification overhead; tuning the draft length also requires repeated experimentation against the specific hardware and model, rather than applying a fixed value.
From an engineering perspective, integrating it into an existing inference framework is not complex. Many mainstream inference engines already have related capabilities built in, and developers usually just need to configure the draft model and draft length to enable it. If you need to roll it out at scale in the cloud, you can combine it with general capabilities such as containerized inference services, monitoring and alerting, and log analysis to continuously observe metrics like acceptance length, throughput, and latency, and dynamically optimize the draft strategy.
Conclusion
The essence of speculative decoding is transforming the memory-intensive, serial process of “shuttling weights one token at a time” into the efficient pattern of “batch guessing plus a single verification.” It doesn’t swap the GPU, doesn’t change the weights, and doesn’t sacrifice output quality, yet it can significantly ease the awkwardness of large models “loading word by word” locally. For developers who want a faster inference experience on limited hardware, understanding and embracing the role of the draft model is becoming a required lesson for running large models locally.
