Speculative Decoding Explained: How Draft Models Yield k+1 Tokens Per Pass Without Changing the Distribution
cneuralnetwork · x · 2026-10-22
A well-illustrated thread walking through speculative decoding, one of the neatest tricks in LLM inference.
- Why decoding is slow: autoregressive generation needs n sequential forward passes; at small batch sizes it's memory-bandwidth bound.
- Key insight: generation and verification are different computational problems — given k tokens, causal attention lets the transformer verify them all in one parallel forward pass.
- Flow: a cheap draft model q proposes k candidate tokens; the target model p verifies them in parallel.
- Rejection sampling preserves the distribution: accept x with probability min(1, p(x)/q(x)); on rejection, sample from the residual r(x) ∝ max(0, p(x)−q(x)). Since min(p,q)+max(0,p−q)=p, the final token distribution is exactly the target's — no retraining, no approximation.
- Details: only the consecutively accepted prefix is kept; if all k tokens pass, one extra token can be sampled, so a single target pass commits up to k+1 tokens.
- Speedup bound: expected acceptance α = Σₓ min(p,q) = 1 − tv(p,q); closer draft-target alignment helps, but a larger draft slows drafting — the core tradeoff.
Related event: Illustrated Guide to Speculative Decoding(3 posts)→
More from Infra
- H100 Rental Rates Keep Climbing Across the Entire Term Structure — isidentical · 2026-10-22
- Phonon TTS and Fluid Speech Mini: a day-long test of lightweight local speech models — gregbarbosa · 2026-10-22
- Databricks AI Runtime goes GA: GPUs in seconds, adopted by Robinhood, Superhuman, Merck — matei_zaharia · 2026-10-22
- Flint MoE model lands in llama.cpp: 39.8B total params, only ~2.5B active per token — jacek2023 · 2026-10-22
- Omarchy package server is timing out: updates failing on cursor, grok-bot, codex-desktop packages — mark_k · 2026-10-22
- AWS shows how to cut agent costs with local SLMs routing to Bedrock only when needed — AWS ML Blog · 2026-10-22