In speculative decoding, a draft model proposes k tokens and each is accepted independently with probability α. How do you derive the expected number of tokens produced per target-model forward pass, what is its value for α=0.8 and k=4, and what is the expected speedup if one draft forward pass costs c=0.05 of a target forward pass?

Sequence models and transformers, Inference
Level L3 Intermediate. Length Medium. Nature Mat Mathematical.

What's being asked

Whether you can derive the expected accepted-token formula for speculative decoding, fold in draft-model overhead to compute wall-clock speedup, and explain why the output distribution stays exact.

Key idea

A target forward pass verifies all k drafted tokens in parallel and emits at least 1 token (if the first draft token is rejected) up to k+1 tokens (if all k are accepted, plus one bonus token). Summing the survival probabilities P(T≥j)=αj−1 gives E[T]=1−αk+11−α, and dividing by the relative iteration cost ck+1 gives the expected speedup.

Steps

  1. Count tokens emitted per target forward pass: let T∈{1,2,…,k+1} be the number of tokens produced in one iteration. If the first m<k drafted tokens are accepted and token m+1 is rejected, the target model replaces token m+1 and emits T=m+1 tokens; if all k are accepted, the target model also emits one bonus token from its next-step distribution, giving T=k+1.
  2. Derive E[T]: token j (for 1≤j≤k+1) is emitted if and only if the first j−1 drafted tokens were all accepted, which has probability P(T≥j)=αj−1. Summing the tail probabilities gives a finite geometric series: E[T]=∑j=1k+1P(T≥j)=∑m=0kαm=1−αk+11−α.
  3. Compute E[T] for α=0.8 and k=4: E[T]=1−0.851−0.8=1−0.327680.2=0.672320.2=3.3616≈3.36 tokens.
  4. Include the draft cost c: running k sequential draft forward passes followed by 1 parallel target verification pass costs ck+1 target-equivalent forward passes (assuming memory-bandwidth-bound verification of k+1 tokens takes about the same time as 1 target forward pass). Standard decoding produces 1 token per 1 target pass, so the expected speedup is Speedup=E[T]ck+1=1−αk+1(1−α)(ck+1). For α=0.8, k=4 and c=0.05: ck+1=0.05×4+1=1.20, so Speedup=3.36161.20≈2.801≈2.80×.
  5. Explain exactness and the k-versus-α trade-off: modified rejection sampling accepts a draft token with probability min⁡(1,p(x)/q(x)) (where p is target and q is draft) and, upon rejection, resamples from the normalised positive residual max⁡(0,p(x)−q(x)), which preserves p(x) identically (proven in the existing acceptance-correctness question). Increasing k pushes E[T] toward its ceiling 1/(1−α) while the cost ck+1 grows linearly, so higher α or smaller c justifies a larger k, whereas low α wastes draft compute if k is too large.

Common mistakes

How long your answer should be

3–4 minutes; derive the geometric sum, compute 3.36 tokens and 2.80× speedup, and briefly explain exactness and choosing k.

Read this

Previous in Sequence models and transformers: Why is autoregressive LLM decoding at batch size 1 memory-bandwidth bound? For a 7-billion-parameter fp16 model (14 GB) on a GPU with 2 TB/s memory bandwidth and 300 TFLOP/s of fp16 compute, what is the upper bound on tokens/s at batch size 1, what is the arithmetic intensity, and near what batch size does decoding reach the compute ridge point?
Next in Sequence models and transformers: What is the sinusoidal positional encoding, and why is PEpos+k a linear function of PEpos? How do rotary position embeddings (RoPE) make attention scores depend only on relative position?