RazorAttention: Efficient KV Cache Compression Through Retrieval Heads
Hanlin Tang, Yang Lin, Jing Lin, Qingsen Han, Danning Ke, Shikuan Hong, Yiwu Yao, Gongyi Wang
摘要
The memory and computational demands of Key-Value (KV) cache present significant challenges for deploying long-context language models. Previous approaches attempt to mitigate this issue by selectively dropping tokens, which irreversibly erases critical information that might be needed for future queries. In this paper, we propose a novel compression technique for KV cache that preserves all token information. Our investigation reveals that: i) Most attention heads primarily focus on the local context; ii) Only a few heads, denoted as retrieval heads, can essentially pay attention to all input tokens. These key observations motivate us to use separate caching strategy for attention heads. Therefore, we propose RazorAttention, a training-free KV cache compression algorithm, which maintains a full cache for these crucial retrieval heads and discards the remote tokens in non-retrieval heads. Furthermore, we introduce a novel mechanism involving a "compensation token" to further recover the information in the dropped tokens. Extensive evaluations across a diverse set of large language models (LLMs) demonstrate that RazorAttention achieves a reduction in KV cache size by over 70% without noticeable impacts on performance. Additionally, RazorAttention is compatible with FlashAttention, rendering it an efficient and plug-and-play solution that enhances LLM inference efficiency without overhead or retraining of the original model.
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
已有 34 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。
脉络
- Efficient Streaming Language Models with Attention Sinks 引用了 Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation
- Efficient Streaming Language Models with Attention Sinks 引用了 SmoothQuant: Accurate and Efficient Post-Training Quantization for Large Language Models
- InfiniPot-V: Memory-Constrained KV Cache Compression for Streaming Video Understanding 引用了 SnapKV: LLM Knows What You are Looking for Before Generation
- Efficient Prompt Compression with Evaluator Heads for Long-Context Transformer Inference 引用了 Efficient Streaming Language Models with Attention Sinks
- Efficient Prompt Compression with Evaluator Heads for Long-Context Transformer Inference 引用了 SnapKV: LLM Knows What You are Looking for Before Generation
- FreeKV: Boosting KV Cache Retrieval for Efficient LLM Inference 引用了 Efficient Streaming Language Models with Attention Sinks
- FreeKV: Boosting KV Cache Retrieval for Efficient LLM Inference 引用了 SnapKV: LLM Knows What You are Looking for Before Generation
- FreeKV: Boosting KV Cache Retrieval for Efficient LLM Inference 引用了 Twilight: Adaptive Attention Sparsity with Hierarchical Top-p Pruning
- SnapKV: LLM Knows What You are Looking for Before Generation 引用了 Efficient Streaming Language Models with Attention Sinks
- Twilight: Adaptive Attention Sparsity with Hierarchical Top-p Pruning 引用了 Efficient Streaming Language Models with Attention Sinks
- Twilight: Adaptive Attention Sparsity with Hierarchical Top-p Pruning 引用了 SnapKV: LLM Knows What You are Looking for Before Generation
- Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Duality 引用了 Efficient Streaming Language Models with Attention Sinks
- Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Duality 引用了 Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation
引用它的顶会 Paper34
- InfiniPot-V: Memory-Constrained KV Cache Compression for Streaming Video UnderstandingMinsoo Kim, Kyuhong Shim, Jungwook Choi, Simyung ChangNeurIPS 2025 · 62 次引用
- Twilight: Adaptive Attention Sparsity with Hierarchical Top- PruningChaofan Lin, Jiaming Tang, Shuo Yang, Hanshuo Wang 等NeurIPS 2025 · 53 次引用
- FreeKV: Boosting KV Cache Retrieval for Efficient LLM InferenceGuangda Liu, Chengwei Li, Zhenyu Ning, Jing Lin 等ICLR 2026 · 17 次引用
- Intrinsic Entropy of Context Length Scaling in LLMsJingzhe Shi, Qinwei Ma, Hongyi Liu, Hang Zhao 等ICLR 2026 · 17 次引用
- Efficient Prompt Compression with Evaluator Heads for Long-Context Transformer InferenceWeizhi Fei, Xueyan Niu, Guoqing Xie, Yingqing Liu 等NeurIPS 2025 · 14 次引用
它引用的 Paper16
- Efficient Streaming Language Models with Attention SinksGuangxuan Xiao, Yuandong Tian, Beidi Chen, Song Han 等ICLR 2024 · 1,714 次引用
- SmoothQuant: Accurate and Efficient Post-Training Quantization for Large Language ModelsGuangxuan Xiao, Ji Lin, Mickaël Seznec, Hao Wu 等ICML 2023 · 1,493 次引用
- Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space DualityTri Dao, Albert GuICML 2024 · 1,407 次引用
- Train Short, Test Long: Attention with Linear Biases Enables Input Length ExtrapolationOfir Press, Noah A. Smith, Mike LewisICLR 2022 · 1,168 次引用
- SnapKV: LLM Knows What You are Looking for Before GenerationYuhong Li, Yingbing Huang, Bowen Yang, Bharat Venkitesh 等NeurIPS 2024 · 1,019 次引用
相关 Paper
- RocketKV: Accelerating Long-Context LLM Inference via Two-Stage KV Cache CompressionPayman Behnam, Yaosheng Fu, Ritchie Zhao, Po-An Tsai 等ICML 2025
- Not All Heads Matter: A Head-Level KV Cache Compression Method with Integrated Retrieval and ReasoningYu Fu, Zefan Cai, Abedelkadir Asi, Wayne Xiong 等ICLR 2025
- Model Tells You What to Discard: Adaptive KV Cache Compression for LLMsSuyu Ge, Yunan Zhang, Liyuan Liu, Minjia Zhang 等ICLR 2024 · 432 次引用
- A Simple and Effective L_2 Norm-Based Strategy for KV Cache CompressionAlessio Devoto, Yu Zhao, Simone Scardapane, Pasquale MinerviniEMNLP 2024 · 3 次引用
- SqueezeAttention: 2D Management of KV-Cache in LLM Inference via Layer-wise Optimal BudgetZihao Wang, Bin Cui, Shaoduo GanICLR 2025
