Speculative decoding interview questions
Speculative decoding interview questions with model answers: how draft and verify works, why the output distribution is unchanged, the expected speed-up formula, EAGLE and Medusa, and when it hurts throughput.
Speculative decoding is a favourite interview topic because it combines the memory-bound nature of decode, probability (rejection sampling) and practical trade-offs with batching. Be ready to derive the expected tokens per step.
Question 1
How does speculative decoding work?
Model answer
Decode is memory-bound, so a forward pass over a few tokens costs almost the same as a pass over one: the weights are read once either way. Speculative decoding exploits that spare compute.
- A cheap draft (a small model, extra heads on the target, n-gram lookup in the prompt) proposes the next tokens.
- The target model runs one forward pass over the context plus all drafted tokens, like a tiny prefill, and gets its own distribution at every position.
- The drafted tokens are checked left to right. Accepted tokens are kept; at the first rejection the target's corrected token is used instead, and if all are accepted the target's distribution at the end gives one bonus token.
Each verification step therefore yields between 1 and tokens for roughly the cost of one target step plus the draft cost. Latency per output token falls by up to 2 to 3 times on many workloads.
Likely follow-up questions
- Why does the target need only one forward pass to verify all tokens?
- What happens to the KV cache entries of rejected tokens?
- Why does speculative decoding help decode but not prefill?
Question 2
Why does speculative decoding not change the output distribution?
Model answer
It uses rejection sampling. Let be the target's probability for a token and the draft's. A drafted token , sampled from , is accepted with probability
If it is rejected, a replacement is sampled from the normalised residual distribution . Working through the two cases shows that the token produced is distributed exactly according to , as if the target had sampled it alone. With greedy decoding this reduces to accepting the draft only if it equals the target's top token.
So speculative decoding is lossless in distribution. In practice outputs can still differ token by token from non-speculative runs because the verification pass batches positions differently, which changes floating-point rounding, but not because of the algorithm.
Likely follow-up questions
- What is the acceptance rate when the draft and target distributions are identical? When they are disjoint?
- Why can't you simply accept drafted tokens whenever the target ranks them in its top 5?
- How does temperature affect the acceptance rate?
Question 3
What speed-up should you expect? Derive the expected tokens per step.
Model answer
Assume each drafted token is accepted independently with probability and the draft proposes tokens. The expected number of tokens produced per verification step, including the bonus or correction token, is
With and : tokens per step.
The wall-clock speed-up is divided by the relative cost of a speculative step, which is one target pass over positions plus draft passes. If the draft costs of a target step and verification costs about one target step, the speed-up is roughly
With that is times. Larger helps only while is high, because the chance of accepting a long run falls geometrically.
Likely follow-up questions
- How would you choose for a given acceptance rate and draft cost?
- Why is the independence assumption optimistic, and in which direction?
- How would you measure the acceptance rate in production?
Question 4
Compare draft models, Medusa, EAGLE and n-gram drafting.
Model answer
- Separate draft model: a small model from the same family (for example a 1B drafting for a 70B). Simple and often high acceptance, but needs the same tokenizer, its own weights and KV cache, and its own forward passes.
- Medusa: extra decoding heads on the target's final hidden state, each predicting a token further ahead, verified with tree attention over several candidates. No separate model, but the heads guess from one hidden state, which limits acceptance.
- EAGLE (and EAGLE-2 and EAGLE-3): a small autoregressive head that drafts at the feature level, reusing the target's hidden states, often with dynamic draft trees. Generally the highest acceptance per unit of draft cost among the lightweight methods and widely supported in vLLM, SGLang and TensorRT-LLM.
- N-gram or prompt lookup: copy continuations from the prompt or earlier output when the recent tokens match. Free to run and very effective for editing, code refactoring and retrieval-heavy answers where the output repeats the input, but useless for novel text.
- Multi-token prediction heads trained with the model (as in DeepSeek-V3) can act as built-in drafters.
Likely follow-up questions
- What is tree attention and why does it raise acceptance?
- Which method would you choose for a code-editing assistant? For open-ended chat?
- What extra training data does an EAGLE head need?
Question 5
When does speculative decoding hurt rather than help?
Model answer
- High batch sizes: speculation spends spare compute. When the server is already batching many sequences, decode moves towards compute-bound and there is less spare compute, so verification of rejected tokens costs real throughput. Many engines reduce or disable speculation as load rises.
- Low acceptance: high temperature, creative tasks, or a draft poorly matched to the target. Below some acceptance rate the extra work outweighs the gain.
- Draft cost: a draft model that is too large, or run on the same GPU competing for memory bandwidth, eats the savings.
- Memory: draft weights and their KV cache take memory that could have held more batch.
- Long context: verification reads the full KV cache for each step; the speed-up still applies, but tree-based verification over long contexts is more expensive.
So the answer to "should we turn it on?" is to benchmark at your real traffic: it often helps latency at low load and costs throughput at high load.
Likely follow-up questions
- How would you design an adaptive policy that adjusts with load?
- Why does speculative decoding interact badly with some structured output constraints, and how can it be fixed?
- What would you report to show the change was worth shipping?
The lesson behind these answers · 15 min · free
Speculative decoding in depth: acceptance maths, draft models, EAGLE and n-grams
Worked numbers, step-through diagrams and a quiz, so you can derive the answer in the interview instead of reciting it.
Read the lesson →Articles on this topic
Related interview questions
- Prefill vs decode interview questions (5 questions)
- Roofline model interview questions for LLM inference (5 questions)
- Batching and continuous batching interview questions (5 questions)
- Structured output interview questions (constrained decoding) (6 questions)