Self-Attention's Quadratic Core: QK^T Matrix Dominance
The primary cause of quadratic compute cost in Transformer models is the self-attention mechanism, specifically the calculation of the attention score matrix (QKT) where each query token is compared with every key token. This operation creates an N×N matrix, directly leading to O(N²) complexity for sequence length N.
The top 3
- Top 3 Architectural Innovations to Combat Quadratic Attention: Key methods like Sparse Attention (e.g., LongFormer), Linear Attention (e.g., Performer), and Locality-Sensitive Hashing (e.g., Reformer) aim to reduce the O(N²) computational and memory complexity of self-attention to near-linear or sub-quadratic.
- The "Attention Is All You Need" Paper: QK^T's Foundational Bottleneck: The seminal 2017 Transformer paper "Attention Is All You Need" by Vaswani et al. introduced the self-attention mechanism, inherently defining the QK^T matrix multiplication as the core operation driving its O(N²) computational complexity.
- QK^T Dominance: Over 60% of Transformer Compute in Long Sequences: In contexts with very long sequences, especially in high-resolution vision tasks, the QK^T matrix computation and the subsequent attention matrix can consume over 60% of a Transformer's total computational resources, making it the primary bottleneck for scaling.
Sources
Open the full topic