DuoAttention: Efficient Long-Context LLM Inference with Retrieval and Streaming Heads
Guangxuan Xiao, Jiaming Tang, Jingwei Zuo, Junxian Guo, Shang Yang,, Haotian Tang, Yao Fu, Song Han

TL;DR
DuoAttention introduces a novel approach to long-context LLM inference by selectively applying full attention to critical retrieval heads and lightweight attention to streaming heads, significantly reducing memory and latency without sacrificing performance.
Contribution
The paper proposes DuoAttention, a framework that distinguishes attention heads to optimize long-context inference efficiency and introduces an algorithm to identify these heads accurately.
Findings
Reduces long-context inference memory by up to 2.55x.
Speeds up decoding by up to 2.18x.
Enables 3.3 million token context length with a single GPU.
Abstract
Deploying long-context large language models (LLMs) is essential but poses significant computational and memory challenges. Caching all Key and Value (KV) states across all attention heads consumes substantial memory. Existing KV cache pruning methods either damage the long-context capabilities of LLMs or offer only limited efficiency improvements. In this paper, we identify that only a fraction of attention heads, a.k.a, Retrieval Heads, are critical for processing long contexts and require full attention across all tokens. In contrast, all other heads, which primarily focus on recent tokens and attention sinks--referred to as Streaming Heads--do not require full attention. Based on this insight, we introduce DuoAttention, a framework that only applies a full KV cache to retrieval heads while using a light-weight, constant-length KV cache for streaming heads, which reduces both LLM's…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Code & Models
Videos
DuoAttention Demo: Running LLMs with 3.3 Million Contextual Tokens on a Single A100 GPU· youtube
Taxonomy
TopicsTime Series Analysis and Forecasting · Data Stream Mining Techniques · Neural Networks and Applications
MethodsSoftmax · Attention Is All You Need · Focus · Pruning
