# What Is Speculative Decoding?

> How a small draft model guesses ahead while a big model checks, why answers come faster, and where the speed-up stops, for your AI interview.

**In short:** Speculative decoding speeds up a language model by letting a small, fast draft model guess several tokens ahead. The big model checks all the guesses in one pass and keeps the ones it agrees with, so the text comes out faster while the big model still makes the final call.

AI and LLM interview question Q321, Inference, performance and cost. Advanced, common (our estimate). From Venkat R. Murty's free Interview Kit: https://designervenkat.online/interview/ai/what-is-speculative-decoding

## Say it in 30 seconds

I explain speculative decoding as a way to make a language model faster. A big model writes one token at a time, which is slow. So a small, cheap draft model guesses the next few tokens, and the big model checks them all in one pass. It keeps the guesses it accepts and writes a replacement token at the first miss. The big model still makes the final call, so the output has the same odds for each word as before. It helps most when the server has spare room.

## Say it in 2 minutes

A large language model writes its answer one token at a time. Each token needs a full run of the big model, and the runs happen one after another, so a long answer takes a long time. Speculative decoding attacks that wait. A small, cheap draft model runs ahead and guesses the next few tokens quickly.

The big model then checks all of those guesses in one pass. It accepts or rejects each guess, with odds based on how likely it finds that guess. At the first one it rejects, it writes a replacement token and drops the rest. Each pass still gives at least one new token, and a good draft lets several guesses survive. The check is cheap because the limit is usually reading memory, and the maths sits partly idle, so the hardware has spare room.

The big model keeps the final say on every word, so the output has the same odds for each word as the big model alone. The gain depends on the draft. A good draft and a server with spare room give the best speed-up. Under heavy load, or with a weak draft, the gain shrinks, so I measure it on real traffic first.

For example, a claims tool that writes a 300-token summary takes about 9 seconds at made-up speeds, and about 4 seconds with a draft model.

## What is speculative decoding, in plain words?

A language model writes text one token at a time. A token is a word or a part of a word. Each new token needs one full run of the big model, and the runs happen one after another, so long answers are slow.

Speculative decoding guesses ahead. A small, cheap draft model proposes the next few tokens. The big model then checks them together, in one run, and keeps the ones it would have written too.

Think of a senior claims adjuster checking a junior's work. The junior races through the routine lines. The senior reads the whole batch in one go, keeps what is right, and fixes the first line that is wrong. Here is a realistic case: an insurance claims assistant writes a 300-token summary for an agent during a live call, and nine seconds of silence feels stuck.

- **Token:** A word or a part of a word, the unit a model writes.
- **Draft model:** The small, cheap model that guesses ahead.
- **Big model:** The large model that makes the final call on every token.
- **Acceptance rate:** The share of guesses the big model keeps. Higher means a bigger speed-up.

## How does the guess-and-check loop work?

Each round has four moves. Read the chart from left to right.

*Diagram, One round of speculative decoding: Each round, a small draft model guesses four tokens and the big model checks them all in one pass. Guesses it agrees with are kept, and at the first miss it writes its own token. Either way the text grows.*
1. The text so far goes to the draft model.
2. Its four guesses go to the big model together.
3. Guesses the big model accepts are kept.
4. At the first miss, the big model writes a replacement token.
5. The kept guesses join the text.
6. The big model's token joins the text too.

1. **The draft guesses:** A small model proposes the next few tokens. Some tokens are easy to guess, and guessing is cheap, so this costs little time.
2. **The big model checks in one pass:** The big model scores every guessed token together, in a single run.
3. **Keep the accepted guesses:** Guesses the big model accepts stay in the text. A good draft keeps several in a row.
4. **Fix the first miss:** At the first guess the big model rejects, it writes a replacement token and the rest are dropped. If every guess is accepted, it adds one more token of its own.

> **Tip:** The draft is only a helper. A wrong guess only wastes a little work. The answer stays right, because the big model checks every token.

## Why is checking several tokens nearly as cheap as one?

Because the limit is usually memory, not maths. Google's own write-up says the bottleneck (the part that limits speed) in LLM inference (running a model to write its output) is usually memory. It also says the hardware has ample spare computing power while a model generates output. So there is spare room while the big model works through a token, and the extra guesses fit into it.

*Diagram, A 300-token reply, two ways (made-up numbers): The same 300-token reply, with made-up numbers. Writing one token per pass takes about nine seconds. Drafting four tokens and checking them in one pass takes about four seconds, because each round yields three tokens.*
1. Plain: 300 passes at 30 ms each, about 9 seconds.
2. Draft and check: 100 rounds of 42 ms, about 4.2 seconds.

Worked example, with made-up numbers. The big model takes 30 ms per pass, so the plain way needs 300 passes, about 9 seconds. The draft model guesses 4 tokens at 3 ms each, then the big model checks them in one 30 ms pass. On average it keeps 2 guesses and adds one token of its own, so each round gives 3 tokens. That is 100 rounds of 42 ms, about 4.2 seconds: a speed-up of about 2.1 times.

```python
# Made-up numbers for one 300-token reply: the big model takes 30 ms per pass,
# the draft model 3 ms per guess, and each round guesses 4 tokens.
TOKENS = 300
BIG_MS = 30
DRAFT_MS = 3
GUESSES = 4
KEPT = 2  # guesses the big model keeps, on average

normal_ms = TOKENS * BIG_MS
# Each check also gives one token of the big model's own, so a round adds KEPT + 1.
tokens_per_round = KEPT + 1
rounds = TOKENS // tokens_per_round
round_ms = GUESSES * DRAFT_MS + BIG_MS
spec_ms = rounds * round_ms

print(f"Normal: {normal_ms} ms")
print(f"Speculative: {rounds} rounds x {round_ms} ms = {spec_ms} ms")
print(f"Speed-up: {normal_ms / spec_ms:.1f}x")
```

