Pidoku

Speculative Decoding Variants

Module 13 Lesson 13.o 1h 15m Difficulty 4/5

Prerequisites 12.n, 13.n


Before you start: words you need#

WordPlain meaning
DrafterWhatever proposes the guessed tokens that the target model then verifies (12.n).
Hidden state / featureThe vector a model computes for a token inside its layers, before turning it into a word. Many drafters read these from the target.
HeadA small extra network attached to the target model that reads its hidden states.
Sequential (autoregressive) draftingDrafting one token, feeding it back, drafting the next: k guesses cost k small passes.
Parallel draftingProposing all k guesses in a single pass of the drafter.
MTP (multi-token prediction)Extra layers trained with the model itself to predict tokens further ahead; reused as a built-in drafter.
Tree verificationVerifying several alternative guess paths in one target pass, using an attention mask so each path sees only its own ancestors.
Acceptance lengthTokens produced per verify step: accepted guesses plus the target’s one bonus token (13.n).

12.n gave the algorithm and a short list of variants; 13.n covered deployment. This lesson is the deep home for the variants: how each family drafts, what it costs, and an honest comparison — including the 2026 parallel drafters.

Facts checked on 12 November 2026 (vLLM v0.32.0).


1. What is it? The design space#

Every variant answers three questions:

1. WHERE DO THE GUESSES COME FROM?
     the text itself / a smaller model / heads on the target's hidden states /
     layers trained into the model / a diffusion-style block drafter

2. HOW ARE THEY PRODUCED?
     one at a time (sequential) or all at once (parallel); a chain or a tree

3. WHAT DOES IT COST?
     extra memory / training / drafting time / verification compute
VARIANT               GUESSES FROM             HOW         TRAINING?   STATUS (2026)
N-gram / prompt look. the context itself       chain       no          ESTABLISHED
Suffix decoding       context + past outputs   tree        no          ESTABLISHED
Draft model           a smaller LLM            sequential  no*         ESTABLISHED
Medusa                k heads on last layer    tree        yes         superseded
EAGLE / EAGLE-2       feature-level head       sequential  yes         superseded by EAGLE-3
EAGLE-3               head on multi-layer      sequential, yes         ESTABLISHED (common
                      features                 tree                    default for heads)
Native MTP            layers in the model      sequential  with model  ESTABLISHED where shipped
P-EAGLE               EAGLE-style, parallel    parallel    yes         EMERGING (in vLLM)
DFlash                block-diffusion drafter  parallel    yes         EMERGING (in vLLM)
DSpark                DFlash + sequential fix  parallel +  yes         EMERGING (DeepSeek, vLLM)
                      + confidence scheduling  scheduled
Lookahead decoding    Jacobi iteration         n-gram pool no          niche
Self-speculation      a subset of own layers   sequential  light       research

* a distilled draft accepts more

2. Why does it exist? Why so many variants#

12.n’s speedup formula has three knobs: acceptance α, draft cost c, and draft length k. Each generation of variants attacked whichever knob was the limit:

2022–23  draft models          work anywhere, but c is high and α modest
2024     Medusa, EAGLE-1/2      cheap heads (low c) reading the target's own features (higher α)
2025     EAGLE-3, native MTP    much higher α: train on the target's own outputs,
                                use features from several layers, or build it in
2026     parallel drafters      the new limit was SEQUENTIAL drafting: k guesses
                                cost k passes, so long drafts did not pay.
                                Draft all k in one pass → k = 7+ becomes cheap.
         DSpark scheduling      the next limit: at high load, verifying long
                                drafts wastes batch capacity → verify only the
                                guesses likely to be accepted

The direction of travel: drafters get closer to the target (its features, its training) and cheaper per guessed token (parallel), and verification gets load-aware.


3. Simple analogy#

Guessing the rest of a friend’s sentence.

  • N-gram: they have said this phrase before, so you repeat what came next last time.
  • Draft model: a younger sibling who talks like them guesses the next few words, one at a time.
  • EAGLE: you watch their face (hidden states) while they speak, not just their words.
  • MTP: your friend was trained from childhood to say where the sentence is going.
  • Parallel drafter: you blurt out the next seven words in one breath instead of one at a time.
  • DSpark: you blurt them out, but only say aloud the ones you are confident about when your friend is busy.

4. Tiny example: why parallel drafting changes the best k#

