Our new X account is live! Follow @wizwand_team for updates
WorkDL logo mark

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

About

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.

Jintao Zhang, Chendong Xiang, Haofeng Huang, Jia Wei, Haocheng Xi, Jun Zhu, Jianfei Chen• 2025

Related benchmarks

TaskDatasetResultRank
Long-context Language UnderstandingLongBench (test)
Average Score35.87
133
Long-context UnderstandingRULER 128k
Accuracy75.42
7
Video GenerationVBench Wan2.1
Sparsity72.7
7
Long-context UnderstandingRULER 64k
Accuracy83.03
7
Video GenerationVBench CogVideoX v1.5
Sparsity67.3
6
Video GenerationVBench Hunyuan Video
Sparsity70.7
6
Video GenerationVBench Wan 2.1 training-free 1.3B
VBench Aesthetics Score (Aes.)0.6232
6
Video GenerationVBench Wan 2.1 training-free 14B
VBench Aesthetic Score0.6083
6
Video GenerationWan 14B 720p resolution 2.1 (test)
IQ38.46
6
Video GenerationWan2.1-1.3B 480p resolution (test)
IQ35.28
6
Showing 10 of 12 rows

Other info

Follow for update