Skip to main content
How LLM serving worksLesson 6 of 9

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.

Tokens per target pass1
Acceptance rate—
Time per token (TPOT)one weight read
Main bottleneckMemory reads
One acceleratorUserstreamed answerDraftcheap guesserTarget modelthe real modelVerifieraccept or rejectTarget weightsaccelerator memoryKV cacheprompt + answerall weights1 token
RequestResponse / reportWatchAppears in a later step

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​

MethodWhere guesses come fromExtra memoryHelps most when
Draft modelA separate small model with the same tokenizerIts weights and its own KV cacheA good small sibling model exists; general chat
N-gram (prompt lookup)Tokens copied from earlier in the promptNoneOutput repeats the input: summaries, code edits, RAG answers
EAGLE-style headsLight layers reading the target's hidden statesSmallGeneral workloads; usually higher acceptance than a separate draft
MTP modulesMulti-token prediction layers trained with the model (e.g. DeepSeek-V3)Small, often shipped in the checkpointModels 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

  1. Does speculative decoding change the answers the target model would give?
  2. Speculative decoding sped up TPOT in a single-user test, but at 64 concurrent users total throughput dropped. Why?
  3. Your service mostly summarizes documents and edits code that quotes its input. Which draft method fits best with no extra model memory?

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)