# Prefill

- **Canonical URL:** https://getaimath.com/dictionary/prefill/
- **Topics:** [LLM Inference: Prefill & Decode](https://getaimath.com/dictionary/category/llm-inference-prefill-and-decode/)
- **Also called:** Prefill Phase
- **Last updated:** 2026-11-25

## 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.

![How an AI Replies: 1. Read Your Question → 2. Type the Answer — Simple two-step cartoon: Step 1 (Prefill) shows the AI scanning your entire question in one flash (causing the brief pause before it starts talking); Step 2 (Decode) shows it typing out the reply one word at a time.](https://getaimath.com/diagrams/llm-inference-prefill-and-decode.png)
*Napkin Diagram (LLM Inference: Prefill & Decode): Every AI reply has two halves: gulping down your whole prompt at once, then speaking the answer one word at a time.*

## What is an example of Prefill?

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).

| Dimension | Prefill | [Decode](https://getaimath.com/dictionary/decode/) |
| --- | --- | --- |
| Processing style | All prompt tokens processed in parallel | Sequential—1 output token per step |
| Hardware bottleneck | GPU compute (TFLOPS) | VRAM memory bandwidth (GB/s) |
| User metric | Time to First Token (TTFT) | Time Per Output Token (TPOT) / TPS |

## Related Concepts

- [Inference Pipeline](https://getaimath.com/dictionary/inference-pipeline/): An inference pipeline is the full chain of steps from receiving a request to returning the model's answer.
- [Decode](https://getaimath.com/dictionary/decode/): Decode is the second step of answering, where the model writes its reply one token at a time.
- [Inference Engine](https://getaimath.com/dictionary/inference-engine/): An inference engine is software built to run trained AI models quickly and efficiently.
- [Time to First Token (TTFT)](https://getaimath.com/dictionary/time-to-first-token-ttft/): Time to First Token is how long you wait between sending a request and seeing the first token of the answer.
- [Inference](https://getaimath.com/dictionary/inference/): Inference is when a trained AI model is actually used to give answers, instead of still learning.
- [Time Per Output Token (TPOT)](https://getaimath.com/dictionary/time-per-output-token-tpot/): Time Per Output Token is the average time it takes to generate each new token after the first one.

---
Source: The AI Math Dictionary (https://getaimath.com/dictionary/prefill/)
