at autoregressive decode time every new token must attend to all history, so past K/V are cached to avoid recomputation: cache size
=2⋅2⋅L⋅H⋅d⋅s⋅b (2 bytes per fp16 element × K and V × layers × heads × head dim × seq len × batch); LLaMA-3 70B at
s=8192,
b=32 needs about 687GB — far exceeding its 140GB of weights — and about 86GB with GQA (8 groups). Management techniques: PagedAttention (vLLM) manages the cache via page tables in 16-token blocks to remove fragmentation; StreamingLLM uses attention sinks plus a rolling window; PD separation runs prefill and decode on separate instances.