back

Understanding how Flash-Attention works

Sep 5, 2026

·
#transformers#attention#cuda#gpu

Note: This blog is currently incomplete and still a work in progress. I’m publishing it in its current state so I can gradually build on it and improve the explanations as I learn more.


Okay, so here I’ll try to explain how exactly FlashAttention works. This is my first blog, so I’ll try to keep it as straightforward and easy to understand as possible.

Before diving into the paper, you should have some context about why we need FlashAttention and some of the concepts used throughout the paper and its implementation.

Prerequisites.

  1. You should know how attention works.

    I’ll someday (not sure when) probably write a separate blog explaining how attention works and breaking down the infamous “Attention Is All You Need” paper.

    Until then, you can refer to this blog by Neural here to get a good understanding of the mathematics behind attention.

  2. You should understand memory hierarchy.

    You should have a basic understanding of how the GPU memory hierarchy works and how different types of memory are used to store and process data.

  3. You should understand compute-bound vs. memory-bound operations.

    This will help you understand why simply having a powerful GPU does not necessarily mean that an operation will run as fast as possible.

Maybe this much context is enough to get started with the paper. I’ll add more prerequisites here later if I feel that they’re necessary for understanding the paper in depth.


Okay, so let’s get into the paper

FlashAttention was introduced by researchers at the University of Chicago, Stanford University, and NVIDIA. It is an IO-aware attention algorithm that takes advantage of the GPU’s memory hierarchy to significantly reduce the amount of data that needs to be moved between different levels of memory.

And this is basically the core idea that we’re going to explore throughout this blog.

But before understanding how FlashAttention achieves this, we first need to understand why standard attention is inefficient in the first place.

manthan 2026