Understanding LLM inference: How Prefill and Decode phases impact speed
techNmak · x · 2026-08-12
This post breaks down the underlying mechanics of LLM inference latency by splitting the process into two core phases:
- Prefill Phase: The model tokenizes the input prompt and processes it through transformer layers with heavy parallelization, building the KV cache. The computational work here is the primary contributor to Time To First Token (TTFT). Longer prompts mean more prefill work before generation begins.
- Decode Phase: The model generates new tokens one by one. This is a strictly sequential process (token N depends on token N-1) that reuses and updates the KV cache. The speed of this phase is measured by Tokens Per Second (TPS).
The author notes that beyond input/output lengths, factors like model architecture, memory pressure, hardware bandwidth, and batch size significantly impact inference speed and cost. Thus, when an LLM feels slow, it's crucial to distinguish whether the bottleneck is waiting for the first token (Prefill) or slow subsequent generation (Decode).
Related event: Explaining LLM Inference: How Prefill and Decode Stages Affect Speed(2 posts)→
More from Infra
- Chess Transformer hits 2545 Elo after 260x training speedup — realSharonZhou · 2026-11-30
- Tokens/sec alone is misleading: quantized LLM speed hides quality costs — OrganizationAgile361 · 2026-11-30
- Samsung's new memory chief warns record quarters don't mean competitiveness is back — tengyanAI · 2026-11-30
- Which free local AI model to download for your GPU, from 6GB to 24GB VRAM — alex_verem · 2026-11-30
- tqLLM 1.9.0: C++ LLM engine claims 4.6x Strata on 16GB, adds AMD RX 580 support — pmttyji · 2026-11-30
- oMLX 0.8.4 doubles Inkling 2 Mini decode speed on Mac, adds concurrent MTP — pcuenq · 2026-11-30