← Back to LLMs Mind Map
⚡Flashcard Drill➔
⚡ LLMsID: flashattention

FlashAttention

🎯Core Definition
FlashAttention is an IO-aware exact attention implementation: it tiles QKTQ K^T into SRAM, uses online softmax with running max mim_i and normalization factor lil_i (recursively rescaled when merging blocks: mnew=max(m,mlocal)m_{new} = max(m, m_{local})), never writes the O(n2)O(n^2) attention matrix back to HBM in the forward pass, and recomputes rather than stores in the backward pass; the motivation is the ~10-20x bandwidth gap between HBM and SRAM (A100: 40GB HBM vs ~108KB SRAM).
💡Use Cases
the de-facto attention implementation for LLM training and inference (PyTorch SDPA, NVIDIA FA2/FA3, DeepSeek/Meta stacks); gains grow with sequence length, and long-context training essentially requires it.
⚡Key Problems Solved
standard implementations shuttle the attention matrix between HBM and SRAM repeatedly, making IO the bottleneck; tiling + recomputation cuts HBM traffic from O(n2d)O(n^2 d) to O(n2d2M)O(\frac{n^2 d^2}{M}) (MM = SRAM size), giving 2-4x speedup and O(n)O(n) memory instead of O(n2)O(n^2), with results bit-identical to standard softmax (not an approximation).
🎯Core Interview Exam Points
Fundamentals · Production Scenarios · Deep Dive
Core Def
Explain the core definition, underlying mechanism/math, and key principles of FlashAttention.
Use Cases
In production engineering, what are the primary use cases for FlashAttention and what core pain points does it solve?
🔥 High-Frequency Deep-Dive Questions
1
Why is attention memory-bound? The bandwidth/capacity gap between HBM and SRAM?
2
How does online softmax merge block statistics (recursive formulas for running max m and normalizer l)?
3
Why recompute in the backward pass instead of storing? Memory from O(n2)O(n^2) to what?
4
What did FlashAttention-2 improve over v1 (dropping intermediate matrices, fewer non-matmul ops, ~2x)?
5
Why is FlashAttention exact? Essential difference from sparse/low-rank attention?
Updated 2026-08-12
🎯
Verify Mastery: Practice Exam Questions for "FlashAttention"
Take pitfall multiple-choice questions with derivation options; mistakes are automatically logged.
🚀 Start Card Practice ➔
⚡
Test muscle memory on this topic via 3-Layer Flashcards
Active Recall: Mentally formulate Prompt ➔ Math Derivation ➔ Benchmark Implementation in 3 minutes.
🎯 Drill This Card Now➔
← Previous CardPre-LN & RMSNormNext Card →Supervised Fine-Tuning (SFT)

🔗 More LLMs Knowledge Cards

引用出处: TalentMe 450+ 工业级 AI 架构考点知识库 (Tech Vault) · 遵循 CC-BY-4.0 知识共享协议
URL: https://talentme.airsota.com/resources/tech/roadmap/mindmap/LLM/card/flashattention