CompileMask: Bridging the Gap Between Expressiveness and Efficiency in Attention Masking

arXiv:2610.13474 First posted 2026-10-09 v2
Cite this paper ×
BibTeX
@misc{li2026compilemask,
  title = {CompileMask: Bridging the Gap Between Expressiveness and Efficiency in Attention Masking},
  author = {Hongzheng Li and Jiacheng Wan and Zhaolong Xing and Zhida Jiang and Yuanhang Yang and Junhua Shu and Jiaxing Wang and Xupeng Miao and Yingxia Shao and Zhen Chen and Ke Zhang},
  year = {2026},
  eprint = {2610.13474},
  archivePrefix = {arXiv},
  primaryClass = {cs.DC},
  url = {https://arxiv.org/abs/2610.13474}
}
APA
Li, H., Wan, J., Xing, Z., Jiang, Z., Yang, Y., Shu, J., Wang, J., Miao, X., Shao, Y., Chen, Z., & Zhang, K. (2026). CompileMask: Bridging the Gap Between Expressiveness and Efficiency in Attention Masking [Preprint]. arXiv. https://doi.org/10.48550/arXiv.2610.13474
GB/T 7714
LI H, WAN J, XING Z, et al. CompileMask: Bridging the Gap Between Expressiveness and Efficiency in Attention Masking[EB/OL]. (2026-10-09)[2026-11-29]. https://arxiv.org/abs/2610.13474.

Abstract

Modern attention workloads require diverse masks whose shapes depend on per-sequence parameters, yet efficient attention kernels natively support only a small set of mask patterns. Existing methods for custom masks face an expressiveness-efficiency trade-off. Predicate-based methods are expressive but evaluate a user-defined predicate on every element at substantial cost, whereas interval-based methods execute efficiently but lack the expressiveness for complex masks. We present CompileMask, which bridges this gap by compiling the mask predicate users write into an Execution Descriptor that the attention kernel executes efficiently. We design a compiler that automatically lowers a mask predicate into an intermediate representation and generates a mask-specific preprocessing kernel, which builds the descriptor for each batch with a few expressions per row rather than by evaluating the predicate on every element. We further propose Tile-local Records, a compact representation of row visibility within each tile that lets the attention kernel check every element with a few integer operations, so that masking stays efficient even for complex masks. Experiments show that CompileMask achieves up to 3.3x speedup over FlexAttention and up to 1.2x over FlashMask in single-operator benchmarks, while supporting complex masks that FlashMask cannot express.

Post #1 · the paper

Discussion

No comments yet. Start the discussion!