Output:

```text
Normal: 9000 ms
Speculative: 100 rounds x 42 ms = 4200 ms
Speed-up: 2.1x
```

## Does the output stay the same?

In theory, yes. The big model still tests every token, and a guess is only kept when it passes that test, so the output keeps the same odds for each word as the big model alone. The papers say so directly, and so do the people who run it in production.

> "an algorithm to sample from autoregressive models faster without any changes to the outputs, by computing several tokens in parallel." (Leviathan, Kalman and Matias, 2022 paper)
>
> "The algorithm speeds up generation from autoregressive models by computing several tokens in parallel, without affecting output quality; in fact, the method guarantees an identical output distribution." (Google Research, 2024 write-up)
>
> "Speculative decoding sampling is theoretically lossless up to the precision limits of hardware numerics." (vLLM documentation)

The papers also measured the gain on their own test setups. Leviathan and colleagues reported 2X to 3X on T5-XXL, a large research model from Google, with identical outputs. Chen and colleagues reported a 2 to 2.5 times speed-up on Chinchilla, a 70 billion parameter model (a parameter is one of the learned numbers inside a model), without changing the model. Google says it uses the method in AI Overviews in Google Search.

> **Tip:** Say the honest limit. Hardware maths can nudge results slightly, and the vLLM docs say so (vLLM is an open-source server for running models). Say the same odds, up to rounding on the hardware. Do not promise identical text every time.

## Where does it help, and where does it stop?

It helps most when one user waits on a long reply and the hardware has spare room. The vLLM docs describe the aim as lower latency for memory-bound work (work held back by how fast memory can be read) at low to medium request rates. A separate draft model needs its own memory and work, and simpler guessers give only modest gains at peak traffic.

- **Helps: Long replies, spare room.** A user waits on one long answer while the hardware has idle capacity.
- **Weaker: Busy peak traffic.** Many requests share the hardware, so there is less spare room and the gain shrinks.
- **Weaker: Poor guesses.** Free-form writing is hard to guess, so the big model rejects more drafts and the gain falls.

> **Tip:** Measure before you ship. Track the acceptance rate and the time per answer on real traffic. A draft that is rarely kept can cost more time than it saves.

## What does the interviewer want to hear?

**A strong answer covers**

- [ ] A plain definition: a small model guesses, and a big model checks in one pass.
- [ ] Why it is faster: checking several tokens costs about one pass, because memory is the limit.
- [ ] Why the output stays the same: the big model keeps the final say, with a rounding caveat.
- [ ] When it helps: long replies, spare capacity and a draft that often matches.
- [ ] When it doesn't: busy peaks, poor guesses and the extra memory for the draft.
- [ ] A plan to measure acceptance and time per answer on real traffic before rollout.

**Common traps**

- Trap: "The small model writes the answer, and the big one just approves it." Better: The big model decides every token. The draft only proposes, and a wrong guess is thrown away.
- Trap: "It makes the model smaller, so it gets less accurate." Better: Nothing shrinks. The same big model runs, and the draft is a separate helper.
- Trap: "It always makes things faster." Better: Only with spare capacity and good guesses. At peak load and with poor drafts, the gain shrinks.

## Can you spot the mistake?

**Spot the mistake:** A team adds a draft model to its claims summariser. Which plan is sound?

A. Pick any small model, since its guesses are never checked.
B. Measure how often the big model keeps the draft's guesses on real traffic before rollout.
C. Turn it on for all traffic at peak hours, where the speed-up is largest.
D. Expect identical text every time, even with sampling on, because the drafts are fixed.

**Answer:** B. The gain depends on how often guesses are kept, and that depends on real traffic. Peak load and a weak draft both shrink it, so measure first. The other plans ignore the check or expect the wrong thing.

**Quick check:** Your summariser gets no faster at peak hours, even with speculative decoding on. What is the likeliest reason?

A. The draft model writes the final summary.
B. At peak load the hardware is already busy, so the spare room for checking shrinks.
C. The prompt is too short for the draft to read.
D. The server stopped writing request times to its log.

**Answer:** B. The method uses spare capacity while one user waits. When many users share the server, that spare room is gone, so the gain shrinks. The draft never writes the final text, and a missing log line does not slow the model.

## Can you answer these from memory?

**Flash cards**

- **What is speculative decoding?** A small draft model guesses tokens, and the big model checks them in one pass.
- **Who makes the final call?** The big model. It keeps the guesses it accepts and writes a replacement token at the first miss.
- **Why is checking cheap?** Memory reads limit the big model, so checking several tokens costs about one pass.
- **Does the output change?** The odds for each word stay the same, up to rounding in hardware maths.
- **When does it help most?** Long replies with spare capacity, and a draft that the big model often keeps.
- **What is the main cost?** A separate draft model, which uses extra memory and work.

## Likely follow-up questions

- Q316 TTFT vs tokens/sec vs total latency? https://designervenkat.online/interview/ai/ttft-vs-tokens-per-second-vs-latency
- Q317 The latency vs throughput trade-off? https://designervenkat.online/interview/ai/the-latency-vs-throughput-trade-off
- Q320 Serving engines (vLLM, SGLang, TensorRT-LLM, llama.cpp)? https://designervenkat.online/interview/ai/serving-engines-vllm-sglang-tensorrt-llm-llama-cpp
- Q322 What is model routing (cascades)? https://designervenkat.online/interview/ai/what-is-model-routing
- Q327 GPU basics: why does memory bandwidth limit decoding? https://designervenkat.online/interview/ai/gpu-basics-why-does-memory-bandwidth-limit-decoding
