Prefill is the first phase of Transformer inference: the model processes all prompt tokens in parallel and populates the key–value (KV) cache. No tokens are generated yet. Autoregressive decoding then uses that cached attention state to produce tokens without recomputing attention over the entire prompt at each step. section 4.3.1
The KV cache consumes memory, but reduces repeated computation during decoding. Prefill also contributes to end-to-end latency: a practical estimate adds prefill time to the time spent generating tokens. section 4.3.1 section 4.3.3
Figure 4.1 The (Q × KT) × V computation process with caching
The attention-computation diagram illustrates where caching fits into the process. section 4.3.1
Estimating prompt-processing time
For GPT-Neo on a T4 GPU, a 300-token prompt has an estimated prefill time of about 50 ms. Add this to the estimated per-token decoding time to approximate total generation time. section 4.3.3
