Bring the mental model from Efficient Attention at Scale: KV Cache, GQA & FlashAttention; this page will reuse it instead of restarting from zero.
FlashAttention: IO-Aware Attention
A fused, tiled attention implementation that avoids materializing the full T x T matrix by using an online softmax, reducing memory traffic and speeding up long-context training/inference.
01
Intuition
Build the mental picture first so the rest of the page has something to attach to.
Standard attention is conceptually simple but computationally awkward on GPUs:
- Compute the T×T score matrix S=QK⊤/dk.
- Apply a row-wise softmax to get attention weights P=softmax(S).
- Multiply by values: PV.
The problem is step (1): materializing a T×T matrix is huge, and moving it to and from GPU memory (HBM) is slow. For long sequences, attention is often memory-bandwidth bound rather than FLOPs bound.
FlashAttention is the idea: keep computations in fast on-chip SRAM by tiling, and compute the softmax in a streaming way so you never need to store the full T×T matrix.
Copy-only prompts — each action copies a page-grounded prompt to your clipboard. Nothing is sent by this site.
02
Math
Translate the story into symbols, assumptions, and a derivation you can inspect.
Standard attention (and the T×T issue)
For one head, with Q,K,V∈RT×dk:
The attention weights matrix is P∈RT×T. If you store it explicitly, memory scales like O(T2).
Online softmax (streaming trick)
For a single row of scores s∈RT, the softmax uses:
You can compute this in blocks without ever storing all scores at once by maintaining a running max m and a running normalizer ℓ.
For a block b of scores with:
you can merge block statistics with the running state via:
At the end, the attention output for that row is:
This is the core idea: you can compute PV without ever materializing P.
Copy-only prompts — each action copies a page-grounded prompt to your clipboard. Nothing is sent by this site.
03
Code
Keep the implementation aligned with the notation so the algorithm is legible.
import numpy as np
def softmax(x):
m = float(x.max())
e = np.exp(x - m)
return e / e.sum()
def attn_out_stream(scores, values, block=2):
m, l, o = -np.inf, 0.0, 0.0
for i in range(0, len(scores), block):
sb = scores[i:i+block]
vb = values[i:i+block]
mb = float(sb.max())
eb = np.exp(sb - mb)
lb = float(eb.sum())
ob = float((eb * vb).sum())
m_new = max(m, mb)
l = np.exp(m - m_new) * l + np.exp(mb - m_new) * lb
o = np.exp(m - m_new) * o + np.exp(mb - m_new) * ob
m = m_new
return o / l
s = np.array([2.0, 1.0, -1.0, 0.5, 3.2, -0.3])
v = np.array([0.1, 0.2, -0.4, 0.0, 0.7, 0.3])
out_full = float((softmax(s) * v).sum())
out_stream = float(attn_out_stream(s, v, block=2))
print("full:", round(out_full, 6), "stream:", round(out_stream, 6), "diff:", round(abs(out_full - out_stream), 9))
Copy-only prompts — each action copies a page-grounded prompt to your clipboard. Nothing is sent by this site.
04
Interactive Demo
Use direct manipulation to connect the explanation to a moving system.
Live Concept Demo
Explore FlashAttention: IO-Aware Attention
The stage is code-native and interactive. Use it to test the explanation against the mechanism.
Manipulate one control and predict the visible change.
Choose what to inspect in FlashAttention: IO-Aware Attention. This shared fallback is an observation guide, not evidence of learning.
The demo below asks you to predict the memory bottleneck first, then reveal how the online softmax state (m,ℓ,o) is merged across tiles. The key invariant is that FlashAttention computes exact attention while avoiding a stored T×T probability matrix.
Copy-only prompts — each action copies a page-grounded prompt to your clipboard. Nothing is sent by this site.
Concept: FlashAttention: IO-Aware Attention
What is the smallest example that makes FlashAttention: IO-Aware Attention click without losing the math?
Object contextAttention & Transformers
concept:attention-transformers/flash-attentionFlashAttention: IO-Aware Attention
What is the smallest example that makes FlashAttention: IO-Aware Attention click without losing the math?
Start with the prediction checkpoint, then compare the reveal to the mental model.
Take this moveStudy modes
Keep the object fixed; change the lens.Route back through the notebook
Carry the same object through intuition, math, code, and demo.
A fused, tiled attention implementation that avoids materializing the full T x T matrix by using an online softmax, reducing memory traffic and speeding up long-context training/inference.
The next edge should feel earned: use the demo prediction here before following LLM Serving at Scale: Prefill, Decode & Continuous Batching.
After The First Pass
Turn the concept into an inspected object.
The lower panels are one second act: keep the object fixed, inspect it visually, check source boundaries, practice transfer, then attach the research question.Mechanism Storyboard
See the idea move before the page explains it
A fused, tiled attention implementation that avoids materializing the full T x T matrix by using an online softmax, reducing memory traffic and speeding up long-context training/inference.

