Learn · Serving & engines

Speculative Decoding: How It Works, What It Costs, and Where It Fits

How speculative decoding speeds up LLM decoding with a draft model, what it does to the KV cache, how to enable it in vLLM, and when it costs throughput.
A man with short brown hair wearing a dark blue long-sleeve shirt against a light gray background.

Matt Tanner

Oct 12, 2026

11 min read

IN THIS GUIDE

Your model’s answer starts on time, then streams at a slow, steady clip while the GPU’s compute sits mostly idle. That’s decode: one forward pass of the full model per token, each spending most of its time reading weights out of memory.

Speculative decoding spends that idle compute. A cheap drafter guesses several tokens ahead, the target model checks them all in one pass, and you keep the ones it agrees with. With exact speculative sampling, the output distribution stays the target model’s, though single runs can differ. The drafter costs GPU memory, adds its own KV state, and pays less as batches grow. This guide covers the draft, verify, and accept loop, vLLM’s methods and setup, and where it sits next to KV cache reuse.

What is speculative decoding?

Speculative decoding is an inference optimization for autoregressive large language models: a cheap draft model, or extra heads, proposes several tokens, and the target model verifies them in a single forward pass. Accepted tokens are kept, and the first rejected one is corrected. With exact speculative sampling, the output stays within the target model’s distribution, within hardware numerics.

Yaniv Leviathan, Matan Kalman and Yossi Matias at Google Research introduced it in Fast Inference from Transformers via Speculative Decoding (2022), reporting 2X-3X acceleration on T5-XXL with identical outputs. Charlie Chen and colleagues at DeepMind arrived at the same idea independently with speculative sampling, measuring a 2-2.5x decoding speedup on the 70-billion-parameter Chinchilla. Google Research says it now speeds up AI Overviews in Search.

Why decode is the slow part of LLM inference

A request runs in two phases of LLM inference: prefill and decode. Decode produces one token per forward pass, repeatedly reading model weights from GPU memory for relatively little arithmetic. Modern accelerators can perform far more operations per byte than that step needs. Memory bandwidth becomes the bottleneck while compute capacity remains available for checking draft tokens.

That spare compute is the budget. Scoring several proposed tokens together can take about as long as generating one token with the target model. Accepted guesses let the request advance without waiting for a separate target pass for each one.

It also sets the limit: drafting starts after prefill, so speculative decoding reduces inter-token latency on suitable workloads. A slow first token needs a different fix.

How speculative decoding works, step by step

The name comes from speculative execution, best known through CPU branch prediction: do the work before you know it’s needed, and discard it if the guess was wrong.

Draft: a cheap model or head proposes K tokens

The drafter can be a smaller model from the same family, a lightweight head on the target, or a lookup over text already in the context. A typical draft contains 3 to 12 tokens, though the useful depth depends on acceptance and drafting cost. Drafting is sequential but cheap; in the original paper’s experiments, a drafter run always cost less than 0.05 of a target run.

Verify: the target scores every draft position in one forward pass

The target runs one forward pass over the draft and produces a probability distribution at every draft position, plus one after the last. Because the prefix is already in the KV cache, only the speculated tokens add compute.

Accept or reject: keep the agreed run, then correct

Going left to right, each draft token is accepted with probability min(1, p_target / p_draft), so a token the target model likes at least as much as the drafter did always stays. At the first rejection, the target model samples a replacement from an adjusted distribution and discards the rest of the draft; if all K survive, it adds a bonus token. Each pass yields between 1 and K+1 tokens, so speculation never needs more target passes than standard autoregressive decoding.

Take the prefix “The cache stores keys and” with a draft of “values”, “for”, “each”, “layer”. The target accepts “values” and “for”, rejects “each” and samples “every” in its place, and “layer” is thrown away: three tokens from one target pass. Four correct guesses would have returned five.

Assuming, as the paper does for simplicity, that each position is accepted independently with probability α, a pass yields (1 - α^(K+1)) / (1 - α) tokens on average. At α = 0.8 and K = 4, that’s about 3.4 tokens per pass, before you subtract drafting time.

One speculative decoding cycle with K=4: the drafter proposes four tokens, the target model verifies them in one forward pass, two are accepted and the target corrects the third
One draft, verify and accept cycle on the worked example above; tokens are illustrative.

Why the output distribution is preserved

The acceptance rule uses rejection sampling to preserve the target model’s distribution across both accepted guesses and corrected tokens. Exact speculative sampling provides that guarantee within hardware numerics. vLLM validates its rejection sampler against the target distribution and tests matching greedy output with and without speculation. The guarantee concerns the distribution, rather than identical text in every run: floating-point effects and batch size can shift probabilities, and vLLM doesn’t guarantee stable logprobs.

Speculative decoding methods: draft models, EAGLE, Medusa, MTP and n-gram

Use the qualitative vLLM ratings in the last column as a starting point for choosing a method. Actual gains depend on the model family, traffic, hardware, and sampling settings, so the ratings don’t replace a workload benchmark.

