LLM + RoboticsModule 12 · Video 04

Speculative decoding: draft, verify, and the EAGLE/Medusa/DFlash family

A big language model writes one token per forward pass, and each pass is slow mostly because it has to read every weight from memory. Speculative decoding lets something cheap guess several tokens ahead and has the big model check all the guesses in one pass. A careful accept-or-resample rule means the output distribution doesn't change at all. This guide walks through the video's chapters, from the basic trick to draft trees, Medusa, multi-token prediction, the EAGLE line and the parallel drafters DFlash and DFlash 2.

Video length24:34
Published28 August 2026
LevelIntermediate: you should know what a forward pass, a softmax and a KV cache are
Builds onModule 09 · Speculative decoding problem, Module 09 · KV cache, Module 05 · Serving

Video by Jia-Bin Huang · Watch on YouTube

Start here (no maths needed)

A big AI model writes one word at a time, and each word takes a long think. Speculative decoding lets a fast helper guess the next few words, and the big model checks all the guesses at once. Good guesses are kept, and the first bad one is replaced. The final text is exactly what the big model would have written on its own, just faster.

Think of it like this

Imagine a teacher marking a spelling test. A slow way: the student says one letter, the teacher nods, the student says the next letter, the teacher nods again. A faster way: a friend who is usually right writes down the next five letters, and the teacher looks at all five at once. The teacher keeps every letter up to the first mistake, fixes that one, and they move on. The teacher still decides every letter, so the answer is the teacher's answer. The friend only saves time.

How it works

  1. A small, fast "draft" model (or a few extra layers bolted onto the big model) guesses the next few words.
  2. The big "target" model reads all the guesses in a single pass, which costs about the same as checking one word.
  3. Going left to right, each guess is accepted with a chance that depends on how much the big model agrees with it.
  4. At the first rejected guess, the big model picks a replacement word in a special way, so the overall result is exactly what it would have chosen alone.
  5. Newer methods guess smarter: several possible branches at once (a tree), or a whole block of words in one go (DFlash).

Why robots care

A robot that talks, plans or picks its next action with a language model has to answer quickly. If a reply takes three times longer than it needs to, the robot stands there frozen, or acts on old information. Speculative decoding makes the same model answer faster without making it any less accurate.

Try it

Words to know

Token
A word or piece of a word, the unit a language model writes.
Target model
The big, accurate model whose answers we want.
Draft
The fast guesser, either a small separate model or extra heads on the big one.
Acceptance rate
How often the big model keeps a guessed token.
Lossless
The speed-up doesn't change what the big model would have written (or its odds of writing it).

Going deeper: everything below is the full version, with some maths. On a first read, skim the headings and the "Why it matters for robotics" box, and come back for the rest later.

1. Watch

Chapter guide

TimeChapterWhat to look for
0:00Autoregressive decodingWhy each token needs its own full forward pass, and why that pass is limited by memory bandwidth rather than arithmetic.
0:51Speculative decoding: Draft and verifyThe two roles, and why scoring k drafted tokens in one target pass costs about the same as generating one.
2:08Rejection samplingThe accept probability min(1, p/q), the residual distribution used after a rejection, and the argument that the output follows p exactly. This is the heart of the video's title.
7:08Draft treesProposing several branches instead of one chain, and how a tree attention mask lets the target verify all branches in one pass.
9:43MedusaExtra decoding heads on the target's last hidden state, each predicting a token further ahead, with no separate draft model.
12:44MTP: Multi-token predictionTraining the model itself to predict several future tokens, and how those extra predictions can double as a built-in draft.
14:41EAGLE: Feature-level draftingDrafting in the target's feature space (the layer before the output head) rather than in token space, and feeding in the sampled token to remove ambiguity.
16:25EAGLE-2: Dynamic draft treesGrowing the tree where the draft is confident, using its confidence as a stand-in for acceptance probability.
17:19EAGLE-3: Token prediction + layer fusionDropping the feature-prediction target, predicting tokens directly, and fusing features from several target layers.
17:47DFlash: Parallel draftingA draft that produces a whole block of tokens in one forward pass instead of one token at a time.
19:43DFlash 2: Path selector and local mixingThe two fixes for independent parallel guesses: choosing a coherent path through each position's candidates, and letting neighbouring positions share information.
24:06RecapHow the family fits together: better drafts raise acceptance, cheaper drafts cut overhead, and the verification rule stays the same throughout.

