A User’s Guide to FlexAttention in FlashAttention CuTe DSL – Colfax Research
Many variants of attention (Vaswani et al., 2017) have become popular in recent years, for reasons related to performance and model quality. These include: The PyTorch team at Meta recognized that most of these variants (including all of the above) can be unified under one elegant framework, dubbed FlexAttention (Guessous et al., 2024). This simple API allows users to define and work with a large collection of attention variants, including novel combinations of existing ones, with relatively little development overhead and decent performance. FlexAttention adds two options for customization: a score_mod callable that modifies pre-softmax attention scores and a mask_mod callable that masks out pre-softmax attention scores. Altogether, FlexAttention takes the form Note that mask_mod is a special case of score_mod where scores are set to -inf; we keep the two separate for efficiency reasons, as will be explained when discussing block sparsity. The original FlexAttention implementation is
A User's Guide to FlexAttention in FlashAttention CuTe DSL - Colfax Research Skip to content A User’s Guide to FlexAttention in FlashAttention CuTe DSL Many variants of attention ( Vaswani et al., 2017 ) have become popular in recent years, for reasons related to performance and model quality. These include: Causal attention for autoregressive language modeling, where a token only attends to those prior; Sliding window attention for long-context language modeling, where a token only attends to those prior within a predefined window, reducing computational complexity of attention fro
Explore this link on the map →saved by
related reading
- 2502.11089arxiv.org
- Linear Attention Fundamentals | Hailey Schoelkopfhaileyschoelkopf.github.io
- From Online Softmax to FlashAttentioncourses.cs.washington.edu
- flash-attention/csrc/flash_attn/src/flash_fwd_kernel.h at main · Dao-AILab/flash-attention · GitHubgithub.com
- Transformers Inference Optimization Toolset | AstraBlogastralord.github.io
- Overleaf Examplearxiv.org
- Flash Attention from Scratch Part 1: Introlubits.ch
- The Annotated Transformernlp.seas.harvard.edu
- 1706.03762arxiv.org
- Mamba: The Easy Wayjackcook.com
- [2012.09852] SpAtten: Efficient Sparse Attention Architecture with Cascade Token and Head Pruningarxiv.org
- Attention-Residuals/Attention_Residuals.pdf at master · MoonshotAI/Attention-Residuals · GitHubgithub.com