Abstract
Transformers have emerged as a preferred model for many tasks in natural language processing and vision. Recent efforts on training and deploying Transformers more efficiently have identified many strategies to approximate the self-attention matrix, a key module in a Transformer architecture. Effective ideas include various prespecified sparsity patterns, low-rank basis expansions and combinations thereof. In this paper, we revisit classical Multiresolution Analysis (MRA) concepts such as Wavelets, whose potential value in this setting remains underexplored thus far. We show that simple approximations based on empirical feedback and design choices informed by modern hardware and implementation challenges, eventually yield a MRA-based approach for self-attention with an excellent performance profile across most criteria of interest. We undertake an extensive set of experiments and demonstrate that this multi-resolution scheme outperforms most efficient self-attention proposals and is favorable for both short and long sequences.
Introduction
The Transformer architecture has revolutionized machine learning, yet it remains constrained by the "quadratic bottleneck." The computational and memory cost of the self-attention mechanism scales at $O(n^2)$ relative to the sequence length $n$, making the processing of long documents or high-resolution images prohibitively expensive.
Existing solutions generally fall into two categories: low-rank approximations, which assume the attention matrix is globally compressible, and sparsity-based methods, which focus on local or random token interactions. However, real-world attention patterns are often a hybrid of both diffuse and concentrated signals. This paper introduces MRA-Attention, a novel approximation method that utilizes Multiresolution Analysis (MRA) to adaptively capture these patterns across multiple scales with linear $O(n)$ complexity.
Methodology: The MRA Approach
Pyramidal Approximation
MRA-Attention treats the attention matrix as a signal that can be decomposed into a hierarchy of resolutions. Instead of computing every individual interaction, the model employs a pyramidal strategy:
- Coarse Scale: The model computes a low-resolution version of the attention matrix (e.g., using $8 \times 8$ blocks).
- Adaptive Refinement: The system identifies "important" regions where attention weights are high. It then recursively replaces these coarse blocks with higher-resolution representations (e.g., $4 \times 4$, then $2 \times 2$) until reaching individual tokens where necessary.
This acts like a "foveated" lens: the model spends its computational budget on high-resolution details for critical token interactions while maintaining a "blurry" coarse view for the rest of the matrix.
Achieving Linear Complexity
A primary challenge in MRA is that calculating the average attention of a block typically requires computing all values within that block, which would revert the complexity to $O(n^2)$. The authors circumvent this by leveraging the convexity of the exponential function. They demonstrate that the average attention of a block can be lower-bounded by the dot product of the averaged Query and Key vectors for that block. This mathematical insight allows the model to estimate which regions require high resolution in $O(n)$ time without ever materializing the full matrix.
Experimental Results
The authors evaluated MRA-Attention against a wide array of benchmarks, including the Long Range Arena (LRA), WikiHop, RoBERTa, and ImageNet.
Performance and Accuracy
On the Long Range Arena (LRA) benchmark, which is specifically designed to stress-test efficient Transformers, MRA-Attention achieved an average score of 59.4%. This outperformed several popular efficient models, including Longformer (58.9%), Big Bird (59.0%), and Performer (58.3%). In approximation error tests, MRA-Attention consistently demonstrated the lowest relative error across varying sequence lengths compared to all other efficient baselines.
Efficiency Gains
The model provides substantial improvements in resource management. For a sequence length of 4096 tokens:
- Memory: MRA-Attention (MRA-2) utilized only 0.28 GB of memory, compared to the 3.93 GB required by a standard Transformer.
- Speed: The method was approximately 4x faster than the standard implementation.
Discussion and Key Insights
- Attention Parsimony: Empirical analysis shows that over 95% of wavelet coefficients in a typical attention matrix are negligible, confirming that attention is naturally compressible when using the correct basis.
- Hybrid Nature: MRA-Attention effectively bridges the gap between low-rank and sparse methods. The coarse-scale approximation provides the benefits of low-rank global views, while high-resolution refinements provide the benefits of local sparsity.
- Compatibility: Unlike kernel-based methods that change the mathematical nature of attention, MRA-Attention approximates the actual softmax attention. This makes it highly compatible as a drop-in replacement for pretrained models like BERT or RoBERTa.
Conclusion and Future Work
MRA-Attention offers a principled, multi-scale solution to the quadratic bottleneck. While the current implementation relies on custom CUDA kernels to achieve its $O(n)$ speedup on NVIDIA hardware, the underlying theory provides a robust framework for future "MRA-native" architectures. Future research may explore deeper integration of MRA into the training process and the use of Locality Sensitive Hashing (LSH) to further optimize token ordering for hierarchical refinement.
Summary updated