Skip to main content
CookLLM logoCookLLM Docs
Systems

Flash Attention

Deeply understand Flash Attention principles and Triton implementation

Overview

Flash Attention is an efficient attention implementation that uses tiling and online softmax to cut the extra memory from O(N2)O(N^2) to O(N)O(N) and make far fewer memory reads and writes (which still grow with the square of the sequence length), greatly speeding up Transformer training and inference.

This series assumes you know GPU programming basics. If SIMT, shared memory, etc. are unfamiliar, start with GPU Programming Basics.

Chapters

Why Learn This?

What You Want to DoWhat You Need
Understand why standard attention is slowHBM vs SRAM, IO-bound concept
Build your own attention kernelOnline softmax, tiling
Optimize kernel performanceAutotune, pipeline, block pointers
Support long-sequence inferenceUnderstand O(N2)→O(N)O(N^2) \to O(N) memory optimization

References