Efficiently Dispatching Flash Attention For Partially Filled Attention Masks
Not on the map. Why?
Abstract (arXiv)
Transformers are widely used across various applications, many of which yield sparse or partially filled attention matrices. Examples include attention masks designed to reduce the quadratic complexity of attention, sequence packing techniques, and recent innovations like tree masking for fast validation in MEDUSA. Despite the inherent sparsity in these matrices, the state-of-the-art algorithm Flash Attention still processes them with quadratic complexity as though they were dense. In this paper, we introduce Binary Block Masking, a highly efficient modification that enhances Flash Attention by making it mask-aware. We further propose two optimizations: one tailored for masks with contiguous non-zero patterns and another for extremely sparse masks. Our experiments on attention masks derived from real-world scenarios demonstrate up to a 9x runtime improvement. The implementation will be publicly released to foster further research and application.
Key facts. Cited by 2 papers in the map (data through 14 Oct 2026). Builds on 19 of its 29 references that are in the map. First posted on arXiv 23 Sep 2024.
Builds on
19 of 29 references.
References · 19
- 2017Attention Is All You Needcited by 60,361
- 2019Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformercited by 14,599
- 2022FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awarenesscited by 3,673
- 2020Longformer: The Long-Document Transformercited by 3,413
- 2023FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioningcited by 2,598
- 2020Big Bird: Transformers for Longer Sequencescited by 1,684
- 2020Reformer: The Efficient Transformercited by 1,668
- 2022Fast Inference from Transformers via Speculative Decodingcited by 1,653
- 2019Generating Long Sequences with Sparse Transformerscited by 1,546
- 2020Linformer: Self-Attention with Linear Complexitycited by 1,474
- 2023Accelerating Large Language Model Decoding with Speculative Samplingcited by 1,006
- 2024Medusa: Simple LLM Inference Acceleration Framework with Multiple Decoding Headscited by 843
7 more
- 2020Efficient Transformers: A Surveycited by 790
- 2024FlashAttention-3: Fast and Accurate Attention with Asynchrony and Low-precisioncited by 519
- 2021A Survey of Transformerscited by 401
- 2023SpecInfer: Accelerating Generative Large Language Model Serving with Tree-based Speculative Inference and Verificationcited by 365
- 2023Accelerating LLM Inference with Staged Speculative Decodingcited by 151
- 2019Learning Fast Algorithms for Linear Transforms Using Butterfly Factorizationscited by 76
- 2023Sparsifiner: Learning Sparse Instance-Dependent Attention for Efficient Vision Transformerscited by 16
Built on by
Citing papers per year: 2025: 2.
2 papers.