cs.DSNov 4, 2026

Softmax Attention with Any Temperature in Fixed Dimension: Matching the Best Known Maximum-Inner-Product Bounds

Authors: Zixuan Huang, Guozhang Chen

Organizations: State Key Laboratory of Multimedia Information Processing, School of Computer Science, Peking University, Beijing, China · School of Physics, Peking University, Beijing, China · National Engineering Research Center of Visual Technology, School of Computer Science, Peking University, Beijing, China

Abstract

Attention is central to modern AI models for language, vision, and scientific modeling. However, direct evaluation compares every query with every key, requiring quadratic time in the context length, which limits its scalability to long contexts. Consequently, characterizing the complexity bounds of attention is of fundamental importance. For every fixed dimension dd, we give an algorithm for mm queries, nn key-value pairs, and additive error ε\varepsilon, with expected time O~((mn)k/(k+1)+m+n),k=⌊d/2⌋.\widetilde{\mathrm{O}}\bigl((mn)^{k/(k+1)}+m+n\bigr),\qquad k=\lfloor d/2\rfloor. For fixed dimension and a fixed number of value channels, soft-O hides factors of the form poly⁡d(b,log⁡(m+n),log⁡B,log⁡(1/ε)),\operatorname{poly}_d\bigl(b,\log(m+n),\log B,\log(1/\varepsilon)\bigr), where bb bounds input encoding lengths and BB bounds coordinate and value magnitudes. In particular, the dependence on BB and 1/ε1/\varepsilon is polylogarithmic, which allows arbitrary positive temperature. When m=nm=n and d≥2d\ge2, the bound is O~(n2−2/(⌊d/2⌋+1))\widetilde{\mathrm{O}}(n^{2-2/(\lfloor d/2\rfloor+1)}): near-linear in dimensions two and three, with exponent 4/34/3 in dimensions four and five and 3/23/2 in dimensions six and seven. It improves the previous O~(n2−1/d)\widetilde{\mathrm{O}}(n^{2-1/d}) upper bound and matches the best known batch maximum-inner-product bound in each fixed dimension. Additionally, we reduce integer batch maximum inner product computation to one attention call with the same dimension and input sizes m,nm,n.

Figures & tables

Explore similar work

Sep 29, 2026

Efficiently Approximating Attention Is Hard

Softmax attention is ubiquitous in modern machine learning, but its quadratic scaling with sequence length makes it costly. To reduce this cost, attention is often approximated with fast algorithms, which incur error but can still perform well in practice and on some inputs. At the same time, the growing diversity of attention applications makes approximation guarantees that do not depend on particular input structure a compelling target. For such uniform guarantees over all inputs, known runtime lower bounds rule out fast algorithms for near-exact attention, but leave open the practically important regime: is there an efficient algorithm with even a modest uniform approximation guarantee? We answer this question negatively. Under standard complexity-theoretic assumptions, no truly subquadratic algorithm can approximate attention with any nontrivial additive or relative guarantee uniformly over all inputs. This impossibility holds in the mildest parameter regime for which known algorithms do not already achieve strong approximation guarantees in near-linear time, and extends to practically relevant relaxations: even after polynomial preprocessing of the KV cache, no efficient algorithm can obtain a nontrivial uniform approximation guarantee, or identify a small set of keys receiving substantial attention under sparsity. Overall, our results settle the computational limits of uniform attention approximation.
May 22, 2026

Approaching I/O-optimality for Approximate Attention

We revisit the I/O complexity of attention in large language models. Given query-key-value matrices Q,K,V∈Rn×dQ,K,V\in\mathbb{R}^{n\times d}, and a machine with fast memory size MM, the goal is to compute the "attention matrix" A=softmax(QK⊤/d)VA=\text{softmax}(Q K ^{\top}/\sqrt{d}) V with the minimal number of data transfers between fast and slow memory. Existing methods in the literature, most notably FlashAttention and its variants, incur an I/O cost that depends quadratically on the context length nn, while a trivial lower bound only requires Ω(nd)Ω(nd) I/O's to read the inputs and write the output. In this work we show that the dependence on nn can be reduced to almost-linear, by developing I/O-efficient algorithms inspired by the recent approximate attention method of Alman and Song [NeurIPS'23]. We also provide (algorithm-specific) lower bounds in different parameter regimes, which nearly match the corresponding upper bounds, indicating that the proposed algorithms are indeed close to I/O-optimal.
Aug 28, 2026

Intrinsic Interaction Geometry Controls the Low-Rank Complexity of Softmax Attention

How much matrix rank is required to preserve every bounded value output of normalized softmax attention? We study the unrestricted maximum-row-ℓ1\ell_1 approximation rank rε(A)r_\varepsilon(A), exactly the least rank achieving uniform error over all bounded vector-valued values. Row softmax exposes the intrinsic interaction C=Pm(log⁡A)PNC=P_m(\log A)P_N, whereas invertible Q/KQ/K gauges leave AA fixed while changing the Euclidean geometry of a chosen query/key factorization. We replace that coordinate-dependent description by a projective residual q(C−T)q(C-T) and an attained factor-radius size κ(T)κ(T). For every rank-rr retained interaction with τ(T)<ετ(T)<\varepsilon, we prove rε(A)≤min⁡{N,  Cr(1+κ(T)(ε−τ(T))2)r/2},r_\varepsilon(A)\le \min\left\{ N,\; C_r\left( 1+\frac{κ(T)} {(\varepsilon-τ(T))^2} \right)^{r/2} \right\}, with the same unknown dimension constant as the underlying weighted Gibbs-row cover. The profile is gauge invariant, termwise no worse than native retained-subspace bounds at the same declared dimension, and has a worst-case sharp r/2r/2 size exponent at fixed rr and ε\varepsilon. We then measure rε(A)r_\varepsilon(A) directly on learned attention using 9,978 certified brackets across BERT, GPT-2, Qwen2.5, and two ViT checkpoints; where certificates do not close, the optimum remains interval-valued. A pre-specified 2,302-cell held-out study further shows that the historical native-coordinate geometry block contains coarse, mostly head-level information but no detectable incremental information beyond a strong calibrated baseline. The new intrinsic descriptor is not evaluated in that study. Together, the theory and measurements distinguish an operator-intrinsic complexity control from a stronger empirical explanation that the learned-head evidence does not support.