atlas

Research map / Architectures and efficiency / Attention and transformers

FlashMask: Efficient and Rich Mask Extension of FlashAttention

ICLR 2025 · Architectures and efficiency › Attention and transformers · approach: Linear attention approximations · 0 citations (OpenAlex)

Read the paperCheck your idea against 108,967 papers

AI-extracted summary. Written by AI from the paper's full text. Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.

Proposes FlashMask, a column-wise sparse (four interval vectors) attention mask representation integrated into FlashAttention-2 kernels, giving O(N) mask memory and skipping fully masked blocks, with end-to-end and kernel speedups over FlashAttention dense masks and FlexAttention.

Problem

Vanilla and dense-mask attention require O(N^2) memory for masks, and FlashAttention natively supports only a few fixed mask patterns, while complex masks used in SFT, LoRA, DPO, RM and long-context training need efficient support.

Approach

Represent each column's masked row intervals with four 1D vectors (LTS, LTE, UTS, UTE) and precompute per-block min/max values so that tiling-based FlashAttention-2 kernels can classify blocks as fully masked, partially masked, or unmasked and skip the fully masked ones, with bit-level numerical equivalence to dense-mask FlashAttention.

Key results

Measured effects reported in the paper

What was changedWhereMeasuredEffect
Replace FlashAttention dense masks with FlashMask column-wise sparse masksLlama-2 fine-tuning and alignment training · SFT, LoRA, DPO, and RMthroughput: 1.65x to 3.22xHelped
Use FlashMask instead of FlexAttentionAttention kernels · 12 mask casesTFLOPs/s: 12.1% to 60.7%Helped
Use FlashMask instead of FlashAttention dense masksLlama 3.1 8B training · SFT, LoRA, DPO, and RMloss convergenceNo clear effect
Use FlashMask rather than dense mask methodsLlama-2 7B LoRA training · 544K sequence lengthmaximum supported sequence length: 544K vs 64KHelped

Surprising findings

Limitations

Experimental setup

Datasets: allenai/tulu-v2-sft-mixture HuggingFaceH4/ultrafeedback_binarized synthetic packed-document sequences

Benchmarks: end-to-end training throughput (SFT, LoRA, DPO, RM) kernel TFLOPs/s on 12 mask types loss convergence curves

Metrics: throughput TFLOPs/s latency (ms) peak memory training loss

Baselines: FlashAttention dense mask FlexAttention Vanilla attention xFormers

Builds on: FlashAttention-2 FlexAttention xFormers Sparse Causal Flash Attention

Closest papers by meaning

Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.

Open scime draft

Get the next scime Dispatch and a monthly field update

Free. We send a confirmation link first; every email has a one-click unsubscribe. Privacy