FlashMask-3 speeds structured attention across GPUs
FlashMask-3: Efficient and Expressive Mask-Aware Distributed Attention · arXiv:2610.17901
In plain words
Long-context training can use masks to control which tokens attend to which others. But applying those masks and dividing the work across GPUs can slow training, especially when some GPUs receive more work than others.
FlashMask-3 is a method that makes the mask guide both GPU computation and how work and data are shared across devices. In tests, it increased full-training speed over a standard balancing and communication setup for one large model and three document-mask datasets. The result is limited to that tested setup.
The research
When training uses long sequences split across GPUs, can structured attention masks be applied without making mask processing and uneven workloads a new bottleneck? The question matters because distributing the sequence adds both computation and communication to the work that the masks shape.
FlashMask-3 combines a Hopper attention kernel with rank-local masks, sparse-work balancing, and overlapped communication for distributed training.
FlashMask-3 combines a Hopper GPU attention kernel with distributed methods for localizing masks, balancing sparse work, and overlapping computation with communication.
The comparison measured full training against Dual Chunk balancing and all-gather communication for a 118B-A14B model at 128K context on 128 H100 GPUs.
Training throughput was higher on all three document-mask datasets, by 7.3% to 11.0% across datasets with 70% to 86% average mask sparsity. This supports a gain for the combined method in that setup; attention benchmarks alone would not establish a full-training improvement.
The full-training gain was measured for one 118B-A14B model, document masks, three datasets, and a specific 128-H100 setup. The paper also reports that disabling hierarchical routing reduced the combined method’s gain to below the baseline on two of those datasets.
What the evidence shows
- Masks complicate long training
FlashMask-3 is an attention method for structured masks on Hopper GPUs and across context-parallel ranks, which divide query sequences among devices. The paper addresses a practical bottleneck: as long-context training spreads across devices, masks can add processing work and leave some ranks with more computation than others.
Earlier FlashMask supported structured masks but did not provide Hopper-specific optimization or distributed context-parallel support.
- One mask guides the work
The method represents each key position’s masked query rows with up to two intervals. A Hopper kernel scans those boundaries and skips key-value blocks that are fully masked, while applying the mask to partly masked blocks.
For distributed execution, FlashMask-3 converts the global intervals into rank-local coordinates without communicating between ranks, and it balances work according to the mask’s sparse pattern.
- Distributed tests show faster attention
In distributed attention tests, FlashMask-3 had higher throughput than MagiAttention and Megatron-Core’s ring and all-gather versions across supported masks and context-parallel degrees from 4 to 32. Each device processed 8K query tokens; the Megatron comparisons omitted Prefix LM Document Mask because those versions do not support it.
This is evidence about attention throughput in the tested distributed configurations, not full training speed.
- Routing shaped the training result
The full-training comparison used a 118B-A14B model at 128K context on 128 H100 GPUs. Compared with Dual Chunk balancing and all-gather communication, FlashMask-3 increased training throughput on three document-mask datasets with different average sparsities.
A control disabling hierarchical routing fell below the baseline on two datasets, showing that the combined result depended on routing in this setup.
Deep
- Original paper authors
- Guoxia Wang, Qianyue He, Siming Wu, Haoyang Xie, Qiwen Bao
- Submitted to arXiv
- License
- arXiv non-exclusive