A giant model reads out one token at a time — slow, because each token drags all its weights through the GPU. So hire an understudy: a small fast model guesses the next few tokens, and the star checks them all in one pass, keeping every guess it agrees with. Same performance, a fraction of the passes.
Act 1 · Why decode is slow
One token, one whole model
Generating text token-by-token means one forward pass per token — and each pass streams every weight of a 70B model through the GPU. The compute is trivial; the memory movement is the wall. Watch the passes stack up.
Output (1 forward pass each)
0
Tokens produced
0
Forward passes
1.0
Tokens / pass
Standard autoregressive decode: tokens-per-pass is stuck at exactly 1. Every token pays the full memory cost of the model. Speculative decoding attacks precisely this ratio.
Act 2 · The trick
Draft, then verify in one pass
The draft model (small, fast) guesses the next 4 tokens. The target model checks all 4 in a single pass, accepting each while it agrees — until the first mismatch, which it corrects. Then the draft guesses again from there.
Draft model proposes
Target verifies → committed output
0
Tokens committed
0
Target passes
—
Tokens / pass
Every green token was produced "for free" — verified in a pass that would otherwise make just one token. The one yellow correction per round is the target having the final say, which is what keeps output identical.
Act 3 · The dial that matters
Acceptance rate is everything
Speedup rides entirely on how often the draft agrees with the target. A draft that mimics the target well gets long accepted runs; a poor one gets rejected constantly. Tune the acceptance rate and the draft length, and watch the speedup respond.
Draft acceptance rate70%
Tokens drafted per round (K)4
—
Avg accepted / round
—
Wall-clock speedup vs plain
—
Optimal K here
There's a sweet spot in K: draft too few and you underuse the free parallel pass; draft too many and you waste the small model on tokens that get rejected anyway. The best K rises as acceptance rises.
Why guessing is faster than working
The counterintuitive core: the big model still runs, yet you finish sooner. The resolution is that LLM decode is memory-bound. Producing one token means streaming every weight of the model through the GPU once; the actual arithmetic barely registers next to that memory traffic. So a forward pass has enormous spare compute — you're paying to move the weights whether you use that compute or not.
Speculative decoding spends that spare compute. Instead of asking the target "what's the next token?", you ask "here are 4 proposed tokens — for each position, what would you have said?" — and it answers all 4 in one weight-streaming pass. Every proposal it agrees with is a token you got without paying a second pass.
The lossless guarantee
It's not a quality gamble. The acceptance test uses the target's own probabilities, and rejected positions are re-sampled from the target — so the output is provably distributed exactly as if the target generated every token. You are not trading accuracy for speed. You're trading spare compute for it.
Where the draft comes from
The draft model just needs to be fast and usually right: a small model from the same family, a distilled version, or even the model's own extra prediction head (as in Medusa or the multi-token-prediction head DeepSeek-V3 trains). The closer the draft mimics the target, the higher the acceptance rate, the bigger the win.
The tuning
Two knobs. Acceptance rate is set by draft quality — better draft, longer accepted runs. K, the number of tokens drafted per round, has a sweet spot: too small underuses the free parallel verification, too large wastes draft effort on tokens likely to be rejected. Real systems see roughly 2-3× faster generation — pure latency, identical output.
The picture: one round, four drafts, three tokens
Act 2’s round, drawn with the accept rule from the step-by-step section below. The probabilities are illustrative. “sat” is never at risk, because the target likes it at least as much as the draft did. “on” survives a coin flip weighted 0.6. “a” loses its flip, so the target samples a replacement from the probability the draft under-covered. “mat” was drafted on the assumption that “a” came before it, so it is thrown away along with its cache entry. If all four had passed, the bonus slot would have added a fifth token from the same pass.
Cost and trade-offs: when the draft pays for itself
Time is wall-clock speed relative to plain decoding: tokens per target pass divided by 1 + K·c. Space is the extra memory. The widget prices one draft step at c = 0.12 of a target pass, and the figures use that.
The baseline. Every token pays the full cost of streaming the weights.
Separate draft, α = 0.7, K = 4
2.77 tokens per pass, 1.87× wall-clock
A second model, plus its own KV cache
Act 3’s defaults. The draft’s cost is why 2.77 tokens per pass becomes 1.87×.
Separate draft, α = 0.3, K = 4
1.43 tokens per pass, 0.96×
Same
Slower than not speculating. At this acceptance rate the best K is 1 (1.16×). A weak draft needs a short K, or no draft at all.
Draft always rejected (α → 0)
1 token per round, 0.68× at K = 4
Same
The floor: you pay for four draft steps and still get only the one token the target corrects.
Extra heads on the target (Medusa, MTP)
Draft cost near zero, acceptance lower for later positions
A few small heads, no second KV cache
The heads have to be trained, but serving one model is simpler than keeping two in step.
Prompt lookup (n-gram copy)
Draft cost about zero
None
Only wins when the output copies the input: edits, quoting, extraction. On open-ended chat it is rarely accepted.
Large batch
The speedup shrinks
Verification slots for every sequence
The target is closer to compute-bound, so the extra positions it checks are no longer free.
The page’s 2–3× figure assumes a good draft. The break-even is easy to compute. With K = 4 at this draft cost, speculation pays only above an acceptance rate of about 0.33. The widget’s headline speedup in Act 3 is this wall-clock figure, so it does fall below 1×: at 30% acceptance and K = 4 it reads 0.96×, slower than plain decoding. Measure α on real traffic before turning speculation on, and let K adapt to it.
Where this shows up in production
Interactive serving at small batch
A chat or coding assistant serving one user per sequence is the memory-bound case, where a pass has spare compute to verify drafts. Teams measure acceptance by traffic class, because code and templated replies accept far more drafts than free-form conversation. As batches fill up the gain shrinks, so it is worth shortening K or turning speculation off under load.
Local inference
On a laptop or a single GPU the batch size is almost always one, which is the case speculation helps most. llama.cpp, for example, can load a second, smaller model as the draft. The draft must use the target’s tokenizer, which in practice means a smaller model from the same family.
Models that draft for themselves
Medusa adds extra decoding heads. EAGLE drafts from the target’s own hidden features. DeepSeek-V3 trains a multi-token-prediction module that can be reused as a draft at inference. All three move the draft inside the target, so there is no second model to deploy, version and keep in step.
The interview question
“Make decoding twice as fast without changing a single output.” A strong answer covers four things. Decode is memory-bound, so verifying K tokens costs about one pass. The accept-or-resample rule keeps the output distribution exact. Speedup is (1 − α^(K+1)) / (1 − α) divided by the draft overhead. And the gain falls at large batch sizes, and can turn negative when acceptance is low.
Speculative decoding, step by step
The accept-or-resample rule is what makes the speedup free of any quality cost. Here it is as steps, then checked by hand on a three-token vocabulary, with the arithmetic behind the speedup numbers in Act 3.
One round of the algorithm
Draft. The small model q proposes K tokens one at a time, recording the probability q(x) it gave each.
Score in one pass. The target p runs once over the prefix plus all K drafts and returns its distribution at all K + 1 positions.
Accept left to right. Keep draft token x with probability min(1, p(x) / q(x)), and stop at the first rejection.
Repair or extend. At a rejection, sample a replacement from norm(max(0, p − q)), the target probability the draft under-covered. If all K pass, sample one bonus token from the target's last distribution. Each round therefore yields between 1 and K + 1 tokens.
Worked example: proof that nothing changes
Setup. Over tokens A, B and C the draft gives q = (0.6, 0.3, 0.1) and the target p = (0.4, 0.4, 0.2).
Acceptance. B and C are always kept, since p ≥ q for both. A is kept with probability 0.4/0.6 = 2/3, so a rejection happens 0.6 × 1/3 = 0.2 of the time.
Repair. max(0, p − q) = (0, 0.1, 0.1), normalized to (0, 0.5, 0.5).
Result. A: 0.6 × 2/3 = 0.4. B: 0.3 + 0.2 × 0.5 = 0.4. C: 0.1 + 0.2 × 0.5 = 0.2. Exactly the target's p, and the acceptance rate is α = Σ min(p, q) = 0.8.
Tokens per target pass are (1 − α^(K+1)) / (1 − α) when each draft is accepted with probability α: 3.36 for α = 0.8 and K = 4, 2.31 at α = 0.6, and 4.33 at α = 0.8 with K = 8.
Wall-clock speedup divides that by 1 + K·c, where c is one draft step's cost relative to a target pass. At c = 0.05 and α = 0.8, K = 4 gives 2.80× and K = 8, the best K, gives 3.09×. Act 3's defaults, α = 0.7 and K = 4, give 2.77 tokens per pass; with its draft cost of 0.12 that is 1.87× in wall-clock time, and K = 4 is the optimum.
Knobs and pitfalls
The draft must share the target's tokenizer, and the key-value cache entries for rejected tokens have to be rolled back. The gain is largest at small batch sizes, where decode is memory-bound; in a large batch the target is closer to compute-bound, verification stops being free, and the speedup shrinks. Measure α on your real traffic, since predictable text such as code or templated output is accepted more often than open-ended chat.
Draft sources trade quality for cost: a small model from the same family, extra prediction heads (Medusa, or DeepSeek-V3's multi-token prediction), a feature-level draft head (EAGLE), or no model at all, with n-gram prompt lookup that copies spans from the context, which works well for edits and retrieval answers. vLLM, SGLang and TensorRT-LLM all ship speculative decoding.
Check yourself
Four questions. No guessing — well, a little.
See every answer, with the reasoning
Why can the big model produce several tokens in one forward pass?
Answer: Decode is memory-bound, so a pass has spare compute to verify several drafted tokens at once — Streaming the weights once is the cost; verifying K guesses in that pass is nearly free compute.
Does speculative decoding change the output distribution?
Answer: No — rejected tokens are re-sampled from the target, so it is provably lossless — The target has the final say at every position, so output matches plain decoding exactly.
What most determines the speedup?
Answer: The acceptance rate — how often the draft agrees with the target — Better draft → longer accepted runs → bigger win. It is the dial that matters most.
What is a good source of a draft model?
Answer: A small same-family model, a distilled version, or the target’s own extra prediction head — The draft must be fast and usually right; MTP heads (e.g. DeepSeek-V3) do this in-model.