LGAICVPFFeb 25, 2025

SpargeAttention: Accurate and Training-free Sparse Attention Accelerating Any Model Inference

Tsinghua
arXiv:2502.18137v884 citationsh-index: 13Has CodeICML
Originality Highly original
AI Analysis

This addresses the need for efficient attention in large models to reduce quadratic time complexity, offering a universal solution that works across various domains without retraining.

The paper tackles the problem of accelerating model inference by proposing SpargeAttn, a universal sparse and quantized attention method that uses a two-stage online filter to skip computations, significantly speeding up diverse models like language, image, and video generation without sacrificing performance.

An efficient attention implementation is essential for large models due to its quadratic time complexity. Fortunately, attention commonly exhibits sparsity, i.e., many values in the attention map are near zero, allowing for the omission of corresponding computations. Many studies have utilized the sparse pattern to accelerate attention. However, most existing works focus on optimizing attention within specific models by exploiting certain sparse patterns of the attention map. A universal sparse attention that guarantees both the speedup and end-to-end performance of diverse models remains elusive. In this paper, we propose SpargeAttn, a universal sparse and quantized attention for any model. Our method uses a two-stage online filter: in the first stage, we rapidly and accurately predict the attention map, enabling the skip of some matrix multiplications in attention. In the second stage, we design an online softmax-aware filter that incurs no extra overhead and further skips some matrix multiplications. Experiments show that our method significantly accelerates diverse models, including language, image, and video generation, without sacrificing end-to-end metrics. The code is available at https://github.com/thu-ml/SpargeAttn.

Code Implementations1 repo
Foundations

The foundational work for this paper's niche, ranked by how specifically the neighbourhood builds on it — not by global fame.

Your Notes