Guess Ahead, Check Once (Speculative Decoding)
Decode writes one token per step, and each step reads all model weights from memory. Speculative decoding lets a cheap draft guess several tokens ahead, then has the big target model check all of them in one forward pass. When the guesses are good, one expensive pass yields several tokens, and the answer is the same as without the trick.
What you will learn
- Why checking several tokens costs about as much as making one
- How the draft proposes and the target verifies in one pass
- Why the output distribution stays the same as the target alone
- Draft sources: small model, n-gram lookup, EAGLE and MTP heads
- Why the gain shrinks under heavy batching
Draft methods compared
| Method | Where guesses come from | Extra memory | Helps most when |
|---|---|---|---|
| Draft model | A separate small model with the same tokenizer | Its weights and its own KV cache | A good small sibling model exists; general chat |
| N-gram (prompt lookup) | Tokens copied from earlier in the prompt | None | Output repeats the input: summaries, code edits, RAG answers |
| EAGLE-style heads | Light layers reading the target's hidden states | Small | General workloads; usually higher acceptance than a separate draft |
| MTP modules | Multi-token prediction layers trained with the model (e.g. DeepSeek-V3) | Small, often shipped in the checkpoint | Models that come with MTP weights |
In all cases the target model makes the final decision, so the method changes speed, not the answer.
Running it on Kubernetes
- Speculative decoding is set when the engine starts, so it belongs in the serving Pod's args. Roll it out like any other config change, with a canary replica.
- Run load tests at your real concurrency with and without it. Compare TPOT, TTFT and total output tokens per second. A win at 1 user can be a loss at 64.
- Leave memory headroom for the draft. A draft model adds its own weights and KV cache, so fewer requests fit in the same accelerator.
- Watch the acceptance rate over time. If traffic shifts to more creative or high-temperature requests, the gain can quietly disappear.
Try it yourself
# vLLM: n-gram drafting needs no extra model (check the speculative decoding docs for your version)
vllm serve meta-llama/Llama-3.1-8B-Instruct \
--speculative-config '{"method": "ngram", "num_speculative_tokens": 4, "prompt_lookup_max": 4}'
# vLLM: a separate small draft model
vllm serve meta-llama/Llama-3.1-70B-Instruct \
--speculative-config '{"model": "meta-llama/Llama-3.2-1B-Instruct", "num_speculative_tokens": 4}'
# Compare TPOT with and without speculation at the same concurrency
vllm bench serve --model meta-llama/Llama-3.1-8B-Instruct --max-concurrency 8 --num-prompts 200
# Acceptance: accepted draft tokens / proposed draft tokens
curl -s http://<engine>:8000/metrics | grep -E 'vllm:spec_decode_num_(accepted|draft)_tokens_total'
Check yourself
Further reading: Leviathan et al., 2023: Fast Inference from Transformers via Speculative Decoding · Chen et al., 2023: Accelerating LLM Decoding with Speculative Sampling · EAGLE · vLLM speculative decoding · Reading the Question, Writing the Answer (Prefill and Decode) · Batching Requests (Continuous Batching)