NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

FlashBias: Fast Computation of Attention with Bias

Haixu Wu, Minghao Guo, Yuezhou Ma, Yuanxu Sun, Jianmin Wang, Wojciech Matusik, Mingsheng Long

Abstract

Modern Transformer architectures frequently incorporate "attention with bias"—such as relative position encodings or domain-specific priors—to enhance performance in vision, language, and scientific tasks. However, these dense $N \times N$ bias matrices introduce significant memory I/O overhead, negating the efficiency gains of optimized kernels like FlashAttention. We present FlashBias, an optimization framework that leverages the low-rank nature of common attention biases. By decomposing these matrices into low-rank factors, FlashBias bypasses memory bottlenecks, achieving up to 2× speedups in vision and language models and 1.5× for AlphaFold 3, while maintaining full model accuracy and reducing memory usage by up to 10× for long sequences.

Introduction

The standard attention mechanism has seen dramatic speedups through I/O-aware tiling techniques like FlashAttention, which minimize data movement between slow GPU High Bandwidth Memory (HBM) and fast on-chip SRAM. Despite these advances, many state-of-the-art models—including Swin Transformer (vision), ALiBi (language), and AlphaFold (science)—rely on "attention with bias." In this variant, a dense matrix representing spatial or relational priors is added to the query-key scores.

Figure 1: (a) Common attention masks. (b) Examples of attention biases in popular Transformers. (c) The standard attention computation process showing the I/O bottleneck between HBM and SRAM.

These bias matrices are typically $N \times N$ in size, where $N$ is the sequence length. Reading such large, dense matrices from HBM during every attention step creates a massive efficiency bottleneck. The GPU often spends more time moving bias data than performing actual computation, effectively stripping away the performance benefits of modern hardware accelerators.

Methodology: Low-Rank Decomposition

FlashBias addresses this bottleneck by replacing the massive $N \times N$ bias matrix with a low-rank decomposition. The authors provide a theoretical proof that the optimal efficiency of attention computation is fundamentally limited by the rank of the bias matrix. By using two much smaller "factor tensors" that can be multiplied on-the-fly, the framework avoids materializing the full dense matrix in memory.

The framework employs three distinct strategies for finding these factors:

  1. Exact Decomposition: For structured biases like ALiBi (linear relative distance), the authors demonstrate that they can be mathematically decomposed into factors with a rank as low as $R=2$.
  2. SVD Decomposition: For static, learnable biases (e.g., in Swin Transformer), offline Singular Value Decomposition (SVD) is used to find the optimal low-rank approximation.
  3. Neural Decomposition: For complex, dynamic biases (e.g., pair representations in AlphaFold 3), lightweight neural networks are trained to predict low-rank factors directly from input data.

These factors are concatenated with the Query and Key tensors, allowing the entire operation to utilize highly optimized matrix multiplication kernels (such as those in PyTorch's SDPA or Triton) without ever storing the full $N \times N$ bias matrix in HBM.

Evaluation and Results

FlashBias was evaluated across a diverse set of domains and models, including GPT-2 (1.5B) with ALiBi bias, Swin Transformer v2 on ImageNet-1K, and scientific applications like AlphaFold 3 and Transformer-based PDE solvers.

Performance Gains

FlashBias achieved a 1.5× speedup for the Pairformer module in AlphaFold 3 and over 2× speedup in various vision and language backbones. For long sequences ($N=16,384$), GPU memory usage was reduced by up to 10× during inference compared to standard implementations.

Accuracy and Training

Crucially, these speedups do not come at the cost of accuracy. In Swin Transformer v2, top-1 accuracy fluctuations were negligible (less than 0.05%). Furthermore, FlashBias supports the training phase, enabling the training of PDE solvers on significantly larger point clouds (up to 32k points) that previously caused Out-of-Memory (OOM) errors.

Discussion and Future Work

The core insight of FlashBias is that the I/O bottleneck is a function of data complexity (rank) rather than just size. Most widely used attention biases are inherently low-rank; for instance, SwinV2 biases can be represented with a rank of 16–32 while preserving over 99% of the original matrix's energy.

A current limitation is the reliance on the low-rank assumption. For models utilizing high-rank or "noisy" biases, a simple low-rank approximation might lose information. Future work aims to explore "Low-rank + Sparse" decompositions (similar to Robust PCA) to handle high-rank residuals while maintaining the efficiency of the low-rank bulk.

Summary updated

BibTeX
@inproceedings{wu2025flashbias,
  author = {Haixu Wu and Minghao Guo and Yuezhou Ma and Yuanxu Sun and Jianmin Wang and Wojciech Matusik and Mingsheng Long},
  title = {{FlashBias: Fast Computation of Attention with Bias}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=7L4NvUtZY3},
}
Figure