Towards Accurate Post-Training Quantization for Diffusion Models

Changyuan Wang, Ziwei Wang, Xiuwei Xu, Yansong Tang, Jie Zhou, Jiwen Lu

Abstract

Diffusion models have revolutionized image generation but remain computationally intensive due to their iterative denoising process. This paper presents APQ-DM, a novel post-training quantization (PTQ) framework designed to enable efficient deployment on edge devices. By addressing the dynamic nature of activation distributions and the inefficiency of random calibration, APQ-DM achieves high-fidelity generation at 6-bit precision. The framework introduces distribution-aware quantization groups and an active calibration strategy based on Structural Risk Minimization (SRM), significantly outperforming existing PTQ methods.

Introduction

State-of-the-art diffusion models, such as Stable Diffusion, require dozens or hundreds of iterative denoising steps, each involving a forward pass through a massive neural network. This computational demand poses a significant barrier to deployment on resource-constrained platforms like mobile phones or robotics. While quantization—reducing numerical precision from 32-bit floats to lower-bit integers—is a standard optimization technique, conventional Post-Training Quantization (PTQ) often fails for diffusion models.

The failure of standard PTQ stems from two primary challenges:

  1. Dynamic Distributions: Unlike static classifiers, a diffusion model's internal activations evolve significantly as noise is transformed into a clean image. Applying a single quantization rule across all timesteps introduces substantial errors.
  2. Uninformative Calibration: Standard PTQ relies on random timestep sampling for calibration, which often misses critical "informative" steps necessary for the model to learn accurate quantization parameters.

Methodology

APQ-DM introduces two core innovations to overcome these challenges: Distribution-aware Quantization and Active Calibration Timestep Selection.

Overview of the APQ-DM framework, illustrating (a) distribution-aware quantization grouping and (b) the active calibration timestep selection process compared to conventional sampling.

Distribution-aware Quantization

Rather than employing a global quantization function, APQ-DM partitions the denoising process into discrete timestep groups (e.g., 8 groups). A differentiable search framework is utilized to automatically assign timesteps to these groups and optimize rounding parameters. This allows the quantization logic to adapt to the specific noise levels present at different stages of generation, minimizing both clipping and rounding errors.

Active Calibration Timestep Selection

To improve calibration efficiency, the authors move away from random sampling. Instead, they apply the Structural Risk Minimization (SRM) principle to identify "difficult" timesteps characterized by high uncertainty or entropy in quantization weights. By focusing the calibration process on these informative steps, the model achieves superior generalization with a smaller set of calibration samples (e.g., 1024 images).

Experimental Evaluation

The researchers evaluated APQ-DM across diverse benchmarks, including unconditional generation (CIFAR-10, CelebA, LSUN-Bedroom/Church), high-resolution latent diffusion (CelebA-HQ), and conditional generation (ImageNet).

Key Results

APQ-DM establishes a new state-of-the-art for PTQ in diffusion models:

  • 6-bit Precision (W6A6): On the LSUN-Bedroom dataset, APQ-DM achieved an FID score of 15.72, a significant improvement over the previous best of 17.57 (Q-Diffusion). Lower FID scores indicate higher image quality and diversity.
  • 8-bit Precision (W8A8): Performance is nearly identical to the full-precision (FP32) baseline. For CIFAR-10, APQ-DM reached an FID of 4.24, compared to the baseline's 4.23.
  • Visual Fidelity: Qualitative assessments confirm that APQ-DM maintains sharp edges and realistic textures at 6-bit precision, where earlier methods often produced blurry or distorted results.

Discussion and Insights

The success of APQ-DM highlights that a diffusion model should be treated as a sequence of evolving functions rather than a static entity. The "moving target" of activation distributions requires a temporal-aware quantization strategy. Furthermore, the results demonstrate that the quality of calibration data is more critical than quantity; selecting informative timesteps via SRM allows for high-performance quantization with minimal data overhead.

Limitations and Future Work

While APQ-DM offers significant improvements, some challenges remain. The differentiable search phase introduces additional post-training overhead, and the number of quantization groups is currently a fixed hyperparameter. Future research could explore more flexible, hardware-aware partitioning strategies. Additionally, achieving accurate results at ultra-low bit-widths (e.g., 4-bit or 2-bit) remains an open problem for PTQ without full model retraining.

Summary updated

BibTeX
@inproceedings{wang2024towards,
  author = {Changyuan Wang and Ziwei Wang and Xiuwei Xu and Yansong Tang and Jie Zhou and Jiwen Lu},
  title = {{Towards Accurate Post-Training Quantization for Diffusion Models}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2024},
  doi = {10.1109/cvpr52733.2024.01517},
}
Figure