Persistent Context: KV Cache Growth in Long Sessions

Unlike single-turn interactions, agentic AI maintains a growing session history, including prior LLM outputs and tool results. This accumulated context, particularly the Key-Value (KV) cache, continuously occupies GPU memory for the entire duration of a multi-step task, leading to sustained and increased utilization.

The top 3

  1. KV Cache Outgrows Model Weights at Long Contexts: For large language models like Llama 3 70B, the KV cache alone can consume over 40GB of GPU memory for a 128K context, frequently exceeding the model's weights and potentially becoming 2.4 times larger at 8 concurrent users.
  2. Top 3 Techniques to Shrink KV Cache Memory: Leading methods to reduce KV cache memory include PagedAttention by vLLM (cutting waste to under 4%), quantization techniques like KVQuant (enabling 2-bit compression for 1M context), and architectural innovations such as Multi-Query Attention (MLA by DeepSeek-V2 reducing cache by 93.3%).
  3. Single-GPU Context Limits Due to KV Cache: Even with powerful hardware like an A100-80GB GPU, KV cache memory demands frequently limit 70B+ parameter models to context lengths below 128K tokens for a single request, necessitating multi-GPU systems or offloading to CPU/NVMe for longer sessions.

Sources

Open the full topic