StepbaQ: Stepping backward as Correction for Quantized Diffusion Models

Yi-Chung Chen, Zhi-Kai Huang, Jing-Ren ChenNeurIPS 2024

TL;DR

StepbaQ is a novel "plug-and-play" method that significantly improves the quality of quantized diffusion models by treating quantization error as a temporal "stepback" in the denoising process. By calibrating the sampling trajectory using simple error statistics from a small dataset, it allows high-quality image generation on resource-constrained mobile devices without the need for expensive retraining.

The Challenge of Quantizing Diffusion Models

Diffusion models, such as Stable Diffusion, are the gold standard for image generation. However, they are computationally expensive, requiring many iterations through complex neural networks. To run these models efficiently on edge devices like smartphones, engineers rely on quantization—the process of converting high-precision floating-point numbers into low-bit integers (e.g., 8-bit or 4-bit).

The primary challenge with this approach is the iterative nature of diffusion models. A small quantization error introduced at an early step does not remain isolated; it accumulates and compounds over every subsequent step. This "error accumulation" distorts the sampling trajectory, leading to blurry images, strange artifacts, or complete generation failures in aggressive low-bit settings (like W4A8). While previous methods have attempted to minimize error at each individual step, they often fail to account for how these errors shift the overall distribution of the data being processed over time.

Methods: Quantization Error as a "Stepback"

The authors introduce a clever conceptual shift: quantization error is essentially a "stepback" in time.

In a diffusion model, the generation process moves from high noise to low noise along a predefined schedule. Quantization inherently adds noise back into the system. Mathematically, the authors demonstrate that a quantized latent variable at step $t$ possesses a noise profile that actually corresponds to an earlier, noisier step $\tau$ (where $\tau > t$).

To correct this trajectory, they propose StepbaQ, a method consisting of three main components:

  1. Temporal Information Alignment: Instead of conditioning the model on the current step $t$, StepbaQ feeds it the "corrected" step $\tau$ that accurately matches its actual, noisier state.
  2. Latent Adjustment: The data is rescaled to align its distribution with the expected distribution at the corrected step $\tau$.
  3. Step Size Adaptation: Because the model is effectively "further back" in the denoising process than intended, StepbaQ utilizes a larger step size to reach the next target, effectively "catching up" to the original trajectory.
Conceptual illustration of StepbaQ realigning the sampling trajectory.

Crucially, StepbaQ is a post-training quantization (PTQ) technique. It only requires calculating error statistics (mean $\mu$ and variance $\sigma^2$) from a tiny calibration set of 128 images, making it extremely efficient and practical to implement.

Key Insights

  • The SNR Perspective: The core insight links quantization error to the Signal-to-Noise Ratio (SNR). Quantization decreases the SNR of the latent variable. By mapping this lower SNR back onto the model's original noise schedule, the system can pinpoint exactly which "time" the model is currently operating in.
  • Plug-and-Play Compatibility: Unlike previous methods limited to specific types of samplers, StepbaQ is highly generalizable. It works seamlessly with off-the-shelf quantization tools without requiring modifications to the underlying quantization settings.
  • Accounting for Accumulation: StepbaQ measures errors across multiple steps to obtain accurate statistics for correction. It allows the error to accumulate until it is "large enough" to warrant a discrete step correction, rather than over-correcting at every micro-step.

Key Results

The researchers evaluated StepbaQ using the MS-COCO dataset (for general image generation quality) and the SDprompts dataset (for text-to-image alignment). StepbaQ demonstrated state-of-the-art performance across various models and bit-widths:

  • Stable Diffusion v1.5 (W8A8): Improved the Frechet Inception Distance (FID)—a standard measure of image quality—by 7.30 on the SDprompts dataset compared to naive quantization.
  • SDXL-Turbo (W4A8): In the highly challenging 4-bit weight setting, StepbaQ improved FID by a massive 17.31, effectively eliminating the "crack-like" artifacts commonly seen in naive quantization.
  • Efficiency: The calibration process for a 20-step model takes only about 20 minutes on a single A6000 GPU.
Quantitative results showing StepbaQ outperforming baseline quantization methods.

Qualitatively, the method successfully restores fine details, such as facial features and complex textures, that are typically lost or distorted when models are heavily compressed for mobile deployment.

Limitations and Future Work

  • Single-Step Models: Because StepbaQ relies on correcting a multi-step trajectory, it currently cannot be applied to "one-step" diffusion models (like 1-step SDXL-Turbo), as there are no intermediate steps to calibrate.
  • Gaussian Assumption: The underlying mathematics assume that quantization error follows a Gaussian distribution. While the authors show this holds up well in practice, extreme outliers could potentially reduce the method's effectiveness.
  • Future Directions: The authors suggest exploring how to prevent performance degradation in single-step scenarios as a primary area for future research.

Summary updated

BibTeX
@inproceedings{chen2024stepbaq,
  author = {Yi-Chung Chen and Zhi-Kai Huang and Jing-Ren Chen},
  title = {{StepbaQ: Stepping backward as Correction for Quantized Diffusion Models}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=cEtExbAKYV},
}
Figure