Speculative Decoding & Draft Model Distillation
Training efficient draft models for speculative decoding: distilling small models to match large model token distributions, acceptance rate optimization, MedUSA heads, and Eagle-style draft architectures.
Prerequisites
Table of Contents
- Learning Objectives
- Notation
- Core Intuition
- Speculative Decoding Overview
- Training Draft Models via Distillation
- Optimizing Acceptance Rate
- Medusa: Multi-Head Draft
- Eagle: Autoregressive Draft Heads
- Online Speculative Distillation
- Common Pitfalls
- Summary
- Exercises
Learning Objectives
- Explain speculative decoding and the role of the draft model.
- Derive the optimal distillation objective for maximizing acceptance rate.
- Describe Medusa's parallel multi-head drafting.
- Explain Eagle's feature-level autoregressive drafting.
- Design a distillation pipeline for creating draft models.
Notation
- — target (large) model distribution
- — draft (small) model distribution
- — expected acceptance length
- — acceptance rate per token
Core Intuition
Speculative decoding uses a small "draft" model to quickly propose multiple tokens, then a large model verifies them in parallel. The draft model's quality determines the acceptance rate — how many proposed tokens the large model agrees with. Distillation is the IDEAL way to train draft models: make the small model's distribution match the large model's distribution as closely as possible, maximizing the acceptance rate.
Speculative Decoding Distillation
Speculative Decoding Overview
Algorithm:
- Draft model generates tokens autoregressively (fast, small model).
- Target model verifies all tokens in ONE forward pass (parallel).
- Accept longest prefix where draft matches target (rejection sampling).
- Expected speedup: where is expected accepted length.
Acceptance probability for token :
Expected accepted length:
where is the average per-token acceptance rate.
For : Expected acceptance = 5 tokens. With 7B draft and 70B target: 3-4x speedup.
Training Draft Models via Distillation
Standard approach: Distill the large model into a smaller architecture:
Token-level KL minimization directly optimizes acceptance rate, because:
Lower KL → higher acceptance → more speedup.
On-policy distillation (using target model's own generations as training data):
- Generate sequences from the target model.
- Compute target model's next-token distributions.
- Train draft on these distributions.
- Better than off-policy (training data distribution = inference distribution).
Optimizing Acceptance Rate
Beyond KL minimization:
Top-k focused distillation: Acceptance mostly depends on high-probability tokens. Focus distillation on the top- entries of the target distribution:
Temperature matching: Use same temperature for draft and target (usually for greedy, or matched sampling temperature).
Domain-specific drafts: A small model fine-tuned on the deployment domain has higher acceptance than a generic small model.
Medusa: Multi-Head Draft
Cai et al. (2024): Add multiple prediction heads to the TARGET model itself:
where is the target model's hidden state at position .
Each head predicts tokens ahead (independently, in parallel).
Tree-based verification: Generate a tree of candidate continuations from the multiple heads. Verify all candidates in one forward pass using tree attention.
Training (distillation from target):
- Freeze the target model backbone.
- Train only the Medusa heads to predict future tokens.
- Each head is distilled from the target's ground-truth next-token distribution.
Advantage: No separate draft model; heads are tiny (1 linear layer each). 2-3x speedup with minimal quality impact.
Eagle: Autoregressive Draft Heads
Li et al. (2024): Use the target model's FEATURES (not just last hidden state) for autoregressive drafting:
where DraftNet is a lightweight transformer (1-2 layers) that predicts the next hidden state.
Key insight: Predicting in FEATURE space (then projecting to vocab) is easier than predicting in TOKEN space directly.
Architecture:
- DraftNet takes current hidden state + current token embedding.
- Produces predicted next hidden state.
- Target model's LM head converts to distribution.
- Autoregressive: feed predicted hidden state back for multiple steps.
Advantage over Medusa: Autoregressive drafting captures token dependencies. Higher acceptance rate (0.85+ vs 0.75 for Medusa).
Online Speculative Distillation
Continuously improve draft model during serving:
- Serve requests using speculative decoding.
- Collect rejected tokens (where draft disagreed with target).
- Fine-tune draft on these "hard" examples.
- Deploy updated draft.
The rejection signal is free — it comes from the verification step that's already happening.
Result: Draft model gradually improves on the actual deployment distribution, increasing acceptance rate over time.
Common Pitfalls
Pitfall 1. Training draft model on different data than the target will see at inference. Distribution mismatch → low acceptance rate. Always distill on representative data.
Pitfall 2. Making the draft model too small. Below a certain capacity, no amount of distillation can achieve high acceptance. Rule of thumb: draft should be at least 1/10th the target's size.
Pitfall 3. Using greedy decoding for draft when target uses sampling. The acceptance criterion requires distribution matching; greedy draft with sampling target has poor acceptance on non-argmax tokens.
Summary
- Speculative decoding uses small draft model to propose tokens, large model verifies.
- Draft distillation: Minimize KL between draft and target distributions.
- Medusa: Multiple parallel heads on the target model itself (no separate model).
- Eagle: Feature-space autoregressive drafting (highest acceptance rate).
- Online distillation: Continuously improve draft from rejection signal.
- Acceptance rate of 0.8+ achievable with good distillation → 3-4x speedup.
Exercises
Exercise 1. For acceptance rate and draft length : compute expected accepted tokens and overall speedup if draft is 10x faster than target.
Exercise 2. Derive equation 4 (the relationship between TV distance, KL divergence, and acceptance rate).
Exercise 3. For Medusa with 3 heads: how many candidate sequences are generated with top-3 per head? How many tokens in the verification tree?
Exercise 4. Compare the memory overhead of Medusa (3 linear heads) vs a separate 1B draft model for a 70B target.
Exercise 5. Design an online speculative distillation loop: specify the data buffer, update frequency, and stopping criterion for a production chatbot.