Scatterbrain: Unifying Sparse and Low-rank Attention Approximation

Beidi Chen, Tri Dao, Eric Winsor, Zhao Song, Atri Rudra +1 more
10/28/2021
cs.LG
transformer-attention

Official code: HazyResearch/fly (224 stars, Python, Apache-2.0, last commit 2023-02-21).

Abstract

Recent advances in efficient Transformers have exploited either the sparsity or low-rank properties of attention matrices to reduce the computational and memory bottlenecks of modeling long sequences. However, it is still challenging to balance the trade-off between model quality and efficiency to perform a one-size-fits-all approximation for different tasks.

Show full abstract

To better understand this trade-off, we observe that sparse and low-rank approximations excel in different regimes, determined by the softmax temperature in attention, and sparse + low-rank can outperform each individually. Inspired by the classical robust-PCA algorithm for sparse and low-rank decomposition, we propose Scatterbrain, a novel way to unify sparse (via locality sensitive hashing) and low-rank (via kernel feature map) attention for accurate and efficient approximation. The estimation is unbiased with provably low error. We empirically show that Scatterbrain can achieve 2.1x lower error than baselines when serving as a drop-in replacement in BigGAN image generation and pre-trained T2T-ViT. On a pre-trained T2T Vision transformer, even without fine-tuning, Scatterbrain can reduce 98% of attention memory at the cost of only 1% drop in accuracy. We demonstrate Scatterbrain for end-to-end training with up to 4 points better perplexity and 5 points better average accuracy than sparse or low-rank efficient transformers on language modeling and long-range-arena tasks.

View on arXivView PDF

Code Implementations(1)

HazyResearch/flyOfficial100%
Apache-2.0
22424Python, DockerfileOct 26, 20213 years agoApache-2.0

Similar Papers

Cite this paper

@article{chen2021scatterbrain,
  title  = {Scatterbrain: Unifying Sparse and Low-rank Attention Approximation},
  author = {Beidi Chen and Tri Dao and Eric Winsor and Zhao Song and Atri Rudra and Christopher Ré},
  year   = {2021},
  eprint = {2110.15343},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2110.15343}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2110.15343.svg)](https://codeofpaper.com/paper/2110.15343)

Discussion