Zenaique
Glossary · Inference

KV Cache

Also known as: Key-value cache

Cache attention's K and V tensors per layer so each new token doesn't re-process every prior token.

A memory optimization in transformer inference that stores previously computed key-value pairs from self-attention layers, avoiding redundant recomputation during autoregressive token generation.

In practice

The single biggest reason long-context inference is feasible. Expect questions on cache memory math (layers × heads × dim × seqlen × 2) and paged-attention variants.

Comparisons that include KV Cache

Related topics

Practice questions

Questions that mention this term

Related terms