Technical GUIDE
Speculative Decoding
Speculative decoding can speed up large-model generation by letting a faster drafter propose tokens for a target model to verify in batches.
Listen to this guideAI-narrated · ~2 min
On this page2 min read
Overview
Exact speculative sampling can preserve the target distribution, but speedup depends on draft cost, acceptance rate, batching and hardware.
Deep Dive
Normally an LLM generates text one token at a time: each token requires a full forward pass through the giant model, and you can't start the next until the current one finishes. For large models at low batch sizes, decoding can be memory-bandwidth bound: each token step reads many weights, so moving data may dominate arithmetic. Other batch sizes and workloads can have different bottlenecks. Speculative decoding breaks the bottleneck. A small, cheap draft model proposes a chunk of, say, five candidate tokens. The large 'target' model then processes all five in a single parallel forward pass and checks them. In greedy decoding, the target accepts the matching prefix and uses its own token at the first mismatch, discarding the remaining draft. Exact sampling uses a rejection-sampling correction to preserve the target distribution; acceptance is not always simple token equality. The target can verify a drafted block in a parallel pass, but verification still costs computation. Net speedup depends on draft-model cost, how many tokens are accepted, and the hardware and workload.
Real-World Implementation
A 7B draft model proposing tokens for a 70B chat model to cut response latency in a production assistant
Medusa heads bolted onto an LLM so it predicts several future tokens at once without a separate draft model
vLLM enabling speculative decoding to raise tokens-per-second throughput on a serving cluster
EAGLE drafting in the model's hidden-feature space to boost the acceptance rate and overall speed
The Future of Speculative Decoding
Serving frameworks offer speculative decoding and self-drafting variants, but the best method depends on the target model, workload and hardware. Systems should measure latency, throughput, acceptance rate, memory use and output-distribution requirements rather than assume a fixed speedup. Some methods use a separate drafter; others add heads or use feature-space proposals. Continued research is likely to improve these tradeoffs, but deployment gains must be measured on the actual service.
Putting it into practice
Why it matters
- Cost and budget. Architecture decisions drive performance and operating cost for years.
- Clearer decisions. Technical education helps teams choose the right stack, not just the newest one.
- Quality control. Better engineering choices reduce reliability incidents in production.
Watch out for
- Optimizing one benchmark can hide broader system weaknesses.
- Infrastructure and maintenance costs are often underestimated.
- Security and observability gaps can grow as systems become more complex.
Next steps
- Define latency, quality, and cost targets before implementation.
- Benchmark under realistic load and data conditions.
- Instrument monitoring for errors, drift, and user impact.
- Prepare rollback and incident response paths before scaling.
Keep Exploring
Free newsletter
Keep up with AI in 3 minutes a day
One short email each weekday with the three AI stories that actually matter. Free forever, no ads.
One email each weekday. Unsubscribe in one click. We never sell or share your address.
Test yourself
Take the Speculative Decoding quiz
Instant feedback on every answer, and a shareable certificate with a verifiable ID once you pass a course.
Support free AI education. AI Understanding is a 501(c)(3) nonprofit — no ads, no paywall, ever. Make a donation
Frequently asked questions
What is Speculative Decoding?
Speculative decoding can speed up large-model generation by letting a faster drafter propose tokens for a target model to verify in batches. Exact speculative sampling can preserve the target distribution, but speedup depends on draft cost, acceptance rate, batching and hardware.
How does speculative decoding speed up generation from a large model?
A fast draft model proposes multiple tokens, and the large target model checks them all in a single parallel pass.
For a large model at low batch size, why can one-token autoregressive decoding be slow?
For large models at low batch sizes, repeatedly reading weights can dominate arithmetic, though the bottleneck depends on workload.
In greedy speculative decoding, what happens at the first token where draft and target predictions disagree?
In greedy verification, the target corrects the first mismatch and the remaining drafted suffix is discarded; exact sampling uses a rejection-sampling correction instead.
Under exact speculative sampling, how does the output distribution compare with sampling from the target model alone?
The exact rejection-sampling correction preserves the target model’s distribution; this is distinct from relaxed variants.
What most directly determines the speedup from speculative decoding?
The more drafted tokens the target model accepts per verification step, the greater the speedup.
Keep learning
Related guides
More guides picked for this topic