SVDQunat: Absorbing Outliers by Low-Rank Components for 4-Bit Diffusion Models
该论文提出了一种名为SVDQuant的4位量化方法,通过低秩分支吸收异常值,从而有效加速扩散模型并保持图像质量。
更新于 2024-11-09。作者:Muyang Li、Yujun Lin、Zhekai Zhang、Tianle Cai、Xiuyu Li、Junxian Guo、Enze Xie、Chenlin Meng、Jun-Yan Zhu、Song Han。
中文摘要
扩散模型已被证明在生成高质量图像方面非常有效。然而,随着这些模型规模的扩大,它们需要更多的内存,并且具有更高的延迟,这对部署构成了重大挑战。在本工作中,我们旨在通过将模型的权重和激活量化为4位来加速扩散模型。在如此激进的水平上,权重和激活都极其敏感,传统的大型语言模型后训练量化方法,如平滑,变得不足以应对。为了克服这一限制,我们提出了SVDQuant,一种新的4位量化范式。与平滑不同,平滑将异常值在权重和激活之间重新分配,我们的方法使用低秩分支来吸收这些异常值。我们首先通过将异常值从激活转移到权重中巩固这些异常值,然后利用高精度的低秩分支通过奇异值分解(SVD)来吸收权重异常值。这一过程简化了双方的量化。然而,简单独立地运行低秩分支会因额外的激活数据移动而产生显著的开销,从而抵消了量化速度的提升。为了解决这个问题,我们协同设计了一个推理引擎Nunchaku,将低秩分支的核心融合到低比特分支的核心中,以切断冗余的内存访问。它还可以无缝支持现成的低秩适配器(LoRAs)而无需重新量化。在SDXL、PixArt-Sigma和FLUX.1上的大量实验验证了SVDQuant在保留图像质量方面的有效性。我们降低了12B FLUX.1模型的内存使用量,将其减少了3.5倍,在16GB笔记本电脑4090 GPU上,相较于仅对权重进行4位量化的基线,实现了3.0倍的加速,为PC上更互动的应用铺平了道路。我们的量化库和推理引擎已开源。
英文摘要
Diffusion models have been proven highly effective at generating high-quality images. However, as these models grow larger, they require significantly more memory and suffer from higher latency, posing substantial challenges for deployment. In this work, we aim to accelerate diffusion models by quantizing their weights and activations to 4 bits. At such an aggressive level, both weights and activations are highly sensitive, where conventional post-training quantization methods for large language models like smoothing become insufficient. To overcome this limitation, we propose SVDQuant, a new 4-bit quantization paradigm. Different from smoothing which redistributes outliers between weights and activations, our approach absorbs these outliers using a low-rank branch. We first consolidate the outliers by shifting them from activations to weights, then employ a high-precision low-rank branch to take in the weight outliers with Singular Value Decomposition (SVD). This process eases the quantization on both sides. However, na\"{\i}vely running the low-rank branch independently incurs significant overhead due to extra data movement of activations, negating the quantization speedup. To address this, we co-design an inference engine Nunchaku that fuses the kernels of the low-rank branch into those of the low-bit branch to cut off redundant memory access. It can also seamlessly support off-the-shelf low-rank adapters (LoRAs) without the need for re-quantization. Extensive experiments on SDXL, PixArt-Sigma, and FLUX.1 validate the effectiveness of SVDQuant in preserving image quality. We reduce the memory usage for the 12B FLUX.1 models by 3.5times, achieving 3.0times speedup over the 4-bit weight-only quantized baseline on the 16GB laptop 4090 GPU, paving the way for more interactive applications on PCs. Our quantization library and inference engine are open-sourced.
解读
一句话总结
该论文提出了一种名为SVDQuant的4位量化方法,通过低秩分支吸收异常值,从而有效加速扩散模型并保持图像质量。
问题1:这篇论文想要解决什么具体问题?
• 问题背景:扩散模型在生成高质量图像方面表现出色,但随着模型规模的增加,它们需要更多的内存和更高的延迟,这对实际部署构成了挑战。 • 现有方案不足:现有的4位量化方法,如平滑,在处理权重和激活中的异常值时效果不佳。 • 研究目标:提出一种新的4位量化范式,以加速扩散模型,同时保持图像质量。
问题2:论文的核心创新点是什么?
• 技术创新:SVDQuant通过引入低秩分支来吸收权重和激活中的异常值。 • 方法改进:设计了一个名为Nunchaku的推理引擎,将低秩分支的计算内核与低比特计算内核融合,以减少内存访问开销。 • 优势:与现有方法相比,SVDQuant在保持图像质量的同时,显著降低了内存使用量和提高了推理速度。
问题3:实验结果如何验证了方法的有效性?
• 关键实验:在SDXL、PixArt-Σ和FLUX.1上进行的大量实验验证了SVDQuant的有效性。 • 性能提升:与原始的BF16模型相比,SVDQuant将FLUX.1模型的内存使用量减少了3.5倍,并在16GB笔记本电脑上的RTX4090 GPU上实现了3.0倍的速度提升。 • 对比结果:SVDQuant在所有指标上均优于其他4位基线方法,包括ViDiT-Q和MixDQ。
问题4:这个研究的实际应用价值是什么?
• 应用场景:SVDQuant可以用于加速扩散模型在边缘设备上的部署,从而推动交互式AI应用的更广泛应用。 • 实施建议:将SVDQuant与Nunchaku推理引擎一起使用,以实现最佳性能。 • 局限与展望:目前,SVDQuant无法报告FP4模型的加速效果,因为缺乏对Blackwell GPU的访问。未来研究可以探索在更广泛的硬件平台上实现SVDQuant。
来源
机器可读索引:llms.txt