What speculative decoding is
Normal decoding runs the full model once per output token. At small batch sizes each pass is limited by reading the weights from memory, so the GPU's compute sits mostly idle. Checking several candidate tokens in one pass costs little more than generating one, because the weights are read once either way.
Leviathan, Kalman and Matias described the method in 2022. A smaller approximation model drafts tokens; the large model verifies them in parallel and accepts or rejects each with a sampling rule that keeps the output distribution unchanged. They reported a 2-3× speedup on T5-XXL with identical outputs and no retraining or architecture change.
vLLM's documentation states that its sampling is theoretically lossless up to the precision limits of hardware numerics, and notes that batch size changes and hardware differences can cause small variations in log probabilities. Relaxed verification modes, which vLLM labels as not distribution-preserving, trade that guarantee for speed.
References: Leviathan, Kalman and Matias, Fast Inference from Transformers via Speculative Decoding · vLLM documentation: Speculative decoding
The math: expected tokens per verification
If each drafted token is accepted with probability α and the drafter proposes k tokens, the expected number of tokens produced per target-model pass is (1 − α^(k+1)) ÷ (1 − α), from the Leviathan paper. The +1 counts the token the target model adds itself after the last accepted draft or at the first rejection.
Worked example: with α = 0.7 and k = 4, the result is (1 − 0.7^5) ÷ 0.3 = (1 − 0.168) ÷ 0.3 ≈ 2.77 tokens per pass. With α = 0.5 it drops to about 1.94. Real speedup is lower than these figures, because drafting and verification take time too. Raising k helps only while acceptance stays high; past that, extra drafts are wasted work.
| Acceptance rate α | k = 2 | k = 4 | k = 8 |
|---|---|---|---|
| 0.5 | 1.75 | 1.94 | 2.00 |
| 0.7 | 2.19 | 2.77 | 3.20 |
| 0.9 | 2.71 | 4.10 | 6.13 |
References: Leviathan, Kalman and Matias, Fast Inference from Transformers via Speculative Decoding
Drafting methods: draft model, EAGLE, MTP and n-gram
The drafter is the main design choice. A separate draft model is the original approach: a small model from the same family and tokenizer. EAGLE drafts at the feature level, predicting the target model's second-to-top-layer features with a light head; its paper reports a 2.7-3.5× latency speedup on LLaMA2-Chat 70B while keeping the output distribution. Multi-token prediction (MTP) uses heads that some models ship with.
N-gram speculation needs no extra model. It looks for the latest tokens earlier in the prompt and proposes what followed. It works well when the output copies from the input, as in code edits, summarization and retrieval answers, and poorly for open-ended text. vLLM groups EAGLE, MTP and draft models as model-based methods with the largest latency reductions, and n-gram and suffix decoding as lightweight methods with modest speedups.
| Method | Extra weights | Best for | Trade-off |
|---|---|---|---|
| Draft model | Small model, same tokenizer | General text when a family model exists | Uses memory and compute for a second model |
| EAGLE / EAGLE-3 | Light head trained for the target | Chat and general generation | Needs a head built for your exact model |
| MTP | Heads shipped with the model | Models released with MTP layers | Only for models that include them |
| N-gram / prompt lookup | None | Code edits, summaries, RAG answers | Low acceptance on novel text |
References: Li et al., EAGLE: Speculative Sampling Requires Rethinking Feature Uncertainty · vLLM documentation: Speculative decoding
Published results
SGLang's documentation includes a benchmark on one H100 with Llama 3.1 8B Instruct on MT-Bench: 158.34 tokens per second without speculation, 244.10 with EAGLE-2 and 373.25 with EAGLE-3. That is about 2.4× for EAGLE-3 in that setup. These are the SGLang project's numbers, not ours, measured at its chosen settings; your gain will depend on the model, the drafter, the prompts and the load.
| SGLang docs benchmark (1× H100, Llama 3.1 8B, MT-Bench) | Throughput |
|---|---|
| No speculation | 158.34 tokens/s |
| EAGLE-2 | 244.10 tokens/s |
| EAGLE-3 | 373.25 tokens/s |
References: SGLang documentation: Speculative decoding
Configure speculative decoding in vLLM, SGLang and llama.cpp
vLLM takes a JSON --speculative-config. For n-gram: {"method": "ngram", "num_speculative_tokens": 4, "prompt_lookup_min": 2, "prompt_lookup_max": 5}. For a draft model: {"method": "draft_model", "model": "<draft>", "num_speculative_tokens": 5}. EAGLE-3 uses "method": "eagle3" with "model" pointing at a head trained for your target.
SGLang uses --speculative-algorithm with EAGLE, EAGLE3, NEXTN, STANDALONE, NGRAM and newer options. Its EAGLE-3 example sets --speculative-draft-model-path, --speculative-num-steps 3, --speculative-eagle-topk 4 and --speculative-num-draft-tokens 16. Its docs list NGRAM as CUDA-only.
In llama.cpp's server, -md (--model-draft) loads a draft model and -ngld sets how many of its layers go on the GPU. --spec-type selects methods such as draft-simple, draft-eagle3, draft-mtp and several n-gram variants, and --spec-draft-n-max replaces the removed --draft-max flag. Flags here change often, so check the README for your build.
| Engine | Switch | N-gram | Model-based |
|---|---|---|---|
| vLLM | --speculative-config JSON | "method": "ngram" | "draft_model", "eagle3", MTP |
| SGLang | --speculative-algorithm | NGRAM (CUDA only) | EAGLE, EAGLE3, NEXTN, STANDALONE |
| llama.cpp | --spec-type, -md | ngram-simple, ngram-mod and others | draft-simple, draft-eagle3, draft-mtp |
References: vLLM documentation: Speculative decoding · SGLang documentation: Server arguments · SGLang documentation: Speculative decoding · llama.cpp server README
How it changes cost per token
vLLM's docs say the method mainly reduces inter-token latency at medium-to-low request rates in memory-bound workloads. At high load the GPU is already busy with large batches, so spare compute for verification shrinks and gains fade. That makes it best suited to latency-sensitive services that cannot fill big batches.
An illustrative example with assumed numbers: a single-tenant assistant on one GPU at an assumed $2 per hour serves 8 concurrent users at an assumed 400 aggregate output tokens per second, or $1.39 per million tokens. If speculation raises that to an assumed 720 tokens per second at the same load, cost falls to $0.77 per million and each user sees faster streaming. On a GPU already saturated by batching, expect little change. Measure with your own traffic using benchmark LLM inference.
| Setup (illustrative) | Assumed output tokens/s | Tokens per hour | Cost per million at $2/h |
|---|---|---|---|
| 8 users, no speculation | 400 | 1.44 million | $1.39 |
| 8 users, with speculation | 720 | 2.59 million | $0.77 |
References: vLLM documentation: Speculative decoding
Common misconceptions
It does not make the model smarter or change its answers under standard verification. It does not cut time to first token, since prefill is unchanged. It is not free: the drafter takes memory that the KV cache could otherwise use. And a high acceptance rate on one dataset may not carry over to yours, so measure acceptance on real prompts before turning it on in production.
References: vLLM documentation: Speculative decoding
Related terms
Tokens per second per user is the number this method improves. Continuous batching competes for the same spare compute. Quantization is another way to speed up memory-bound decode and can be combined with speculation.
Checklist and next step
Measure baseline inter-token latency at your real load. Pick a drafter: n-gram for copy-heavy outputs, EAGLE-3 or a draft model for open text. Start with 3 to 5 draft tokens. Compare latency, aggregate throughput and acceptance with and without it. Keep it only where the gain holds at peak traffic.
Then size the hardware. NeuraMesh rents GPUs by the hour: choose a GPU, a plan, GPU count, hours and region on rent GPUs, and you receive a confirmed quotation, typically within one business day, with nothing charged until you approve. The compute advisor can help pick a card.
NeuraMesh prices for these GPUs
| GPU | Memory | Data center | Value |
|---|---|---|---|
| RTX 4090 | 24 GB | $0.46 | $0.40 |
| L40S | 48 GB | $1.26 | $0.54 |
| A100 | 80 GB | $1.56 | $0.98 |
| H100 | 80 GB | $2.88 | $2.00 |
Every order is confirmed in a quotation before you pay. See all GPU prices.
Questions readers ask
Does speculative decoding change model output?
With the standard rejection sampler, no: the output distribution matches normal decoding, up to the precision limits of the hardware. Relaxed verification modes, which some engines offer, trade that guarantee for speed and should be labelled as lossy.
When does it not help?
At high request rates where the GPU is already compute-bound from large batches, and on text the drafter predicts poorly. In those cases verification overhead can cancel the gain or make things slower.
What is a good draft model?
A much smaller model from the same family that shares the target's tokenizer. Purpose-built EAGLE heads for popular models often reach higher acceptance than a generic small model.
Does llama.cpp support speculative decoding?
Yes. The llama.cpp server can load a draft model with -md and select methods with --spec-type, including draft-model, EAGLE-3, MTP and n-gram variants. The flag names have changed across releases, so read the server README for the build you run.
How many draft tokens should I use?
Start around 3 to 5 and tune. More draft tokens only help while acceptance stays high; at an acceptance rate of 0.5, going from 4 to 8 drafts adds almost nothing.
Sources and editorial notes
- Leviathan, Kalman and Matias, Fast Inference from Transformers via Speculative Decoding
- vLLM documentation: Speculative decoding
- Li et al., EAGLE: Speculative Sampling Requires Rethinking Feature Uncertainty
- SGLang documentation: Speculative decoding
- SGLang documentation: Server arguments
- llama.cpp server README
Primary documentation reviewed November 24, 2026. Provider descriptions reflect published documentation. Recommendations are our analysis; worked figures are illustrative unless explicitly stated otherwise. No independent provider benchmark or uptime ranking is claimed.
Need this GPU? Rent it from NeuraMesh: choose a GPU and plan, get a confirmed quotation, and pay only when you approve. See pricing.
