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#
The loop in code#
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, 1one verifier forward
bonus = sample(q, rng)all N accepted: free token
emitted.append(bonus)
Serving stack#
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) |
|---|