The program uses 12.n’s expected tokens per verify step, (1 − α^(k+1)) / (1 − α), and charges each drafter for its passes: a sequential drafter pays k draft passes, a parallel one pays one.

Go
// Expected speedup of speculative decoding at batch 1, for different drafters.
package main

import (
	"fmt"
	"math"
)

// tokensPerStep is the expected number of tokens one verify step produces
// when each drafted token is accepted with probability alpha (12.n).
func tokensPerStep(alpha float64, k int) float64 {
	return (1 - math.Pow(alpha, float64(k+1))) / (1 - alpha)
}

func main() {
	type drafter struct {
		name     string
		alpha    float64
		cost     float64 // one draft pass, as a fraction of one target pass
		parallel bool    // one pass for all k tokens?
	}
	drafters := []drafter{
		{"draft model 1B for 70B", 0.65, 0.05, false},
		{"EAGLE-3 head", 0.75, 0.03, false},
		{"parallel drafter", 0.75, 0.05, true},
	}
	fmt.Println("drafter                  k  tokens/step  step cost  speedup")
	for _, d := range drafters {
		for _, k := range []int{3, 5, 7} {
			passes := float64(k)
			if d.parallel {
				passes = 1
			}
			cost := 1 + passes*d.cost // one target verify pass + the drafting
			t := tokensPerStep(d.alpha, k)
			fmt.Printf("%-24s %d  %11.2f  %9.2f  %6.2fx\n", d.name, k, t, cost, t/cost)
		}
	}
}

Output:

drafter                  k  tokens/step  step cost  speedup
draft model 1B for 70B   3         2.35       1.15    2.04x
draft model 1B for 70B   5         2.64       1.25    2.11x
draft model 1B for 70B   7         2.77       1.35    2.05x
EAGLE-3 head             3         2.73       1.09    2.51x
EAGLE-3 head             5         3.29       1.15    2.86x
EAGLE-3 head             7         3.60       1.21    2.97x
parallel drafter         3         2.73       1.05    2.60x
parallel drafter         5         3.29       1.05    3.13x
parallel drafter         7         3.60       1.05    3.43x

The draft model peaks around k = 5 because every extra guess costs another pass. The parallel drafter keeps improving with k because the drafting cost does not grow. The numbers are a model at batch 1, not measurements: real parallel drafters accept later positions less often (each guess does not see the ones before it), which is exactly the weakness DSpark’s sequential correction targets.


5. Technical explanation#

N-gram / prompt lookup — try this first#

IDEA: find the current suffix earlier in the context; propose what followed it.

  context: "...the quick brown fox jumps over the lazy dog. The quick brown"
  suffix:  "The quick brown"   →   propose "fox jumps over"

COST: zero. No model, no memory, no training. A string search
      (vLLM v0.32.0 also has a GPU n-gram drafter with variable-length drafts).

ACCEPTANCE (rough)
  summarization, editing, code edits:   high (0.5–0.9)
  RAG answers quoting documents:        medium (0.3–0.6)
  open-ended chat or creative writing:  low (0.05–0.3)
Go
// ngramPropose finds the last earlier occurrence of the current n-gram and proposes what followed.
func ngramPropose(context []int, n, k int) []int {
	if len(context) < n {
		return nil
	}
	suffix := context[len(context)-n:]
	for i := len(context) - n - 1; i >= 0; i-- {
		if slices.Equal(context[i:i+n], suffix) {
			return context[i+n : min(i+n+k, len(context))]
		}
	}
	return nil
}

Suffix decoding (Snowflake, 2024) generalizes this: it builds suffix trees over the prompt and previous outputs, so it shines on agent loops that repeat themselves. vLLM: "method": "suffix".

Draft model — the classic#

  ✓ works for any content
  ✓ no training if a same-family small model exists
  ✗ needs the same tokenizer; costs memory and its own KV
  ✗ sequential: k guesses = k draft passes
SELECTION: minimize c, maximize α (13.n).

Medusa — extra heads (superseded)#

IDEA: add K heads to the target. Head i predicts token t+i+1 directly from the
      last hidden state; their top candidates form a tree, verified in one pass.
  ✓ no separate model; tiny heads
  ✗ head i cannot see what heads 1..i−1 guessed → acceptance falls fast with i
  ✗ needs training

Historically important (it popularized tree verification); replaced by EAGLE-style heads.

