AI State of the Art
SOTA/Inference & Optimization/34 min
Section 122

Speculative decoding: draft model and verification

Listen as a podcast →

The speed problem

Generating text with a large language model (LLM) happens one token at a time. Each token requires a full traversal of the model, a forward pass: numbers go in one end, travel through every layer, and a token comes out the other.

That traversal is limited by memory bandwidth, not by compute power. To produce a single token, the chip must re-read all of the model's weights from memory, and its arithmetic units spend most of their time waiting for data. This is the fact that governs the whole module; it is laid out in detail in Quantization: the concepts, and it is worth revisiting before reading on.

The orders of magnitude, on an 80 GB NVIDIA A100 graphics processing unit (GPU), from its datasheet:

  • compute: roughly 312 TFLOPS in 16-bit format, FLOPS stands for floating-point operations per second, and "tera" means a thousand billion, so 312,000 billion operations per second;
  • memory bandwidth: roughly 2 TB/s, that is 2,000 billion bytes read per second.

Divide one by the other: the chip can perform about 156 operations in the time it takes to read a single byte (312,000 ÷ 2,000). But when generating a token for one request, each weight that is read feeds only two operations, one multiply and one add. In FP16 a weight takes 2 bytes, so that is one operation per byte read. We are using barely 1/156 of the available compute: the chip sits idle more than 99 % of the time.

Now the clock. A 7-billion-parameter model in FP16 weighs 14 GB (2 bytes × 7 × 10⁹). Streaming those 14 GB at 2 TB/s takes 7 milliseconds. That is a floor: even with instantaneous arithmetic, this model cannot exceed roughly 140 tokens per second for a single isolated request. A 70-billion-parameter model means 140 GB, more than one A100 holds, so you need several, and the floor rises accordingly.

The single-request paradox

Generating one token consumes as much memory bandwidth as generating ten at once: either way the same weights have to be streamed. That is enormous waste, and two families of techniques exploit it. Speculative decoding gets several tokens of the same request out of one pass of the large model. Batching makes one pass serve several different requests. Both answer the same underlying cause.

The idea

The clearest analogy: a senior partner (the large model) and an intern (the small model). The intern drafts five sentences at once. The partner reads all five in a single glance, signs off on the first three, strikes the fourth and writes the right one himself. That is far faster than the partner writing every sentence from scratch, and the result still carries his signature, because nothing gets through without his review.

The trick, in four steps

  1. A small, fast model proposes K candidate tokens (often 4 to 8). It does K passes, but they are cheap: the model is light, there are few weights to stream.
  2. The large model checks them all in a single pass. This is the heart of the method: it receives the text so far plus all K candidates at once, and computes in one go the probability it would have assigned to each.
  3. You keep the accepted prefix: the candidates validated in order, up to the first rejection.
  4. At that first rejection, the large model writes the replacement token itself, and you continue from there.
Nine successive lines of text generation. Each line starts with START, then shows already-validated tokens in black, accepted draft tokens in green, one struck-through red token that was rejected, and a blue token produced by the large model as its replacement.
Each line is one iteration of the procedure. In green, the tokens proposed by the small model and accepted as-is. Struck through in red, the first rejected token, immediately replaced by the blue token the large model produces instead. One iteration advances the text by several words at once instead of just one. In the authors' example, a 38-token sentence was produced with only 9 passes of the large model.Source : Fast Inference from Transformers via Speculative Decoding paper (Leviathan et al., 2023), figure 1, via ar5iv

Why checking K tokens costs almost nothing

Because the bottleneck is reading the weights, and that cost is the same whatever the number of tokens being checked. Streaming 14 GB of weights to judge one token, or to judge six, is the same stream. You pay once and collect up to six answers.

This is exactly the previous section turned the right way round: the chip was 99 % idle, and we fill a little of that idleness with useful work.

The guarantee: identical, not approximate

