Softmax Attention with Any Temperature in Fixed Dimension: Matching the Best Known Maximum-Inner-Product Bounds
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 , we give an algorithm for queries, key-value pairs, and additive error , with expected time For fixed dimension and a fixed number of value channels, soft-O hides factors of the form where bounds input encoding lengths and bounds coordinate and value magnitudes. In particular, the dependence on and is polylogarithmic, which allows arbitrary positive temperature. When and , the bound is : near-linear in dimensions two and three, with exponent in dimensions four and five and in dimensions six and seven. It improves the previous 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 .
Figures & tables
| Dimension | Time upper bounds | |||
|---|---|---|---|---|
| Prior work [ 38 ] | Offline counting baseline | This work | Batch Max-IP | |
Efficient Attention
Efficient attention reduces the compute, memory traffic, and cache costs of Transformer attention while preserving useful long-range interactions.
See all 148 papers