Draft types side by side # Factor Vanilla draft Medusa EAGLE-3 MTP (DeepSeek-V3) Draft Separate small LLM Extra LM heads on verifier Multi-layer feature fusion + TTT 1 transformer block + projection Trained when Reuse an existing model SFT stage on the verifier Post-pre-training During pre-training Training cost None ~1B SFT tokens ~60-200B tokens About 10% slower pre-training α0.55-0.70 0.65-0.75 0.88-0.92 0.80+ at depth 1 Speedup 1.8-2.3× 2-3× 3.5-6.5× 1.8× Second model Yes No Tiny draft head No, part of the model Existing weights Yes Needs fine-tune Yes No, re-train
One speculative step # 1 Draft the cheap model $M_p$ proposes $N$ tokens with probabilities $p_1 \ldots p_N$. 2 Verify the verifier $M_q$ runs once on prefix plus drafts. It returns $q_1 \ldots q_{N+1}$. 3 Accept walk left to right. Accept with probability $\min(1, q_i(d_i) / p_i(d_i))$. 4 Reject at the first rejection, sample from $(q_j - p_j)_+$ normalized. Discard later drafts. 5 Bonus when all $N$ accept, sample one more token from $q_{N+1}$. 6 Roll back set the KV cache to the accepted prefix length. 7 Result output is identically distributed to the verifier alone.
The loop in code # Copy for i, d in enumerate (drafts):
u = rng. random ()
ratio = q_prob / p_prob if p_prob > 0 else float ( "inf" ) q verifier, p draft
if u < min ( 1.0 , ratio):
emitted. append (d)
kv. extend ( 1 ) accepted: cache grows by one
else :
correction = sample ( residual (q, p), rng) (q - p)+ renormalized
emitted. append (correction)
kv. truncate_to (prefix_len + len (emitted)) KV rollback
return emitted, 1 one verifier forward
bonus = sample (q, rng) all N accepted: free token
emitted. append (bonus)
Serving stack # k tokens accept, resample client Request ingress chat completions process vLLM or SGLang one replica per GPU model Draft EAGLE-3 heads or ngram gpu Target FP8 or INT4 quantized process Verify pass k draft tokens in one pass client Token stream accepted prefix to client store Prometheus metrics acceptance, queue wait, p99 queue HPA scales on queue wait k tokens accept, resample client Request ingress chat completions process vLLM or SGLang one replica per GPU model Draft EAGLE-3 heads or ngram gpu Target FP8 or INT4 quantized process Verify pass k draft tokens in one pass client Token stream accepted prefix to client store Prometheus metrics acceptance, queue wait, p99 queue HPA scales on queue wait Functions in the lessons # Task Code Residual on rejection residual(q, p) One step with KV rollback spec_step(q, p, N, kv, rng) Tokens per verify expected_tokens_per_verify(alpha, N) Wall time per token wall_time_per_token(alpha, N, c) Speedup for a config expected_speedup(p)Tree verify mask tree_attention_mask(tree)Distribution check chi_square(observed, expected) Measured acceptance m.acceptance_rate(k)