Learn AI Math

Prefill

Also called: Prefill Phase

What is Prefill?

In one sentence: Prefill is the first step of answering, where the model reads your whole prompt at once and builds its memory of it.

During prefill, all input tokens are processed in parallel, which keeps the GPU very busy. The model stores what it learned about each token in the KV cache. Long prompts mean longer prefill, which is why big documents make the first word take longer to appear.

What does Prefill look like?

Pasting a 50-page report makes prefill take longer before the chatbot starts typing.

Why does Prefill matter?

Prefill sets how long you wait before the first token appears.

Prefill vs. Decode

Prefill digests your entire input prompt in parallel (compute-bound) to produce the first token; decode generates the reply one token at a time (memory-bandwidth-bound).

DimensionPrefillDecode
Processing styleAll prompt tokens processed in parallelSequential—1 output token per step
Hardware bottleneckGPU compute (TFLOPS)VRAM memory bandwidth (GB/s)
User metricTime to First Token (TTFT)Time Per Output Token (TPOT) / TPS

Last updated · Fact-checked by The AI Math

Linking to this page from a lesson or article?

Like this explanation? Get one every week.

The AI Math newsletter turns confusing AI news into plain English. No hype, no jargon walls.