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=0and 2.6x attemp=1on 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 (
cnear 0) still achievesalpha = 0.20on T5-XXL translation, yielding a 1.25x speedup atgamma = 3.
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.
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), acceptxunconditionally (100%chance). - If
q(x) > p(x), acceptxwith probabilityp(x) / q(x); otherwise rejectxand draw a replacement from the residual distributionp'(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.
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 spotTwo 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.
T5-large (800M) drafting for T5-XXL (11B)
Cost penaltyHigher token agreement cannot rescue a draft model whose serial latency cost c=0.11 exceeds 10% of the target model per step.
- Why the naive fix breaks
- Picking the most accurate draft raises alpha only modestly (0.75 to 0.82 on EnDe T=0; 0.53 to 0.56 on CNN/DM T=1) while multiplying c by 5.5x.
- Walltime speedup
- Speedup drops to 1.7x (EnDe, temp=0, gamma=7), 1.4x (EnDe, temp=1, gamma=3), 2.2x (CNN/DM, temp=0, gamma=3), and 1.7x (CNN/DM, temp=1, gamma=3).
- Optimal gamma shift
- Because each extra guess adds 0.11 target-steps of serial latency, optimal gamma shrinks from 7 down to 3 on most T5-large runs.
- Builder rule
- Draft runtime cost c matters more than squeezing the last 5% of alpha; a 100x smaller draft consistently beats a 10x smaller draft.
Unigram, bigram, and LaMDA 100M lightweight drafts
Minimal draftEven table-lookup n-gram models with near-zero compute cost yield measurable speedups whenever tasks repeat local phrases.
- Trivial n-gram alphas
- On T5-XXL EnDe (T=0), unigram hits alpha=0.08 and bigram hits alpha=0.20 (yielding 1.25x speedup at gamma=3 with c near 0); CNN/DM bigram hits 0.23.
- LaMDA 137B scaling
- On 137B dialog (Top-40), a tiny 100M draft achieves alpha=0.61 (T=0) and 0.57 (T=1), while 2B reaches 0.71 and 8B reaches 0.75 (T=0) / 0.74 (T=1).
- Compute overhead
- Under Table 1 (c=0), getting 3.69x speed at alpha=0.8, gamma=5 increases total arithmetic ops by 1.63x; at alpha=0.9, gamma=10, speed hits 6.86x for 1.60x ops.
- Context copying
- Section 3.6 notes that copying matching prefixes from prompt context gives high alpha for summarization and multi-turn code editing at zero GPU cost.
Trading exact distribution via lenience factor l
Relaxed boundScaling draft probability q(x) by l in (0, 1] before comparison boosts acceptance up to 5x while bounding worst-case token probability inflation.
- Formal guarantee
- No token can ever be sampled with probability exceeding p(x) / l (e.g., l=0.1 caps tail inflation at 10x), keeping ultra-rare tokens suppressed.
- Measured EnDe gains
- On T5-XXL with T5-small (T=1, c=0.015), alpha climbs from 0.62 (l=1) to 0.71 (l=0.5), 0.76 (l=0.3), and 0.84 (l=0.1), pushing speedup from 2.5x to 5x.
- Greedy lenience
- At temp=0, accepting any draft token within p(x) >= l * max(p) lifts T5-small alpha from 0.75 (l=1) to 0.87 (l=0.1), reaching 4.9x speedup at gamma=8.
- Distribution caveat
- Unlike strict Algorithm 1, lenience gives no lower bound on token probabilities, so aggressive l values can reduce output diversity.
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 inalpha. - Table lookups still work: Even a zero-parameter bigram table hits
alpha = 0.20(1.25xspeedup), while LaMDA 100M reachesalpha = 0.61drafting 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
qbyl = 0.1caps any token’s probability inflation at10xand 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.