EAGLE, EAGLE-2, EAGLE-3 — reading the target’s features#

EAGLE (2024)    a one-layer head takes the target's top-layer hidden state plus
                the last token and predicts the NEXT hidden state, then decodes
                a token from it. Features are smoother to predict than tokens.
EAGLE-2 (2024)  a dynamic draft tree whose shape follows the head's confidence.
EAGLE-3 (2025)  drops feature prediction and predicts TOKENS directly, from a
                fusion of low-, middle- and top-layer features, trained with
                "training-time test" (the head practises on its own earlier
                guesses, as it will at inference).
                Authors report up to 6.5× at batch 1, ~1.4× over EAGLE-2, and
                1.38× throughput at batch 64 in SGLang.

EAGLE-3 heads are published for many popular models and supported in vLLM ("method": "eagle3"), SGLang and TensorRT-LLM. The cost: it needs the target’s internal hidden states, and must be retrained when the target changes.

Native multi-token prediction (MTP)#

The model is TRAINED with extra MTP layers that predict tokens further ahead
(DeepSeek-V3/V4, GLM-4.5 and later, Qwen3-Next, Nemotron and others).

  DeepSeek-V3 report: second-token acceptance 85–90%, ~1.8× tokens per second.

✓ nothing to find or train; aligned with the model by construction
✓ engines support it directly: "method": "mtp"
✗ only if the model ships it; usually 1–3 MTP layers, so k is small

Where MTP exists it is the default choice, and it is the baseline the newest drafters are measured against.

Parallel drafters: P-EAGLE, DFlash, DSpark (2026)#

All three propose a whole block of k tokens in one drafter pass, so drafting time stops growing with k. They differ in how the target’s hidden states reach the drafter. vLLM and its Speculators training library support all three since July 2026.

P-EAGLE (Feb 2026)
  EAGLE made parallel: a learnable shared hidden state stands in for the
  not-yet-drafted positions, so all k are predicted at once. The smallest
  change from EAGLE-3.
  Authors: 1.10–1.36× over EAGLE-3 on gpt-oss-120b/20b and Qwen3-Coder-30B, in vLLM.

DFlash (Feb 2026)
  A small BLOCK-DIFFUSION model drafts the block in one pass, conditioned on
  target features injected into the drafter's KV cache rather than its input.
  Authors: over 6× lossless speedup, up to 2.5× more than EAGLE-3.
  vLLM: "method": "dflash".

DSpark (DeepSeek, July 2026)
  DFlash's parallel backbone + a light sequential module (a low-rank head that
  conditions each position on the previous token) to slow the acceptance decay
  at later positions, + a confidence head that predicts how likely each prefix
  is to survive. Verification length is then chosen per request from those
  confidences and the engine's throughput profile.
  DeepSeek, in production on DeepSeek-V4: 60–85% faster per-user generation
  than their MTP-1 baseline at matched throughput.
  vLLM: "method": "dspark"; adaptive verification currently works with DSpark.

All figures above are the authors’ own; the vLLM team’s comparison post shows parallel drafters ahead of EAGLE-3 on its test setups but warns that results vary by model, task and hardware.

Lookahead decoding and self-speculation#

LOOKAHEAD   Jacobi iteration guesses several future positions at once and harvests
            the n-grams that emerge into a pool. No draft model, no training.
            Paper reports up to ~1.8× on chat and more on code. Little engine support.

SELF-SPECULATION / LAYER SKIP
            Use a subset of the target's own layers as the drafter. No extra memory,
            but α is usually lower. Mostly research.

6. Under the hood: tree and confidence-scheduled verification#

Tree verification#

CHAIN: propose t+1..t+4. If t+2 is wrong, t+3 and t+4 are wasted.

TREE: propose branching candidates
                    t+1
              ┌──────┴──────┐
            "the"          "a"
           ┌──┴──┐       ┌──┴──┐
        "cat" "dog"   "cat" "bird"
  → verify ALL paths in one target pass; accept the longest matching path

THE MECHANISM: a custom attention mask where each node attends only to its
               ancestors, not its siblings.
  positions: [prompt...][the][a][cat][dog][cat][bird]
  "cat" (child of "the") attends to prompt + "the", NOT to "a"

A tree gives more accepted tokens per target pass, for more verification compute. That compute is free at low batch and expensive at high batch, so trees degrade faster with load than chains.

