Why it matters

Understanding latency components shapes serving optimization.

Advertisement

The architecture

Prefill: process input tokens. GEMM-heavy.

Decode: generate one token at a time. GEMV-heavy, memory-bandwidth bound.

LLM latency phasesPrefill (TTFT)GEMM, compute-boundDecode (TPOT)GEMV, memory-boundTrade-offsdifferent optimizationsSpeculative decoding attacks TPOT; prefix caching attacks TTFT
Latency phases.
Advertisement

How it works end to end

Prefill parallelizes tokens; benefits from larger batches.

Decode: 1 token at a time per sequence; batching helps throughput but not latency.

Optimize TTFT: prefix caching, chunked prefill.

Optimize TPOT: speculative decoding, faster hardware.