Online Softmax & Tiling: Memory's Quadratic to Linear Shift
FlashAttention's 'online softmax' algorithm, coupled with a tiling strategy, computes attention scores incrementally within fast on-chip SRAM. This method avoids materializing the massive N x N attention matrix in slower HBM, dramatically reducing VRAM usage and changing memory complexity from quadratic to linear.
The top 3
- Online Softmax: Exact Results in a Single Pass: Online Softmax computes attention probabilities incrementally by updating running maximum and normalization terms for each block, crucially avoiding the need to materialize the entire attention matrix and delivering mathematically identical results to traditional softmax.
- Tiling's Memory Magic: How Block Processing Scales: Tiling breaks large attention computations into smaller blocks that fit into fast on-chip memory (SRAM), drastically reducing transfers to slower global memory (HBM). This prevents the need to materialize the full N² attention matrix, scaling memory usage linearly with sequence length N.
- Combined Force: FlashAttention's 9x Speedup & Linear Memory: FlashAttention, by combining online softmax and tiling, achieves up to 9x speedup in attention computations and transforms memory complexity from quadratic O(N²) to linear O(N). This breakthrough drastically reduces memory traffic to GPU HBM, enabling much longer context windows for large language models.
Sources
Open the full topic