FlashMask: Efficient and Rich Mask Extension of FlashAttention
Not on the map. Why?
Abstract (arXiv)
The computational and memory demands of vanilla attention scale quadratically with the sequence length N, posing significant challenges for processing long sequences in Transformer models. FlashAttention alleviates these challenges by eliminating the O(N2) 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(N2) 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(N), 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 and integrated into PaddleNLP, supporting models with over 100 billion parameters for contexts up to 128K tokens.
Key facts. Cited by 20 papers in the map (data through 14 Oct 2026). Builds on 28 of its 38 references that are in the map. First posted on arXiv 2 Oct 2024.
Builds on
28 of 38 references.
References · 28
- 2017Attention Is All You Needcited by 60,361
- 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,399
- 2023GPT-4 Technical Reportcited by 18,396
- 2022Training language models to follow instructions with human feedbackcited by 15,971
- 2017Proximal Policy Optimization Algorithmscited by 15,215
- 2024The Llama 3 Herd of Modelscited by 14,715
- 2019Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformercited by 14,599
- 2021LoRA: Low-Rank Adaptation of Large Language Modelscited by 14,380
- 2024DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Modelscited by 9,379
- 2023Direct Preference Optimization: Your Language Model is Secretly a Reward Modelcited by 8,065
- 2022FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awarenesscited by 3,673
- 2020Longformer: The Long-Document Transformercited by 3,413
16 more
- 2024Gemini 1.5: Unlocking multimodal understanding across millions of tokens of contextcited by 3,224
- 2022Scaling Instruction-Finetuned Language Modelscited by 3,024
- 2023FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioningcited by 2,598
- 2020Reformer: The Efficient Transformercited by 1,668
- 2024DoRA: Weight-Decomposed Low-Rank Adaptationcited by 758
- 2023RAFT: Reward rAnked FineTuning for Generative Foundation Model Alignmentcited by 686
- 2023Statistical Rejection Sampling Improves Preference Optimizationcited by 323
- 2023LongLoRA: Efficient Fine-tuning of Long-Context Large Language Modelscited by 244
- 2022OPT-IML: Scaling Language Model Instruction Meta Learning through the Lens of Generalizationcited by 236
- 2023Patch n' Pack: NaViT, a Vision Transformer for any Aspect Ratio and Resolutioncited by 229
- 2018Online normalizer calculation for softmaxcited by 162
- 2021Self-attention Does Not Need O(n2) Memorycited by 154
- 2024In-Context Learning with Long-Context Models: An In-Depth Explorationcited by 128
- 2024LiPO: Listwise Preference Optimization through Learning-to-Rankcited by 96
- 2024NACL: A General and Effective KV Cache Eviction Framework for LLMs at Inference Timecited by 43
- 2023Faster Causal Attention Over Large Sequences Through Sparse Flash Attentioncited by 25
Built on by
Citing papers per year: 2024: 1; 2025: 10; 2026: 9.
20 papers.
Sort:
By area:
- 2025MAGI-1: Autoregressive Video Generation at Scalecited by 276
- 2024Flex Attention: A Programming Model for Generating Optimized Attention Kernelscited by 185
- 2025Inference-Time Hyper-Scaling with KV Cache Compressioncited by 27
- 2025FlashBias: Fast Computation of Attention with Biascited by 11
- 2026ERNIE 5.0 Technical Reportcited by 11
- 2025DCP: Addressing Input Dynamism In Long-Context Training via Dynamic Context Parallelismcited by 7
- 2026Toward Native Multimodal Modeling: A Roadmapcited by 7
- 2025Tree Training: Accelerating Agentic LLMs Training via Shared Prefix Reusecited by 5
- 2025Attention in Diffusion Model: A Surveycited by 4
- 2025FG-Attn: Leveraging Fine-Grained Sparse Attention in Video Diffusion Modelscited by 4
- 2026MaxCode: A Max-Reward Reinforcement Learning Framework for Automated Code Optimizationcited by 4
- 2025Unifying and Enhancing Graph Transformers via a Hierarchical Mask Frameworkcited by 2
8 more
- 2026CuBridge: An LLM-Based Framework for Understanding and Reconstructing High-Performance Attention Kernelscited by 2
- 2025A Scalable Distributed Framework for Multimodal GigaVoxel Image Registrationcited by 1
- 2026SAFE-DiT: Semantics-Aware Fast-path Execution for High-Resolution Diffusion Transformerscited by 1
- 2025Accelerating Sparse Transformer Inference on GPUcited by 0
- 2026Graphical einops: bridging tensor networks and computation graphscited by 0
- 2026SPADE: An Input-Adaptive Sparse Attention Engine for Fast Video Diffusion Models Inferencecited by 0
- 2026Competition Domains Matter: Selective Head Globalization for Training-Free Sparse Attention in Video Diffusion Transformerscited by 0
- 2026FlashMask-3: Efficient and Expressive Mask-Aware Distributed Attentioncited by 0
- 2026FlashMask-3: Efficient and Expressive Mask-Aware Distributed Attention13 Oct 2026
- 2026Competition Domains Matter: Selective Head Globalization for Training-Free Sparse Attention in Video Diffusion Transformers10 Oct 2026
- 2026SPADE: An Input-Adaptive Sparse Attention Engine for Fast Video Diffusion Models Inference4 Aug 2026
- 2026SAFE-DiT: Semantics-Aware Fast-path Execution for High-Resolution Diffusion Transformers28 Jun 2026
- 2026Graphical einops: bridging tensor networks and computation graphs29 May 2026
- 2026Toward Native Multimodal Modeling: A Roadmap25 May 2026
- 2026CuBridge: An LLM-Based Framework for Understanding and Reconstructing High-Performance Attention Kernels6 May 2026
- 2026ERNIE 5.0 Technical Report4 Feb 2026
- 2026MaxCode: A Max-Reward Reinforcement Learning Framework for Automated Code Optimization9 Jan 2026
- 2025Tree Training: Accelerating Agentic LLMs Training via Shared Prefix Reuse1 Nov 2025
- 2025Unifying and Enhancing Graph Transformers via a Hierarchical Mask Framework21 Oct 2025
- 2025DCP: Addressing Input Dynamism In Long-Context Training via Dynamic Context Parallelism12 Oct 2025
8 more
- 2025A Scalable Distributed Framework for Multimodal GigaVoxel Image Registration29 Sep 2025
- 2025FG-Attn: Leveraging Fine-Grained Sparse Attention in Video Diffusion Models20 Sep 2025
- 2025Accelerating Sparse Transformer Inference on GPU6 Jun 2025
- 2025Inference-Time Hyper-Scaling with KV Cache Compression5 Jun 2025
- 2025MAGI-1: Autoregressive Video Generation at Scale19 May 2025
- 2025FlashBias: Fast Computation of Attention with Bias17 May 2025
- 2025Attention in Diffusion Model: A Survey1 Apr 2025
- 2024Flex Attention: A Programming Model for Generating Optimized Attention Kernels7 Dec 2024
- 2025Attention in Diffusion Model: A Surveycited by 4
- 2025FG-Attn: Leveraging Fine-Grained Sparse Attention in Video Diffusion Modelscited by 4
- 2026SAFE-DiT: Semantics-Aware Fast-path Execution for High-Resolution Diffusion Transformerscited by 1
- 2026SPADE: An Input-Adaptive Sparse Attention Engine for Fast Video Diffusion Models Inferencecited by 0
- 2026Competition Domains Matter: Selective Head Globalization for Training-Free Sparse Attention in Video Diffusion Transformerscited by 0
- 2026Competition Domains Matter: Selective Head Globalization for Training-Free Sparse Attention in Video Diffusion Transformers10 Oct 2026
- 2026SPADE: An Input-Adaptive Sparse Attention Engine for Fast Video Diffusion Models Inference4 Aug 2026
- 2026SAFE-DiT: Semantics-Aware Fast-path Execution for High-Resolution Diffusion Transformers28 Jun 2026
- 2025FG-Attn: Leveraging Fine-Grained Sparse Attention in Video Diffusion Models20 Sep 2025
- 2025Attention in Diffusion Model: A Survey1 Apr 2025
- 2026ERNIE 5.0 Technical Reportcited by 11
- 2025Unifying and Enhancing Graph Transformers via a Hierarchical Mask Frameworkcited by 2
- 2026ERNIE 5.0 Technical Report4 Feb 2026
- 2025Unifying and Enhancing Graph Transformers via a Hierarchical Mask Framework21 Oct 2025
- 2025MAGI-1: Autoregressive Video Generation at Scalecited by 276
- 2026Toward Native Multimodal Modeling: A Roadmapcited by 7
- 2026Toward Native Multimodal Modeling: A Roadmap25 May 2026
- 2025MAGI-1: Autoregressive Video Generation at Scale19 May 2025
- 2025Inference-Time Hyper-Scaling with KV Cache Compressioncited by 27
- 2025Inference-Time Hyper-Scaling with KV Cache Compression5 Jun 2025
- 2024Flex Attention: A Programming Model for Generating Optimized Attention Kernelscited by 185
- 2025FlashBias: Fast Computation of Attention with Biascited by 11
- 2025DCP: Addressing Input Dynamism In Long-Context Training via Dynamic Context Parallelismcited by 7
- 2026CuBridge: An LLM-Based Framework for Understanding and Reconstructing High-Performance Attention Kernelscited by 2
- 2025A Scalable Distributed Framework for Multimodal GigaVoxel Image Registrationcited by 1
- 2025Accelerating Sparse Transformer Inference on GPUcited by 0
- 2026Graphical einops: bridging tensor networks and computation graphscited by 0
- 2026FlashMask-3: Efficient and Expressive Mask-Aware Distributed Attentioncited by 0
- 2026FlashMask-3: Efficient and Expressive Mask-Aware Distributed Attention13 Oct 2026
- 2026Graphical einops: bridging tensor networks and computation graphs29 May 2026
- 2026CuBridge: An LLM-Based Framework for Understanding and Reconstructing High-Performance Attention Kernels6 May 2026
- 2025DCP: Addressing Input Dynamism In Long-Context Training via Dynamic Context Parallelism12 Oct 2025
- 2025A Scalable Distributed Framework for Multimodal GigaVoxel Image Registration29 Sep 2025
- 2025Accelerating Sparse Transformer Inference on GPU6 Jun 2025
- 2025FlashBias: Fast Computation of Attention with Bias17 May 2025
- 2024Flex Attention: A Programming Model for Generating Optimized Attention Kernels7 Dec 2024
Similar, not cited
Close in wording, no citation either way
- 2025SCOUT: Toward Sub-Quadratic Attention via Segment Compression for Optimized Utility in Transformers
- 2023Gated Linear Attention Transformers with Hardware-Efficient Training
- 2026QFlash: Bridging Quantization and Memory Efficiency in Vision Transformer Attention
- 2021Energon: Towards Efficient Acceleration of Transformers Using Dynamic Sparse Attention
- 2023AttMEMO : Accelerating Transformers with Memoization on Big Memory Systems
- 2025FlashOmni: A Unified Sparse Attention Engine for Diffusion Transformers
- 2023FlashFFTConv: Efficient Convolutions for Long Sequences with Tensor Cores
- 2026Scaling Attention via Feature Sparsity