The video credits Inco AI's DFlash 2 blog post for its DFlash 2 material. Timestamps link to YouTube.

2. The ideas, explained

Why one token per pass is slow

At batch size 1, generating a token means streaming every weight from GPU memory into the compute units, then doing comparatively little arithmetic with them. The GPU spends most of the step waiting for memory. Scoring 5 tokens in one pass reads the same weights once and does 5 times the arithmetic, which the idle compute units absorb almost for free. Speculative decoding exploits this gap: if something cheap can propose tokens, the expensive model can check several per pass. The full latency story, including when the trick stops paying, is on Module 09's speculative decoding problem; this page focuses on the drafting methods.

Draft, verify and rejection sampling

Speculative decoding was published independently by Leviathan, Kalman and Matias (2022, "speculative decoding") and by Chen, Borgeaud, Irving and colleagues at DeepMind (2023, "speculative sampling"). Both use the same acceptance rule. Let p be the target's next-token distribution and q the draft's, at the same position:

draft samples       x ~ q
accept x with prob  min(1, p(x) / q(x))
if rejected, sample from the residual
                    r(x) = max(0, p(x) − q(x)) / Σ_y max(0, p(y) − q(y))

P(output = x) = q(x)·min(1, p(x)/q(x))  +  (1 − β)·r(x)  =  p(x)
acceptance prob     β = Σ_x min(p(x), q(x)) = 1 − TV(p, q)

Why the last line equals p(x): the first term is min(q(x), p(x)). The rejection mass is 1 − β, which equals Σ max(0, p − q), the normaliser of r. So the second term is max(0, p(x) − q(x)), and min(q, p) + max(0, p − q) = p. The draft affects only speed, never the distribution. The acceptance probability is the overlap between the two distributions, which is exactly what the demo below draws.

With k drafted tokens, the target scores all k + 1 positions in one pass, accepts a prefix, and always contributes one token of its own: either the replacement at the first rejection or a bonus token after the last accepted one. With a constant per-token acceptance rate α, the expected tokens per pass is (1 − αk+1) / (1 − α). Greedy decoding is the special case where p and q are one-hot: accept if the draft's token matches the target's argmax.

Interactive: why rejection sampling is lossless

Eight candidate next tokens. Outlined bars: the target's distribution p. Filled bars: the draft's distribution q. The highlighted part of each bar is min(p, q); its total is the acceptance probability. After a simulation, the dots show how often each token was actually emitted using the accept-or-resample rule.

Acceptance β = Σ min(p, q)
–
Accepted in simulation
–
Largest gap, output vs p
–
Draft
–

