SpargeAttn: Accurate Sparse Attention Accelerating Any Model Inference
Abstract
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 codes are available at https://github.com/thu-ml/SpargeAttn.
Community
SpargeAttention is a training-free sparse attention that can accelerate any model inference, achieving a 4-7x speedup.
This is an automated message from the Librarian Bot. I found the following papers similar to this paper.
The following papers were recommended by the Semantic Scholar API
- LServe: Efficient Long-sequence LLM Serving with Unified Sparse Attention (2025)
- Sparse VideoGen: Accelerating Video Diffusion Transformers with Spatial-Temporal Sparsity (2025)
- SparAMX: Accelerating Compressed LLMs Token Generation on AMX-powered CPUs (2025)
- MoBA: Mixture of Block Attention for Long-Context LLMs (2025)
- HALO: Hadamard-Assisted Lower-Precision Optimization for LLMs (2025)
- A Proximal Operator for Inducing 2:4-Sparsity (2025)
- AttentionEngine: A Versatile Framework for Efficient Attention Mechanisms on Diverse Hardware Platforms (2025)
Please give a thumbs up to this comment if you found it helpful!
If you want recommendations for any Paper on Hugging Face checkout this Space
You can directly ask Librarian Bot for paper recommendations by tagging it in a comment:
@librarian-bot
recommend
Models citing this paper 0
No model linking this paper
Datasets citing this paper 0
No dataset linking this paper
Spaces citing this paper 0
No Space linking this paper