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 by optimizing the Key-Value (KV) cache across both the sequence (token) and layer dimensions. By dynamically reallocating cache budgets from less critical attention layers to more important ones on-the-fly, it achieves 30% to 70% memory reductions and up to a 2.2× throughput boost without sacrificing model accuracy.

What Problem Does This Paper Address?

During LLM inference, the Key-Value (KV) cache stores intermediate attention states to avoid redundant computations during autoregressive token generation. However, this cache grows linearly with sequence length, batch size, and the number of layers, quickly becoming a massive memory bottleneck that dominates I/O costs.

While many state-of-the-art methods (like H2O, StreamingLLM, or Sliding Window Attention) compress the KV cache by dropping "unimportant" tokens along the sequence dimension, they treat all transformer layers equally. Every layer gets the exact same cache budget. This is highly suboptimal because different attention layers contribute unequally to the final output; some layers are highly sensitive to context, while others are relatively redundant.

Methods

SqueezeAttention addresses this gap by introducing 2D KV-cache management, optimizing both sequence-wise token retention and layer-wise budget allocation.

The algorithm operates in three main steps during the prompt prefilling phase:

  1. Importance Measurement: It calculates the cosine similarity of the hidden states immediately before and after each self-attention layer. A higher cosine similarity indicates that the layer changed the embedding very little, meaning it contributes less new information.
  2. Layer Clustering: Using K-Means, it clusters the layers into three groups based on their average cosine similarity. Group 1 contains highly critical layers (typically the first and last few layers), while Group 3 contains the least important layers (often representing 50% to 70% of the total layers).
  3. Budget Reallocation: It reduces the cache budget of the unimportant layers using a hyperparameter $p$ and reallocates or optimizes the remaining budget for the critical layers.

Crucially, SqueezeAttention is orthogonal to existing sequence-wise eviction algorithms. Once the layer-wise budgets are set, standard sequence-wise algorithms (like H2O or Sliding Window) compress each layer using its newly customized budget.

Figure 1: Demonstrations of KV-cache policies in inference from the view of the sequence and at- tention layer. Full Cache (leftmost column) simply stores the KV embeddings for all the tokens in all the layers. Sequence-wise compression algorithms (middle column) drop tokens in the sequence’s dimension, where each layer has the same cache budget. SQUEEZEATTENTION (rightmost column) further compresses the KV-cache by adaptively re-allocating the cache budgets in the layer’s dimen- sion.

Datasets

The authors evaluated SqueezeAttention across 5 diverse datasets spanning various context lengths and tasks:

  • CNN/Daily Mail & XSUM: Text summarization tasks (average length ~2k tokens).
  • SAMSUM: Few-shot chat/dialogue summarization (average length ~6k tokens).
  • TriviaQA: Few-shot question answering (average length ~8k tokens).
  • NarrativeQA: Single-document QA (average length ~18k tokens).

Key Insights and Ideas

  • Layer-Wise Asymmetry: The first half of an LLM's attention layers generally contributes significantly more to the output embeddings than the second half. Additionally, the very first and very last few layers are almost always critical to maintaining model accuracy.
  • The "One-Time Price" Advantage: Measuring layer importance and clustering via K-Means happens exclusively during the prefilling phase. Because it does not add overhead during the iterative decoding phase, it is computationally cheaper than token-eviction methods that require recalculations at every single token step.
  • Multiplicative Efficiency: Because layer-wise budget allocation is orthogonal to token-wise sparsification, combining them creates a compounding effect, squeezing out significantly more memory savings than token-eviction alone.

Key Results

The authors integrated SqueezeAttention into 7 popular LLMs (ranging from 7B to 70B parameters, including Mistral-7B, Llama2-7B/70B, and Mixtral-8×7B).

  • Memory Savings: SqueezeAttention achieved 30% to 70% overall memory reductions. Per-token decoding memory usage dropped by 70% to 80% compared to a full cache, and by 25% to 66% compared to baseline sequence-wise algorithms alone.
  • Throughput Improvements: Token generation throughput increased by up to 2.2× for Mistral-7B and 1.4× for Llama2-70B compared to using a full cache.
  • Increased Batch Sizes: By drastically lowering the memory footprint, SqueezeAttention allowed serving much larger batch sizes (e.g., up to 224 for Mistral-7B) that would otherwise trigger Out-Of-Memory (OOM) errors.
  • Minimal Overhead: The profiling phase only introduced a minor 6.3% increase in prefilling time, which becomes negligible when factored into the total time spent during long decoding sequences.

Limitations and Future Work

SqueezeAttention relies on the prerequisite that a reliable sequence-wise sparsification policy already exists for a given model and dataset. If the underlying sequence-wise algorithm fails to maintain accuracy under a certain token budget, SqueezeAttention's layer-wise adjustments may not perform as expected.

Additionally, the authors noted slight task-specific fluctuations in layer importance, suggesting that some layers are task-sensitive. A promising direction for future work includes a deeper analysis of these task-sensitive layers to make the budget allocation even more adaptive.

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