MethodWhat drafts the tokensExtra model to load?Best fit (vLLM rating, low/high QPS)
Separate draft modelA smaller model from the same familyYes, a full modelHigh/medium gain
EAGLE / EAGLE-3A light head reading the target’s hidden states (EAGLE: second-to-top-layer features; EAGLE-3: fused multi-layer features)A small head checkpointHigh / medium to high; general purpose
Medusa-style headsExtra decoding heads, each predicting a further-out token, verified with tree attentionExtra head weightsNot rated; accepted as medusa in v0.30.0
MTPThe model’s own multi-token prediction modules (DeepSeek and GLM MTP, Gemma 4 assistant checkpoints)No separate draft model (Gemma 4: assistant checkpoint)High/medium to high; needs native MTP
N-gramMatches the latest tokens against earlier text in the requestNoLow to medium/medium; lightweight
Suffix decodingSuffix trees over the prompt and earlier outputs, adaptive draft lengthNo (needs arctic-inference )Low to medium/medium; repetitive output

EAGLE’s authors reported a 2.7x-3.5x latency speedup on LLaMA2-Chat 70B. DeepSeek’s V3 report gives an 85% to 90% acceptance rate for its MTP head’s extra token and 1.8 times the tokens per second. The SuffixDecoding paper reports up to 5.3x on agentic benchmarks such as SWE-Bench. These are model- and setup-specific results.

Medusa-2 fine-tunes the backbone too, so you serve a modified model. A separate draft model needs a matching vocabulary unless you enable vLLM’s use_heterogeneous_vocab, which currently requires greedy draft sampling. In TensorRT-LLM’s draft/target setup, incompatible tokenizers lead to very low acceptance: the drafter does work, but too few of its guesses survive to repay it.

How to use speculative decoding in vLLM

For vLLM speculative decoding, every method goes through one flag, --speculative-config, a JSON object with method, model, and num_speculative_tokens. In v0.30.0, the draft-model configuration looks like this:

vllm serve Qwen/Qwen3-4B-Thinking-2507 \
  --speculative-config '{"method": "draft_model", "model": "Qwen/Qwen3-0.6B", "num_speculative_tokens": 5}'

To drop the second model, change the JSON. {"method": "ngram", "num_speculative_tokens": 4} drafts from text already in the context, and {"method": "mtp", "num_speculative_tokens": 1} uses native MTP heads, where vLLM suggests 1 as the starting depth. Keep the configuration fields separate: tensor_parallel_size isn’t valid here (use draft_tensor_parallel_size), temperature and top_p belong in sampling parameters, and --speculative-model is deprecated.

Speculative decoding in vLLM targets inter-token latency at medium-to-low QPS on memory-bound workloads. Use spec_decode_offline.py or the benchmark CLI to measure acceptance on your traffic before raising num_speculative_tokens: a deeper draft helps only if the additional positions are accepted.

SGLang and TensorRT-LLM both ship EAGLE-3, MTP, draft-model and n-gram options, among others.

When speculative decoding helps, and when it hurts

It pays when decode is limited by memory bandwidth and compute is idle: small batches, latency targets, and predictable output. IBM’s internal production deployment saw 2x on Llama3 8B, Llama2 13B and Granite 7B, and 3x on its Granite 20B code models.

The spare compute shrinks as batches grow. TensorRT-LLM’s fixed-depth speculation targets low batch sizes, where the extra work can reduce latency. IBM saw throughput drop beyond a batch size of 64. The line moves with method and engine: EAGLE-3 reported a 1.38x throughput gain at batch size 64 in SGLang v0.4.4, for LLaMA-Instruct 3.1 8B on one H100 with MT-Bench.

Rejected draft tokens consume compute without advancing the output. In SGLang, the draft tree, CUDA graphs, and verification buffers also consume extra VRAM.

Signal in your workloadWhat it points to
Low concurrency, inter-token latency target missedA model-based drafter (EAGLE, MTP, draft model)
Large batches or high QPSSmaller gains; benchmark at real batch sizes, where vLLM still rates EAGLE and MTP above n-gram
Repetitive output: code edits, agent loops, RL rolloutsSuffix decoding or n-gram
GPU memory already tightNative MTP or n-gram before a separate draft model
Slow first token on long, repeated promptsA prefill problem; speculation won’t fix it

If you’re separating prefill and decode onto different workers, the decode workers’ batch size decides whether speculative decoding pays.

What speculative decoding does to the KV cache

Speculative decoding isn’t free in memory, and it changes how the KV cache gets written.

Two models, two caches

A separate draft model adds attention layers with their own KV state alongside the target’s. In vLLM v0.30.0, those layers are registered with the KV-cache machinery. Native MTP can add state too: DeepSeek-V4-Flash’s MTP head has a separate KV-cache layer, which LMCache stores and retrieves with the target’s cache. Gemma 4 assistant checkpoints are an exception because vLLM lets them share the target model’s KV cache.

Verification runs on the cached prefix

