Drastic Memory Reduction: From Quadratic to Linear

By avoiding the materialization of the N x N attention matrix, FlashAttention's single-pass online softmax reduces memory usage from quadratic (O(N²)) to linear (O(N*d)) with respect to sequence length, drastically cutting High Bandwidth Memory (HBM) traffic by up to 33x for typical configurations (e.g., N=4096, d=128).

Sources

Open the full topic