Lune

ICLR2026Top-tier venue

Subquadratic Algorithms and Hardness for Attention with Any Temperature

Shreya Gupta, Boyang Huang, Barna Saha, Yinzhan Xu, Christopher Ye

Abstract

Despite the popularity of the Transformer architecture, the standard algorithm for computing Attention suffers from quadratic time complexity in context length nn. Alman and Song showed that when the head dimension d=Θ(log⁡n)d = \Theta(\log n), subquadratic Attention is possible if and only if the inputs have small entries bounded by B=o(log⁡n)B = o(\sqrt{\log n}) in absolute values, under the Strong Exponential Time Hypothesis (SETH\mathsf{SETH}). Equivalently, subquadratic Attention is possible if and only if the softmax is applied with high temperature for d=Θ(log⁡n)d=\Theta(\log n). Running times of these algorithms depend exponentially on BB and thus they do not lead to even a polynomial-time algorithm outside the specific range of BB.

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 BB? In this work, we resolve this question and characterize when fast Attention for arbitrary temperatures is possible. First, for all constant d=O(1)d = O(1), we give the first subquadratic O~(n2−1/d⋅polylog(B))\tilde{O}(n^{2 - 1/d} \cdot \mathrm{polylog}(B)) time algorithm for Attention with large BB. Our result holds even for matrices with large head dimension if they have low rank. Combined with a reduction from Gradient Computation to Attention, we obtain a subquadratic algorithm 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=2Θ(log⁡∗n)d = 2^{\Theta(\log^* n)}, Attention requires n2−o(1)n^{2 - o(1)} time under SETH\mathsf{SETH}.

Finally, in the regime where d=poly(n)d = \mathrm{poly}(n), the standard algorithm requires O(n2d)O(n^{2} d) time while previous lower bounds only ruled out algorithms with truly subquadratic time in nn. We close this gap and show that the standard algorithm is optimal under popular fine-grained complexity assumptions.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

1 top-tier paper has cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention cites Reformer: The Efficient Transformer
  • On the Computational Hardness of Transformers cites Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention
  • On the Computational Hardness of Transformers cites Big Bird: Transformers for Longer Sequences
  • On the Computational Hardness of Transformers cites Reformer: The Efficient Transformer
  • On the Computational Hardness of Transformers cites Language Models are Few-Shot Learners
  • Big Bird: Transformers for Longer Sequences cites Reformer: The Efficient Transformer
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers1

  1. On the Computational Hardness of TransformersBarna Saha, Yinzhan Xu, Christopher Ye, Hantao YuSTOC 2026

Builds on24

  1. Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah et al.NeurIPS 2020 · 64,255 citations
  2. A Simple Framework for Contrastive Learning of Visual RepresentationsTing Chen, Simon Kornblith, Mohammad Norouzi, Geoffrey E. HintonICML 2020 · 24,064 citations
  3. Big Bird: Transformers for Longer SequencesManzil Zaheer, Guru Guruganesh, Kumar Avinava Dubey, Joshua Ainslie et al.NeurIPS 2020 · 3,159 citations
  4. Reformer: The Efficient TransformerNikita Kitaev, Lukasz Kaiser, Anselm LevskayaICLR 2020 · 2,878 citations
  5. Transformers are RNNs: Fast Autoregressive Transformers with Linear AttentionAngelos Katharopoulos, Apoorv Vyas, Nikolaos Pappas, François FleuretICML 2020 · 2,665 citations

Related papers

  1. Fast Attention Requires Bounded EntriesJosh Alman, Zhao SongNeurIPS 2023 · 115 citations
  2. The Fine-Grained Complexity of Gradient Computation for Training Large Language ModelsJosh Alman, Zhao SongNeurIPS 2024 · 33 citations
  3. How to Capture Higher-order Correlations? Generalizing Matrix Softmax Attention to Kronecker ComputationJosh Alman, Zhao SongICLR 2024 · 53 citations
  4. Improved Algorithms for Kernel Matrix-Vector Multiplication Under Sparsity AssumptionsPiotr Indyk, Michael Kapralov, Kshiteej Sheth, Tal WagnerICLR 2025
  5. HyperAttention: Long-context Attention in Near-Linear TimeInsu Han, Rajesh Jayaram, Amin Karbasi, Vahab Mirrokni et al.ICLR 2024 · 104 citations
Dusk over the sea between two cliffs drawn in fine vertical lines