SLA:通过可微调稀疏-线性注意力突破扩散Transformer的稀疏性限制
SLA: Beyond Sparsity in Diffusion Transformers via Fine-Tunable Sparse-Linear Attention
AI总结:
针对扩散Transformer注意力计算的二次复杂度瓶颈,提出可微调的SLA稀疏-线性注意力方法,融合两类注意力机制并优化GPU内核,可大幅降低计算量、实现显著加速且不损失生成质量。
摘要:
在以视频生成为代表的扩散Transformer(DiT)模型中,长序列长度与注意力的二次复杂度导致注意力延迟成为主要性能瓶颈。我们研究发现,注意力权重可拆分为两部分:占比很小的高秩大权重,以及剩余的极低秩权重,这一特性天然适配对前者采用稀疏加速、对后者采用低秩加速的方案。基于该发现,我们提出SLA(Sparse-Linear Attention,稀疏-线性注意力),这是一种融合稀疏注意力与线性注意力的可训练注意力方法,可加速扩散模型。SLA将注意力权重划分为关键、边缘、可忽略三类,对关键权重应用O(N²)注意力计算,对边缘权重应用O(N)注意力计算,跳过可忽略权重的计算。SLA将上述计算整合到单个GPU内核中,同时支持前向与反向传播。仅需使用SLA进行少量微调步骤,DiT模型的注意力计算量即可降低20倍,在不损失生成质量的前提下实现显著加速。实验表明,SLA可减少95%的注意力计算量,且不会降低端到端生成质量,性能优于基线方法。此外,我们为SLA实现了高效GPU内核,在Wan2.1-1.3B模型上实现了13.7倍的注意力计算加速,以及2.2倍的视频生成端到端加速。代码可在https://github.com/thu-ml/SLA获取。
英文摘要:
In Diffusion Transformer (DiT) models, particularly for video generation, attention latency is a major bottleneck due to the long sequence length and the quadratic complexity. We find that attention weights can be separated into two parts: a small fraction of large weights with high rank and the remaining weights with very low rank. This naturally suggests applying sparse acceleration to the first part and low-rank acceleration to the second. Based on this finding, we propose SLA (Sparse-Linear Attention), a trainable attention method that fuses sparse and linear attention to accelerate diffusion models. SLA classifies attention weights into critical, marginal, and negligible categories, applying O(N^2) attention to critical weights, O(N) attention to marginal weights, and skipping negligible ones. SLA combines these computations into a single GPU kernel and supports both forward and backward passes. With only a few fine-tuning steps using SLA, DiT models achieve a 20x reduction in attention computation, resulting in significant acceleration without loss of generation quality. Experiments show that SLA reduces attention computation by 95% without degrading end-to-end generation quality, outperforming baseline methods. In addition, we implement an efficient GPU kernel for SLA, which yields a 13.7x speedup in attention computation and a 2.2x end-to-end speedup in video generation on Wan2.1-1.3B. The code is available at https://github.com/thu-ml/SLA.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。