Subquadratic Algorithms and Hardness for Attention with Any Temperature
Not on the map. Why?
Abstract (arXiv)
Despite the popularity of the Transformer architecture, the standard algorithm for computing Attention suffers from quadratic time complexity in context length n. Alman and Song [NeurIPS 2023] showed that when the head dimension d = Theta(log n), subquadratic Attention is possible if and only if the inputs have small entries bounded by B = o(√log n) in absolute values, under the Strong Exponential Time Hypothesis (mathsfSETH). Equivalently, subquadratic Attention is possible if and only if the softmax is applied with high temperature for d=Theta(log n). Running times of these algorithms depend exponentially on B and thus they do not lead to even a polynomial-time algorithm outside the specific range of B. This naturally leads to the question: when can Attention be computed efficiently without strong assumptions on temperature? Are there fast attention algorithms that scale polylogarithmically with entry size B? In this work, we resolve this question and characterize when fast Attention for arbitrary temperatures is possible. First, for all constant d = O(1), we give the first subquadratic tildeO(n2 - 1/d · polylog(B)) time algorithm for Attention with large B. Our result holds even for matrices with large head dimension if they have low rank. In this regime, we also give a similar running time for Attention gradient computation, and therefore for the full LLM training process. Furthermore, we show that any substantial improvement on our algorithm is unlikely. In particular, we show that even when d = 2Theta(log^* n), Attention requires n2 - o(1) time under mathsfSETH. Finally, in the regime where d = poly(n), we show that the standard algorithm is optimal under popular fine-grained complexity assumptions.
Key facts. Cited by 5 papers in the map (data through 14 Oct 2026). Builds on 37 of its 55 references that are in the map. First posted on arXiv 20 May 2025.
Builds on
37 of 55 references.
References · 37
- 2017Attention Is All You Needcited by 60,361
- 2020Language Models are Few-Shot Learnerscited by 32,419
- 2020A Simple Framework for Contrastive Learning of Visual Representationscited by 12,049
- 2020Transformers are RNNs: Fast Autoregressive Transformers with Linear Attentioncited by 2,022
- 2020Big Bird: Transformers for Longer Sequencescited by 1,684
- 2020Understanding Contrastive Representation Learning through Alignment and Uniformity on the Hyperspherecited by 1,405
- 2020Understanding the Behaviour of Contrastive Losscited by 398
- 2023Fine-Tuning Language Models with Just Forward Passescited by 345
- 2022On The Computational Complexity of Self-Attentioncited by 139
- 2023Representational Strengths and Limitations of Transformerscited by 133
- 2021Can contrastive learning avoid shortcut solutions?cited by 114
- 2023Fast Attention Requires Bounded Entriescited by 102
25 more
- 2020AdCo: Adversarial Contrast for Efficient Learning of Unsupervised Representations from Self-Trained Negative Adversariescited by 90
- 2023HyperAttention: Long-context Attention in Near-Linear Timecited by 85
- 2024Transformers, parallel computation, and logarithmic depthcited by 79
- 2024Understanding Transformer Reasoning Capabilities via Graph Algorithmscited by 67
- 2023KDEformer: Accelerating Transformers via Kernel Density Estimationcited by 58
- 2023Temperature Schedules for Self-Supervised Contrastive Methods on Long-Tail Datacited by 44
- 2023Algorithm and Hardness for Dynamic Attention Maintenance in Large Language Modelscited by 37
- 2023PolySketchFormer: Fast Transformers via Sketching Polynomial Kernelscited by 36
- 2020Temperature check: theory and practice for training models with softmax-cross-entropy lossescited by 31
- 2023A Fast Optimization View: Reformulating Single Layer Attention in LLM Based on Tensor and SVM Trick, and Solving It in Matrix Multiplication Timecited by 30
- 2024More Asymmetry Yields Faster Matrix Multiplicationcited by 27
- 2023Differentially Private Attention Computationcited by 25
- 2023Solving Attention Kernel Regression Problem via Pre-conditionercited by 20
- 2022Optimal-Degree Polynomial Approximations for Exponentials and Gaussian Kernel Density Estimationcited by 19
- 2014Edit Distance Cannot Be Computed in Strongly Subquadratic Time (unless SETH is false)cited by 18
- 2023Beyond Classical Attention: Quantum Attention for Scalable Computationcited by 18
- 2023Trainable Transformer in Transformercited by 17
- 2018On The Hardness of Approximate and Exact (Bichromatic) Maximum Inner Productcited by 12
- 2025Depth-Width tradeoffs in Algorithmic Reasoning of Graph Tasks with Transformerscited by 11
- 2024Fundamental Limitations on Subquadratic Alternatives to Transformerscited by 9
- 2025Exploring the Impact of Temperature Scaling in Softmax for Classification and Adversarial Robustnesscited by 9
- 2023Dynamically Scaled Temperature in Self-Supervised Contrastive Learningcited by 4
- 2013Faster all-pairs shortest paths via circuit complexitycited by 2
- 2024Finer-Grained Hardness of Kernel Density Estimationcited by 2
- 2021Approximation Algorithms for Min-Distance Problems in DAGscited by 1
Built on by
Citing papers per year: 2025: 2; 2026: 3.
5 papers.
- 2025Only Large Weights (And Not Skip Connections) Can Prevent the Perils of Rank Collapsecited by 7
- 2025Minimalist Softmax Attention Provably Learns Constrained Boolean Functionscited by 4
- 2026Towards Tight Bounds for Streaming Attentioncited by 2
- 2026On the Computational Hardness of Transformerscited by 0
- 2026Efficiently Approximating Attention Is Hardcited by 0
- 2026Efficiently Approximating Attention Is Hard29 Sep 2026
- 2026Towards Tight Bounds for Streaming Attention5 Jun 2026
- 2026On the Computational Hardness of Transformers11 Mar 2026
- 2025Minimalist Softmax Attention Provably Learns Constrained Boolean Functions26 May 2025
- 2025Only Large Weights (And Not Skip Connections) Can Prevent the Perils of Rank Collapse22 May 2025