Abstract
Tensor Attention, a multi-view attention that is able to capture high-order correlations among multiple modalities, can overcome the representational limitations of classical matrix attention. However, the $\Omega(n^3)$ time complexity of tensor attention poses a significant obstacle to its practical implementation in transformers, where $n$ is the input sequence length. In this work, we prove that the backward gradient of tensor attention training can be computed in almost linear $n^{1+o(1)}$ time, the same complexity as its forward computation under a bounded entries assumption. We provide a closed-form solution for the gradient and propose a fast computation method utilizing polynomial approximation methods and tensor algebraic tricks. Furthermore, we prove the necessity and tightness of our assumption through hardness analysis, showing that slightly weakening it renders the gradient problem unsolvable in truly subcubic time. Our theoretical results establish the feasibility of efficient higher-order transformer training and may facilitate practical applications of tensor attention architectures.
Introduction: Beyond Pairwise Correlations
Standard "matrix attention," the backbone of modern Large Language Models like GPT-4, calculates attention scores based on pairs of tokens—typically a single query and a single key. While powerful, this pairwise approach struggles with complex multi-modal reasoning tasks, such as those requiring the simultaneous integration of text, audio, and visual data.
Tensor Attention was introduced to overcome these limitations by capturing "triple-wise" or higher-order correlations. Instead of a single key-value pair, it utilizes multiple views to build a more expressive representation of the input sequence. However, this increased expressivity traditionally comes with a massive "complexity tax."
The Computational Barrier
While standard attention scales quadratically ($O(n^2)$) with sequence length $n$, tensor attention scales cubically ($O(n^3)$). For a modern context window of 4,096 tokens, an $O(n^3)$ operation is roughly 4,000 times more expensive than an $O(n^2)$ one.
Previous research successfully accelerated the forward pass of tensor attention to almost linear time under certain conditions. However, the backward pass—the gradient computation necessary for training—remained a cubic-time bottleneck. This paper bridges that gap, providing the first provably efficient training algorithm for higher-order transformers.
Methodology: Achieving Almost Linear Time
The authors propose a fast computation method for the backward gradient that reduces complexity from $O(n^3)$ to $n^{1+o(1)}$. Their approach relies on three main pillars:
- Closed-Form Gradient Derivation: They derive a formal mathematical expression for the gradient of the tensor attention loss function, pinpointing the exact $n \times n^2$ matrix operations that cause the $O(n^3)$ bottleneck.
- Polynomial Approximation: To avoid materializing massive tensors, they use polynomial methods to approximate the Softmax-like exponential functions. This allows the attention mechanism to be represented as a sum of low-rank matrices.
- Advanced Tensor Algebra: By utilizing specific properties of Kronecker products and a specialized "Tensor-trick," they distribute operations across smaller constituent matrices. This ensures that the gradient is computed without ever building the full cubic-scale tensor.
Theoretical Insights and Hardness Analysis
A critical finding of the paper is the necessity of the "Bounded Entries" assumption. The authors prove that if the entries in the input matrices are allowed to grow unbounded, the gradient problem becomes "hard" under the Strong Exponential Time Hypothesis (SETH). Specifically, they show that slightly weakening this assumption renders the problem unsolvable in truly sub-cubic time ($O(n^{3-\delta})$). This demonstrates that their algorithm is not only efficient but also theoretically "tight."
Furthermore, the work reveals a fundamental symmetry in complexity: training a higher-order Transformer is not inherently harder than running one. By cleverly conveying low-rank properties through the gradient formulation, the backward pass inherits the same $n^{1+o(1)}$ efficiency as the forward pass.
Conclusion
This work establishes that higher-order Transformers are computationally feasible for large-scale training. By reducing the training complexity to almost linear time, the authors remove the primary obstacle to implementing more expressive, multi-view attention architectures in practice. Future work will likely focus on empirical evaluations to see how these theoretical speedups translate to real-world GPU performance in deep multi-modal models.
Summary updated