Speculative Decoding & Parallel Token Generation
Draft-then-verify speculative decoding, Medusa multi-head prediction, EAGLE speculative decoding, lookahead decoding. Acceptance rate, speedup formula, and when speculation hurts.
Overview
Autoregressive generation produces exactly one token per forward pass, however predictable that token is. Speculative decoding lets a fast draft model propose several tokens, then has the large target model verify them all in one parallel pass, so several tokens come out for the cost of one target pass.
Each round is a short loop. The draft model reads the context and proposes K tokens. The target model verifies K+1 positions in one pass. What comes back is an accepted run plus one corrected token, which joins the context, and the next round starts from there.
The algorithm
The core method (Leviathan et al., 2022; Chen et al., 2022) pairs a small draft model, the speculator, with a large target model, the verifier. One round takes five steps.
- The draft model generates K draft tokens on its own.
- It sends the K-token draft to the target model.
- The target model runs one forward pass over K+1 positions.
- The target accepts or rejects each draft token in order.
- It returns the accepted tokens plus a corrected token, and stops at the first rejection.
The rule in step 4 compares what the two models think of each draft token x_i.
- When p_target(x_i) >= p_draft(x_i): accept the token with probability 1.
- When p_target(x_i) [!IMPORTANT] The procedure is lossless: the output distribution is identical to running the target model without speculation.
Interview questions
- Explain the speculative sampling acceptance procedure and prove it produces the correct distribution.
Sign up free to read the full topic
More AI Infrastructure topics
- ROCm & the AMD GPU Stack
- Running CI on Scarce Accelerators: Scheduling, Artifacts & Cost
- Serving LLMs On-prem: Triton, NIM, vLLM & the Model Store
- Silicon Root of Trust & Key Provisioning in Manufacturing
- Silicon Software Release Trains: SDKs, BSPs, Drivers & Firmware Across SKUs and Steppings
- Slurm for GPU Clusters
- Storage for GPU Training: Parallel Filesystems & GPUDirect Storage
- Tape-out Release Engineering & Signoff Gates
- The Chip Design Flow as a CI Pipeline
- Verification Regressions at Scale
Start free on Cariara · Coding problems · System design studio