Long Context's GPU Memory Drain: KV Cache Overload

The quadratic growth in context length dramatically increases GPU memory requirements, primarily due to the Key-Value (KV) cache. For instance, a 128,000-token context on Llama 3.1-70B can demand approximately 40GB of High Bandwidth Memory (HBM) just for the KV cache, often exceeding the capacity of a single A100 GPU before model weights are even loaded.

The top 3

  1. Top 3 KV Cache Memory Optimization Techniques: PagedAttention, quantization (FP8/INT4), and Grouped-Query Attention (GQA) are leading methods; PagedAttention alone can boost throughput by 2-4x by reducing memory fragmentation from 60-80% to under 4%.
  2. Staggering KV Cache Memory Footprint Records: A 70B parameter model with a 200K token context can consume 40-80GB of GPU memory for KV cache alone, potentially filling an entire 80GB H100 card before model weights are even loaded.
  3. KV Cache's Critical Impact on LLM Throughput: KV cache memory consumption, growing linearly with context length and batch size, is the primary bottleneck for LLM inference, limiting batch sizes and making deployments memory-bandwidth bound rather than compute-bound.

Sources

Open the full topic