Here is the decisive point, and the one most often stated badly. The token sequence produced by speculative decoding follows exactly the same probability distribution as if the large model had written everything itself. Not "almost as good", not a controlled approximation: statistically the same thing. The original paper's abstract puts it bluntly, a 2× to 3× speedup, "with identical outputs".

This is not magic, it is an acceptance test borrowed from statistics. Set up the notation. For a candidate token written xx:

  • q(x)q(x) is the probability the small model assigns to that token;
  • p(x)p(x) is the probability the large model assigns to it.

Both are numbers between 0 and 1, recomputed at each position from the text so far. They are not parameters of the model: they are computed results.

accept x with probability min⁡(1,p(x)q(x))\text{accept } x \text{ with probability } \min\left(1, \frac{p(x)}{q(x)}\right)

In one sentence: if the large model likes the token at least as much as the small one does, accept it always; otherwise accept it only in proportion to how much less it likes it. Symbol by symbol: p(x)/q(x)p(x)/q(x) is the ratio of the two probabilities. If it is 1 or more, the large model agrees or is more enthusiastic, so the smaller of 1 and the ratio is 1, and acceptance is certain. If it is, say, 0.4, the small model was two and a half times overconfident, and the token is accepted only 40 % of the time. The test strips out exactly that excess confidence.

On rejection you do not let the large model sample as usual: that would be biased, because the easy cases have already been served by the acceptances. Instead you sample from the residual distribution: what is left of pp once you subtract what the acceptances already delivered. For each token in the vocabulary that leftover mass is max⁡(0, p(x)−q(x))\max(0,\ p(x) - q(x)), and you then divide everything by its total so the probabilities sum to 1 (that is what renormalizing means). The max⁡(0,⋅)\max(0, \cdot) ("the larger of 0 and p(x)−q(x)p(x)-q(x)") zeroes out the tokens the small model was already overestimating: those have had their share, they do not come back for more.

Add it up, token by token: accepted mass + residual mass = p(x)p(x), exactly. That is where the guarantee comes from.

Bar chart titled Probability Mass Decomposition. For five tokens A to E, each bar is split into three colored parts: green for the accepted mass (overlap between the two distributions), blue for the residual present only in the large model, red for the small model's excess that gets rejected.
Probability decomposition for each candidate token. The green part is the overlap between the small model q and the large model p: that is what gets accepted outright. Red is what the small model over-proposes and gets rejected; blue is the missing mass, recovered by sampling from the residual distribution. Green plus blue reconstructs exactly p, which is why the scheme is provably lossless.Source : Marcel Brenndoerfer, Speculative Decoding Math: Algorithms and Speedup Limits
Fast Inference from Transformers via Speculative Decoding (Leviathan et al., 2023)

What sets the payoff: the acceptance rate

The method is exact no matter what. What varies is how much it saves, and that comes down to a single quantity: the acceptance rate, written α\alpha (alpha), the average probability that a token proposed by the small model passes the test. The authors show that the average number of tokens gained per pass of the large model is:

E=1−αγ+11−αE = \frac{1 - \alpha^{\gamma+1}}{1 - \alpha}

The symbols: α\alpha is the average acceptance rate, a number between 0 and 1; γ\gamma (gamma) is how many tokens the small model proposes per iteration (the K above); EE is the average number of tokens produced per iteration, hence per pass of the large model. αγ+1\alpha^{\gamma+1} reads "alpha to the power gamma plus one".

In one sentence: you advance more tokens per pass the better the small model guesses, and lengthening the draft only helps if you already guess well. Two limiting cases make the formula clear:

  • If α\alpha is near 0 (the small model is always wrong), EE equals 1: you fall back to ordinary decoding, one token per pass. You never lose ground, and that is where the "plus one" in γ+1\gamma+1 comes from: even when every candidate is rejected, the large model still produces its own replacement token, which is correct.
  • If α\alpha is near 1, EE tends to γ+1\gamma+1: you bank the whole draft plus one.

The wall-clock gain is somewhat smaller, because running the small model costs something. Writing cc for the cost of one pass of the small model relative to one pass of the large one (say 0.06 if the small one is about sixteen times cheaper), the speedup is E/(γc+1)E / (\gamma c + 1): the denominator is what you pay, namely γ\gamma passes of the small model plus one pass of the large.

A worked example, end to end. With α=0.75\alpha = 0.75 and γ=4\gamma = 4: 0.755=0.2370.75^5 = 0.237, so E=(1−0.237)/0.25≈3.05E = (1 - 0.237) / 0.25 \approx 3.05 tokens per pass. If the small model costs c=0.06c = 0.06, the denominator is 4×0.06+1=1.244 \times 0.06 + 1 = 1.24, and the speedup is 3.05/1.24≈2.5×3.05 / 1.24 \approx 2.5\times. That lands squarely in the range the authors measured.

Measured acceptance rates

The paper reports observed values of α\alpha. All the ones below are for greedy decoding, always taking the most probable token, which the authors label T=0. They speak directly to how you pick the small model.

Large verifying modelSmall proposing modelAcceptance rate α\alpha
LaMDA, 137 billion parametersLaMDA, 100 million0.61
LaMDA, 137 billionLaMDA, 2 billion0.71
LaMDA, 137 billionLaMDA, 8 billion0.75
T5-XXL, 11 billion (translation)T5-small0.75
T5-XXL, 11 billion (translation)plain bigram table0.20

Source: Leviathan et al., 2023, table 3. Two lessons. First, a small model from the same family works remarkably well even when it is a thousand times smaller (0.61 for LaMDA 100M against 137B). Second, growing the proposer buys little: going from 2 to 8 billion parameters lifts α\alpha from 0.71 to 0.75 while quadrupling the cost cc. That is a trade, not a clear win.

The authors also note that the acceptance rate drops when tokens are sampled at random according to their probability rather than always taking the most probable one, which matches intuition: the more open-ended the generation, the harder it is to guess.

Chart titled Expected Tokens per Iteration. The x-axis is acceptance probability from 0 to 1, the y-axis the average number of tokens produced per iteration. Four curves correspond to draft lengths k equal to 1, 3, 5 and 10; all rise slowly then very steeply beyond 0.8. An annotation marks the asymptotic limit 1 over 1 minus alpha.
The average number of tokens gained per iteration, plotted against the acceptance rate: the formula above, drawn. The payoff is not proportional, it climbs gently through the usual range, then very steeply beyond 0.8. Making the draft longer (larger k) only pays off when the acceptance rate is already high, hence the value of picking a small model close to the large one.Source : Marcel Brenndoerfer, Speculative Decoding Math: Algorithms and Speedup Limits
Choosing the small model

Take it from the same family as the large one: trained on similar data, and above all using the same tokenizer. That last point is not negotiable, if the two models do not cut text into the same pieces, you cannot even compare pp and qq token by token, and the acceptance test loses its meaning. Two unrelated models pose a correctness problem before they pose a performance problem.

Measured results

The authors compare wall-clock times on T5-XXL, an 11-billion-parameter model, on two tasks (English-to-German translation and news summarization) against the reference T5X implementation. They report a 2× to 3× speedup with no change to the outputs. That is the number to remember, together with its conditions: that hardware, that model, those tasks, one request at a time.

Be careful not to carry that "2× to 3×" elsewhere unexamined. The gain depends on the model pair, the task, the sampling settings and the server load. The formula in the previous section says precisely what it depends on; apply the formula to your own case, not the number.

Variants

Self-speculative decoding

Do without the second model by using the model's own intermediate layers as the draft: read the output after, say, a third of the layers, draw candidates from it, then verify with the full model. Real advantage: no second model to hold in memory. Expected drawback: intermediate layers guess less well than a genuine small model, so the acceptance rate is lower.

N-gram speculation

No draft model at all. An n-gram is simply a run of n consecutive words. The idea: look in the text already on hand (the user's prompt, plus whatever has been generated) to see whether the current run has appeared before, and if so propose the continuation that followed. If the document contains "machine learning" and the model has just written "machine", bet on "learning". Zero memory overhead, but the acceptance rate depends entirely on how repetitive the text is, excellent for document rewriting or form filling, weak for open prose.

Multiple heads

Instead of a second model, graft extra prediction heads onto the large model itself, each one guessing one step further ahead. That is a distinct family, covered in Medusa and Multi-token prediction. The difference fits in one sentence: two separate models here, one model with several outputs there.

Confidence-scheduled speculation (DSpark)

Two weaknesses show up when a model is served at scale. Drafts proposed all at once degrade quickly (the fifth guessed token ignores what became of the first four), and systematically verifying a long draft whose tail will probably be rejected wastes compute, which is expensive when the server is full. DSpark, published by DeepSeek in July 2026, adds a small sequential module to the drafter that accounts for the previous tokens, and above all a confidence head that estimates, position by position, the probability that the draft is accepted up to that point. The scheduler then chooses, for each request, how many tokens to verify, taking the engine's load into account. On DeepSeek-V4's service, the paper reports per-user speed 60 to 85% higher than the single-guessed-token baseline, at equal total throughput. The technique ships in the open DeepInfer engine.

DSpark: Confidence-Scheduled Speculative Decoding with Semi-Autoregressive Generation

In practice

The common serving engines (vLLM, TGI (Text Generation Inference, Hugging Face's inference server) and TensorRT-LLM (NVIDIA's inference engine)) all offer speculative decoding as a configuration option: you name the draft model and how many tokens to speculate. The exact option names change from release to release, so check the documentation for the version you have installed.

The memory cost

The draft model occupies GPU memory, and that memory comes out of what was left for the attention cache. A 1-billion-parameter draft in FP16 weighs 2 GB (2 bytes × 1 × 10⁹). On an 80 GB GPU that is little, but it is 2 GB less for stacking up requests, see PagedAttention and vLLM for why that memory is precious.

When it helps

  • One request at a time, or few requests: that is where the chip is emptiest, so where there is room to reclaim.
  • Predictable text: templates, repetitive code, highly structured answers. The small model guesses easily.
  • Low-randomness generation: when you almost always take the most probable token, the two models are easier to make agree.

When it does nothing, or hurts

  • Many concurrent requests: the chip is already busy thanks to batching, there is no idleness left to fill, and verification passes compete with useful work.
  • Unpredictable text: highly random generation, varied vocabulary, hence a low acceptance rate.
  • Tight memory: if loading the draft forces you to cut the number of concurrent requests, you gain latency and lose total throughput.
Always measure

Speculative decoding can slow you down. The formula says so: when α\alpha is low and γ\gamma high, the denominator γc+1\gamma c + 1 grows faster than the numerator, and the speedup drops below 1. A mediocre draft adds work and returns nothing. Theory tells you what the gain depends on; only measurement on your workload tells you what it is worth.

What to take away

Speculative decoding is now a standard option in serving systems. Its notable property, technically and legally: it accelerates inference without touching the model. Quantization approximates the weights, pruning removes some, distillation trains a different model, all of these change what is deployed and open a discussion about quality. Speculative decoding does not: the verifying model is untouched and the output distribution is preserved. The small model is only an accelerator; if it guesses badly, you are merely slower.

Check your understanding0 / 5

1. A deployment turns on speculative decoding with a draft model a hundred times smaller than the main one. What happens to answer quality?

2. Why can the large model check six candidate tokens for barely more than the cost of producing one?

3. The third token of the draft fails the acceptance test. What does the system do?

4. Which criterion is non-negotiable when choosing the small draft model?

5. Can speculative decoding make generation slower than normal decoding?