CompileMask: Bridging the Gap Between Expressiveness and Efficiency in Attention Masking
Hongzheng Li, Jiacheng Wan, Zhaolong Xing, Zhida Jiang, Yuanhang Yang, Junhua Shu, Jiaxing Wang, Xupeng Miao, Yingxia Shao, Zhen Chen, Ke Zhang
Abstract
Modern attention workloads require diverse masking patterns whose boundaries depend on runtime metadata, yet efficient attention kernels natively support only a small set of patterns. Existing methods for supporting custom masks in these kernels face an expressiveness-efficiency trade-off. Predicate-based methods are expressive but incur substantial preprocessing and execution overhead, whereas interval-based methods execute efficiently but restrict expressiveness through a predefined interval count. We present CompileMask, which addresses this trade-off by connecting expressive mask specifications with efficient attention execution. We design a compiler that analyzes visibility rules during the offline stage and generates a mask-specific preprocess kernel. We further propose MaskSpec, a region-based DSL that lets users express these rules. During the online stage, the generated kernel reads batch metadata and produces a compact Execution Descriptor that lets the attention kernel efficiently check visibility by comparing element indices against precomputed endpoints. Experiments show that CompileMask achieves up to 3.8× speedup over state-of-the-art methods.
Create a lesson
Related papers
Scheduling in Cloud,Fog, and Edge Computing: A Comparative Analysis and Decision Framework for Technique Selection
Rana Ghazali, Douglas G. Down
GPU-resident Execution for Timing-predictable Sensor Processing Systems
Soham Sinha, Rahul Choudhury, Shekhar Dwivedi et al.
ShoreKeeper: Accelerating Iterative Data Analytics in the Cloud via Distributed Recovery-Cost-Aware Caching
Jongseop Lee, Minsu Sun, Xinyue Ma et al.
Stacked Intelligent Metasurface-Based MultiModal Feature Fusion for Collaborative Inference in Edge Networks
Yushi Wang, Zhengxin Yu, Guhan Zheng et al.
Taking Tokenization off the Host for Agentic LLM Serving
Mohammad Siavashi, Pascal Schwinte, Ali Banaei et al.
SnapShare: Isolation-Preserving Deduplication for Serverless Snapshots
Leonid Kondrashov, Likun Zhang, André Filipe do Pilar de Jesus et al.