Lune

ICLR2025顶会

FlashMask: Efficient and Rich Mask Extension of FlashAttention

Guoxia Wang, Jinle Zeng, Xiyuan Xiao, Siming Wu, Jiabin Yang, Lujing Zheng, Zeyu Chen, Jiang Bian, Dianhai Yu, Haifeng Wang

摘要

The computational and memory demands of vanilla attention scale quadratically with the sequence length 𝑁, posing significant challenges for processing long sequences in Transformer models. FlashAttention alleviates these challenges by eliminating the O (𝑁 2 ) memory dependency and reducing attention latency through IO-aware memory optimizations. However, its native support for certain attention mask types is limited, and it does not inherently accommodate more complex masking requirements. Previous approaches resort to using dense masks with O (𝑁 2 ) memory complexity, leading to inefficiencies. In this paper, we propose FLASHMASK, an extension of FlashAttention that introduces a column-wise sparse representation of attention masks. This approach efficiently represents a wide range of mask types and facilitates the development of optimized kernel implementations. By adopting this novel representation, FLASHMASK achieves linear memory complexity O (𝑁), making it suitable for modeling long-context sequences. Moreover, this representation enables kernel optimizations that eliminate unnecessary computations by leveraging sparsity in the attention mask, without sacrificing computational accuracy, resulting in higher computational efficiency. We evaluate FLASHMASK's performance in fine-tuning and alignment training of LLMs such as SFT, LoRA, DPO, and RM. FLASHMASK achieves significant throughput improvements, with end-to-end speedups ranging from 1.65x to 3.22x compared to existing FlashAttention dense method. Additionally, our kernel-level comparisons demonstrate that FLASHMASK surpasses the latest counterpart, FlexAttention, by 12.1% to 60.7% in terms of kernel TFLOPs/s, achieving 37.8% to 62.3% of the theoretical maximum FLOPs/s on the A100 GPU. The code is open-sourced on PaddlePaddle 1 and integrated into PaddleNLP 2 , supporting models with over 100 billion parameters for contexts extending up to 128K tokens.

问 Lune

几分钟读透这篇 Paper,不用再花一下午。

Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。

已有 8 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。

可以从这些问题问起

Lune 可以查阅

全文 · 引用它的顶会 Paper · 相关的 Paper

获取答案

免费开始,无需绑卡

脉络

  • CuBridge: An LLM-Based Framework for Understanding and Reconstructing High-Performance Attention Kernels 引用了 FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
  • CuBridge: An LLM-Based Framework for Understanding and Reconstructing High-Performance Attention Kernels 引用了 FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning
  • CuBridge: An LLM-Based Framework for Understanding and Reconstructing High-Performance Attention Kernels 引用了 Training language models to follow instructions with human feedback
  • FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness 引用了 Reformer: The Efficient Transformer
  • FlashBias: Fast Computation of Attention with Bias 引用了 FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
  • FlashBias: Fast Computation of Attention with Bias 引用了 FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning
  • Direct Preference Optimization: Your Language Model is Secretly a Reward Model 引用了 Training language models to follow instructions with human feedback
  • Efficient Distributed MLLM Training with Cornstarch 引用了 FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
  • Efficient Distributed MLLM Training with Cornstarch 引用了 FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning
  • FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning 引用了 FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
  • FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning 引用了 Reformer: The Efficient Transformer
  • Accelerating Sparse Transformer Inference on GPU 引用了 FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
  • Accelerating Sparse Transformer Inference on GPU 引用了 FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning
  • Accelerating Sparse Transformer Inference on GPU 引用了 Training language models to follow instructions with human feedback
  • Unifying and Enhancing Graph Transformers via a Hierarchical Mask Framework 引用了 FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
它引用的引用它的从左到右按年份排列,引用越多,位置越高。

引用它的顶会 Paper8

  1. FlashBias: Fast Computation of Attention with BiasHaixu Wu, Minghao Guo, Yuezhou Ma, Yuanxu Sun 等NeurIPS 2025 · 13 次引用
  2. Efficient Distributed MLLM Training with CornstarchInsu Jang, Runyu Lu, Nikhil Bansal, Ang Chen 等ICML 2026 · 6 次引用
  3. CuBridge: An LLM-Based Framework for Understanding and Reconstructing High-Performance Attention KernelsXing Ma, Yangjie Zhou, Wu Sun, Zihan Liu 等ACL 2026 · 2 次引用
  4. Unifying and Enhancing Graph Transformers via a Hierarchical Mask FrameworkYujie Xing, Xiao Wang, Bin Wu, Hai Huang 等NeurIPS 2025 · 2 次引用
  5. Accelerating Sparse Transformer Inference on GPUWenhao Dai, Haodong Deng, Mengfei Rong, Xinyu Yang 等PPoPP 2026 · 1 次引用

它引用的 Paper10

  1. Training language models to follow instructions with human feedbackLong Ouyang, Jeffrey Wu, Xu Jiang, Diogo Almeida 等NeurIPS 2022 · 24,707 次引用
  2. Direct Preference Optimization: Your Language Model is Secretly a Reward ModelRafael Rafailov, Archit Sharma, Eric Mitchell, Christopher D. Manning 等NeurIPS 2023 · 10,924 次引用
  3. FlashAttention: Fast and Memory-Efficient Exact Attention with IO-AwarenessTri Dao, Daniel Y. Fu, Stefano Ermon, Atri Rudra 等NeurIPS 2022 · 5,493 次引用
  4. Reformer: The Efficient TransformerNikita Kitaev, Lukasz Kaiser, Anselm LevskayaICLR 2020 · 2,878 次引用
  5. FlashAttention-2: Faster Attention with Better Parallelism and Work PartitioningTri DaoICLR 2024 · 2,600 次引用

相关 Paper

  1. ELFATT: Efficient Linear Fast Attention for Vision TransformersChong Wu, Maolin Che, Renjie Xu, Zhuoheng Ran 等ACM MM 2025 · 3 次引用
  2. Fast Attention Over Long Sequences With Dynamic Sparse Flash AttentionMatteo Pagliardini, Daniele Paliotta, Martin Jaggi, François FleuretNeurIPS 2023 · 26 次引用
  3. Sparser Block-Sparse Attention via Token PermutationXinghao Wang, Pengyu Wang, Dong Zhang, Chenkun Tan 等ICML 2026 · 2 次引用
  4. Token Sparse Attention: Efficient Long-Context Inference with Interleaved Token SelectionDongwon Jo, Beomseok Kang, Jiwon Song, jae-joon kimICML 2026 · 1 次引用
  5. Scaling Attention via Feature SparsityYan Xie, Tiansheng Wen, Tangda Huang, Bo Chen 等ICLR 2026 · 3 次引用
黄昏的海面,两侧是细线勾勒的悬崖