按年被提到
20222023 · 6 次2026
系统、数据库与网络›计算机体系结构与硬件·arXiv:2205.14135 · cs.LG

FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness

FlashAttention:具备 IO 感知的快速且省内存的精确注意力
Tri Dao, Daniel Y. Fu, Stefano Ermon, Atri Rudra, Christopher Ré · 2022

用分块减少 GPU 显存读写的 IO 感知精确注意力算法

开始阅读 ↗PDFalphaXiv 讨论
被提及 · 12 人首次 2022-06-01 · 最近 2025-04-25
12不同的人
9活跃月份
12讨论串
1,364被引(OpenAlex)

自注意力的时间和显存复杂度随序列长度呈二次增长,近似注意力方法往往牺牲质量却没有换来实际加速。论文认为缺失的原则是让注意力算法具备 IO 感知,即考虑 GPU 各级内存之间的读写,并提出 FlashAttention:用分块(tiling)减少 GPU 高带宽显存(HBM)与片上 SRAM 之间的读写次数,经分析需要的 HBM 访问比标准注意力更少,并在一定范围的 SRAM 大小下最优。它还可扩展成块稀疏注意力。训练上,BERT-large 比 MLPerf 1.1 记录端到端快 15%,GPT-2 快 3 倍,长程竞技场快 2.4 倍,并带来更长上下文和更高质量。

HN 为什么提它

评论者把它当作缓解注意力二次方成本的可行方案和现代 LLM 训练的常用组件来引用,也有人指出其主要局限是需要针对每种 GPU 架构手写 CUDA 内核。

方法难度 4 / 5约 60 分钟经得起时间
读之前最好知道
1自注意力(self-attention)机制
2GPU 内存层级(HBM 与 SRAM)
3分块(tiling)与 softmax 计算
4IO 复杂度分析

HN 书评

推荐在前,同类按时间 · 每篇最多保留 20 条,统计用全部提及
引用visarga · 2022-12

“Maybe Flash attention has a shot.”

提出 Flash attention 也许有机会取代二次复杂度的注意力
GPT3/DALL-E2 in Discord, chat like ChatGPT, generate images, and more原评论 ↗
引用dpflan · 2023-04

“Maybe Flash attention has a shot.”

提出 Flash attention 也许能缓解长上下文中二次方的注意力开销
The Coming of Local LLMs原评论 ↗
引用lhl · 2023-04

“FlashAttention - Section 5 suggests that the biggest limitation is that custom CUDA kernels need to be coded on a per-GPU architecture basis.”

指出论文第 5 节认为最大局限是需要为每种 GPU 架构手写 CUDA kernel
Stability AI Launches the First of Its StableLM Suite of Language Models原评论 ↗
引用EnricoShippole · 2023-05

“The models were trained with Flash Attention, Xpos Rotary Embeddings for better length extrapolation, and multi-query single-key-value attention for more efficient decoding: FlashAttention”

说明这些模型训练时用了 Flash Attention 等技术,并附上该论文
引用scribu · 2023-12

“I would still have expected this paper to at least mention FlashAttention [1] since they both leverage flash memory.”

认为某篇论文至少该提到 FlashAttention,因为两者都利用闪存
LLM in a Flash: Efficient LLM Inference with Limited Memory原评论 ↗
引用kristjansson · 2024-02

“FlashAttention(2)[0] reduces context-length space complexity to linear.”

指出 FlashAttention(2) 把上下文长度的空间复杂度降为线性
LongRoPE: Extending LLM Context Window Beyond 2M Tokens原评论 ↗
看全部 8 条 →
引用araes · 2024-03

“Specifically: FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness.”

具体点出 FlashAttention 这篇论文,一种具备 IO 感知的快速省内存的精确注意力
Show HN: Flash Attention in ~100 lines of CUDA原评论 ↗
引用elegantly · 2025-04

“OpenAI FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness: Tri Dao et al., 2022, FlashAttention”

把 FlashAttention 作为某项 CPU softmax 说法的基准对照
400x AI Acceleration原评论 ↗
被提交为 story · 4 次