Abstract
Diffusion models have revolutionized image synthesis, setting new benchmarks in quality and creativity. However, their widespread adoption is hindered by the intensive computation required during the iterative denoising process. Post-training quantization (PTQ) presents a solution to accelerate sampling, albeit at the expense of sample quality, particularly in low-bit settings. Addressing this, our study introduces a unified Quantization Noise Correction Scheme (QNCD), aimed at diminishing quantization noise throughout the sampling process. We identify two primary quantization challenges: intra and inter quantization noise. Intra quantization noise, mainly exacerbated by embeddings in the resblock module, extends activation quantization ranges, increasing disturbances in each single denoising step. Additionally, inter quantization noise stems from cumulative quantization deviations across the entire denoising process, altering data distributions step-by-step. QNCD combats these through embedding-derived feature smoothing for eliminating intra quantization noise and an effective runtime noise estimation module for dynamically filtering inter quantization noise. Extensive experiments demonstrate that our method outperforms previous quantization methods for diffusion models, achieving lossless results in W4A8 and W8A8 quantization settings on ImageNet (LDM-4).
Introduction
Diffusion models, such as Stable Diffusion, represent the state-of-the-art in high-fidelity image generation. Despite their success, these models are computationally demanding, requiring numerous iterative denoising steps that involve massive neural network passes. This complexity makes deployment on consumer-grade hardware or edge devices challenging. Post-Training Quantization (PTQ) is a common strategy to mitigate these costs by reducing the precision of weights and activations (e.g., from 32-bit float to 8-bit or 4-bit integer). However, diffusion models are particularly sensitive to quantization, especially as the data distribution shifts at every timestep. This research identifies two critical noise sources—intra-step and inter-step quantization noise—and proposes the Quantization Noise Correction (QNCD) scheme to address them.
Methodology
Intra-Quantization Correction
The researchers identified that the 'ResBlock' modules within diffusion models act as quantization bottlenecks. Specifically, when time and text embeddings are integrated into the feature maps, they introduce significant outliers in specific channels. These outliers expand the dynamic range required for quantization, leading to higher precision loss for the remaining values.
To resolve this, QNCD employs channel-specific feature smoothing. During a calibration phase, a smoothing factor ($S$) is calculated based on the embeddings. During inference, activations are divided by $S$ to normalize the distribution, making them more 'quantization-friendly.' This factor is mathematically integrated into the model weights to ensure the overall output remains consistent with the original floating-point model.
Inter-Quantization Correction
Beyond single-step errors, quantization noise accumulates over the iterative denoising process, causing the data distribution to 'drift' away from the expected path. QNCD introduces a runtime noise estimation module to dynamically correct this drift. Leveraging the fact that diffusion models are inherently noise predictors, the system periodically estimates the quantization error by adding a known amount of Gaussian noise to a previous step. By observing the quantized model's response, QNCD can estimate and subtract the cumulative 'quantization drift,' keeping the sampling process accurate over many steps.
Evaluation and Results
QNCD was evaluated across standard benchmarks including CIFAR-10, ImageNet (LDM-4), LSUN-Bedrooms, and MS-COCO (Stable Diffusion).
Key findings include:
- Lossless 4-bit Performance: On ImageNet, QNCD achieved virtually lossless results in W4A8 (4-bit weights, 8-bit activations) settings, outperforming existing PTQ methods.
- Extreme Low-Bit Stability: In challenging W4A6 configurations, where previous state-of-the-art methods like Q-Diffusion failed (FID of 39.07), QNCD maintained high quality with an FID of 12.26.
- Enhanced Semantic Alignment: On MS-COCO, QNCD demonstrated superior text-to-image alignment, as evidenced by higher CLIP scores and more realistic detail compared to competing quantized models.
- Efficiency: The intra-step correction is computationally 'free' as it is pre-computed, and the inter-step correction adds negligible overhead, maintaining the speed advantages of quantization.
Conclusion
QNCD provides a robust framework for the low-bit quantization of diffusion models by specifically targeting the noise generated by embedding integration and cumulative sampling drift. While achieving lossless performance at W4A8 is a significant milestone, future work may explore even lower activation precision (e.g., W4A4) and the potential of combining QNCD with Quantization-Aware Training (QAT) to further push the boundaries of model efficiency.
Summary updated