HyperAttention: Long-context Attention in Near-Linear Time
Insu Han, Rajesh Jayaram, Amin Karbasi, Vahab Mirrokni, David P. Woodruff, Amir Zandieh
摘要
We present an approximate attention mechanism named "HyperAttention" to address the computational challenges posed by the growing complexity of long contexts used in Large Language Models (LLMs). Recent work suggests that in the worst-case scenario, quadratic time is necessary unless the entries of the attention matrix are bounded or the matrix has low stable rank. We introduce two parameters which measure: (1) the max column norm in the normalized attention matrix, and (2) the ratio of row norms in the unnormalized attention matrix after detecting and removing large entries. We use these fine-grained parameters to capture the hardness of the problem. Despite previous lower bounds, we are able to achieve a linear time sampling algorithm even when the matrix has unbounded entries or a large stable rank, provided the above parameters are small. HyperAttention features a modular design that easily accommodates integration of other fast low-level implementations, particularly FlashAttention. Empirically, employing Locality Sensitive Hashing (LSH) to identify large entries, HyperAttention outperforms existing methods, giving significant speed improvements compared to state-of-the-art solutions like FlashAttention. We validate the empirical performance of HyperAttention on a variety of different long-context length datasets. For example, HyperAttention makes the inference time of ChatGLM2 50% faster on 32k context length while perplexity increases from 5.6 to 6.3. On larger context length, e.g., 131k, with causal masking, HyperAttention offers 5-fold speedup on a single attention layer.
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
已有 47 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。
脉络
- Big Bird: Transformers for Longer Sequences 引用了 Reformer: The Efficient Transformer
- The Fine-Grained Complexity of Gradient Computation for Training Large Language Models 引用了 Language Models are Few-Shot Learners
- Informer: Beyond Efficient Transformer for Long Sequence Time-Series Forecasting 引用了 Reformer: The Efficient Transformer
- An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale 引用了 Language Models are Few-Shot Learners
- H2O: Heavy-Hitter Oracle for Efficient Generative Inference of Large Language Models 引用了 Reformer: The Efficient Transformer
- H2O: Heavy-Hitter Oracle for Efficient Generative Inference of Large Language Models 引用了 Language Models are Few-Shot Learners
- NoMAD-Attention: Efficient LLM Inference on CPUs Through Multiply-add-free Attention 引用了 Big Bird: Transformers for Longer Sequences
- NoMAD-Attention: Efficient LLM Inference on CPUs Through Multiply-add-free Attention 引用了 H2O: Heavy-Hitter Oracle for Efficient Generative Inference of Large Language Models
- NoMAD-Attention: Efficient LLM Inference on CPUs Through Multiply-add-free Attention 引用了 Reformer: The Efficient Transformer
- Tensor Product Attention Is All You Need 引用了 H2O: Heavy-Hitter Oracle for Efficient Generative Inference of Large Language Models
- Tensor Product Attention Is All You Need 引用了 Language Models are Few-Shot Learners
- PolySketchFormer: Fast Transformers via Sketching Polynomial Kernels 引用了 Big Bird: Transformers for Longer Sequences
- PolySketchFormer: Fast Transformers via Sketching Polynomial Kernels 引用了 Reformer: The Efficient Transformer
- PolySketchFormer: Fast Transformers via Sketching Polynomial Kernels 引用了 Language Models are Few-Shot Learners
引用它的顶会 Paper47
- H2O: Heavy-Hitter Oracle for Efficient Generative Inference of Large Language ModelsZhenyu Zhang, Ying Sheng, Tianyi Zhou, Tianlong Chen 等NeurIPS 2023 · 1,003 次引用
- Tensor Product Attention Is All You NeedYifan Zhang, Yifeng Liu, Huizhuo Yuan, Zhen Qin 等NeurIPS 2025 · 48 次引用
- The Fine-Grained Complexity of Gradient Computation for Training Large Language ModelsJosh Alman, Zhao SongNeurIPS 2024 · 33 次引用
- PolySketchFormer: Fast Transformers via Sketching Polynomial KernelsPraneeth Kacham, Vahab Mirrokni, Peilin ZhongICML 2024 · 27 次引用
- NoMAD-Attention: Efficient LLM Inference on CPUs Through Multiply-add-free AttentionTianyi Zhang, Jonah Yi, Bowen Yao, Zhaozhuo Xu 等NeurIPS 2024 · 25 次引用
它引用的 Paper17
- Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah 等NeurIPS 2020 · 64,255 次引用
- An Image is Worth 16x16 Words: Transformers for Image Recognition at ScaleAlexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn 等ICLR 2021 · 21,477 次引用
- Informer: Beyond Efficient Transformer for Long Sequence Time-Series ForecastingHaoyi Zhou, Shanghang Zhang, Jieqi Peng, Shuai Zhang 等AAAI 2021 · 7,289 次引用
- Big Bird: Transformers for Longer SequencesManzil Zaheer, Guru Guruganesh, Kumar Avinava Dubey, Joshua Ainslie 等NeurIPS 2020 · 3,159 次引用
- Reformer: The Efficient TransformerNikita Kitaev, Lukasz Kaiser, Anselm LevskayaICLR 2020 · 2,878 次引用
相关 Paper
- Fast Attention Over Long Sequences With Dynamic Sparse Flash AttentionMatteo Pagliardini, Daniele Paliotta, Martin Jaggi, François FleuretNeurIPS 2023 · 26 次引用
- RACE Attention: A Strictly Linear-Time Attention for Long-Sequence TrainingSahil Joshi, Agniva Chowdhury, Amar Kanakamedala, Ekam Singh 等ICLR 2026 · 2 次引用
- Token Sparse Attention: Efficient Long-Context Inference with Interleaved Token SelectionDongwon Jo, Beomseok Kang, Jiwon Song, jae-joon kimICML 2026 · 1 次引用
- FSA: An Alternative Efficient Implementation of Native Sparse Attention KernelRan Yan, Youhe Jiang, Zhuoming Chen, Haohui Mai 等ICLR 2026 · 10 次引用
- SALE : Low-bit Estimation for Efficient Sparse Attention in Long-context LLM PrefillingXiaodong Ji, Hailin Zhang, Fangcheng Fu, Bin CuiICML 2026 · 3 次引用
