Archive/PAPERS

Speculative decoding: faster answers without changing them

A small model drafts, a big model checks several tokens at once, and the output distribution stays exactly the same. How and when it speeds things up.

Speculative decoding: faster answers without changing them

Large language models generate text one token at a time, and each token requires a full pass through the model. For a big model, that pass is slow, not mainly because of arithmetic but because the hardware must read billions of weights from memory for every single token. The GPU spends much of its time waiting.

Speculative decoding exploits that idle capacity. A small, fast model guesses several tokens ahead; the large model checks all the guesses in one pass, keeping the ones it agrees with. When the guesses are good, you get several tokens for roughly the cost of one large-model step. And with the right acceptance rule, the output follows exactly the same probability distribution as the large model alone. This explainer covers how it works, why it is lossless, what determines the speed-up, popular variants and practical limits.

Why generation is slow

Generating a token with a large model involves reading all of its weights from GPU memory. For one sequence at a time, the amount of computation per byte read is low, so throughput is limited by memory bandwidth, not compute. The same reasoning explains why local models run faster when quantized; see how to run an 8B LLM on a laptop.

The key observation: checking several tokens at once costs about the same as generating one, because the weights only need to be read once for the whole batch of positions. If you already had good candidate tokens, the large model could verify them in parallel.

How speculative decoding works

Two papers introduced the technique independently: Leviathan, Kalman and Matias (2023), "Fast Inference from Transformers via Speculative Decoding," and Chen et al. (2023), "Accelerating Large Language Model Decoding with Speculative Sampling."

The loop:

  1. Draft. A small draft model generates *k* tokens, for example 4, one after another. This is fast because the draft model is small.
  2. Verify. The large target model processes the prompt plus all *k* draft tokens in a single forward pass, producing its own probabilities for each position.
  3. Accept or reject. Starting from the first draft token, each is accepted with a probability based on how the target model's probability compares with the draft model's. The first rejected token is replaced by a sample from an adjusted distribution, and the rest of the draft is discarded.
  4. Bonus token. If all *k* drafts are accepted, the target model's pass also yields one more token for free.
  5. Repeat from the new position.
textexample
Prompt: "The capital of France is"
Draft (small model):  " Paris" "." " It" " is"
Target verifies in one pass:
  " Paris"  accept
  "."       accept
  " It"     reject → target samples " The" instead
Result this step: " Paris" "." " The"   (3 tokens for 1 target pass + 4 cheap draft steps)

Why the output does not change

The acceptance rule is a form of rejection sampling. Both papers proved that, with this rule, the final tokens follow exactly the target model's distribution, the same as if the target model had generated every token itself. With greedy decoding, the output is identical token for token (up to floating-point effects).

This is what distinguishes speculative decoding from approaches that trade quality for speed, such as quantization or using a smaller model outright. The large model's outputs stay the same; only the time to produce them changes.

What determines the speed-up

The original papers reported speed-ups of roughly 2× to 3× in their settings without changes to outputs: Leviathan et al. on T5-XXL and Chen et al. on the 70B Chinchilla model, which they reported at roughly 2 to 2.5×. Real-world gains vary with the workload.

Variants

Speculative decoding variants
VariantWhere the draft comes fromTrade-off
Classic draft modelA separate smaller model from the same familyNeeds a compatible tokenizer and a good small model
Medusa (Cai et al., 2024)Extra prediction heads on the target modelNo separate model; heads must be trained
EAGLE (Li et al., 2024)A lightweight head predicting from target featuresOften high acceptance; needs training
Prompt lookup / n-gram draftsCopying spans from the prompt or earlier outputFree drafts; great for editing and summarising
Self-speculativeSkipping layers of the target model to draftNo extra model; acceptance varies

Prompt-lookup decoding is worth highlighting for builders: when the output repeats large parts of the input, as in code edits, document rewriting or extraction, simply proposing tokens copied from the prompt can give large speed-ups with no extra model.

Where you will see it

Choosing a draft model

If you run open models yourself and use the classic approach, the draft model choice decides most of the gain:

Limits and practical advice

It combines with other efficiency techniques: quantization shrinks the weights that must be read, mixture of experts reduces computation per token, and sparse attention lowers the cost of long contexts.

Frequently asked questions

What is speculative decoding?

Speculative decoding is an inference technique in which a fast draft model proposes several tokens and the large target model verifies them in a single pass, accepting those it agrees with. It reduces latency while preserving the target model's output distribution.

Does speculative decoding change the model's output?

No. With the standard acceptance rule, outputs follow exactly the same distribution as the target model alone; with greedy decoding they are identical apart from floating-point effects.

How much faster is speculative decoding?

Published results report around 2 to 3 times faster generation in favourable settings. Actual gains depend on how often the draft is accepted, how cheap the draft is, and how busy the hardware is.

What is a draft model?

A draft model is a smaller, faster model, usually from the same family and sharing the same tokenizer, that proposes candidate tokens for the large model to verify.

JL
WRITTEN BYJonas LindInfrastructure nerd. Runs the local-model lab and the tokens-per-watt spreadsheet.

Keep reading

Liked this? The Sunday Diff has one like it every week.