Key Scalars: Max and Logsumexp for Attention

FlashAttention's single-pass online softmax tracks two crucial scalars per query row: a running maximum (m) for numerical stability and a running logsumexp (l) to accurately normalize probabilities, eliminating the need to store a full N x N attention matrix.

Sources

Open the full topic