Table of Contents
Fetching ...

SpargeAttention2: Trainable Sparse Attention via Hybrid Top-k+Top-p Masking and Distillation Fine-Tuning

Jintao Zhang, Kai Jiang, Chendong Xiang, Weiqi Feng, Yuezhou Hu, Haocheng Xi, Jianfei Chen, Jun Zhu

TL;DR

SpargeAttention2 is proposed, a trainable sparse attention method that achieves high sparsity without degrading generation quality, and is consistently outperforming prior sparse attention methods.

Abstract

Many training-free sparse attention methods are effective for accelerating diffusion models. Recently, several works suggest that making sparse attention trainable can further increase sparsity while preserving generation quality. We study three key questions: (1) when do the two common masking rules, i.e., Top-k and Top-p, fail, and how can we avoid these failures? (2) why can trainable sparse attention reach higher sparsity than training-free methods? (3) what are the limitations of fine-tuning sparse attention using the diffusion loss, and how can we address them? Based on this analysis, we propose SpargeAttention2, a trainable sparse attention method that achieves high sparsity without degrading generation quality. SpargeAttention2 includes (i) a hybrid masking rule that combines Top-k and Top-p for more robust masking at high sparsity, (ii) an efficient trainable sparse attention implementation, and (iii) a distillation-inspired fine-tuning objective to better preserve generation quality during fine-tuning using sparse attention. Experiments on video diffusion models show that SpargeAttention2 reaches 95% attention sparsity and a 16.2x attention speedup while maintaining generation quality, consistently outperforming prior sparse attention methods.

SpargeAttention2: Trainable Sparse Attention via Hybrid Top-k+Top-p Masking and Distillation Fine-Tuning

TL;DR

SpargeAttention2 is proposed, a trainable sparse attention method that achieves high sparsity without degrading generation quality, and is consistently outperforming prior sparse attention methods.

Abstract

Many training-free sparse attention methods are effective for accelerating diffusion models. Recently, several works suggest that making sparse attention trainable can further increase sparsity while preserving generation quality. We study three key questions: (1) when do the two common masking rules, i.e., Top-k and Top-p, fail, and how can we avoid these failures? (2) why can trainable sparse attention reach higher sparsity than training-free methods? (3) what are the limitations of fine-tuning sparse attention using the diffusion loss, and how can we address them? Based on this analysis, we propose SpargeAttention2, a trainable sparse attention method that achieves high sparsity without degrading generation quality. SpargeAttention2 includes (i) a hybrid masking rule that combines Top-k and Top-p for more robust masking at high sparsity, (ii) an efficient trainable sparse attention implementation, and (iii) a distillation-inspired fine-tuning objective to better preserve generation quality during fine-tuning using sparse attention. Experiments on video diffusion models show that SpargeAttention2 reaches 95% attention sparsity and a 16.2x attention speedup while maintaining generation quality, consistently outperforming prior sparse attention methods.
Paper Structure (25 sections, 19 equations, 4 figures, 6 tables, 2 algorithms)

This paper contains 25 sections, 19 equations, 4 figures, 6 tables, 2 algorithms.

Figures (4)

  • Figure 1: Qualitative examples of text-to-video generation. We compare the original full-attention model with SpargeAttention2 under high attention sparsity. SpargeAttention2 preserves visual quality, temporal coherence, and text–video alignment comparable to full attention, while substantially reducing attention computation. The prompts used for generation is in Appendix \ref{['app:prompts']}
  • Figure 2: Uniform and skewed heatmap examples for Case \ref{['case1']}.
  • Figure 3: Heatmaps before and after fine-tuning for Case \ref{['case2']}.
  • Figure 4: A representative example of text-to-video generation under high attention sparsity, evaluated on Wan2.1-14B at 720p. SpargeAttention2 produces a semantically correct video. In contrast, SLA and VSA produce videos in which the male character walks backward, while VMoBA fails to generate the female character specified in the prompt. The prompt used for generation is in Appendix \ref{['app:prompts']}