arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2406.17343cs.CVcs.AI
收藏

Q-DiT:面向扩散 Transformer 的精确训练后量化

Q-DiT: Accurate Post-Training Quantization for Diffusion Transformers

Tsinghua University(清华大学);MMLab, CUHK(香港中文大学MMLab);Shenzhen Technology University(深圳技术大学)

Lei Chen, Yuan Meng, Chen Tang, Xinzhu Ma, Jingyan Jiang, Xin Wang, Zhi Wang, Wenwu Zhu

AI总结:

针对扩散 Transformer 量化中权重与激活的时空方差问题,提出 Q-DiT 方法,通过自动量化粒度分配和逐样本动态激活量化,在 W6A8 和 W4A8 设置下显著提升图像与视频生成质量。

摘要:

扩散模型的最新进展,特别是从基于 UNet 的模型向扩散 Transformer(DiTs)的架构转变,显著提升了图像和视频生成的质量与可扩展性。然而,尽管这些大规模模型能力出众,其高昂的计算成本给实际部署带来了重大挑战。训练后量化(PTQ)作为一种有前景的解决方案应运而生,它能够在无需昂贵重训练的情况下,对预训练模型进行压缩并加速推理。然而,关于 DiT 量化的研究仍然较少,且现有的 PTQ 框架主要针对传统扩散模型设计,往往存在偏置量化问题,导致性能明显下降。在本工作中,我们发现 DiTs 通常在权重和激活上表现出显著的空间方差,同时在激活上表现出时间方差。为解决这些问题,我们提出 Q-DiT,这是一种新颖的方法,无缝整合了两项关键技术:自动量化粒度分配,用于处理权重和激活在输入通道上的显著方差;以及逐样本动态激活量化,用于自适应地捕捉激活在时间步和样本间的变化。在 ImageNet 和 VBench 上进行的大量实验证明了所提出的 Q-DiT 的有效性。具体而言,在 ImageNet($256 \times 256$)上将 DiT-XL/2 量化为 W6A8 时,与基线相比,Q-DiT 实现了 FID 显著降低 1.09。在更具挑战性的 W4A8 设置下,它仍能在图像和视频生成中保持高保真度,为 DiTs 的高效、高质量量化建立了新的基准。代码可在 \href{https://github.com/Juanerx/Q-DiT}{https://github.com/Juanerx/Q-DiT} 获取。

英文摘要:

Recent advancements in diffusion models, particularly the architectural transformation from UNet-based models to Diffusion Transformers (DiTs), significantly improve the quality and scalability of image and video generation. However, despite their impressive capabilities, the substantial computational costs of these large-scale models pose significant challenges for real-world deployment. Post-Training Quantization (PTQ) emerges as a promising solution, enabling model compression and accelerated inference for pretrained models, without the costly retraining. However, research on DiT quantization remains sparse, and existing PTQ frameworks, primarily designed for traditional diffusion models, tend to suffer from biased quantization, leading to notable performance degradation. In this work, we identify that DiTs typically exhibit significant spatial variance in both weights and activations, along with temporal variance in activations. To address these issues, we propose Q-DiT, a novel approach that seamlessly integrates two key techniques: automatic quantization granularity allocation to handle the significant variance of weights and activations across input channels, and sample-wise dynamic activation quantization to adaptively capture activation changes across both timesteps and samples. Extensive experiments conducted on ImageNet and VBench demonstrate the effectiveness of the proposed Q-DiT. Specifically, when quantizing DiT-XL/2 to W6A8 on ImageNet ($256 \times 256$), Q-DiT achieves a remarkable reduction in FID by 1.09 compared to the baseline. Under the more challenging W4A8 setting, it maintains high fidelity in image and video generation, establishing a new benchmark for efficient, high-quality quantization in DiTs. Code is available at \href{https://github.com/Juanerx/Q-DiT}{https://github.com/Juanerx/Q-DiT}.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