I/O Complexity of Attention, or How Optimal is FlashAttention?
Barna Saha, Christopher Ye
摘要
Attention is at the heart of the popular Transformer architecture, yet suffers from quadratic time and memory complexity. In a recent significant development, FlashAttention shows that the I/O complexity of attention is the true bottleneck in scaling Transformers. Given two levels of memory hierarchy, a fast cache (e.g. GPU onchip SRAM) where computation happens and a slow memory (e.g. GPU high-bandwidth memory) where the data resides, the I/O complexity measures the number of accesses to the slow memory. FlashAttention is an I/O-aware algorithm for self-attention that requires N 2 d 2 M I/O operations where N is the dimension of the attention matrix, d is the head-dimension and M is the size of cache. Naturally, to further reduce the computational costs of Attention, the authors ask the question: is FlashAttention's I/O complexity optimal for every value of M ? We resolve the above question in its full generality by showing an I/O complexity lower bound that matches the upper bound provided by FlashAttention for any values of M ≥ d 2 within any constant factors. Moreover, our lower bounds do not rely on using combinatorial matrix multiplication for computing the attention matrix: even if one uses fast matrix multiplication, the above I/O complexity bounds cannot be improved. Further, we give a better algorithm with lower I/O complexity for M < d 2 , and show that it is optimal for combinatorial algorithms. We do so by introducing a new communication complexity protocol for matrix compression, and connecting communication complexity to I/O complexity. We believe this connection could be of independent interest and will find more applications in proving I/O complexity lower bounds in future.
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
已有 2 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。
脉络
- Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention 引用了 Reformer: The Efficient Transformer
- On the Computational Hardness of Transformers 引用了 Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention
- On the Computational Hardness of Transformers 引用了 Big Bird: Transformers for Longer Sequences
- On the Computational Hardness of Transformers 引用了 FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
- On the Computational Hardness of Transformers 引用了 Subquadratic Algorithms and Hardness for Attention with Any Temperature
- On the Computational Hardness of Transformers 引用了 Reformer: The Efficient Transformer
- On the Computational Hardness of Transformers 引用了 Language Models are Few-Shot Learners
- Big Bird: Transformers for Longer Sequences 引用了 Reformer: The Efficient Transformer
- FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness 引用了 Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention
- FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness 引用了 Big Bird: Transformers for Longer Sequences
- FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness 引用了 Reformer: The Efficient Transformer
- FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness 引用了 Language Models are Few-Shot Learners
- Subquadratic Algorithms and Hardness for Attention with Any Temperature 引用了 Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention
- Subquadratic Algorithms and Hardness for Attention with Any Temperature 引用了 Big Bird: Transformers for Longer Sequences
- Subquadratic Algorithms and Hardness for Attention with Any Temperature 引用了 Reformer: The Efficient Transformer
- Subquadratic Algorithms and Hardness for Attention with Any Temperature 引用了 Language Models are Few-Shot Learners
引用它的顶会 Paper2
它引用的 Paper17
- Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah 等NeurIPS 2020 · 64,255 次引用
- FlashAttention: Fast and Memory-Efficient Exact Attention with IO-AwarenessTri Dao, Daniel Y. Fu, Stefano Ermon, Atri Rudra 等NeurIPS 2022 · 5,493 次引用
- 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 次引用
- Transformers are RNNs: Fast Autoregressive Transformers with Linear AttentionAngelos Katharopoulos, Apoorv Vyas, Nikolaos Pappas, François FleuretICML 2020 · 2,665 次引用
相关 Paper
- FlashAttention-2: Faster Attention with Better Parallelism and Work PartitioningTri DaoICLR 2024 · 2,600 次引用
- I/O Analysis is All You Need: An I/O Analysis for Long-Sequence AttentionXiaoyang Lu, Boyu Long, Xiaoming Chen, Yinhe Han 等ASPLOS 2026 · 1 次引用
- Fast Attention Over Long Sequences With Dynamic Sparse Flash AttentionMatteo Pagliardini, Daniele Paliotta, Martin Jaggi, François FleuretNeurIPS 2023 · 26 次引用
- FlashAttention-3: Fast and Accurate Attention with Asynchrony and Low-precisionJay Shah, Ganesh Bikshandi, Ying Zhang, Vijay Thakkar 等NeurIPS 2024 · 727 次引用
- ELFATT: Efficient Linear Fast Attention for Vision TransformersChong Wu, Maolin Che, Renjie Xu, Zhuoheng Ran 等ACM MM 2025 · 3 次引用
