Speculative decoding uses a small, fast draft model to guess γ candidate tokens ahead, then has the target model verify the whole candidate sequence in one parallel forward pass, accepting matching tokens and resampling where they diverge — turning each forward pass from producing 1 token into >1, trading decode's bandwidth-bound bottleneck for prefill-style compute parallelism. Pipeline: ① the draft model autoregressively generates
γ candidates (fast per-step on a small model); ② the target model does a single forward pass over the candidates, obtaining true next-token distributions
pi alongside draft distributions
qi; ③ compare position by position — greedy mode accepts when argmax
pi equals the draft token, otherwise rolls back and resamples from that position; ④ optionally use rejection sampling: accept with probability
min(1,pi/qi), otherwise resample from
norm(max(0,pi−qi)), which provably preserves the target model's exact distribution (lossless). Speedup formula (acceptance rate
α, draft length
γ, expected accepted tokens per round):
E≈1−α1−αγ. Worked example:
α=0.8, γ=4 →
E=1−0.81−0.84=0.20.5904≈2.95×. Note the diminishing returns of larger
γ (bounded by
1/(1−α) as
αγ→0): raising the acceptance rate beats lengthening the draft. Variants: EAGLE feeds the target model's previous-token hidden states through a small autoregressive head to predict the next layer's feature before mapping to vocabulary, giving high-quality drafts (
α 0.7-0.9); Medusa attaches multiple parallel decoding heads to the backbone so no separate draft model is needed; both can use tree attention to verify several candidate branches in one forward pass, pushing
α toward 1 while bounding verification cost.