Key-Value Cache (KVCache)

A saved copy of an AI model's calculations for past tokens so it doesn't redo all that work each time it generates a new word.

Technically: During autoregressive decoding, attention keys and values for all previously processed tokens are stored in a per-layer cache, so each new token runs attention with its own query against the cached K/V rather than recomputing everything. This makes each decoding step linear rather than quadratic in sequence length. The cache grows with sequence length and batch size and is the dominant inference VRAM constraint, motivating GQA, MLA, paged attention, and quantized KV caches.

Category: Attention Mechanisms

Related ideas