不需训练即可加速扩散Transformer,生成8192×8192图像提速35.8倍
Grouping First, Attending Smartly: Training-Free Acceleration for Diffusion Transformers
- 先分组后共享注意力,利用预训练模型的局部关注特性
- 在8192×8192图像生成上实现35.8倍加速,质量无损
- 适用于图像视频生成,无需微调,适合部署场景
基于扩散的Transformer虽生成效果出色,但计算成本高昂,例如在A100 GPU上生成8192×8192图像需超过一小时。本文提出GRAT(Grouping first, Attending smartly),一种无需训练的注意力加速策略,可在不损失输出质量的前提下实现快速图像与视频生成。核心思路是利用预训练扩散Transformer中注意力图的固有稀疏性(通常局部聚焦),并优化GPU并行效率。GRAT首先将连续标记划分为不重叠的组,与GPU执行模式及模型学习到的局部注意力结构对齐;随后,同组内所有查询标记共享一组可关注的键值标记,且这些键值被限制在特定区域(如邻近块或十字形区域),显著降低计算开销(生成8192×8192图像时达35.8倍加速),同时保留关键注意力模式和长程上下文。我们在预训练的Flux和HunyuanVideo上验证了GRAT,均实现大幅推理加速,无需任何微调,性能等同于完整注意力。希望GRAT能推动扩散Transformer在大规模视觉生成中的应用。
原文摘要 · Abstract (English)
Diffusion-based Transformers have demonstrated impressive generative capabilities, but their high computational costs hinder practical deployment, for example, generating an $8192\times 8192$ image can take over an hour on an A100 GPU. In this work, we propose GRAT (\textbf{GR}ouping first, \textbf{AT}tending smartly), a training-free attention acceleration strategy for fast image and video generation without compromising output quality. The key insight is to exploit the inherent sparsity in learned attention maps (which tend to be locally focused) in pretrained Diffusion Transformers and leverage better GPU parallelism. Specifically, GRAT first partitions contiguous tokens into non-overlapping groups, aligning both with GPU execution patterns and the local attention structures learned in pretrained generative Transformers. It then accelerates attention by having all query tokens within the same group share a common set of attendable key and value tokens. These key and value tokens are further restricted to structured regions, such as surrounding blocks or criss-cross regions, significantly reducing computational overhead (e.g., attaining a \textbf{35.8$\times$} speedup over full attention when generating $8192\times 8192$ images) while preserving essential attention patterns and long-range context. We validate GRAT on pretrained Flux and HunyuanVideo for image and video generation, respectively. In both cases, GRAT achieves substantially faster inference without any fine-tuning, while maintaining the performance of full attention. We hope GRAT will inspire future research on accelerating Diffusion Transformers for scalable visual generation.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。