« All posts

AI Inference Engineering: Inside the Prefill-Decode Split

A technical look at how LLM inference splits into compute-bound prefill and memory-bound decode phases, and the optimization techniques engineers use to scale them.

Every LLM response involves two sequential operations on the same GPU: a compute-bound prefill phase that processes the prompt and emits the first token, and a memory-bandwidth-bound decode phase that generates subsequent tokens one at a time. Because these phases have opposite bottlenecks, techniques that speed up one often do little for the other — a structural split that underlies the entire discipline of inference engineering.

What was once a niche practiced inside frontier AI labs has become a broad specialty as open models like DeepSeek V3 closed the gap with closed APIs. With Hugging Face's open model count growing roughly 25x in five years, companies now weigh self-hosting against paid APIs, gaining tunable latency, four-nines uptime, and cost reductions of around 80 percent at scale.

The piece walks through core optimization techniques through the prefill-decode lens: batching improves GPU throughput by serving many requests concurrently at the cost of per-user latency, while prefix caching reuses KV cache values across requests sharing a prompt prefix to cut prefill cost. For engineers running production AI systems, understanding this split is the starting point for choosing the right optimization strategy.