提升视频生成效率,让注意力聚焦更准且不丢信息
Rectified SpaAttn: Revisiting Attention Sparsity for Efficient Video Generation

- 用隐式全注意力参考修正稀疏注意力分配偏差
- 在保持画质前提下,速度最高提升3.33倍
- 适合追求高效视频生成的开发者和研究者
扩散变换器主导视频生成,但注意力计算的二次复杂度导致显著延迟。注意力稀疏化通过聚焦关键帧而忽略非关键帧来降低计算开销,但现有方法导致性能严重下降。本文重新审视注意力稀疏性,发现现有方法存在系统性偏差:(1) 对关键帧过度关注,放大其注意力权重;(2) 完全忽略非关键帧,造成相关注意力丢失。为此提出 Rectified SpaAttn,通过隐式全注意力参考修正注意力分配,增强稀疏与全注意力图对齐。具体而言:(1) 针对关键帧,提出孤立池化注意力重分配,通过多模态池化权重重构校正因子;(2) 针对非关键帧,提出增益感知池化校正,确保校正增益始终超过池化误差。此外,基于 Triton 定制并集成 Rectified SpaAttn 核函数,在 HunyuanVideo 与 Wan 2.1 上分别实现最高 3.33 倍和 2.08 倍加速,同时维持高质量生成。代码已开源:https://github.com/BienLuky/Rectified-SpaAttn。
原文摘要 · Abstract (English)
Diffusion Transformers dominate video generation, but the quadratic complexity of attention computation introduces substantial latency. Attention sparsity reduces computational costs by focusing on critical tokens while ignoring non-critical tokens. However, existing methods suffer from severe performance degradation. In this paper, we revisit attention sparsity and reveal that existing methods induce systematic biases in attention allocation: (1) excessive focus on critical tokens amplifies their attention weights; (2) complete neglect of non-critical tokens causes the loss of relevant attention weights. To address these issues, we propose Rectified SpaAttn, which rectifies attention allocation with implicit full attention reference, thereby enhancing the alignment between sparse and full attention maps. Specifically: (1) for critical tokens, we show that their bias is proportional to the sparse attention weights, with the ratio governed by the amplified weights. Accordingly, we propose Isolated-Pooling Attention Reallocation, which calculates accurate rectification factors by reallocating multimodal pooled weights. (2) for non-critical tokens, recovering attention weights from the pooled query-key yields attention gains but also introduces pooling errors. Therefore, we propose Gain-Aware Pooling Rectification, which ensures that the rectified gain consistently surpasses the induced error. Moreover, we customize and integrate the Rectified SpaAttn kernel using Triton, achieving up to 3.33 and 2.08 times speedups on HunyuanVideo and Wan 2.1, respectively, while maintaining high generation quality. We release Rectified SpaAttn as open-source at https://github.com/BienLuky/Rectified-SpaAttn .
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。