본문으로 건너뛰기
AI NEWS JOURNAL
arXiv cs.DCAI NEWS / JOURNAL

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

arXiv:2610.13474v2 Announce Type: replace 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.3\times$ speedup over FlexAttention and up to $1.2\times$ over FlashMask in single-operator benchmarks, while supporting complex masks that FlashMask cannot express.

번역 서비스가 일시 중지되어 원문을 표시합니다.

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.3\times$ speedup over FlexAttention and up to $1.2\times$ over FlashMask in single-operator benchmarks, while supporting complex masks that FlashMask cannot express. Submission history Access Paper: View PDF HTML (experimental) TeX Source Additional Features Audio Summary Current browse context: References & Citations Google Scholar Semantic Scholar Bookmark Institution arXivLabs is a framework that allows collaborators to develop and share new arXiv features directly on our website. Both individuals and organizations that work with arXivLabs have embraced and accepted our values of openness, community, excellence, and user data privacy. arXiv is committed to these values and only works with partners that adhere to them. Have an idea for a project that will add value for arXiv's community? Learn more about arXivLabs.

자료 출처

원문 읽기 ↗

관련 주제

← 전체 소식 이어 읽기