Post-training Quantization with Progressive Calibration and Activation Relaxing for Text-to-Image Diffusion Models

Siao Tang, Xin Wang, Hong Chen, Chaoyu Guan, Zewen Wu, Yansong Tang, Wenwu Zhu

Introduction

Text-to-image diffusion models like Stable Diffusion XL (SDXL) have achieved remarkable generative capabilities but at a high computational cost. With billions of parameters and iterative denoising steps, deploying these models on edge devices is challenging. Post-training quantization (PTQ) offers a path to efficiency by converting 32-bit weights and activations to lower bit-widths (e.g., INT8). However, standard PTQ methods often fail to maintain image quality due to error accumulation across timesteps and the use of inappropriate evaluation metrics.

Challenges in Diffusion Quantization

Existing PTQ approaches face two primary hurdles:

  1. Error Accumulation: Quantization errors introduced in early denoising steps propagate and amplify through subsequent iterations, leading to significant distribution shifts. As shown in Figure 1, the distribution of activations deviates from the full-precision (FP32) baseline as the denoising process progresses.
  2. Evaluation Distribution Gap: Standard metrics like FID compare generated images to the MS-COCO dataset. However, modern diffusion models often generate artistic or stylized content that differs significantly from COCO's photorealistic domain. This can lead to misleading results where a quantized model appears better than the original simply because its noise profile accidentally aligns closer to COCO statistics.
Distribution shift between FP32 and quantized activations across different timesteps.

The PCR Framework

To address these issues, we propose Progressive Calibration and Relaxing (PCR).

Progressive Calibration

Unlike traditional methods that calibrate each timestep independently, PCR employs a step-by-step calibration process. When calibrating at timestep $t$, the model uses input data generated by a version of the model where all preceding steps ($t+1$ to $T$) have already been quantized. This ensures that the calibration process is aware of the accumulated errors from previous steps, effectively "correcting" the trajectory of the denoising process.

The progressive calibration process where each step accounts for quantization in previous steps.

Activation Relaxing and Sensitivity Discrepancy

Analysis reveals a "sensitivity discrepancy" across the denoising process. In models like SDXL, early steps (near noise) are crucial for establishing textual semantics, while later steps (near the final image) refine image fidelity. Quantizing these critical steps leads to specific failure modes, such as a lack of prompt alignment or degraded visual details. PCR "relaxes" the bit-width (e.g., using 10-bit instead of 8-bit) for a small fraction (5-20%) of the most sensitive timesteps, significantly improving quality with minimal impact on overall efficiency.

QDiffBench: A New Evaluation Standard

To provide a more accurate assessment, we introduce QDiffBench. This benchmark utilizes the FID to FP32 metric, which compares the output of the quantized model directly against the output of its full-precision counterpart on the same prompts. This eliminates the domain gap issue and focuses purely on the degradation caused by quantization.

Results and Impact

PCR is the first method to successfully quantize the 3.5B parameter SDXL model while maintaining high performance. In W8A8 configurations, PCR achieved an FID-to-FP32 of 8.35 on Stable Diffusion v1.4, significantly outperforming previous state-of-the-art methods like Q-diffusion (18.64) and PTQ4DM (14.60). Furthermore, the activation relaxing strategy preserves high CLIP scores, ensuring that the quantized models remain faithful to user prompts. The method adds negligible overhead, with an 8-bit model using 5% relaxation averaging approximately 8.1 bits.

Conclusion

By accounting for the iterative nature of diffusion and the varying sensitivity of denoising timesteps, PCR enables efficient, high-quality quantization of large-scale text-to-image models. This work paves the way for deploying state-of-the-art generative AI on resource-constrained hardware without sacrificing creative performance.

Summary updated

BibTeX
@inproceedings{tang2024post,
  author = {Siao Tang and Xin Wang and Hong Chen and Chaoyu Guan and Zewen Wu and Yansong Tang and Wenwu Zhu},
  title = {{Post-training Quantization with Progressive Calibration and Activation Relaxing for Text-to-Image Diffusion Models}},
  booktitle = {European Conference on Computer Vision},
  year = {2024},
  doi = {10.1007/978-3-031-72992-8\_23},
}
Figure