In How attention works you built the query·key score grid — one score for every pair of tokens. That grid is the problem: it grows with the square of the sequence. FlashAttention gets the exact same answer without ever storing it whole.
Attention scores every token against every other token. That's an N×N grid — and doubling the sequence quadruples it. This is the memory wall long context runs into.
FlashAttention computes the same attention, but block by block. It slides small tiles of the grid through the GPU's tiny fast memory (SRAM), keeping only a running summary — so the full N×N grid is never stored.
There's a second memory cost when a model answers: the KV cache — the keys and values of every past token, kept so they aren't recomputed. Giving every query head its own K/V is expensive, so heads share them.
Attention now scales to long context without the memory wall. Next, Mixture of Experts: the other half of a big model — routing each token to just a few expert sub-networks, so the model can be huge while only a slice of it runs per token.