Notes

Flash Decoding

Generating a reply over a very long prompt has a strange property: the GPU is mostly idle. Flash-Decoding is the fix for that specific idleness — a way of splitting the attention step during generation so the whole chip stays busy.

The problem it solves

During generation the model emits one token at a time, and that single token must attend to everything already in the KV cache. FlashAttention spreads attention work across the batch and the attention heads, which fills a GPU nicely during training. At decoding time, with a batch of one and a hundred-thousand-token context, there are not enough independent pieces of work to occupy thousands of cores — so the attention step goes memory-bound and comes to dominate per-token latency.

How it works

Flash-Decoding adds a third axis to split on: the length of the cache itself. Keys and values are cut into chunks, each chunk's partial attention is computed in parallel, and the partials are merged with a rescaling step that uses the stored softmax normalisers, so the combined result is exactly equal to the unsplit one. Nothing is approximated. On long contexts the reported speedup on the attention portion of decoding reaches around 8×.

Where you meet it

You rarely call it yourself. It ships inside the FlashAttention library and is used by serving stacks such as vLLM and TensorRT-LLM, which is where a kernel-level win turns into tokens per second and a smaller bill.

Flash-Decoding is an attention kernel optimisation for generating tokens over long contexts. Standard FlashAttention parallelises across batch and heads, which leaves a GPU underused when decoding a single token against a very long KV cache. Flash-Decoding also splits along the cache length, computing partial attention per chunk and recombining the parts exactly using their softmax normalisers. It cuts long-context decoding latency substantially, without approximation.

Imagine one librarian asked to check a single sentence against a hundred thousand pages, while everyone else in the library stands around doing nothing. That is roughly what happens inside a graphics chip when an AI writes the next word of a reply about a very long document — thousands of tiny processors, almost all idle. Flash-Decoding hands slices of those pages to many workers at once, then stitches their findings together so the final answer is identical to what the single worker would have found, just far sooner. It is part of why long documents can be answered without a long wait.