How to Capture Higher-order Correlations? Generalizing Matrix Softmax Attention to Kronecker Computation

Josh Alman, Zhao Song

Abstract

Standard attention mechanisms in Transformer architectures inherently capture only pairwise relationships between tokens, limiting their ability to process complex, higher-order linguistic or logical dependencies. This paper introduces a "tensor generalization" of attention designed to capture these higher-order correlations (such as triples of words). While naive implementations of higher-order attention scale cubically, the authors prove that this generalized attention can be computed in near-linear time, provided the input values remain within a specific mathematically bounded range.

Introduction: The Limits of Pairwise Attention

The core driver of the Transformer architecture is the attention mechanism, which computes the relevance of every token in a sequence to every other token. Mathematically, this is a pairwise operation resulting in an $n \times n$ matrix. However, language and logic frequently involve higher-order dependencies where understanding a relationship requires analyzing three or more tokens simultaneously.

Recent theoretical work demonstrates that standard attention units are mathematically incapable of solving certain simple problems involving triples of connected words. While one could theoretically design "Triple-Attention" or "Tensor-Attention" modules, the computational cost is prohibitive. For a sequence of length $n$, pairwise attention scales at $O(n^2)$, but triple-wise attention scales at $O(n^3)$. In the era of long-context models where $n$ routinely exceeds 100,000, cubic scaling is computationally infeasible. This paper investigates whether it is possible to capture these higher-order correlations without incurring the cubic-time penalty.

Methodology: Tensor Generalization of Attention

To address this limitation, the authors define a Tensor Generalization of Attention. Instead of the standard Query ($Q$), Key ($K$), and Value ($V$) matrices, the generalized form introduces multiple Key and Value matrices (e.g., $K_1, K_2, V_1, V_2$). It utilizes column-wise Kronecker products ($\oslash$) to represent triple-wise interactions mathematically.

To solve the resulting efficiency bottleneck, the authors employ several advanced theoretical techniques:

  1. The Polynomial Method: Computing the exact softmax (exponential) function couples all tokens, forcing $O(n^3)$ time for triples. Instead, the authors use a low-degree polynomial to approximate the exponential function. This approximation allows the massive tensor operations to be "factorized" into a series of smaller, highly efficient matrix multiplications.
  2. Kernel Density Estimation (KDE): The attention problem is reframed as a higher-order variant of KDE, a classic computational geometry problem, enabling the adaptation of existing algorithmic tools.
  3. Fine-Grained Complexity Theory: To prove the strict optimality of their algorithm, the authors leverage the Strong Exponential Time Hypothesis (SETH), reducing the "3-Orthogonal Vectors" problem to the attention problem to establish rigorous computational lower bounds.

Key Results: The Phase Transition of Efficiency

The paper's most striking insight is that the computational speed of higher-order attention depends entirely on the magnitude of the numbers within the input matrices. The authors identify a strict mathematical "phase transition" at the value $\sqrt[k]{\log n}$, where $k$ is the order of correlation (e.g., $k=3$ for triples).

  • Positive Result (Near-Linear Upper Bound): For triple-wise correlations ($k=3$), if all entries in the input matrices are strictly bounded above by $o(\sqrt[3]{\log n})$, the attention matrix can be approximated in near-linear time ($n^{1+o(1)}$). This bypasses the naive $O(n^3)$ bottleneck entirely.
  • Negative Result (Cubic Lower Bound): Conversely, if the entries can be as large as $\Omega(\sqrt[3]{\log n})$, the authors prove that no algorithm can run faster than sub-cubic time ($n^{3-o(1)}$), assuming standard complexity theory conjectures hold.
  • Generalization to $k$-th Order: These bounds scale naturally. For any $k$-th order correlation, the efficiency threshold for input entries remains $o(\sqrt[k]{\log n})$.

This establishes a fundamental tradeoff between expressivity and activation magnitude: capturing highly complex (higher $k$) relationships requires strictly smaller input values to maintain near-linear processing times.

Limitations and Future Directions

As a purely theoretical work, the paper focuses on algorithmic bounds rather than empirical evaluation. Several challenges remain for practical deployment:

  • Approximation Error: The near-linear algorithm approximates the attention output. While theoretically bounded, small approximation errors could compound across the deep layers of a standard neural network.
  • Hardware Implementation: Translating this mathematical blueprint into a hardware-aware implementation (akin to FlashAttention for standard pairwise operations) poses a significant engineering challenge.
  • Normalization Strategies: Because the algorithm's speed relies on bounded entries, future architectural work must investigate specific normalization layers or weight initialization schemes that constrain activations to the "fast zone" ($o(\sqrt[k]{\log n})$) without degrading the model's learning capacity.

Summary updated

BibTeX
@inproceedings{alman2024how,
  author = {Josh Alman and Zhao Song},
  title = {{How to Capture Higher-order Correlations? Generalizing Matrix Softmax Attention to Kronecker Computation}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=v0zNCwwkaV},
}
Figure