The I/O Complexity of Attention, or How Optimal is Flash Attention?
Not on the map. Why?
Abstract (arXiv)
Self-attention is at the heart of the popular Transformer architecture, yet suffers from quadratic time and memory complexity. The breakthrough FlashAttention algorithm revealed I/O complexity as the true bottleneck in scaling Transformers. Given two levels of memory hierarchy, a fast cache (e.g. GPU on-chip SRAM) and a slow memory (e.g. GPU high-bandwidth memory), the I/O complexity measures the number of accesses to memory. FlashAttention computes attention using fracN2d2M I/O operations where N is the dimension of the attention matrix, d the head-dimension and M the cache size. However, is this I/O complexity optimal? The known lower bound only rules out an I/O complexity of o(Nd) when M=Theta(Nd), since the output that needs to be written to slow memory is Omega(Nd). This leads to the main question of our work: Is FlashAttention I/O optimal for all values 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 ≥ d2 within any constant factors. Further, we give a better algorithm with lower I/O complexity for M < d2, and show that it is optimal as well. Moreover, our lower bounds do not rely on using combinatorial matrix multiplication for computing the attention matrix. We show even if one uses fast matrix multiplication, the above I/O complexity bounds cannot be improved. We do so by introducing a new communication complexity protocol for matrix compression, and connecting communication complexity to I/O complexity. To the best of our knowledge, this is the first work to establish a connection between communication complexity and I/O complexity, and we believe this connection could be of independent interest and will find many more applications in proving I/O complexity lower bounds in the future.
Key facts. Cited by 6 papers in the map (data through 7 Oct 2026). Builds on 26 of its 35 references that are in the map. First posted on arXiv 12 Feb 2024.
Builds on
26 of 35 references.
References · 26
- 2017Attention Is All You Needcited by 59,932
- 2020Language Models are Few-Shot Learnerscited by 32,199
- 2022FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awarenesscited by 3,611
- 2023FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioningcited by 2,551
- 2020Transformers are RNNs: Fast Autoregressive Transformers with Linear Attentioncited by 1,979
- 2020Big Bird: Transformers for Longer Sequencescited by 1,673
- 2021Scatterbrain: Unifying Sparse and Low-rank Attention Approximationcited by 128
- 2023Fast Attention Requires Bounded Entriescited by 102
- 2023HyperAttention: Long-context Attention in Near-Linear Timecited by 85
- 2023New Bounds for Matrix Multiplication: from Alpha to Omegacited by 34
- 2016Fast Learning Requires Good Memory: A Time-Space Lower Bound for Parity Learningcited by 32
- 2019Memory-Sample Tradeoffs for Linear Regression with Small Errorcited by 22
14 more
- 2022Memory Bounds for the Experts Problemcited by 20
- 2022Memory Bounds for Continual Learningcited by 18
- 2022Online Prediction in Sub-linear Spacecited by 16
- 2023Near Optimal Memory-Regret Tradeoff for Online Learningcited by 15
- 2019Space lower bounds for linear prediction in the streaming modelcited by 14
- 2022Efficient Convex Optimization Requires Superlinear Memorycited by 14
- 2017Improved Rectangular Matrix Multiplication using Powers of the Coppersmith-Winograd Tensorcited by 13
- 2017On Communication Complexity of Classification Problemscited by 11
- 2020Towards a combinatorial characterization of bounded memory learningcited by 9
- 2019Open Problem: The Oracle Complexity of Convex Optimization with Limited Memorycited by 8
- 2023Memory-Query Tradeoffs for Randomized Convex Optimizationcited by 4
- 2013The Input/Output Complexity of Triangle Enumerationcited by 1
- 2014The Input/Output Complexity of Sparse Matrix Multiplicationcited by 1
- 2016The I/O complexity of Strassen's matrix multiplication with recomputationcited by 1
Built on by
Citing papers per year: 2024: 4; 2025: 1; 2026: 1.
6 papers.
- 2024A Tighter Complexity Analysis of SparseGPTcited by 19
- 2024Debiasing Watermarks for Large Language Models via Maximal Couplingcited by 18
- 2025Compression Barriers for Autoregressive Transformerscited by 5
- 2024Model Agnostic Hybrid Sharding For Heterogeneous Distributed Inferencecited by 2
- 2024kNN Attention Demystified: A Theoretical Exploration for Scalable Transformerscited by 0
- 2026FlashBoB: I/O-Efficient Exact Backward-over-Backward for Softmax Attentioncited by 0
- 2026FlashBoB: I/O-Efficient Exact Backward-over-Backward for Softmax Attention21 Sep 2026
- 2025Compression Barriers for Autoregressive Transformers21 Feb 2025
- 2024Debiasing Watermarks for Large Language Models via Maximal Coupling17 Nov 2024
- 2024kNN Attention Demystified: A Theoretical Exploration for Scalable Transformers6 Nov 2024
- 2024A Tighter Complexity Analysis of SparseGPT22 Aug 2024
- 2024Model Agnostic Hybrid Sharding For Heterogeneous Distributed Inference29 Jul 2024