KV Cache
Stored key/value representations of prior tokens used during autoregressive transformer decoding so each new token can attend to the previous context without recomputing every prior layer from scratch.
Key points
- During decode, the new token runs through the model weights and attends to internal representations of previous tokens; those stored representations are the KV cache [src-042].
- KV-cache access is mostly a memory-bandwidth problem rather than a matrix-multiply problem [src-042].
- Unlike model weights, KV cache is unique to each sequence, so it cannot be amortized across a larger batch in the same way [src-042].
- Long context raises serving cost because every decode step may need to fetch more KV-cache bytes from memory [src-042].
- Keeping KV cache in memory saves compute, while deleting and rematerializing it saves storage at the cost of another forward pass [src-042].
Related concepts
- Prefill vs Decode
- KV Cache Tiering
- Memory Wall for Long Context
- Prompt Caching for Agents
- Claude Code Context Management Discipline
Source references
- [src-042] Dwarkesh Patel — “How GPT, Claude, and Gemini are actually trained and served – Reiner Pope” (2026-04-29)
Recommended next
Keep reading from this thread
From 491 indexed pages and articles.
- Wiki concept LLM Inference Economics The cost and latency structure of serving large language models, driven by compute throughput, memory bandwidth, batch size, context length, KV-cache storage, and Related by cache
- Wiki concept Scale-Up vs Scale-Out Networking Distinction between fast intra-rack accelerator communication and slower inter-rack or data-center communication in AI clusters. Readers have engaged with this next
- Insight AI Measurement and Experimentation How to measure AI product impact with evals, adoption metrics, online experiments, guardrails, and cost tracking Related by value