In speculative decoding, a small draft model with next-token distribution proposes a token , and the large target model with distribution accepts it with probability . If it is rejected, a token is drawn from the residual . Show that the output token is distributed exactly as . For and , find the acceptance probability and the expected number of tokens per target pass when tokens are drafted?
Sequence models and transformers, Inference
Level L5 Expert. Length Long. Nature Mat Mathematical.
What's being asked
Whether you can prove that rejection sampling with a residual correction gives samples from the target distribution, and turn the acceptance rate into a speed-up estimate.
Key idea
The probability of returning token is . The first term is , and the residual term supplies exactly the missing mass .
Steps
- Accepted branch. Token is proposed with probability and accepted with , so it is output this way with probability .
- Total acceptance probability , so . This is also the normaliser of the residual.
- Rejected branch. The residual density is . Multiplying by cancels the normaliser, leaving .
- Add both branches: for every . So the output is distributed exactly as .
- Numbers. , so . The residual is , normalised to . Check token 1: . Token 2: . Token 3: . These match .
- Tokens per pass. With acceptance probability per drafted token (assumed independent), the target pass verifies drafts and always yields at least one token (the first rejection's replacement, or a bonus token if all pass). The expected number is .
- Speed-up is therefore up to in target passes, minus the cost of running the draft model times.
Common mistakes
- Sampling the replacement token from instead of from the residual. That puts too much mass on tokens the draft already proposes.
- Forgetting the residual's normalisation, or forgetting that it uses only the positive part of .
- Saying speculative decoding changes the output quality. With this accept/reject rule the distribution is exactly that of the target, only the speed changes.
- Using as the expected tokens. The expected count is the geometric sum .
How long your answer should be
One page; 7–9 minutes.
Last checked on 4 December 2026.
Read this
Previous in Sequence models and transformers: Prove that a transformer encoder layer without positional encodings is permutation-equivariant: permuting the input tokens permutes the outputs in the same way. How do you show that a decoder with a causal mask and no positional encodings is not, and that it can still recover position information?
Next in Sequence models and transformers: none