Skip to the document
Madhuopen lab
Outcome School · Inference and serving33 min read

by Amit Shekhar · 5 July 2026

Prefill vs Decode: LLM Inference Optimization

Prefill vs Decode, the two phases of LLM inference, and how understanding them helps us optimize the speed of an LLM. We will also see how the prefill and decode phases work, how the KV cache connects them, how they differ and when to use which one based on our use case, and how we optimize each phase to make an LLM faster.

6,465 words#llm#ai#system-design4 recall cards

Prefill vs Decode: LLM Inference Optimization
Read on Outcome School ↗then come back to lock it in
Before you read, guess

How does the prefill phase process the prompt and generate the initial output?

Ten seconds, a guess, then read — a wrong guess still makes the answer stick.

Before you go

In one sentence, what was this chapter about?

From memory, without scrolling up. Writing it is what makes it yours; the grade is only to show you what you had.

How sure?