TL;DR
Standard Transformers are too computationally expensive for training on long sequences, while sub-quadratic linear attention models lack the state capacity to effectively retain and learn from massive contexts. To break this deadlock, the authors introduce Power Attention, a linear-cost attention mechanism that decouples state size from parameter count, enabling balanced, hardware-efficient, and highly effective long-context training.
What Problem Does This Paper Address?
As language models are increasingly deployed as agents, coding assistants, and multi-step reasoners, their context windows need to scale to millions or even billions of tokens. However, standard Transformers rely on softmax self-attention, which suffers from a quadratic computational cost ($O(t^2)$) relative to sequence length $t$. This makes training on long sequences prohibitively expensive.
To bypass this bottleneck, researchers have turned to sub-quadratic alternatives like linear attention or modern RNNs. While these models boast a constant-size memory state that keeps compute costs low, their fixed capacity severely limits their ability to perform in-context learning (ICL) over long sequences. Other workarounds, like sliding window attention, reduce the cost-per-token but destroy long-range history tracking. The core challenge this paper addresses is creating an attention mechanism that scales linearly in cost without sacrificing the memory capacity required for deep in-context learning.
Methods
The authors introduce Power Attention, which replaces the standard exponential function in self-attention with a $p$-th power:
$$\text{attn}_{\text{pow}}(Q, K, V)_i = \sum_{j=1}^i (Q_i^T K_j)^p V_j$$
Because this formulation relies on a simple inner product, it can be unrolled into a recurrent, linear-cost formulation using feature maps ($\phi$). Crucially, the hyperparameter $p$ acts as a knob that expands the model's hidden state size independently of its parameter count.
To make this practical on modern GPUs, the authors had to overcome a major memory bandwidth bottleneck: explicitly expanding feature dimensions normally floods the GPU's High-Bandwidth Memory (HBM). They designed Tiled Symmetric Power Expansion (TSPOW), an algorithmic approach that blends the GPU-friendly tiled structure of Tensor Powers (TPOW) with the reduced redundancy of Symmetric Powers (SPOW). They implemented custom Triton and CUDA kernels using a fused expand-MMA pattern, which performs the feature expansion on-the-fly inside fast on-chip SRAM, completely avoiding HBM materialization bottlenecks.
Datasets
- LongCrawl64: A dataset consisting of 6.6 million pre-tokenized documents, each exactly 65,536 tokens long (totaling 435 billion tokens). Sourced from Common Crawl, it was specifically filtered to ensure documents possessed true, long-term structural dependencies required to evaluate genuine long-context learning.
- OpenWebText: Used as a baseline to analyze and contrast document length distributions against LongCrawl64.
Key Insights and Ideas
-
The Weight-State FLOP Ratio (WSFR): Compute-optimal models require a balanced ratio (~1:1) between weight FLOPs (compute involving parameters) and state FLOPs (compute involving context states). Standard Transformers become heavily state-dominated at long contexts, while linear attention remains heavily weight-dominated. Power attention allows explicit tuning to hit this sweet spot.
Figure 2: Compute-optimal transformers have a balanced WSFR. See Appendix D for details. -
State Size Dictates Performance: At short context lengths, linear and exponential attention perform identically. As context grows, exponential attention wins purely because its effective state size scales up, providing more capacity to store information.
Figure 1: Exponential attention (blue) vs linear attention (red). -
Windowed Attention is an ICL Illusion: While windowed attention balances the WSFR by truncating old states, it completely halts in-context learning beyond its narrow window size, making it a poor choice for true long-context understanding.
Key Results
- Massive Hardware Speedups: At a context length of 65,536 tokens on an NVIDIA A100 GPU, degree-2 Power Attention achieves a 3.3x throughput speedup for a head size of 64, and an 8.6x speedup for a head size of 32 compared to FlashAttention.
- Loss-per-FLOP Dominance: When training on 64k sequence lengths, Power Attention dominates both standard exponential attention and native linear attention (like RWKV) in terms of loss-per-FLOP, striking a superior balance between low computational cost and high context utilization.
Limitations and Future Work
- Evaluation Scope: The empirical validation is strictly limited to measuring negative log-likelihood on generic natural language text (LongCrawl64). The authors note the need to test on other modalities (audio, video) and complex downstream tasks like chain-of-thought or tool use.
- Coarse State Adjustments: The current normalization technique requires positive inner products, meaning Power Attention currently only supports even integer powers ($p=2, 4, 6$), making state-size adjustments relatively coarse.
- Kernel Optimization Gap: The initial implementation relies on Triton for rapid prototyping. While fast, it still lags behind the hardware utilization efficiency of pure CUDA implementations like FlashAttention, indicating that future pure CUDA rewrites could unlock even greater speedups.
Summary updated