Every modern language model — GPT, LLaMA, Gemini — is built on the same core operation: self-attention. For each token in a sequence, attention computes a weighted blend of all the other tokens, letting every word "look at" every other word at once.
The catch is the cost. With tokens you need an matrix of scores — quadratic in both time and memory. For short sequences that is fine. For sequences of thousands of tokens, that matrix alone can fill and overflow the fast on-chip memory of a GPU.
In 2022, Tri Dao and colleagues at Stanford published FlashAttention: an algorithm that computes the exact same result as standard attention while never materializing the full matrix in fast memory. The trick is not an approximation. It is an IO-aware kernel — a piece of code that reasons about where data lives (slow HBM vs. fast SRAM) and moves it as little as possible.
Comments
Loading comments...