Trainable Log-linear Sparse Attention for Efficient Diffusion Transformers
本文提出了一种名为Log-linear Sparse Attention (LLSA)的新颖注意力机制,通过利用分层结构和高效的GPU实现,将扩散Transformer(DiT)的注意力计算复杂度从二次方降低到对数线性,从而有效提升了长序列DiT的训练效率。
更新于 2026-11-18。作者:Yifan Zhou、Zeqi Xiao、Tianyi Wei、Shuai Yang、Xingang Pan。
中文摘要
扩散变换器(DiTs)在视觉生成领域达到了最先进的水平,但它们的二次自注意力成本从根本上限制了扩展到长标记序列。最近的一些Top-K稀疏注意力方法通过将标记压缩成块状表示并选择一小组相关键块来减少DiTs的计算量,但仍然存在(i)压缩标记上的二次选择成本和(ii)随着序列增长而增加的K值以维持模型质量的问题。我们确定其低效是由于单级设计,因为单级粗糙级别不足以表示全局结构。在这篇论文中,我们介绍了对数线性稀疏注意力(LLSA),这是一种用于极长标记序列的可训练稀疏注意力机制,通过利用分层结构将选择和注意力成本从二次降低到对数线性复杂度。LLSA执行分层Top-K选择,逐步采用在前一级别找到的索引进行稀疏Top-K选择,并引入了一种分层KV丰富机制,在注意力计算过程中使用更少的具有不同粒度的标记,同时保留全局上下文。为了支持高效训练,我们开发了一种高性能GPU实现,该实现仅使用稀疏索引进行正向和反向传播,消除了对密集注意力掩码的需求。我们在不使用补丁化和VAE编码的情况下,对高分辨率像素空间图像生成进行了LLSA的评估。LLSA在256x256像素标记序列上加速了注意力推理28.27倍,并加速了DiT训练6.09倍,同时保持了生成质量。结果表明,LLSA为高效训练长序列DiT提供了一种有前景的方向。代码可在以下网址获取:https://github.com/SingleZombie/LLSA
英文摘要
Diffusion Transformers (DiTs) set the state of the art in visual generation, yet their quadratic self-attention cost fundamentally limits scaling to long token sequences. Recent Top-K sparse attention approaches reduce the computation of DiTs by compressing tokens into block-wise representation and selecting a small set of relevant key blocks, but still suffer from (i) quadratic selection cost on compressed tokens and (ii) increasing K required to maintain model quality as sequences grow. We identify that their inefficiency is due to the single-level design, as a single coarse level is insufficient to represent the global structure. In this paper, we introduce Log-linear Sparse Attention (LLSA), a trainable sparse attention mechanism for extremely long token sequences that reduces both selection and attention costs from quadratic to log-linear complexity by utilizing a hierarchical structure. LLSA performs hierarchical Top-K selection, progressively adopting sparse Top-K selection with the indices found at the previous level, and introduces a Hierarchical KV Enrichment mechanism that preserves global context while using fewer tokens of different granularity during attention computation. To support efficient training, we develop a high-performance GPU implementation that uses only sparse indices for both the forward and backward passes, eliminating the need for dense attention masks. We evaluate LLSA on high-resolution pixel-space image generation without using patchification and VAE encoding. LLSA accelerates attention inference by 28.27x and DiT training by 6.09x on 256x256 pixel token sequences, while maintaining generation quality. The results demonstrate that LLSA offers a promising direction for training long-sequence DiTs efficiently. Code is available at: https://github.com/SingleZombie/LLSA
解读
一句话总结
本文提出了一种名为Log-linear Sparse Attention (LLSA)的新颖注意力机制,通过利用分层结构和高效的GPU实现,将扩散Transformer(DiT)的注意力计算复杂度从二次方降低到对数线性,从而有效提升了长序列DiT的训练效率。
问题1:这篇论文想要解决什么具体问题?
- 问题背景:扩散Transformer(DiT)在视觉生成任务中表现出色,但其二次方的自注意力成本限制了其在长序列上的扩展。
- 现有方案不足:现有的Top-K稀疏注意力方法虽然减少了DiT的计算量,但仍然存在二次方选择成本和随着序列增长而增加的K值问题。
- 研究目标:提出一种新的稀疏注意力机制,以降低选择和注意力成本,并支持长序列DiT的高效训练。
问题2:论文的核心创新点是什么?
- 技术创新:引入Log-linear Sparse Attention (LLSA),通过分层结构降低注意力计算复杂度。
- 方法改进:采用分层Top-K选择和分层KV增强机制,以减少信息损失并保持全局上下文。
- 优势:与现有方法相比,LLSA在保持生成质量的同时,显著提高了训练效率。
问题3:实验结果如何验证了方法的有效性?
- 关键实验:在256×256像素的序列上,LLSA将注意力推理加速了28.27倍,将DiT训练加速了6.09倍。
- 性能提升:LLSA在保持生成质量的同时,显著提高了训练效率。
- 对比结果:与现有的Top-K稀疏注意力方法相比,LLSA在生成质量和训练吞吐量上均表现出优势。
问题4:这个研究的实际应用价值是什么?
- 应用场景:LLSA适用于长序列DiT的训练,如高分辨率图像生成。
- 实施建议:建议在训练高分辨率图像生成模型时采用LLSA。
- 局限与展望:LLSA的局限性在于其依赖于高效的GPU实现,未来可以进一步研究其在不同硬件平台上的适应性。