The KV Cache: Memory Usage in Transformers
3-Second Blueprint (English)
- During autoregressive decoding, the KV cache stores past Key and Value vectors in GPU memory to avoid recomputing earlier tokens.
- Only self-attention interacts across tokens, so caching K and V keeps per-token compute constant as sequence length grows.
- KV cache size scales with layers and byte precision, explaining why prompt prefill has higher latency than next-token generation.
KV CacheSelf-AttentionAutoregressive DecodingGPU Memory ScalingPrefill vs Decode Latency
3-Sekunden-Fazit (Deutsch)
- Beim autoregressiven Decoding speichert der KV-Cache frühere Key- und Value-Vektoren im GPU-Speicher gegen Neuberechnung.
- Nur die Self-Attention verknüpft Token untereinander; gecachte K- und V-Matrizen halten die Rechenlast pro neuem Token konstant.
- Der Speicherbedarf wächst mit Layern und Byte-Präzision, und Prompt-Prefill hat höhere Latenz als nachfolgende Einzel-Token.
KV-CacheSelf-AttentionAutoregressives DecodingGPU-SpeicherbedarfPrefill- vs. Decode-Latenz
Note / Hinweis: Blueprints are AI-generated educational summaries (0% Politics · 0% Religion · 0% Brainrot) and do not constitute medical, legal, or financial advice. / KI-generierte Zusammenfassung zu Bildungszwecken – ersetzt keine medizinische, rechtliche oder finanzielle Fachberatung.