RUNLOCALAIv38
->Will it run?Best GPUCompareTroubleshootStartLearnPulseModelsHardwareToolsBench
Run check
RUNLOCALAI

Independently operated catalog for local-AI hardware and software. Hand-written verdicts. Source-cited claims. Reproducible commands when we have them.

OP·Fredoline Eruo
DIR
  • Models
  • Hardware
  • Tools
  • Benchmarks
TOOLS
  • Will it run?
  • Compare hardware
  • Cost vs cloud
  • Choose my GPU
  • Prompting kits
  • Quick answers
REF
  • All buyer guides
  • Learn local AI
  • Methodology
  • Glossary
  • Errors KB
  • Trust
EDITOR
  • About
  • Author
  • How we make money
  • Editorial policy
  • Contact
LEGAL
  • Privacy
  • Terms
  • Sitemap
MAIL · MONTHLY DIGEST
Get monthly local AI changes
Monthly recap. No spam.
DISCLOSURE

Some links on this site are affiliate links (Amazon Associates and other first-class retailers). When you buy through them, we earn a small commission at no extra cost to you. Affiliate links do not influence our verdicts — there are cards we rate highly that we don't have affiliate relationships with, and cards that sell well that we refuse to recommend. Read more →

© 2026 runlocalai.coIndependently operated
RUNLOCALAI · v38
Glossary / Transformer & LLM components / KV Cache
Transformer & LLM components

KV Cache

The KV cache stores the key and value tensors from previous attention computations so the model doesn't recompute them at every generated token. Without it, generation speed would be O(n²); with it, each new token is roughly O(n).

The catch: KV cache memory scales linearly with context length. The formula is 2 × num_layers × num_kv_heads × head_dim × context_length × bytes_per_element. For Llama 3.3 70B at FP16, every 1K tokens of context costs about 320 MB of VRAM.

Modern models use Grouped-Query Attention (GQA), where num_kv_heads << num_attention_heads, dramatically reducing cache size. Llama 3.1 8B has 32 attention heads but only 8 KV heads — a 4× cache reduction over old MHA architectures. Quantized KV cache (FP8 or INT4) halves or quarters this further.

Related terms

Context WindowFlash AttentionGrouped-Query Attention (GQA)
Buyer guides
  • Best GPU for local AI →
  • Best laptop for local AI →
  • Best Mac for local AI →
When it doesn't work
  • CUDA out of memory →
  • Ollama running slowly →
  • ROCm not detected →