Accepted tokens become the next prefix. The target’s weights and KV cache are read once per draft-verify cycle rather than once per generated token.

Drafts are written before anyone knows whether they’ll survive. In vLLM v0.30.0, the KV cache manager allocates slots for unverified draft tokens, the scheduler rolls the request’s computed-token count back by the number rejected, and only verified tokens are committed to the prefix cache. A rejected guess never becomes a cache hit for the next request.

Avoiding cache duplication

Multi-head and tree drafters can multiply that state if each candidate gets a separate copy. IBM’s implementation avoided per-head KV-cache replication by adapting vLLM’s paged attention kernel, so verifying extra candidates didn’t require duplicating the full cache. In SGLang, --speculative-num-steps, --speculative-eagle-topk and --speculative-num-draft-tokens bound draft tree memory.

Where KV cache reuse fits: the prefill half

Cache reuse addresses repeated prefill work; it doesn’t remove a decode bottleneck. In LMCache’s MiniMax-M2.5 benchmark on AMD MI300X, decode remained the limiting phase at the tested concurrency levels. That makes cache reuse one part of the serving plan, alongside optimizations aimed at generation.

The two compose: in the DeepSeek-V4-Flash recipe, LMCache stores and retrieves the MTP draft-layer KV with the target’s. MTP acceptance was 0.947 on the store run and 0.952 on the retrieve run, and cold-vs-warm time to first token (TTFT) improved 6.6x with MTP on throughout. That’s one model and one validation run (100 gsm8k samples, one MTP draft token, vLLM’s MP connector, TP4), with outputs matching at the score level, not token for token.

Tensormesh Platform is a caching layer, not a serving engine, so speculative decoding stays a vLLM setting. We were founded by the creators of LMCache and build on it, and Tensormesh Platform works on the prefill half: it keeps KV cache available across GPU memory, host memory, and filesystem-backed storage so more requests can reuse it.

A node can retrieve compatible cached work from another node, and state saved outside a pod can be reused after it restarts. It runs with vLLM on Kubernetes, and SGLang support is next. The MTP results above evaluate LMCache rather than Tensormesh Platform.

Where the KV cache sits during speculative decoding: prefill builds a reusable prompt KV cache, while the decode loop keeps target and draft KV side by side with unverified draft slots
Prefill builds the prompt’s KV cache once; decode then holds draft and target KV side by side, and only verified tokens join the cached prefix.

Key takeaways

Speculative decoding buys back decode latency with compute the GPU wasn’t using; acceptance rate and batch size decide how much, and the drafter costs memory. With exact speculative sampling, it keeps the target model’s distribution, not the text of every run, and it does nothing for prefill. Treat it as one of two levers: speculative decoding for inter-token latency, KV cache reuse for prefill and TTFT.

Measure acceptance at your real batch size before you pick a drafter, because a drafter the target keeps overruling only adds work.

Contact our team to discuss KV cache reuse alongside speculative decoding in your vLLM deployment.

Frequently asked questions

  1. What is a draft model in speculative decoding?

    A draft model is the cheap proposer: usually a smaller model from the target’s family, trained to imitate the target’s outputs, that guesses tokens ahead for the target to verify. It must share the target’s vocabulary unless you enable vLLM’s use_heterogeneous_vocab.

  2. What is the acceptance rate in speculative decoding?

    It’s the share of draft tokens the target accepts. At 0.8 per position with four draft tokens, the expected-token formula gives about 3.4 tokens per target pass. It varies by model pair, task, and sampling settings, so measure it on your traffic.

  3. How does n-gram speculative decoding work?

    It drafts without a model. vLLM’s n-gram proposer finds the longest earlier n-gram matching the end of the current text and proposes the tokens that followed it. It pays when the output repeats the prompt, as in edits to pasted code.

  4. Does speculative decoding change the model’s output?

    Not its distribution, with exact speculative sampling. Rejection sampling preserves the target model’s distribution within hardware numerics, and vLLM tests that greedy output matches with and without it. Individual sampled runs can still differ, because logprobs aren’t guaranteed stable.

  5. Does speculative decoding work with prefix caching?

    Yes. vLLM caches only verified tokens, and in LMCache’s DeepSeek-V4-Flash recipe, MTP acceptance held (0.947 vs 0.952) when the prefix KV came from LMCache.

WRITTEN BY

A man with short brown hair wearing a dark blue long-sleeve shirt against a light gray background.

Matt Tanner

Developer Relations

KV cache calculator

Size the cache for your model, context length and batch.

RELATED GUIDES

Continuous Batching: How LLM Servers Keep GPUs Busy, and What Caps the Batch

vLLM vs Ollama: Local Development vs. Production Serving

vLLM’s OpenAI-Compatible Server: What Transfers and What Doesn’t

Disaggregated Serving in LLM Inference, Explained

Put it into practice

Keep KV cache beyond a single request

Tensormesh runs LMCache as a self-hosted layer, so the context your GPUs already processed can be reused across requests and nodes.