{
  "schema_version": "1.8.0",
  "rubric_version": "1.2",
  "license": "CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)",
  "record": {
    "id": "K-0026",
    "slug": "kv-cache",
    "title": "KV cache",
    "aliases": [
      "key-value cache",
      "key value cache",
      "KV-cache"
    ],
    "status": "published",
    "last_reviewed": "2026-10-27",
    "review_interval_days": 90,
    "steward": null,
    "provenance": {
      "drafted_by": "ai",
      "reviewed_by": [
        "codex-review"
      ]
    },
    "risk_flags": [],
    "flags": [],
    "one_liner": "Stored attention keys and values from earlier tokens, reused during text generation instead of recomputing them.",
    "sources": [
      {
        "source": "S-0076",
        "supports": "cached attention keys and values; per-request state distinct from static model weights; dependence on tokens and positions; memory use and shared prefixes",
        "locator": "§1; §2.2; §3; §4.4 'Shared prefix'"
      }
    ],
    "related": [
      "K-0025",
      "K-0009"
    ],
    "type": "concept",
    "url": "https://trustbutveri.fyi/concepts/kv-cache/",
    "source_file": "content/concepts/kv-cache.md",
    "flags_all": [],
    "body_markdown": "A key-value (KV) cache stores the attention keys and values computed for earlier tokens in a sequence. During text generation, a Transformer reuses these cached keys and values to produce the next token instead of recomputing them [[S-0076]].\n\nThe cache is working state derived from the sequence, distinct from the model's learned weights. Its values depend on the tokens and their positions, and its memory use can grow with the prompt and generated output [[S-0076]]. The [vLLM serving system](https://doi.org/10.1145/3600006.3613165) can share cached prefixes across requests [[S-0076]].",
    "body_text": "A key-value (KV) cache stores the attention keys and values computed for earlier tokens in a sequence. During text generation, a Transformer reuses these cached keys and values to produce the next token instead of recomputing them [S-0076]. The cache is working state derived from the sequence, distinct from the model's learned weights. Its values depend on the tokens and their positions, and its memory use can grow with the prompt and generated output [S-0076]. The vLLM serving system can share cached prefixes across requests [S-0076].",
    "referenced_by": [
      {
        "id": "I-0001",
        "title": "TOPLOC",
        "url": "https://trustbutveri.fyi/implementations/toploc/"
      }
    ]
  }
}