paper-with-me

홈 › Papers

RazorAttention: Efficient KV Cache Compression Through Retrieval Heads

2024-07-22 · Hanlin Tang, Yang Lin, Jing Lin, Qingsen Han, 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.

📄 PDF Abstract BibTeX arXiv:2407.15891

Code (0)

등록된 구현이 없습니다.

Tasks

Retrieval

Methods 이 논문이 사용한 방법론

Softmax The Softmax output function transforms a previous layer's output into a vector of probabilities. It is commonly used for multiclass classification. Given an input vector $x$…
Attention 설명 없음
SET Dynamic Sparse Training method where weight mask is updated randomly periodically
Focus 설명 없음

Similar Papers 제목 키워드 기반

HeteroCache: A Dynamic Retrieval Approach to Heterogeneous KV Cache Compression for Long-Context LLM Inference

2026-01-20 · Zhiyuan Shi, Qibo Qiu, Feng Xue, Zhonglin Jiang 외 arxiv

The linear memory growth of the KV cache poses a significant bottleneck for LLM inference in long-context tasks. Existing static compression methods often fail to preserve globally important information. Although recent …

Not All Heads Matter: A Head-Level KV Cache Compression Method with Integrated Retrieval and Reasoning

2024-10-25 · Yu Fu, Zefan Cai, Abedelkadir Asi, Wayne Xiong 외

Key-Value (KV) caching is a common technique to enhance the computational efficiency of Large Language Models (LLMs), but its memory overhead grows rapidly with input length. Prior work has shown that not all tokens are …

AllComputational EfficiencyQuestion AnsweringText Generation

HybridKV: Hybrid KV Cache Compression for Efficient Multimodal Large Language Model Inference

2026-04-07 · Bowen Zeng, Feiyang Ren, Jun Zhang, Xiaoling Gu 외 arxiv

Multimodal Large Language Models (MLLMs) have advanced unified reasoning over text, images, and videos, but their inference is hindered by the rapid growth of key-value (KV) caches. Each visual input expands into thousan…

Which Heads Matter for Reasoning? RL-Guided KV Cache Compression

2025-10-09 · Wenjie Du, Li Jiang, Keda Tao, Xue Liu 외 arxiv

Reasoning large language models exhibit complex reasoning behaviors via extended chain-of-thought generation that are highly fragile to information loss during decoding, creating critical challenges for KV cache compress…

Reinforcement Learning

UNComp: Uncertainty-Aware Long-Context Compressor for Efficient Large Language Model Inference

2024-10-04 · Jing Xiong, Jianghan Shen, Fanghua Ye, Chaofan Tao 외

Deploying large language models (LLMs) is challenging due to their high memory and computational demands, especially during long-context inference. While key-value (KV) caching accelerates inference by reusing previously…

Language ModelingLanguage ModellingLarge Language Model