arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2405.16005cs.CV
收藏

PTQ4DiT:面向扩散 Transformer 的训练后量化

PTQ4DiT: Post-training Quantization for Diffusion Transformers

University of Illinois Chicago(伊利诺伊大学芝加哥分校);Illinois Institute of Technology(伊利诺伊理工学院);University of Central Florida(中佛罗里达大学)

Junyi Wu, Haoxuan Wang, Yuzhang Shang, Mubarak Shah, Yan Yan

AI总结:

本文针对扩散 Transformer 推理计算开销大的问题,提出专用训练后量化方法 PTQ4DiT,通过通道显著性均衡与时间校准解决显著通道和时序变异挑战,首次实现 W4A8 量化并保持生成性能。

摘要:

近年来提出的扩散 Transformer(DiTs)通过采用不同的骨干架构,摆脱了传统 U-Net 并充分利用 Transformer 的可扩展特性,在图像生成方面展现出卓越能力。尽管 DiTs 能力先进,但其广泛部署,尤其是面向实时应用时,目前仍受到推理阶段巨大计算需求的制约。训练后量化(Post-training Quantization,PTQ)作为一种快速且数据高效的解决方案应运而生,它通过使用低位宽权重和激活值,能够显著降低计算量和内存占用。然而,PTQ 在 DiTs 上的适用性尚未被探索,并且由于 DiTs 的独特设计而面临不小的困难。本文提出了 PTQ4DiT,一种专门为 DiTs 设计的 PTQ 方法。我们发现 DiTs 中固有的两个主要量化挑战,即存在具有极端幅值的显著通道,以及显著激活分布在多个时间步上具有时间变异性。为应对这些挑战,我们提出了逐通道显著性均衡(Channel-wise Salience Balancing,CSB)和 Spearman $\ ho$ 引导的显著性校准(Spearmen's $\ ho$-guided Salience Calibration,SSC)。CSB 利用通道幅值的互补特性来重新分配极端值,从而同时减轻激活值和权重的量化误差。SSC 在此基础上通过动态调整均衡后的显著性来捕捉激活中的时间变化。此外,为消除 PTQ4DiT 在推理期间带来的额外计算开销,我们为 DiTs 设计了一种离线重参数化策略。实验表明,我们的 PTQ4DiT 成功将 DiTs 量化到 8 位精度(W8A8),同时保持相当的生成能力,并首次进一步实现了有效的 4 位权重量化(W4A8)。

英文摘要:

The recent introduction of Diffusion Transformers (DiTs) has demonstrated exceptional capabilities in image generation by using a different backbone architecture, departing from traditional U-Nets and embracing the scalable nature of transformers. Despite their advanced capabilities, the wide deployment of DiTs, particularly for real-time applications, is currently hampered by considerable computational demands at the inference stage. Post-training Quantization (PTQ) has emerged as a fast and data-efficient solution that can significantly reduce computation and memory footprint by using low-bit weights and activations. However, its applicability to DiTs has not yet been explored and faces non-trivial difficulties due to the unique design of DiTs. In this paper, we propose PTQ4DiT, a specifically designed PTQ method for DiTs. We discover two primary quantization challenges inherent in DiTs, notably the presence of salient channels with extreme magnitudes and the temporal variability in distributions of salient activation over multiple timesteps. To tackle these challenges, we propose Channel-wise Salience Balancing (CSB) and Spearmen's $ρ$-guided Salience Calibration (SSC). CSB leverages the complementarity property of channel magnitudes to redistribute the extremes, alleviating quantization errors for both activations and weights. SSC extends this approach by dynamically adjusting the balanced salience to capture the temporal variations in activation. Additionally, to eliminate extra computational costs caused by PTQ4DiT during inference, we design an offline re-parameterization strategy for DiTs. Experiments demonstrate that our PTQ4DiT successfully quantizes DiTs to 8-bit precision (W8A8) while preserving comparable generation ability and further enables effective quantization to 4-bit weight precision (W4A8) for the first time.

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

↑