Unit 10 of 12 · about 3 hours · explain

N-gram, tree and learned drafters, multi-token heads and structured outputs

The drafter is a cost and acceptance choice, not a leaderboard. Repetitive traffic and open prose want different drafters, and the wrong one is slower than none.

You'll be able to

  • Compare n-gram, tree and learned drafters by extra parameters, training cost and typical strength.
  • Explain how Medusa heads, EAGLE feature drafting and tree attention differ in what the draft conditions on.
  • State the constraint-matching rule for combining structured decoding with speculation.

Covers

N-gram, tree and learned-draft vocabularyMedusa, EAGLE and multi-token-head orientationStructured decoding combined with speculation
1

Read

In this order, only the parts listed

0 of 4 done

  1. Module 08: self-speculation surveyLLM Inference: From scratch, one token at a time - Module 08

    Concept 04 Self-speculation: the method table (draft model, Medusa, EAGLE, n-gram lookup) with extra parameters, training and strength, and the tree-verification attention-mask sketch

  2. Choosing and tuning draftersHands-On LLM Serving and Optimization - Quantization (Chapter 6) and Speculative Decoding (Chapter 7)

    Chapter 7, Tuning and Usage (printed pp. 235 to 239): Choose an existing small model, Use self-drafting with Medusa heads and EAGLE variants, the N-gram subsection with the n equals 3 example, and Tune the number of draft tokens

    Read the n-gram-first recommendation as a cost argument, not a quality ranking.

  3. Draft-based, self-speculative and multi-token decodingAI Systems Performance Engineering - Chapters 15 and 16, speculation and quantization

    Chapter 15: Two-Model, Draft-Based Speculative Decoding and EAGLE; Single-Model Self-Speculative Decoding; Multitoken Decoding with Medusa's Multiple Heads; and Constrained Decoding Performance Implications (printed p. 943 on) for the grammar-masking cost that speculation must also pay

  4. vLLM speculation methods at a glancevLLM Speculative Decoding and Quantization (v0.31.0)

    vLLM Speculation Methods list and Method Selection at a Glance table: which methods gain at low versus high QPS and which need a separate draft model

2

Focus on

  • N-gram lookup costs nothing and wins on repetitive text such as code edits, quoted retrieval and fixed schemas. On novel prose it rarely proposes anything usable.
  • Medusa attaches independent heads that predict several positions ahead without a second model, verified as a tree. Independence caps accuracy at distance.
  • EAGLE autoregresses over the target hidden features with a one-step token shift, so drafts condition on richer state than tokens alone. Later versions add dynamic trees.
  • Structured decoding masks the target at every verified position, so output stays exact whatever the draft proposes. Drafts outside the grammar are never accepted (vLLM v0.31.0 trims them to the longest grammar-valid prefix), so mask the draft too or acceptance falls.
Common mistakes · 3
  • Deploying a same-size draft. The draft must be an order of magnitude cheaper or its cost ratio erases the yield; a near-target draft is a second target.
  • Expecting Medusa heads to condition on each other. They predict independently from one hidden state, which is exactly the gap EAGLE feature autoregression fills.
  • Constraining only the target under structured decoding. Output stays exact, but drafts outside the grammar are always rejected, so acceptance collapses; mask the draft with the same grammar.
3

Try it yourself

Closed-book, before checking anything

Without notes, draw the four-row table (draft model, Medusa, EAGLE, n-gram) with extra parameters, training and strength, and explain why tree verification raises the chance that some path accepts.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 1.Which drafter do you try first on a retrieval-heavy workload, and why?Answer

    N-gram lookup. Answers quote retrieved text, so suffix matches propose well at zero parameter and training cost; measure before buying a trained drafter.

  2. 2.What information does an EAGLE draft condition on that a Medusa head does not?Answer

    The target hidden-feature sequence with the token sequence shifted one step, autoregressively. Medusa heads predict each future position independently from one hidden state.

  3. 3.How does tree attention verify many candidates in one pass?Answer

    Each tree node attends only to its ancestors under a masked pass, so one forward pass scores every candidate path and the best accepted path is kept.

  4. 4.A grammar constrains the target but the draft proposes freely. What breaks?Answer

    Exactness survives, because verification samples from the masked target. Acceptance suffers: drafts outside the grammar are always rejected, so speculation wastes work. Mask the draft with the same grammar.

5

Practice

  • 100 Days of LLM Inference Day 15: n-gram proposer

    N-gram Speculation cells: rewrite ngram_propose from its docstring, run simulate_ngram_speedup on a repetitive prompt and a novel prompt, and report where the free drafter beats a model drafter

    Your two prompts are the workload model; state which traffic each represents before comparing.

You're done when

You fill the four-row drafter table without notes and can pick the drafter for a stated workload with a cost and acceptance argument.

Only when you can do this without notes.

Leads to

Notes

Resources · 4 for this unit, 9 more in the section

Also in this section