Speculative decoding accelerates autoregressive Transformers 2x to 3x out of the box without changing model weights, architecture, or the exact output probability distribution. Yaniv Leviathan, Matan Kalman, and Yossi Matias (Google Research, ICML 2023) proved that a small draft model generating gamma speculative tokens, verified in one parallel pass of the large target model via a modified rejection rule, turns memory-bound serial decoding into parallel compute without losing a single bit of target fidelity.

Standard autoregressive decoding hits a hardware wall: generating K tokens requires K serial runs of the full model, and each step spends most of its time streaming gigabytes of weights and KV cache from HBM rather than saturating arithmetic units. By guessing easy continuations (“of the”, boilerplate syntax, repeated context) with a tiny draft model and verifying them concurrently in one target pass, speculative decoding remains one of the lowest-risk latency wins in modern LLM inference.

  • 2.3x to 3.4x walltime speedup on T5-XXL (11B): On a single TPU-v4 (batch size 1) against optimized T5X, using a 77M T5-small draft cuts walltime 3.4x at temp=0 and 2.6x at temp=1 on WMT English-German translation, plus 3.1x (temp=0) and 2.3x (temp=1) on CNN/DM summarization.
  • Exact distribution equivalence: Speculative sampling guarantees P(x = x0) = p(x0) for every token in both greedy and stochastic sampling, unlike early-exit heuristics or distillation.
  • 9 steps instead of 38: In the paper’s 97M GPT example paired with a 6M draft (alpha = 0.88), generating a 38-token sentence required only 9 serial passes of the target model.
  • Even parameter-free n-grams help: A trivial bigram lookup table (c near 0) still achieves alpha = 0.20 on T5-XXL translation, yielding a 1.25x speedup at gamma = 3.
One step of speculative decoding: draft serially, verify in parallel
1. Draft gamma guesses
Cheap model M_q runs serially for gamma fast steps.
Sequential proposals x_1 … x_gamma
Records draft distributions q_1 … q_gamma at tiny cost coefficient c (under 0.05 for 100x smaller drafts).
2. Parallel target pass
Target M_p scores all gamma + 1 prefixes in one forward call.
One weight load, gamma + 1 logit vectors
Weights and KV cache stream from HBM once while causal masking evaluates every proposed prefix simultaneously.
3. Accept and fix
Keep prefix up to first rejection, then sample one corrected token.
Guaranteed 1 to gamma + 1 tokens
At rejection step n+1, resample from norm(max(0, p - q)); if all gamma pass, emit bonus token from p_(gamma+1).

Algorithm 1 from Leviathan et al. (2023), Section 2.

Why memory bandwidth creates free verification headroom

Autoregressive inference at low batch size is rarely limited by GPU or TPU arithmetic throughput. Each single-token decode pass of an 11B or 137B Transformer must read the entire parameter set and growing KV cache from off-chip memory just to perform matrix-vector multiplications on one token. Most tensor cores sit idle waiting on memory bandwidth.

Speculative execution exploits that slack by trading unused parallel FLOPs for fewer serial memory reads. Scoring gamma + 1 candidate tokens in one causal pass of the target model M_p increases arithmetic operations concurrently, yet loads M_p’s weights and KV cache only once. Under an i.i.d. acceptance rate alpha, a single step of speculative decoding produces (1 - alpha^(gamma+1)) / (1 - alpha) tokens on average, shrinking target weight reads by that exact factor.

This also explains why naive alternatives fall short. Prior adaptive computation methods, such as early-exit Transformers, Wisdom of Committees, Blockwise Parallel Decoding, and Shallow Aggressive Decoding, either restrict generation strictly to greedy decoding (temp=0), require custom architectural hooks and retraining, or change the target distribution. Even standard non-iterative rejection sampling breaks down mathematically here.

Why earlier acceleration tricks fall short of speculative sampling
Early-exit & Blockwise

Requires custom training heads or heuristic exit gates; Blockwise Parallel Decoding supports only greedy decoding and alters output distributions.

Classic rejection sampling

Scales acceptance by 1 / max(p/q). One rare token where p dwarfs q crashes acceptance across the entire vocabulary.

Oversized draft models

T5-large (800M) raises alpha to 0.82 vs 0.75 for T5-small (77M), yet its high cost c = 0.11 cuts EnDe speedup in half (1.7x vs 3.4x).

Comparisons and ablations from Leviathan et al. (2023), Sections 4, 5, and Appendix A.2.

The lossless sampling rule and the speed equation

Speculative sampling begins by unifying greedy argmax, temperature scaling, top-k, and nucleus sampling as standardized distributions p(x) and q(x). At each step i, we draw x from q(x):

  • If q(x) <= p(x), accept x unconditionally (100% chance).
  • If q(x) > p(x), accept x with probability p(x) / q(x); otherwise reject x and draw a replacement from the residual distribution p'(x) = norm(max(0, p(x) - q(x))).

The proof of exactness takes three lines. A token x0 is emitted either by being accepted from q with probability q(x0) * min(1, p(x0)/q(x0)) = min(p(x0), q(x0)), or via rejection (probability 1 - beta, where beta = sum_x min(p(x), q(x))) followed by sampling from p'(x0) = (p(x0) - min(p(x0), q(x0))) / (1 - beta). Adding both paths yields min(p(x0), q(x0)) + p(x0) - min(p(x0), q(x0)) = p(x0) identically. Because standard rejection sampling divides by M = max_x(p(x)/q(x)), its acceptance probability collapses whenever p puts surprise mass on a token q underpredicts; speculative sampling achieves the strictly optimal coupling alpha = 1 - E(D_LK(p, q)), where D_LK is total variation distance.

Theorem 3.8 translates acceptance alpha, draft-to-target runtime ratio c, and lookahead gamma directly into expected walltime speedup:

Speedup = (1 - alpha^(gamma + 1)) / ((1 - alpha) * (gamma * c + 1))

Whenever alpha > c, there exists a positive gamma that speeds up decoding by at least (1 + alpha) / (1 + c). Crucially, speedup is governed by both alpha and c. On T5-XXL (11B) English-German translation at temp=0, upgrading the draft from T5-small (77M, c = 0.02) to T5-large (800M, c = 0.11) nudges alpha from 0.75 to 0.82, yet total speedup drops sharply from 3.4x down to 1.7x because running T5-large serially gamma = 7 times consumes nearly as much walltime as running T5-XXL once. Across GPT-like 97M (draft 6M, alpha = 0.88-0.89), T5-XXL 11B (draft 77M), and LaMDA 137B (drafts 100M/2B/8B reaching alpha = 0.57-0.75), draft models roughly two orders of magnitude smaller than M_p hit the sweet spot.

Compare draft models, tasks, and lenience tradeoffs

Switch through the four empirical regimes below to inspect how draft size, sampling temperature, FLOPs overhead, and optional lenience shift actual speedups across the paper’s experiments.

Empirical regimes across T5-XXL, LaMDA 137B, and GPT-97M

Select a regime (or use Left and Right arrow keys) to inspect exact acceptance rates, draft cost coefficients, and speed vs compute tradeoffs.

T5-small (77M) drafting for T5-XXL (11B)

Sweet spot

Two orders of magnitude smaller than the target, T5-small balances strong alignment with tiny c=0.02 runtime cost to deliver peak walltime speedup.

Measured acceptance
WMT EnDe hits alpha=0.75 (temp=0, gamma=7) and alpha=0.62 (temp=1, gamma=7); CNN/DM summarization hits alpha=0.65 (temp=0) and 0.53 (temp=1) at gamma=5.
Walltime speedup
Achieves 3.4x (EnDe, temp=0), 2.6x (EnDe, temp=1), 3.1x (CNN/DM, temp=0), and 2.3x (CNN/DM, temp=1) vs T5X on a single TPU-v4.
Why it wins
T5-small costs only 2% of a T5-XXL step (c=0.02), allowing 5 to 7 draft guesses before target verification overhead eats the gain.
Model prediction fit
Theorem 3.8 predicts 3.2x (EnDe T=0) and 2.4x (CNN/DM T=0) vs 3.4x and 3.1x measured, matching closely aside from non-i.i.d. beta clustering.

Source: Leviathan et al. (2023), Tables 1 through 5 and Appendix A.5.

If you prefer the short takeaway without clicking through each tab, the four regimes establish the design boundaries for speculative inference:

  • 100x smaller drafts win: T5-small (77M, c = 0.02) beats T5-large (800M, c = 0.11) by 3.4x vs 1.7x on EnDe translation because serial draft latency outweighs small gains in alpha.
  • Table lookups still work: Even a zero-parameter bigram table hits alpha = 0.20 (1.25x speedup), while LaMDA 100M reaches alpha = 0.61 drafting for LaMDA 137B.
  • FLOPs rise as HBM reads fall: At alpha = 0.8, gamma = 5, total arithmetic operations increase 1.63x while target memory reads drop 3.69x, making the algorithm strictly for memory-bound regimes.
  • Lenience unlocks 5x speedups: Multiplying q by l = 0.1 caps any token’s probability inflation at 10x and lifts T5-XXL EnDe speedup to 5x, at the expense of exact distribution matching and diversity.

Caveats and how speculative decoding evolved

Three caveats govern where speculative decoding works in production today.

First, speculative decoding stalls or loses once serving becomes compute-bound. Every rejected guess wastes verification FLOPs, raising total arithmetic operations by (1 - alpha)(gamma * c_hat + gamma + 1) / (1 - alpha^(gamma+1)). At batch size 1 on a TPU-v4 or modern H100, memory bandwidth dominates and parallel verification is nearly free. Inside a heavily loaded datacenter server running large continuous batches under Orca iteration-level scheduling and PagedAttention, tensor cores saturate on matrix multiplications, shrinking the slack that makes gamma + 1 verification free.

Second, fixed gamma leaves latency on the table, and beam search remains expensive. The authors note that acceptance probability beta varies wildly by token: predictable function words accept long streaks while novel facts reject on step 1. An oracle adjusting gamma dynamically per step could add up to ~60% more speedup. Extending Algorithm 1 to beam search (width w) requires running draft beam u >= w and paying (w + u*gamma) target evaluations, cutting heavily into the memory-bandwidth win.

Third, the paper evaluated T5-XXL walltime at batch size 1 and measured alpha separately on GPT and LaMDA. Shortly after release, DeepMind independently published Speculative Sampling showing 2x to 2.5x speedups on Chinchilla 70B. Modern follow-ups solved the two gaps Leviathan et al. flagged in Section 6: custom trained draft heads (like Medusa) eliminated separate draft weights, and EAGLE-2 replaced fixed linear chains with context-aware dynamic draft trees verified in one tree-attention mask.

For engineers deploying LLMs today, the checklist is concrete: speculative decoding gives lossless latency gains whenever requests run at small batch sizes (local inference, coding copilots, real-time voice) with spare GPU FLOPs and a draft model roughly 50x to 100x faster than the target. Once high traffic pushes your cluster into the compute-bound regime, drop the draft model or shrink gamma dynamically so verification FLOPs do not slow down active batches.