How Inference Works

llmsengineeringResearched October 2026

You hit send, wait a beat, and watch the answer type itself out. That beat is the whole prompt being read at once. The typing is tokens being born one at a time, each one joining the conversation for the next. The sentence to remember: the prompt is processed all at once up front; the answer is generated one token at a time, each new token reading everything that came before.

1. The brief

Inference is what happens when a trained model meets your prompt. Training is the months-long factory run that builds the weights; inference is the everyday job of running those weights to turn request tokens into response tokens. Every chat reply, agent action, and voice call you have ever used runs on this loop, and it has a strange shape: your thousand-token prompt is swallowed in a single parallel gulp, then the answer dribbles out one token per pass. That asymmetry explains the pause before the first word, why replies stream, why long prompts are slow to start but fine once they get going, and why serving models is mostly a memory-management business. This primer walks the loop step by step, with a machine you can run yourself.

2. How it works

Seven mechanisms, each doing one job. Tap each card for the plain-language version, one concrete example, and what changed recently. Then run the token machine below it.

Two-panel diagram: on the left, PREFILL shows six prompt token chips feeding into one large red block labeled 1 forward pass; on the right, DECODE shows a single token chip looping through a small red block labeled 1 pass equals 1 token, with the output row growing token by token.

The whole primer in one picture: prefill reads the entire prompt in one forward pass, decode emits one token per pass and repeats.

Diagram of the KV cache: five token chips in a row, each with a small stacked pair of red cards labeled K and V beneath it inside a box titled KV CACHE, with a dashed unknown token sending reading arrows down into the stored keys and values.

Why the cache exists: every token leaves its keys and values behind, so each new token reads the past instead of recomputing it.

The token machine

Run one real request, click by click. The prompt is "Capital of France?" and the model answers "The capital of France is Paris". The token splits and the sampling odds are illustrative, not measured. One tap per step, or use the arrow keys.

Prompt tokens
KV cache
Answer so far

Illustrative, not measured: the token split, the candidate odds, and the pass counts are a teaching model. The shape of the loop is real.

The speed story in two races

Each race is measured on one rig, so the ball speeds are comparable inside each race only. The motion is the data: a faster ball means a faster machine.

Race 1. Qwen3.8-27B (NVFP4) on two RTX 5090s, vLLM 0.27.0, 60K-token prompt. Prefill swallows 60,000 tokens in 26.4 seconds, about 2,270 tokens per second of effective throughput; decode streams at 80.9 tokens per second. Measured by pavle-scalably, Hugging Face blog, 2026.

Race 2. LLaMA2-Chat 13B on one RTX 3090. Vanilla autoregressive decode at 24 tokens per second against EAGLE speculative decoding at 160 tokens per second. Measured by the EAGLE authors, Jan 2024.

Why long prompts are slow to start

Drag the slider. The wait before the first word grows steeply with prompt length; the stream after it barely moves.

60,000 prompt tokens
Time to first tokenthe prefill wait
Decode ratethe stream after

Illustrative model fit to two measured points on Qwen3.8-27B NVFP4 (two RTX 5090s, vLLM 0.27.0): 60K tokens took 26.4 s to first token, 120K took 62.5 s, while decode held at 81 to 87 tok/s. The curve follows the measured ratio; the point is the shape.

3. The landmarks

Eight moments that built modern serving, 2022 to 2026. One tap per step, or use the arrow keys.

4. Key voices

Five people and teams who built this, measured it, or poked holes in it. The real action is at the bottom, where the last two collide.

5. Where leaders think this goes

Frozen as of October 2026. Every item names its people. The research turned up real agreement on the direction and one named bet on where the decode loop itself is headed.

6. Takeaways

Inference is two machines sharing one box: a parallel reader that swallows your prompt in a single pass, and a serial writer that emits one token per pass, reading everything written so far from the KV cache. The wait before the first word is the reader. The stream after it is the writer. Everything in serving, batching, paging, chunking, speculating, is about keeping the writer fed without letting the reader interrupt it.

Every reply you have ever watched type itself out was this loop: read everything at once, then write one word at a time, rolling the dice on each.

Keep exploring

Sources

Every factual claim in sections 2 through 5 traces to one of these.