Try this: the defaults (draft error 1, temperature 1, draft #1) give an acceptance of about 77.5%. Set draft error to 0 and the draft equals the target: 100%. At draft error 2 it falls to about 70.9%. Now simulate: the dots sit on the outlined bars to within roughly a percentage point or two (sampling noise at 10,000 draws), at any setting. A worse draft costs you accepted tokens, not correctness. The draft's logits are the target's plus scaled random noise; "New draft" redraws the noise.

Draft trees

A single chain dies at its first rejection. If the draft's second choice is often the right one, it's cheaper to propose several branches and let the target check them all. SpecInfer (Miao et al., 2023) organised the candidates as a token tree and verified it in one pass using a tree attention mask: the tree's tokens are flattened into one sequence, and each token may attend only to its own ancestors. The target then accepts the longest branch that survives verification. For sampled (non-greedy) decoding, multi-branch verification needs a generalised acceptance rule so the output still follows p; SpecInfer gives one. Trees raise the expected accepted length at the cost of verifying more tokens per pass, which is cheap only while the GPU has spare compute.

Medusa

Medusa (Cai, Li, Geng and colleagues, 2024) avoids a separate draft model. It adds K small heads on top of the target's final hidden state; head k predicts the token k + 1 positions ahead. The heads' top candidates are combined into a tree and verified with tree attention in the next forward pass. "Medusa-1" trains only the heads on a frozen model; "Medusa-2" fine-tunes heads and backbone together. For sampling, the paper proposes a "typical acceptance" scheme that accepts plausible candidates rather than applying exact rejection sampling, which trades strict losslessness for speed; check which acceptance rule a given Medusa deployment uses.

h_t = target's last hidden state at position t
head_k(h_t) = softmax(W_k · (h_t + SiLU(W'_k · h_t)))   predicts token t + k + 1

The weakness: every head sees the same h_t and none of them knows which token the earlier heads picked, so far-ahead heads are much less accurate.

Multi-token prediction (MTP)

Gloeckle et al. (Meta, 2024) trained models to predict the next n tokens with n independent output heads on a shared trunk, as an auxiliary training loss. They report better sample efficiency, especially on code, and that 4-token models were up to 3× faster at inference when the extra heads are used for self-speculative decoding. DeepSeek-V3 (2024) used a sequential variant, where each extra MTP module also sees the embedding of the previous predicted token, and reused it for speculative decoding at serving time. The idea for this chapter: if a model is trained with MTP, it ships with its own draft. Module 08 Stage 08 covers MTP as a design-time choice.

L_MTP = − Σ_t Σ_{i=1..n} log P_θ(x_{t+i} | x_{≤t})

The EAGLE line

EAGLE (Li, Wei, Zhang and Zhang, 2024) makes two observations. Predicting the next feature (the target's second-to-top layer, just before the output head) is easier than predicting the next token, because features vary smoothly. But features are uncertain: the next feature depends on which token was actually sampled. So EAGLE's one-layer draft takes both the current feature sequence and the token sequence shifted one step ahead, predicts the next feature, and runs it through the target's own frozen output head to get draft tokens. It keeps exact rejection-sampling verification, so it's lossless.

f̂_{t+1} = Draft(f_{≤t}, embed(x_{≤t+1}))
q(· | ...) = softmax(LMHead_target(f̂_{t+1}))

EAGLE-2 (2024) noticed that acceptance depends on context, not only on a token's position in the tree, and that EAGLE's draft is well calibrated: its confidence approximates the acceptance rate. So it grows the draft tree dynamically, expanding the branches with the highest cumulative confidence and reranking before verification. The paper reports 3.05–4.26× speed-ups, 20–40% faster than EAGLE-1.

EAGLE-3 (2025) found that EAGLE gained little from more training data, and traced it to the feature-prediction constraint. It drops feature prediction, predicts tokens directly, and fuses low-, middle- and high-level features from the target. Its training uses "training-time test": during training the draft is fed its own earlier predictions, as it will be at inference, so it learns to cope with its own errors over several steps. That last idea is closely related to the exposure-bias theme of Video 05.

DFlash: parallel drafting

Every method so far still drafts autoregressively: k draft tokens take k draft passes, so drafting cost grows with block length. DFlash (Chen, Liang and Liu, 2026) replaces the autoregressive draft with a lightweight block diffusion model that predicts every position of the draft block in a single forward pass, conditioned on context features extracted from the target model. Verification is unchanged, so it stays lossless. The paper's abstract reports over 6× lossless acceleration across models and tasks, and up to 2.5× higher speed-up than EAGLE-3. According to Inco AI's DFlash 2 post, the team released DFlash in January 2026 and it has since been integrated into SGLang, vLLM, TensorRT-LLM and llama.cpp.

DFlash 2: path selection and local mixing

Everything in this section comes from Inco AI's blog post "DFlash 2: Keep Drafting Parallel" (August 2026), which the video credits. It's a company blog post, not a peer-reviewed paper, so treat the numbers as the authors' own measurements.

Predicting every position independently has two weaknesses, the post argues. Positions don't coordinate, so neighbouring picks can clash (the post's example is two neighbours choosing the same word), and accuracy decays towards the end of the block ("suffix decay"). DFlash 2 adds two small pieces, both of which keep drafting in one parallel pass:

path score     S_t(a, b) = U_t(b) + ⟨ A(a) ⊙ H(h_t), B(b) ⟩
               U_t(b): DFlash's own logit for candidate b at position t
               A, B: compact token embeddings; H(h_t): a context gate

local mixing   Conv_k(x)_t = k_{t,0} ⊙ x_t + k_{t,1} ⊙ x_{t−1}

Reported results: on Qwen3.5-4B across five benchmarks, mean acceptance length rose from 4.92 tokens (DFlash) to 5.97 (DFlash 2), about 21%, with the two additions together adding about 1.3% to draft–verify cycle latency. The post sums up its selector result as "Choosing is cheaper than predicting." For the newer model families and engines named in the post, see the post itself.

How the family fits together

MethodWhere the draft comes fromDraft cost for k tokensLossless under sampling?
Classic speculative decoding (2022–23)Separate small model, same tokenizerk small-model passesYes
Draft trees (SpecInfer)Small model(s), several branchesGrows with tree sizeYes, with tree verification
MedusaExtra heads on the target's last stateOne pass of tiny headsOnly with exact verification; typical acceptance relaxes it
MTPHeads trained with the modelBuilt inYes, when verified
EAGLE / -2 / -3One-layer draft on target featuresk light passesYes
DFlash / DFlash 2Light block-diffusion drafter on target featuresOne pass for the whole blockYes

3. Where the course goes deeper

TopicCourse page
Speedup maths, choosing k, when speculation hurts under load (with a speedup demo)Module 09 · Latency, problem 10
Speculative decoding in a trillion-parameter serving stack, with a draft trained for acceptanceModule 05 · Serving
Designing a model to be easy to speculate with (tokenizer, MTP, two KV caches)Module 08 · Stage 08
Why decode is memory-bound; the KV cache that verification readsModule 09 · KV cache and attention
Engines that ship these drafters (vLLM, SGLang)Module 09 · Engines, Video 09 · LLM serving
Distillation, which many drafters are trained withVideo 05 · On-policy distillation, Module 04

Why it matters for robotics

Self-check

Target p = (0.6, 0.3, 0.1) and draft q = (0.3, 0.3, 0.4) over three tokens. What is the acceptance probability, and what is the residual distribution after a rejection?

β = min(0.6,0.3) + min(0.3,0.3) + min(0.1,0.4) = 0.3 + 0.3 + 0.1 = 0.7. The residual is max(0, p − q) = (0.3, 0, 0), normalised to (1, 0, 0): after a rejection you always emit the first token, which is the one the draft under-proposed.

Why can't the draft model change the output distribution, however bad it is?

Accepted mass at token x is min(p(x), q(x)); the rejected mass is redistributed through the residual exactly in proportion to max(0, p(x) − q(x)). The two add to p(x) for every x. A bad draft lowers acceptance, so you get fewer tokens per target pass, but the distribution is still p.

What problem do draft trees solve, and what do they cost?

A single chain stops at the first rejection, even when the draft's second guess was right. Trees propose several branches and verify them all in one pass with a tree attention mask. The cost is more tokens to verify per pass, which is cheap only while the GPU has spare compute (small batches).

How does EAGLE deal with the uncertainty of predicting the next feature?

It feeds the draft the token sequence shifted one step ahead alongside the features, so the draft knows which token was actually sampled and predicts the feature that follows it. The target's frozen output head turns predicted features into draft tokens.

What does DFlash change about drafting, and what two problems does DFlash 2 address?

DFlash drafts a whole block in one forward pass with a light block-diffusion model, instead of k sequential draft passes. Because positions are predicted independently, DFlash 2 adds a path selector (pick a coherent path through each position's top candidates) and local mixing (a short convolution so each position sees its predecessor), targeting incoherent blocks and suffix decay.

Medusa's typical acceptance can be faster than exact verification. What do you give up?

Exact losslessness under sampling: outputs can differ from what the target alone would sample. Under greedy decoding the difference disappears, but for sampled outputs you'd need to re-evaluate quality.

References

From the video's description:

Primary papers cited on this page: