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

VQ4DiT:面向扩散变换器的高效训练后向量量化

VQ4DiT: Efficient Post-Training Vector Quantization for Diffusion Transformers

Zhejiang University(浙江大学);vivo Mobile Communication Co., Ltd(维沃移动通信有限公司)

Juncan Deng, Shuaiting Li, Zeyu Wang, Hong Gu, Kedong Xu, Kejie Huang

AI总结:

本文提出VQ4DiT训练后向量量化方法,通过同时校准码本和分配关系,在单块A100 GPU上高效将扩散变换器量化至2比特,实现模型大小与性能的新最优平衡。

摘要:

扩散变换器模型(DiTs)已将网络架构从传统UNet转变为Transformer,在图像生成方面展现出卓越能力。尽管DiTs已广泛应用于高清视频生成任务,但其庞大的参数量阻碍了在边缘设备上的推理。向量量化(VQ)可以将模型权重分解为码本和分配关系,实现极端权重量化并显著降低内存占用。本文提出VQ4DiT,一种面向DiTs的快速训练后向量量化方法。我们发现传统VQ方法仅校准码本而不校准分配关系,这导致权重子向量被错误地分配到同一分配项,向码本提供不一致的梯度,从而产生次优结果。为解决这一挑战,VQ4DiT基于欧氏距离为每个权重子向量计算候选分配集,并基于加权平均重建子向量。然后,利用零数据和逐块校准方法,在高效地从候选集中选择最优分配的同时校准码本。根据不同的量化设置,VQ4DiT可在单块NVIDIA A100 GPU上于20分钟至5小时内完成DiT XL/2模型的量化。实验表明,VQ4DiT在模型大小与性能权衡方面建立了新的最优水平,将权重量化至2比特精度,同时保持可接受的图像生成质量。

英文摘要:

The Diffusion Transformers Models (DiTs) have transitioned the network architecture from traditional UNets to transformers, demonstrating exceptional capabilities in image generation. Although DiTs have been widely applied to high-definition video generation tasks, their large parameter size hinders inference on edge devices. Vector quantization (VQ) can decompose model weight into a codebook and assignments, allowing extreme weight quantization and significantly reducing memory usage. In this paper, we propose VQ4DiT, a fast post-training vector quantization method for DiTs. We found that traditional VQ methods calibrate only the codebook without calibrating the assignments. This leads to weight sub-vectors being incorrectly assigned to the same assignment, providing inconsistent gradients to the codebook and resulting in a suboptimal result. To address this challenge, VQ4DiT calculates the candidate assignment set for each weight sub-vector based on Euclidean distance and reconstructs the sub-vector based on the weighted average. Then, using the zero-data and block-wise calibration method, the optimal assignment from the set is efficiently selected while calibrating the codebook. VQ4DiT quantizes a DiT XL/2 model on a single NVIDIA A100 GPU within 20 minutes to 5 hours depending on the different quantization settings. Experiments show that VQ4DiT establishes a new state-of-the-art in model size and performance trade-offs, quantizing weights to 2-bit precision while retaining acceptable image generation quality.

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

↑