Before you start: words you need#
| Word | Plain meaning |
|---|---|
| Target model | The big model whose output you want. |
| Drafter (proposer) | Something cheap that guesses the next few tokens: a small model, an extra head, or a text lookup. |
| Draft tokens | The guessed tokens. k is how many per step (num_speculative_tokens). |
| Verification | One target forward pass over the last real token plus the k drafts, checking each guess. |
| Acceptance rate (α) | The chance that a draft is accepted, given that the ones before it were. |
| Rollback | Undoing the scheduler’s count of computed tokens for rejected drafts. |
| Parallel drafting | A drafter that produces all k guesses in one pass instead of k passes in a row. |
| Hidden states | The target model’s internal vectors at a layer. EAGLE-style drafters read them. |
1. What is it?#
Decoding is sequential: one forward pass, one token. But a forward pass can check several tokens about as cheaply as it produces one, because checking is parallel. Speculative decoding exploits that: something cheap proposes the next few tokens, the target model runs once over all of them and verifies, and every guess it agrees with is a token gained. The output is exactly what the target would have produced alone.
The idea and the algorithms belong to 12.n, 13.n and 13.o. This lesson is how vLLM v0.32.0 runs it. In vLLM, drafts are ordinary scheduled tokens with a rollback, which is why the scheduler’s counters were designed the way they were (17.a). Facts checked on 12 November 2026.
2. Why does it exist?#
Decode is limited by memory bandwidth: each step reads all the weights to produce one token per
request, and the arithmetic units are mostly idle (12.c). Feeding 1 + k tokens per request
reads the weights once and uses some of that idle arithmetic. So a verification step costs only a
little more than a plain step, until the GPU’s compute is actually saturated. The gain is lower
inter-token latency; the risk is wasted compute at high load.
3. Simple analogy#
A senior editor (the target) checks a junior writer’s (the drafter’s) next sentence word by word. Reading five words to check them takes barely longer than writing one. Every word the editor agrees with is kept; at the first disagreement the editor writes the right word and the junior starts again from there. On a quiet day this doubles the editor’s output. On a day when the editor is already overloaded, checking bad guesses only slows everything down.
4. Tiny example#
context ... the cat sat
drafter proposes on the mat . (k = 4)
target one pass over: sat | on the mat .
compare on ✓ the ✓ mat ✗ (target wants "floor")
result keep "on the", plus the target's own "floor": 3 tokens from 1 pass
scheduler had counted 1 + 4 positions as computed; rolls back the 2 rejectedEvery step yields at least one token and at most k + 1.
5. Technical explanation#
The acceptance rule#
For greedy decoding a draft is accepted if it equals the target’s top token at that position; the
first mismatch ends acceptance and the target’s own token is kept. For random sampling,
rejection sampling accepts a draft with a probability that depends on how much the target
agrees, and resamples on rejection so the output distribution is identical to the target’s
(13.n). rejection_sample_method can be standard, synthetic (fixed acceptance rates for
benchmarking) or block. Either way, speculative decoding does not change what is generated. If
quality drops with it on, that is a bug.
Configuring it#
vllm serve <target-model> \
--speculative-config '{"method": "eagle3", "model": "<eagle3-head>",
"num_speculative_tokens": 3}'| Method | The drafter is … | Extra memory | Notes |
|---|---|---|---|
ngram / ngram_gpu | A lookup of the last few tokens earlier in the context; proposes what followed | None | Good when output copies input: code edits, summaries, RAG quotations. ngram_gpu runs on the GPU and keeps async scheduling. |
suffix | A suffix-tree lookup over the prompt and earlier responses | Small | Adapts speculation depth to the match length |
draft_model | A separate small model run autoregressively | A whole second model and its KV cache | With parallel_drafting: true and a PARD-trained draft, all k drafts come from one pass |
eagle, eagle3 | A small head that reads the target’s hidden states | A few layers | The strong general-purpose choice when a trained head exists |
mtp (and model-specific *_mtp) | Multi-token-prediction modules shipped with the model | Part of the model | DeepSeek, Qwen 3.5, GLM, Kimi, Gemma 4 assistant checkpoints, … |
dflash | A block drafter that proposes all k tokens in one parallel pass, conditioned on target hidden states | A small model | Low drafting latency; uses bidirectional attention inside the block |
dspark | DFlash’s parallel block pass plus a light sequential head that adds dependencies inside the block | A small model | Some checkpoints ship a confidence head used by adaptive verification |
medusa, mlp_speculator | Extra prediction heads | Small | Older methods; run only on the older model runner |
custom_class | Your class with a propose method | — | Experimental |
Parallel drafters (P-EAGLE, DFlash, DSpark) arrived in vLLM and in the Speculators training
library in July 2026. In v0.32.0, dflash and dspark set parallel_drafting automatically and
run on Model Runner V2. P-EAGLE (EAGLE with parallel_drafting: true) is not yet supported by
MRV2’s EAGLE speculator, so it makes vLLM fall back to the older runner (18.a). The project’s
summary: model-based methods “provide the best latency reduction, while simpler methods such as
n-gram and suffix decoding provide modest speedups without increasing workload during peak
traffic.” Train your own drafter with Speculators.
How the scheduler sees it#
A request has num_computed_tokens and
num_tokens_with_spec = prompt + output + spec tokens; scheduling closes the gap (17.a). Drafts
simply widen it.
Proposal. After a step, drafts are stored on the request as spec_token_ids. With async
scheduling (17.d) the scheduler does not have them yet, so it schedules placeholders (-1) and
the worker, which ran the drafter, fills them in.
Scheduling. The gap is now 1 + k. The scheduler grants those tokens and records the drafts
in scheduled_spec_decode_tokens. It also reserves num_lookahead_tokens KV slots that a drafter
with its own KV will write: k for EAGLE, MTP and draft models; k + 1 for DFlash, which uses a
bonus query plus one per draft.
Budget. Drafts use the token budget like any other tokens.
Verification and rollback. In update_from_output (v0.32.0):
num_draft_tokens = len(scheduled_spec_token_ids)
num_sampled = self.num_sampled_tokens_per_step
num_accepted = max(len(generated_token_ids) - num_sampled, 0)
num_rejected = num_draft_tokens - num_accepted
# Rejections roll back num_computed_tokens (and, under async
# scheduling, num_output_placeholders, which covers the spec
# tokens). A stale rejection count predates the preemption
# rollback and must not apply.
if not output_is_stale:
if request.num_computed_tokens > 0:
request.num_computed_tokens -= num_rejected
if request.num_output_placeholders > 0:
request.num_output_placeholders -= num_rejectedThe KV entries of rejected positions are garbage but need no erasing: the slots are overwritten when the correct tokens are computed.
Caching. Blocks are hashed only up to request.num_tokens, never including drafts (17.g), so
a rejected draft can never enter the prefix cache.
The batch shape stays uniform#
Full CUDA graphs need a uniform batch: every request contributing 1 + k tokens (18.d). A
request that just finished its prompt has no drafts yet and would contribute one token. So the
scheduler pads it:
# Pad new decode requests to uniform spec decoding size to
# preserve full cudagraph for this step.
...
padded_num_tokens = 1 + self.num_spec_tokens
...
if padded_num_tokens > request_token_budget:
# Prefer to not schedule than schedule un-padded.
breakA few wasted rows are cheaper than losing the recorded graph for the whole batch. (Padding is
skipped when dynamic speculative decoding varies k.)
6. Under the hood#
Where the drafters live#
| Runner | Code |
|---|---|
| Model Runner V2 (default) | vllm/v1/worker/gpu/spec_decode/: eagle/, mtp/, dflash/, dflash2/, dspark/, ngram/, standalone_ar/ (draft models), plus rejection_sampler.py and adaptive_verification.py |
| Older runner | vllm/v1/spec_decode/: eagle.py, dflash.py, draft_model.py, medusa.py, ngram_proposer.py, suffix_decoding.py, … |
MRV2 can capture all draft steps of an autoregressive drafter in one full CUDA graph instead of one per draft token (the design document’s “fused multi-step draft decoding”), for attention backends that can update their metadata between draft steps.
Load-aware speculation#
The documentation is explicit that speculative decoding is for “medium-to-low QPS … memory-bound workloads.” Two mechanisms address the high-load case:
- Dynamic speculative decoding picks
kfrom the current batch size each step (num_spec_tokens_to_scheduleinSchedulerOutput): many drafts when quiet, few or none when busy. - Adaptive verification (
enable_adaptive_verification, off by default) scores every (request, position) draft slot by its survival probability and admits the best slots up to a global budget from a cost model profiled at startup. Position 5 of a confident request can beat position 1 of a doubtful one. It works with EAGLE, MTP, DFlash, DSpark and draft models.
Expected yield and cost#
With k drafts each accepted with probability α:
E[tokens] = 1 + α + α² + … + α^k = (1 − α^(k+1)) / (1 − α)The program models step cost as one plain step, plus drafting, plus the extra rows the target processes: almost free when compute is idle, expensive when it is saturated.
package main
import (
"fmt"
"math"
)
// expectedTokens per step with k drafts, each accepted with probability alpha
// given that all earlier ones were accepted.
func expectedTokens(alpha float64, k int) float64 {
if alpha == 1 {
return float64(k + 1)
}
return (1 - math.Pow(alpha, float64(k+1))) / (1 - alpha)
}
// stepCost relative to a plain decode step (= 1.0).
// draft: cost of proposing one token, as a fraction of a target step.
// rowCost: marginal cost of one extra row in the target's batch.
//
// ~0.03 when compute is idle, ~1.0 when the GPU is compute-saturated.
func stepCost(k int, draft, rowCost float64) float64 {
return 1 + float64(k)*draft + float64(k)*rowCost
}
func main() {
type regime struct {
name string
rowCost float64
}
regimes := []regime{{"low load (compute idle)", 0.03}, {"high load (compute saturated)", 0.60}}
const draft = 0.05 // an EAGLE-style head: a few percent of a target step per token
for _, rg := range regimes {
fmt.Printf("%s\n", rg.name)
fmt.Printf(" %-12s", "acceptance")
for _, k := range []int{1, 2, 3, 5, 8} {
fmt.Printf(" k=%d ", k)
}
fmt.Println(" best k")
for _, alpha := range []float64{0.4, 0.6, 0.8, 0.9} {
fmt.Printf(" %-12.1f", alpha)
bestK, best := 0, 1.0
for _, k := range []int{1, 2, 3, 5, 8} {
s := expectedTokens(alpha, k) / stepCost(k, draft, rg.rowCost)
fmt.Printf(" %5.2fx", s)
if s > best {
best, bestK = s, k
}
}
if bestK == 0 {
fmt.Println(" none: slower than baseline")
} else {
fmt.Printf(" %d\n", bestK)
}
}
fmt.Println()
}
}Output:
low load (compute idle)
acceptance k=1 k=2 k=3 k=5 k=8 best k
0.4 1.30x 1.34x 1.31x 1.19x 1.02x 2
0.6 1.48x 1.69x 1.75x 1.70x 1.51x 3
0.8 1.67x 2.10x 2.38x 2.64x 2.64x 8
0.9 1.76x 2.34x 2.77x 3.35x 3.74x 8
high load (compute saturated)
acceptance k=1 k=2 k=3 k=5 k=8 best k
0.4 0.85x 0.68x 0.55x 0.39x 0.27x none: slower than baseline
0.6 0.97x 0.85x 0.74x 0.56x 0.40x none: slower than baseline
0.8 1.09x 1.06x 1.00x 0.87x 0.70x 1
0.9 1.15x 1.18x 1.17x 1.10x 0.99x 2Under low load more drafts pay when acceptance is high. Under high load most cells are below
1.0: the configuration that halved latency at midnight reduces throughput at noon. That table is
the argument for dynamic k and adaptive verification.
7. Performance implications#
- Low load: speedup approaches
E[tokens]divided by the drafting overhead; 1.5x to 3x lower inter-token latency is typical for good drafters. - High load: each request’s
kextra rows displace real work. With lowα, throughput can fall below the baseline. - Parallel drafters (DFlash, DSpark, PARD) cost one drafter pass per step instead of
k, so largerkbecomes affordable; the trade-off is lower per-position acceptance late in the block. - Async scheduling is kept for EAGLE, MTP, draft models,
ngram_gpu, DFlash and DSpark. Plainngramandsuffixturn it off, because their drafts come from the CPU in the engine core. - Memory: draft models need their own weights and KV cache; heads and MTP modules need little.
8. Production implications#
| Metric | Meaning |
|---|---|
vllm:spec_decode_num_drafts | Speculation rounds |
vllm:spec_decode_num_draft_tokens | Tokens proposed |
vllm:spec_decode_num_accepted_tokens | Tokens accepted |
vllm:spec_decode_num_accepted_tokens_per_pos | Acceptance by draft position: shows where drafts stop paying |
- Mean acceptance length is
1 + accepted ÷ draftsand maps directly to speedup. If acceptance at position 4 is 10%, a smallerkcosts less and gains almost as much. Per-request acceptance figures can also be returned in responses. - Interactions: drafts must satisfy structured-output grammars (invalid ones are trimmed with
validate_tokens, 18.e); an accepted run containing end-of-sequence is trimmed after it; a draft model can use a different tensor-parallel size (draft_tensor_parallel_size). - Check which runner you got. P-EAGLE,
suffix,medusaandmlp_speculatorselect the older runner; the log says so. - Benchmark at your real concurrency. A single-user benchmark always looks good.
9. Common mistakes#
- Turning it on for a throughput-bound batch job. At saturation it can lower tokens per second.
- Choosing
kfrom a single-user test. Acceptance per position, at real load, sets the rightk. - Blaming speculative decoding for quality changes. Output is unchanged by design; a difference is a bug or a numerical near-tie.
- Using a drafter trained for a different target (or a different chat template). Acceptance collapses.
- Forgetting the memory of a draft model when sizing the KV cache.
10. Hands-on exercise#
- In the program, model a full draft model by setting
draftto 0.25. How does the bestkchange at acceptance 0.8 under low load? - Find the acceptance rate at which
k = 3breaks even under high load. - On a real server, enable
ngramand send (a) a request to rewrite a long code file with one small change and (b) a request for a poem. Comparespec_decode_num_accepted_tokens. - Run the same model with an EAGLE-3 head and with a DFlash drafter at 1, 16 and 64 concurrent users. Plot inter-token latency and throughput.
11. Interview questions#
- Why does verifying several draft tokens cost much less than generating them one at a time?
- What does the scheduler do to a request’s counters when two of four drafts are rejected?
- Why can speculative decoding reduce throughput on a heavily loaded server, and what does vLLM do about it?
- Why does the scheduler pad a new decode request to
1 + ktokens? - What does a parallel drafter change about the cost of a large
k?
12. Further reading#
Checked on 12 November 2026.
- Speculative decoding (vLLM v0.32.0 docs): methods, the selection table, the config schema
- Adaptive verification
- Dynamic speculative decoding
- Speculators: drafter training for vLLM
vllm/v1/core/sched/scheduler.py: padding, rollback, dynamickvllm/v1/worker/gpu/spec_decode/: MRV2 speculatorsvllm/config/speculative.py:SpeculativeConfig- Fast Inference from Transformers via Speculative Decoding