Confidence-scheduled verification#

Plain verification:     every request sends all k drafted tokens to the target
Confidence-scheduled:   the drafter estimates P(prefix of length j survives)
                        for j = 1..k; the engine sends only as many as are
                        worth their verification cost at the CURRENT load
  low load  → verify long drafts (compute is free)
  high load → verify short drafts (compute is someone else's tokens)

This is how DSpark turns speculation from a low-load-only trick into something that can stay on at peak. In vLLM it appears as adaptive verification.


7. Performance implications#

An honest comparison. Ranges combine the papers with typical production reports; batch 32 is closer to what a busy server sees.

VARIANT            batch 1    batch 32   Training?   Memory      Complexity
n-gram / suffix    1.5–3×     1.1–1.5×   no          none        trivial
draft model        2–2.5×     1.3–1.8×   no*         2–4 GB      moderate
EAGLE-3            2.5–4×+    1.5–2×     yes**       small head  moderate
native MTP         1.8–2.5×   1.3–1.8×   with model  built in    low
parallel drafters  2.5–4×+    1.5–2.5×   yes**       small model moderate
lookahead          1.5–2×     ~1.1–1.3×  no          none        high

*  distillation helps   ** unless a published head exists for your exact model

Every column shrinks with batch (13.n). Parallel drafters and confidence-scheduled verification shrink it least, which is their main practical advantage.


8. Production implications#

CHOOSING

□ Decode-bound at low to moderate batch?        NO → stop (13.n).
□ Model ships MTP layers?                      YES → "mtp".
□ Published EAGLE-3 / DFlash / DSpark for this exact checkpoint?
                                               YES → use it; compare against MTP.
□ Output copies from input, or agent loops?    YES → n-gram or suffix (also as a fallback).
□ Same-family small model available?           YES → draft model.
□ High volume and willing to own training?     YES → train a head with Speculators.
  • Trained drafters create a retraining obligation. Every target update — new checkpoint, fine-tune, even a new quantization — can drop acceptance. Re-measure after each one.
  • Gate on load, or use the engine’s dynamic speculation and adaptive verification modes.
  • Measure acceptance length per workload type, continuously (13.n’s metrics).
  • Tree and long-draft methods degrade fastest with batch unless verification is scheduled.
  • Prefer the drafter the model’s authors ship. MTP or an official head matches the target best.

9. Common mistakes#

  1. Skipping the free options. N-gram, suffix and native MTP cost nothing to try.
  2. Not gating on load. A regression at peak.
  3. Adopting a trained drafter without planning for retraining.
  4. Using a head trained for a different checkpoint of the “same” model.
  5. Believing paper speedups. They are batch 1, on favourable content, measured by the authors.
  6. Setting a large k on a sequential drafter because parallel drafters use one.
  7. Skipping the rejection-sampling correction. A silent quality change.
  8. Forgetting KV rollback for rejected tokens (13.n).

10. Hands-on exercise#

A. Model the trade-off. Run the program in section 4. Add a decay so position j is accepted with probability α·0.9^(j−1) for the parallel drafter. At what k does it stop improving now?

B. Free variants. Implement the n-gram proposer from section 5. Measure acceptance length on summarization, code editing, RAG and creative writing. Then try vLLM’s suffix method on a repetitive agent trace.

C. Compare drafters. For a model with published MTP and EAGLE-3 or DFlash drafters, benchmark each at batch 1, 8, 32 and 128. Plot speedup against batch. Where does each cross 1.0×?

D. Tree vs chain. Implement chain verification and a two-branch tree. Measure tokens accepted per target pass, and the extra tokens verified.

E. Break a drafter. Quantize the target (13.e) and keep the old EAGLE-3 head. How much does acceptance drop?


11. Interview questions#

  1. Survey the speculative decoding variants. Which would you try first for a new model, and why?
  2. What did EAGLE-3 change compared with EAGLE-2, and why did it help?
  3. Why does parallel drafting change the best draft length?
  4. What problem does DSpark’s confidence-scheduled verification solve that parallel drafting does not?
  5. What is tree verification and what does it cost at high batch?
  6. Why is native MTP usually the default when a model has it?
  7. What ongoing obligation does a trained drafter create?

12. Further reading#

Checked on 12 November 2026.

↑↓ navigate↵ openesc close

100% drag to pan · scroll or pinch to zoom · double-click to zoom in