Squeezed Attention: Accelerating Long Context Length LLM Inference
Coleman Richard Charles Hooper, Sehoon Kim, Hiva Mohammadzadeh, Monishwaran Maheswaran, Sebastian Zhao, June Paik, Michael W. Mahoney, Kurt Keutzer, Amir Gholami
Abstract
Emerging Large Language Model (LLM) applications require long input context in order to perform complex tasks like document analysis and code generation. For these long context length applications, the length of the input prompt poses a significant challenge in terms of inference efficiency since the inference costs increase linearly with sequence length. However, for many of these applications, much of the context in the prompt is fixed across different user inputs, thereby providing the opportunity to perform offline optimizations in order to process user inputs quickly, as they are received. We propose Squeezed Attention to accelerate LLM applications where a large portion of the input context is fixed. We first leverage K-means clustering offline to group the keys for the fixed context based on semantic similarity and represent each cluster with a single centroid value. During inference, we compare query tokens from the user input with the centroids to predict which keys from the fixed context are semantically relevant, and then compute exact attention using only the important keys, thereby reducing bandwidth and computational costs. We also present a hierarchical version of our algorithm which can reduce the complexity of attention from linear to logarithmic with respect to the fixed context length. We evaluate our method on various long-context benchmarks including LongBench, where it achieves a 3.1× reduction in KV budget with no noticeable accuracy loss and up to an 8× reduction with only a 0.5 point accuracy gap for the LLaMA-2-7B-32K, LWM-Text-Chat-1M, and Longchat-7B-v1.5-32K models. Futhermore, we implement kernels for centroid comparison and sparse FlashAttention with important keys, achieving more than 4× speedups during both the prefill and generation phases for long-context inference. Our code is available at https://github.com/ SqueezeAILab/SqueezedAttention . Le ve l 2 Cl us te rs Le ve l 1 Cl us te rs Ke ys Query Key
Ask Lune
Know this paper in minutes, not an afternoon.
Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.
20 top-tier papers have cited it since. Know what they found before your reviewers do.
Lune can draw on
the full paper · the top-tier papers that cite it · related work
Free to start. No credit card required.
Lineage
- InfiniPot-V: Memory-Constrained KV Cache Compression for Streaming Video Understanding cites FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning
- InfiniPot-V: Memory-Constrained KV Cache Compression for Streaming Video Understanding cites Model Tells You What to Discard: Adaptive KV Cache Compression for LLMs
- Big Bird: Transformers for Longer Sequences cites Compressive Transformers for Long-Range Sequence Modelling
- KVQuant: Towards 10 Million Context Length LLM Inference with KV Cache Quantization cites Model Tells You What to Discard: Adaptive KV Cache Compression for LLMs
- Multipole Attention for Efficient Long Context Reasoning cites KVQuant: Towards 10 Million Context Length LLM Inference with KV Cache Quantization
- Multipole Attention for Efficient Long Context Reasoning cites FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning
- Multipole Attention for Efficient Long Context Reasoning cites RetrievalAttention: Accelerating Long-Context LLM Inference via Vector Retrieval
- FreeKV: Boosting KV Cache Retrieval for Efficient LLM Inference cites FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning
- FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning cites Big Bird: Transformers for Longer Sequences
- RetrievalAttention: Accelerating Long-Context LLM Inference via Vector Retrieval cites Big Bird: Transformers for Longer Sequences
- RetrievalAttention: Accelerating Long-Context LLM Inference via Vector Retrieval cites Model Tells You What to Discard: Adaptive KV Cache Compression for LLMs
- Sparse Attention Adaptation for Long Reasoning cites Big Bird: Transformers for Longer Sequences
- Sparse Attention Adaptation for Long Reasoning cites FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning
- Sparse Attention Adaptation for Long Reasoning cites Model Tells You What to Discard: Adaptive KV Cache Compression for LLMs
- Sparse Attention Adaptation for Long Reasoning cites RetrievalAttention: Accelerating Long-Context LLM Inference via Vector Retrieval
Cited by top-tier papers20
- RetrievalAttention: Accelerating Long-Context LLM Inference via Vector RetrievalDi Liu, Meng Chen, Baotong Lu, Huiqiang Jiang et al.NeurIPS 2025 · 148 citations
- InfiniPot-V: Memory-Constrained KV Cache Compression for Streaming Video UnderstandingMinsoo Kim, Kyuhong Shim, Jungwook Choi, Simyung ChangNeurIPS 2025 · 62 citations
- FreeKV: Boosting KV Cache Retrieval for Efficient LLM InferenceGuangda Liu, Chengwei Li, Zhenyu Ning, Jing Lin et al.ICLR 2026 · 17 citations
- Sparse Attention Adaptation for Long ReasoningYizhao Gao, Shuming Guo, Shijie Cao, Yuqing Xia et al.ICLR 2026 · 17 citations
- Multipole Attention for Efficient Long Context ReasoningColeman Hooper, Sebastian Zhao, Luca Manolache, Sehoon Kim et al.NeurIPS 2025 · 14 citations
Builds on15
- Big Bird: Transformers for Longer SequencesManzil Zaheer, Guru Guruganesh, Kumar Avinava Dubey, Joshua Ainslie et al.NeurIPS 2020 · 3,159 citations
- FlashAttention-2: Faster Attention with Better Parallelism and Work PartitioningTri DaoICLR 2024 · 2,600 citations
- Compressive Transformers for Long-Range Sequence ModellingJack W. Rae, Anna Potapenko, Siddhant M. Jayakumar, Chloe Hillier et al.ICLR 2020 · 833 citations
- KVQuant: Towards 10 Million Context Length LLM Inference with KV Cache QuantizationColeman Hooper, Sehoon Kim, Hiva Mohammadzadeh, Michael W. Mahoney et al.NeurIPS 2024 · 738 citations
- Model Tells You What to Discard: Adaptive KV Cache Compression for LLMsSuyu Ge, Yunan Zhang, Liyuan Liu, Minjia Zhang et al.ICLR 2024 · 432 citations
Related papers
- ClusterAttn: KV Cache Compression under Intrinsic Attention ClusteringMinwei Zhang, Haifeng Sun, Jingyu Wang, Shaolong Li et al.ACL 2025 · 5 citations
- SALE : Low-bit Estimation for Efficient Sparse Attention in Long-context LLM PrefillingXiaodong Ji, Hailin Zhang, Fangcheng Fu, Bin CuiICML 2026 · 3 citations
- SqueezeAttention: 2D Management of KV-Cache in LLM Inference via Layer-wise Optimal BudgetZihao Wang, Bin Cui, Shaoduo GanICLR 2025
- LongLoRA: Efficient Fine-tuning of Long-Context Large Language ModelsYukang Chen, Shengju Qian, Haotian Tang, Xin Lai et al.ICLR 2024 · 254 citations
- SCBench: A KV Cache-Centric Analysis of Long-Context MethodsYucheng Li, Huiqiang Jiang, Qianhui Wu, Xufang Luo et al.ICLR 2025
