Top 3 Efficient Attention Alternatives

To combat O(N²) costs, researchers employ: 1) Sparse Attention (e.g., BigBird, Longformer) restricting token interactions to O(N) or O(N log N). 2) Linear Attention (e.g., Performer, Linformer) using kernel approximations for O(N) complexity. 3) State Space Models (e.g., Mamba, Hyena) offering sub-quadratic scaling with RNN-like inference.

The top 3

  1. Flash Attention: Exact Attention, Faster GPU Performance: Flash Attention dramatically speeds up and improves memory efficiency of standard Transformer attention on GPUs by optimizing memory movement. It uses tiling and recomputation to perform attention calculations within fast on-chip SRAM, minimizing costly transfers to slower high-bandwidth memory, without approximating the attention mechanism itself.
  2. Performer's FAVOR+: Linearizing Attention with Random Features: The Performer architecture employs a Fast Attention Via Positive Orthogonal Random features (FAVOR+) mechanism to approximate standard softmax attention. This technique reframes attention using kernel methods, achieving linear time and space complexity with respect to sequence length, without relying on sparsity or low-rank assumptions.
  3. Reformer's LSH Attention: Efficient Sparse Grouping: The Reformer model addresses quadratic attention costs using Locality-Sensitive Hashing (LSH) attention. Instead of computing attention for all token pairs, LSH groups similar queries and keys, allowing attention to be calculated only within these smaller, hash-based buckets. This reduces the computational complexity from O(L²) to O(L log L) for sequence length L.

Sources

Open the full topic