FlashBias: Fast Computation of Attention with Bias
Not on the map. Why?
Abstract (arXiv)
Attention with bias, which extends standard attention by introducing prior knowledge as an additive bias matrix to the query-key scores, has been widely deployed in vision, language, protein-folding and other advanced scientific models, underscoring its status as a key evolution of this foundational module. However, introducing bias terms creates a severe efficiency bottleneck in attention computation. It disrupts the tightly fused memory-compute pipeline that underlies the speed of accelerators like FlashAttention, thereby stripping away most of their performance gains and leaving biased attention computationally expensive. Surprisingly, despite its common usage, targeted efficiency optimization for attention with bias remains absent, which seriously hinders its application in complex tasks. Diving into the computation of FlashAttention, we prove that its optimal efficiency is determined by the rank of the attention weight matrix. Inspired by this theoretical result, this paper presents FlashBias based on the low-rank compressed sensing theory, which can provide fast-exact computation for many widely used attention biases and a fast-accurate approximation for biases in general formalizations. FlashBias can fully take advantage of the extremely optimized matrix multiplication operation in modern GPUs, achieving 1.5× speedup for Pairformer in AlphaFold 3, and over 2× speedup for attention with bias in vision and language models without loss of accuracy. Code is available at this repository: https://github.com/thuml/FlashBias.
Key facts. Cited by 11 papers in the map (data through 14 Oct 2026). Builds on 22 of its 45 references that are in the map. First posted on arXiv 17 May 2025.
Builds on
22 of 45 references.
References · 22
- 2017Attention Is All You Needcited by 60,361
- 2019PyTorch: An Imperative Style, High-Performance Deep Learning Librarycited by 20,305
- 2023GPT-4 Technical Reportcited by 18,396
- 2023LLaMA: Open and Efficient Foundation Language Modelscited by 14,132
- 2021Swin Transformer: Hierarchical Vision Transformer using Shifted Windowscited by 12,139
- 2022Scalable Diffusion Models with Transformerscited by 6,054
- 2021RoFormer: Enhanced Transformer with Rotary Position Embeddingcited by 4,703
- 2022FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awarenesscited by 3,673
- 2020Longformer: The Long-Document Transformercited by 3,413
- 2023FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioningcited by 2,598
- 2020Point Transformercited by 1,470
- 2021Swin Transformer V2: Scaling Up Capacity and Resolutioncited by 1,228
10 more
- 2024ChatGLM: A Family of Large Language Models from GLM-130B to GLM-4 All Toolscited by 1,121
- 2021Perceiver: General Perception with Iterative Attentioncited by 1,104
- 2021Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolationcited by 1,103
- 2024Transolver: A Fast Transformer Solver for PDEs on General Geometriescited by 326
- 2023Spherical Fourier Neural Operators: Learning Stable Dynamics on the Spherecited by 233
- 2024Flex Attention: A Programming Model for Generating Optimized Attention Kernelscited by 185
- 2018Online normalizer calculation for softmaxcited by 162
- 2021Self-attention Does Not Need O(n2) Memorycited by 154
- 2024FlashMask: Efficient and Rich Mask Extension of FlashAttentioncited by 20
- 2024Efficiently Dispatching Flash Attention For Partially Filled Attention Maskscited by 2
Built on by
Citing papers per year: 2026: 11.
11 papers.
- 2026Global-Local Dual Perception for MLLMs in High-Resolution Text-Rich Image Translationcited by 3
- 2026Rank-Factorized Implicit Neural Bias: Scaling Super-Resolution Transformer with FlashAttentioncited by 1
- 2026Positional LSH: Binary Block Matrix Approximation for Attention with Linear Biasescited by 1
- 2026Zero-shot generalization of transformer neural operators to larger domainscited by 1
- 2026The Gate Always Closes: On Injecting Auxiliary Signals into Frozen Vision-Language Modelscited by 1
- 2026Inference-Time Attention Steering for Vision-Language-Action Driving Modelscited by 1
- 2026Modular Deep Learning Mechanisms for Auditable Next-Day Wildfire Spread Predictioncited by 1
- 2026Scalable Peptide Design via Memory-Efficient Equivariant Transformercited by 0
- 2026Design-CP: Context Parallelism for Design of Protein Nanoparticlescited by 0
- 2026FLASHSWIN: Unlocking Large Windows and Dense Tokens in Swin Vision Transformers with Memory Efficient Attentioncited by 0
- 2026TurboPairFormer: Fast and Stable Protein Folding Model Training with an Optimized Triangle Attention Kernelcited by 0
- 2026TurboPairFormer: Fast and Stable Protein Folding Model Training with an Optimized Triangle Attention Kernel5 Oct 2026
- 2026FLASHSWIN: Unlocking Large Windows and Dense Tokens in Swin Vision Transformers with Memory Efficient Attention3 Oct 2026
- 2026Modular Deep Learning Mechanisms for Auditable Next-Day Wildfire Spread Prediction15 Sep 2026
- 2026Inference-Time Attention Steering for Vision-Language-Action Driving Models17 Aug 2026
- 2026The Gate Always Closes: On Injecting Auxiliary Signals into Frozen Vision-Language Models25 Jul 2026
- 2026Design-CP: Context Parallelism for Design of Protein Nanoparticles3 Jul 2026
- 2026Scalable Peptide Design via Memory-Efficient Equivariant Transformer23 Jun 2026
- 2026Zero-shot generalization of transformer neural operators to larger domains12 Jun 2026
- 2026Positional LSH: Binary Block Matrix Approximation for Attention with Linear Biases10 May 2026
- 2026Rank-Factorized Implicit Neural Bias: Scaling Super-Resolution Transformer with FlashAttention6 Mar 2026
- 2026Global-Local Dual Perception for MLLMs in High-Resolution Text-Rich Image Translation25 Feb 2026