NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

SqueezeAttention: 2D Management of KV-Cache in LLM Inference via Layer-wise Optimal Budget

Zihao Wang, Bin Cui, Shaoduo Gan

TL;DR

SqueezeAttention introduces a novel "2D" management strategy for Large Language Model (LLM) inference that optimizes the Key-Value (KV) cache across both the sequence and layer dimensions. By identifying which attention layers are less critical to the final output and reallocating their memory budget to more important ones, it achieves 30% to 70% memory reduction and up to 2.2× throughput improvements without sacrificing model accuracy.

The KV-Cache Bottleneck

As LLMs handle increasingly long contexts, the KV-cache—the memory used to store intermediate attention states—becomes a massive bottleneck. In many scenarios, the KV-cache can grow to be several times larger than the model weights themselves, leading to prohibitive memory costs and sluggish inference speeds.

Existing solutions primarily focus on the sequence dimension. They identify "unimportant" tokens and evict them from the cache, keeping only the most recent tokens (Sliding Window) or those with high attention scores (e.g., Heavy Hitter Oracle or H2O). However, these methods treat every layer in the transformer architecture as equally important, assigning them all the identical memory budget.

The authors argue this "one-size-fits-all" approach is suboptimal. Because some layers contribute significantly more to the final representation than others, allocating the same budget across all layers wastes valuable memory on insensitive layers while starving critical ones.

The SqueezeAttention Method

SqueezeAttention solves this by introducing a 2D optimization approach. Rather than replacing existing token-eviction algorithms, it acts as a budget manager that works on top of them, optimizing allocation layer-by-layer.

Comparison of 1D KV-cache management (Sliding Window, H2O) versus 2D SqueezeAttention.

The framework operates in four main steps:

  1. Measuring Layer Importance: During the "prefilling" phase (when the model processes the initial prompt), the algorithm calculates the cosine similarity between the hidden states before and after each self-attention layer. A high similarity score suggests the layer didn't alter the representation much, implying it is less "important" for that specific input.
  2. Dynamic Budget Allocation: Based on these similarity scores, the algorithm categorizes layers into two primary groups (important and unimportant) to adjust their KV budgets accordingly.
  3. The "Squeeze": It takes a portion of the cache budget away from the unimportant layers and redistributes it to the important layers, optimizing the overall memory footprint.
  4. Integration: Once the per-layer budgets are established, SqueezeAttention applies standard sequence-wise algorithms (like H2O or Sliding Window) to manage the tokens within those specific, customized budgets.

Key Insights

  • Layer Importance is Not Uniform: The authors observed that the first half of a model's layers generally contribute more to the output embedding than the second half. Furthermore, the very first and very last layers are almost always critical.
  • 2D Outperforms 1D: By optimizing across layers and sequences, models achieve better accuracy with a smaller total memory footprint. Giving important layers more budget stabilizes the model's performance.
  • Orthogonality and Compatibility: SqueezeAttention is "plug-and-play." Because it focuses on budget allocation rather than the specific eviction logic, it can be combined with almost any existing KV-cache compression technique.
  • Negligible Overhead: The importance calculation and clustering happen only once during the prefilling phase. This adds a tiny one-time cost but pays off significantly during the much longer, memory-bound token generation phase.

Results and Performance

The authors evaluated SqueezeAttention across a diverse set of tasks (summarization, few-shot learning, long-document QA) and popular models (Llama2, Mistral, Falcon, OPT, Mixtral).

  • Memory Savings: Achieved a 30% to 70% reduction in KV-cache memory usage compared to standard models.
  • Throughput Gains: Improved token generation speed by up to 2.2× for Mistral-7B and 1.4× for Llama2-70B.
  • Accuracy Preservation: In many benchmarks, SqueezeAttention achieved the same or better accuracy than sequence-only baselines while using significantly less memory. Remarkably, it could match "Full Cache" performance using only 20% of the total budget by allocating that budget intelligently.

Limitations and Future Work

While highly effective, SqueezeAttention relies on an underlying sequence-wise eviction policy; if that base policy is a poor fit for the task, the benefits of layer-wise reallocation may be diminished. Additionally, the hyperparameter controlling how much budget to "squeeze" requires careful tuning, though 0.3–0.4 generally serves as a sweet spot. Future work may explore even more granular, real-time budget adjustments during the decoding phase to handle task-specific fluctuations.

Summary updated

BibTeX
@inproceedings{wang2025squeezeattention,
  author = {Zihao Wang and Bin CUI and Shaoduo Gan},
  title = {{SqueezeAttention: 2D Management of KV-Cache in LLM Inference via Layer-wise Optimal Budget}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=9HK2rHNAhd},
}
Figure