SVDQunat: 4비트 확산 모델에서 저랭크 성분을 통한 이상치 흡수
SVDQunat: Absorbing Outliers by Low-Rank Components for 4-Bit Diffusion Models
November 7, 2024
저자: Muyang Li, Yujun Lin, Zhekai Zhang, Tianle Cai, Xiuyu Li, Junxian Guo, Enze Xie, Chenlin Meng, Jun-Yan Zhu, Song Han
cs.AI
초록
디퓨전 모델은 고품질 이미지 생성에 매우 효과적인 것으로 입증되었습니다. 그러나 이러한 모델의 규모가 커짐에 따라 더 많은 메모리를 필요로 하고 높은 지연 시간을 겪게 되어 배포에 상당한 어려움을 초래합니다. 본 연구에서는 디퓨전 모델의 가중치와 활성화를 4비트로 양자화하여 가속화하는 것을 목표로 합니다. 이처럼 공격적인 수준에서 가중치와 활성화는 모두 매우 민감하며, 대형 언어 모델에 대한 기존의 훈련 후 양자화 방법(예: 평활화)은 불충분합니다. 이러한 한계를 극복하기 위해 우리는 SVDQuant라는 새로운 4비트 양자화 패러다임을 제안합니다. 가중치와 활성화 사이의 이상치를 재분배하는 평활화와 달리, 우리의 접근 방식은 저랭크 분기를 사용하여 이러한 이상치를 흡수합니다. 먼저 활성화에서 가중치로 이상치를 이동시켜 통합한 다음, 특이값 분해(SVD)를 통해 고정밀 저랭크 분기가 가중치 이상치를 처리하도록 합니다. 이 과정은 양쪽의 양자화를 용이하게 합니다. 그러나 저랭크 분기를 독립적으로 실행하면 활성화의 추가 데이터 이동으로 인해 상당한 오버헤드가 발생하여 양자화의 속도 향상 효과를 상쇄시킵니다. 이를 해결하기 위해 우리는 저랭크 분기의 커널을 저비트 분기의 커널에 융합하여 불필요한 메모리 접근을 차단하는 추론 엔진 Nunchaku를 공동 설계했습니다. 또한 이 엔진은 재양자화 없이도 기존의 저랭크 어댑터(LoRA)를 원활하게 지원할 수 있습니다. SDXL, PixArt-Sigma, FLUX.1에 대한 광범위한 실험을 통해 SVDQuant가 이미지 품질을 유지하는 데 효과적임을 검증했습니다. 우리는 12B FLUX.1 모델의 메모리 사용량을 3.5배 줄이고, 16GB 노트북 4090 GPU에서 4비트 가중치 전용 양자화 기준선 대비 3.0배의 속도 향상을 달성하여 PC에서 더 상호작용적인 애플리케이션을 위한 길을 열었습니다. 우리의 양자화 라이브러리와 추론 엔진은 오픈소스로 공개되었습니다.
English
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.