TFMQ-DM: Temporal Feature Maintenance Quantization for Diffusion Models

Yushi Huang, Ruihao Gong, Jing Liu, Tianlong Chen, Xianglong Liu

Abstract

Diffusion models have become the standard for high-fidelity image generation but require significant computational resources for iterative denoising. Post-Training Quantization (PTQ) is a common strategy to reduce model size and latency, yet it typically leads to substantial performance degradation at low bit-widths. This paper identifies "temporal feature disturbance"—where quantization noise causes a mismatch in the model's perception of the denoising timeline—as a primary failure mode. We propose Temporal Feature Maintenance Quantization (TFMQ-DM), a framework that isolates temporal modules and employs time-step-specific calibration. TFMQ-DM achieves near-lossless 4-bit weight quantization, significantly reducing memory overhead while accelerating the quantization process by up to 2.0x.

Introduction

Diffusion models, such as Stable Diffusion, generate images through a series of iterative denoising steps. Each step is computationally expensive, necessitating effective compression techniques for deployment on edge devices. While PTQ is effective for many neural networks, it often fails for diffusion models at 4-bit precision. The authors pinpoint Temporal Feature Disturbance as the cause: the time-step $t$ is encoded into a temporal feature that guides the model. Standard quantization methods treat these features like image data, leading to a "temporal information mismatch" where the model loses track of its progress in the denoising trajectory. This drift accumulates over time, causing the final output to deviate significantly from the intended result.

Methodology

The TFMQ-DM framework introduces three core innovations to preserve temporal information during quantization.

The TFMQ-DM framework architecture, illustrating the Temporal Information Block (TIB), Temporal Information Aware Reconstruction (TIAR), and Finite Set Calibration (FSC).

Temporal Information Block (TIB)

The framework isolates all modules responsible for processing the time-step $t$ (e.g., time_embed and embedding layers) into a single logical unit. This allows for the independent optimization of temporal layers, ensuring they are not overshadowed by larger image-processing modules during the quantization process.

Temporal Information Aware Reconstruction (TIAR)

Standard PTQ minimizes the overall output error of a block. In contrast, TIAR specifically targets the weights of temporal modules using a specialized loss function designed to align quantized temporal features with their full-precision counterparts. This alignment is crucial for maintaining the correct denoising trajectory.

Finite Set Calibration (FSC)

Exploiting the fact that diffusion models use a finite number of time-steps $T$, FSC observes that temporal activations also belong to a finite set. Instead of using global quantization parameters, FSC employs $T$ sets of parameters—one for each step. This allows the model to adapt to the specific activation range of every time-step without increasing inference overhead, as parameters are stored in a lookup table.

Experimental Evaluation

TFMQ-DM was tested across various benchmarks, including CIFAR-10, ImageNet, and MS-COCO. The results demonstrate that maintaining the "cosine similarity" of temporal features is more critical for image quality than simply reducing absolute error.

Cosine similarity comparison across different quantization methods. TFMQ-DM (red) maintains significantly higher similarity to the full-precision model than baseline methods like PTQD throughout the denoising process.

Key Results

  • State-of-the-Art 4-Bit Quantization: TFMQ-DM is the first method to provide near-lossless performance at 4-bit weight quantization. For instance, on CelebA-HQ, it achieved a 6.71 improvement in FID score over previous state-of-the-art methods.
  • Efficiency Gains: The quantization process is up to 2.0x faster than previous methods like Q-Diffusion or BRECQ.
  • Broad Applicability: The framework's benefits are consistent across different samplers (DDIM, PLMS, DPM++) and model architectures (LDM, Stable Diffusion).

Conclusion

TFMQ-DM demonstrates that preserving the integrity of temporal features is paramount for the successful quantization of diffusion models. By leveraging the independence and finiteness of these features, the proposed framework enables high-quality, low-bit generation. Future research may explore similar maintenance strategies for textual features in large-scale text-to-image models or extend these principles to Quantization-Aware Training (QAT).

Summary updated

BibTeX
@inproceedings{huang2023tfmq,
  author = {Yushi Huang and Ruihao Gong and Jing Liu and Tianlong Chen and Xianglong Liu},
  title = {{TFMQ-DM: Temporal Feature Maintenance Quantization for Diffusion Models}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2023},
}
Figure