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

CardsList
  1. Efficiently Approximating Attention Is Hard

    Sep 29, 2026Lukas Haverbeck, Carmen Amo Alonso, Andres Felipe Posada-Moreno +2Attention ApproximationEfficient Attention

  2. Approaching I/O-optimality for Approximate Attention

    May 22, 2026Pál András Papp, Aleksandros Sobczyk, Anastasios ZouziasSelf-AttentionEfficient Attention

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

    Aug 28, 2026Yuhe Sui, Jianing Zhang, Yingzhi TangSoftmax AttentionLow-Rank Attention