What is KV cache?

Memory in LLM inference holding the attention keys and values of already processed tokens. It avoids recomputation but grows with context length and batch size.

Field: AI Hardware & Software Stack

KV cache in the explanations

Questions that mention KV cache (4)

  1. What is the role of the KV cache in LLM inference?
  2. If a 7-billion-parameter (7B) model's weights are held in FP16 (2 bytes), roughly how much memory do the weights take?
  3. What is a drawback of making the inference batch size too large?
  4. When LLM inference handles long contexts or large batches, what tends to become a problem?

Related terms

Batch size Throughput AI compiler AI inference All-reduce Arithmetic intensity Attention mechanism Backpropagation Computational graph Data parallelism

Back to the glossary