Start with the picture, metaphor, or geometric mechanism.
Before reading further, choose the kind of change FlashAttention: IO-Aware Attention should make visible.
Visual Inquiry
Make the image answer a mathematical question
A fused, tiled attention implementation that avoids materializing the full T x T matrix by using an online softmax, reducing memory traffic and speeding up long-context training/inference.
Which visible object should carry the first intuition?
Pick the cue that should make FlashAttention: IO-Aware Attention easier to reason about before the page gives the answer.
Source Grounding
Canonical references for the mechanism on this page.
What is the smallest example that makes FlashAttention: IO-Aware Attention click without losing the math?
concept:attention-transformers/flash-attentionsources: dao-2022-flashattention
Open the closest source note before trusting the local explanation.
1 selected-object source shown first; 1 reference total.
Audit the claim boundary, then ask from the same selected object.
Primary source for the dense FlashAttention mechanism: IO-aware HBM/SRAM tiling plus block-wise/incremental softmax statistics reduce HBM reads/writes and avoid materializing the full N x N attention matrix.
Dao et al. frame FlashAttention as IO-aware exact attention using HBM/SRAM tiling; Algorithm 1 updates block softmax statistics and returns O=softmax(QK^T)V while avoiding reads/writes of...
"Online softmax" means the paper's block-wise/incremental softmax statistics. This checks the dense FlashAttention mechanism, not block-sparse variants, CUDA numeric equivalence, backward...
Claim Review
A fused, tiled attention implementation that avoids materializing the full T x T matrix by using an online softmax, reducing memory traffic and speeding up long-context training/inference.
What is the smallest example that makes FlashAttention: IO-Aware Attention click without losing the math?
concept:attention-transformers/flash-attentionsources: dao-2022-flashattention
Treat every claim as provisional until source support and a local witness agree.
1 structured claim check on this concept.
Run the prediction or practice transfer before asking for a grounded review.
Publisher-side editorial review is not independent replication. Claims without it still need exact source-support review. 1 reference and 3 local witnesses are available for inspection.
Dao et al. frame FlashAttention as IO-aware exact attention using HBM/SRAM tiling; Algorithm 1 updates block softmax statistics and returns O=softmax(QK^T)V while avoiding reads/writes of the full N x N atte...
"Online softmax" means the paper's block-wise/incremental softmax statistics. This checks the dense FlashAttention mechanism, not block-sparse variants, CUDA numeric equivalence, backward-pass implementation...
Checked Dao et al. against the exact claim: the paper presents FlashAttention as exact attention, uses HBM/SRAM tiling, maintains block softmax statistics (m,l,O) to compute the same softmax(QK^T)V result, and avoids reading/writing the full N x N attention matrix to HBM; local math/code/demo illustrate the same finite-row invariant.
Reviewer: codex+oracle; reviewed 2026-05-07Practice notebook
Use the idea, then test it somewhere new
A fused, tiled attention implementation that avoids materializing the full T x T matrix by using an online softmax, reducing memory traffic and speeding up long-context training/inference.
What is the smallest example that makes FlashAttention: IO-Aware Attention click without losing the math?
concept:attention-transformers/flash-attentionsources: dao-2022-flashattention
Use one state from FlashAttention: IO-Aware Attention to explain what changes, why it changes, and which assumption the explanation needs.
No learner move yet; no learning state is inferred.
Write first, use only the help you need, then try a new case without it.
Use one state from FlashAttention: IO-Aware Attention to explain what changes, why it changes, and which assumption the explanation needs.
Reveal when your model needs a nudge.
Reveal when your model needs a nudge.
Reveal when your model needs a nudge.
Write an attempt before asking the companion.
0 of 3 progressive hints opened.
This draft and any AI response do not establish mastery; a later unassisted case can.
- ObjectConceptFlashAttention: IO-Aware Attention
- PredictBefore revealFlashAttention: IO-Aware Attention prediction
- WitnessCompare codeFlashAttention: IO-Aware Attention code witness 1
- RoomAsk groundedChecking local snapshot
Research Room
Attach the question to an exact object
Pick the concept, equation, source, code witness, claim, misconception, or demo state before asking for help. The handoff stays grounded to that object.Open the draft below to save one note and next action in this browser.
FlashAttention: IO-Aware Attention
What is the smallest example that makes FlashAttention: IO-Aware Attention click without losing the math?
These are fixed, deterministic perspectives derived from the selected object. They do not represent people, community contributions, or independent review.
Source ids dao-2022-flashattention must support the exact object, not just the surrounding topic.
Treat this as a mechanism object: connect the definition to one equation, code witness, or demo before broadening the discussion.
Ask the learner to perturb one representation, then check whether the same invariant survives in math, code, and demo.
The learner can state the mechanism in their own words
Local action draftNo local draft saved yetExpand only when ready to capture one local next action
This draft stays locally in this browser for concept:attention-transformers/flash-attention.
- Source ids to inspect: dao-2022-flashattention
- Definition, prerequisite, and contrast concept links
- The equation or code witness that makes the concept operational
- One demo state that shows the invariant instead of a slogan
- The learner can state the mechanism in their own words
- The learner can name the prerequisite that would repair confusion
- The learner can predict how the mechanism changes under one perturbation
I am working in Continuous Function's research reading room. Object: concept - FlashAttention: IO-Aware Attention Object key: concept:attention-transformers/flash-attention Context: Attention & Transformers Anchor id: concept/concept-notebook/attention-transformers/flash-attention Open question: What is the smallest example that makes FlashAttention: IO-Aware Attention click without losing the math? Evidence to inspect: - Source ids to inspect: dao-2022-flashattention - Definition, prerequisite, and contrast concept links - The equation or code witness that makes the concept operational - One demo state that shows the invariant instead of a slogan Deterministic role lenses for this object: - Boundary: fixed perspectives, not people, community contributions, or independent review - Source-checking summary: Treat this as a mechanism object: connect the definition to one equation, code witness, or demo before broadening the discussion. - Proposed experiment: Ask the learner to perturb one representation, then check whether the same invariant survives in math, code, and demo. - Teach/transfer move: Turn the mechanism into one sentence that predicts a neighboring concept. - Assumptions: - Source ids dao-2022-flashattention must support the exact object, not just the surrounding topic. - The stable content-object key lets local drafts, prompts, and route memory attach without changing the source page. - The concept explanation is local atlas prose until checked against its math, code, and source support. - Prerequisite gaps should become a repair route, not a reason to leave the object vague. - Role-lens requests: - Learner: ask for "Ask what would make "FlashAttention: IO-Aware Attention" feel predictable rather than familiar." | assumption: Source ids dao-2022-flashattention must support the exact object, not just the surrounding topic. | next action: The learner can state the mechanism in their own words - Researcher: ask for "Source ids to inspect: dao-2022-flashattention" | assumption: The stable content-object key lets local drafts, prompts, and route memory attach without changing the source page. | next action: The learner can name the prerequisite that would repair confusion - Experimenter: ask for "Choose one variable or condition to perturb before asking for an explanation." | assumption: The concept explanation is local atlas prose until checked against its math, code, and source support. | next action: The learner can predict how the mechanism changes under one perturbation - Professor: ask for "Find the smallest transferable rule a learner could reuse without the AI." | assumption: Prerequisite gaps should become a repair route, not a reason to leave the object vague. | next action: Teach or transfer: Turn the mechanism into one sentence that predicts a neighboring concept. What would resolve this: - The learner can state the mechanism in their own words - The learner can name the prerequisite that would repair confusion - The learner can predict how the mechanism changes under one perturbation Answer as a careful research tutor: stay source-grounded, separate verified evidence from assumptions, name the relevant math objects, and end with one next action. Current deterministic role lens for this object: - Role lens: Learner - Evidence request: Ask what would make "FlashAttention: IO-Aware Attention" feel predictable rather than familiar. - Assumption to keep visible: Source ids dao-2022-flashattention must support the exact object, not just the surrounding topic. - Proposed experiment: Ask the learner to perturb one representation, then check whether the same invariant survives in math, code, and demo. - Next action: The learner can state the mechanism in their own words
concept/concept-notebook/attention-transformers/flash-attention
concept:attention-transformers/flash-attention