Lattice
Skip to content

KV cache

The saved attention keys and values from tokens already processed, so the model does not recompute them for every new token.

By Entry last reviewedmethod

What it implies

It is what makes generation incremental rather than quadratic, and its size is the main thing that determines how many concurrent sequences fit on a GPU. It grows with context length and batch size, which is why long contexts and high concurrency compete for the same memory.

Related terms

Rules of thumb

  • A definition is only useful next to the decision it changes. Read the linked layer to see where this term bites.
  • If a vendor's definition differs from this one, ask what it measures. Marketing definitions rarely name a number.
  • Every optimisation spends latency, memory or quality somewhere. Find out which before you turn it on.

Ask an AI about this page

Opens the assistant with this page’s link and a question already filled in.