Diffusion Product Quantization

Jie Shao, Hanxiao Zhang, Jianxin WuarXiv 2024 · DOI

Introduction

Diffusion models, such as Stable Diffusion and Diffusion Transformers (DiT), have set the standard for high-fidelity image synthesis. However, their massive parameter counts and iterative sampling processes pose significant challenges for deployment on resource-constrained devices. While quantization is a common strategy to reduce model size, diffusion models are uniquely sensitive to precision loss. Unlike single-pass classifiers, diffusion models run dozens of iterations to generate an image; in this process, minor quantization errors at each step accumulate, often leading to a total "performance collapse" where the model generates only noise.

Researchers from Nanjing University have introduced Diffusion Product Quantization (DPQ), a framework designed to compress DiTs down to as low as 1-bit per weight. By leveraging product quantization and a novel codebook compression strategy, they achieved a 24× reduction in model size while maintaining high image generation quality, significantly outperforming existing low-bit quantization methods.

The Challenge: Iterative Error Accumulation

Standard Vector Quantization (VQ) struggles at extreme compression levels (1-2 bits) because representing high-dimensional weight vectors with a limited "codebook" (a dictionary of representative vectors) is inherently imprecise. In diffusion models, these errors snowball over sampling steps. The paper quantifies this phenomenon, showing how DPQ's higher representational capacity effectively flattens the error curve, keeping the model on track during the long sampling process.

Methodology

DPQ revamps classical product quantization for generative models through three key innovations:

  1. Product Quantization (PQ): Instead of finding one representative codeword for a large weight chunk, PQ splits the weight vector into multiple low-dimensional subspaces. Each subspace has its own codebook, allowing the model to represent an exponentially larger variety of weight patterns with only a linear increase in storage.
  2. Codebook Pool Compression: To prevent the overhead of storing many codebooks from negating compression gains, the authors use a "codebook pool." Centroids are ranked by usage frequency and similar ones are merged, ensuring the "dictionary" remains compact.
  3. Two-Stage Calibration:
    • Forward Pass: The model adjusts weight assignments to minimize reconstruction error in the activations (the data flowing through the model).
  4. Backward Pass: Codebook entries are fine-tuned using the actual DDPM loss (the diffusion training objective), optimizing the quantized weights specifically for image generation.

Key Results

DPQ demonstrates remarkable resilience at ultra-low bit-widths. At 1-bit quantization, DPQ achieved an FID of 14.03 on ImageNet, whereas standard VQ collapsed completely with an unusable FID of 91.71. At 2-bits, DPQ reached an FID of 6.84, nearly matching the original uncompressed model's FID of 5.33.

Figure 1: FID performance across different bit-widths. DPQ (red) maintains high quality even at 1-bit, while other methods fail or collapse.

Qualitative results further highlight the effectiveness of the two-stage calibration. Without it, low-bit models often fail to produce coherent structures. DPQ, particularly with calibration, preserves the semantic integrity of the generated images even at 1-bit and 2-bit levels.

Figure 4: Qualitative comparison of image generation. DPQ with calibration successfully reconstructs images at 1-bit and 2-bit levels where standard quantization fails.

Conclusion and Future Work

DPQ represents a significant step toward making state-of-the-art diffusion models accessible on edge devices. While it achieves massive storage savings (over 24×), the authors note that specialized hardware kernels are still required to translate these memory gains into real-world inference speedups. Future work will focus on developing these optimized kernels to enable fast, low-memory generative AI on mobile platforms.

Summary updated

BibTeX
@misc{shao2024diffusion,
  author = {Jie Shao and Hanxiao Zhang and Jianxin Wu},
  title = {{Diffusion Product Quantization}},
  year = {2024},
  eprint = {2411.12306},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2411.12306},
}
Figure