SparseDM: Toward Sparse Efficient Diffusion Models

Kafeng Wang, Jianfei Chen, He Li, Zhenpeng Mi, Jun Zhu · DOI

Abstract

Diffusion Models (DMs) have revolutionized high-quality image and video generation but remain computationally expensive due to their iterative denoising process. This paper presents SparseDM, a framework designed to bring hardware-friendly 2:4 structured sparsity to DMs. By combining an improved Straight-Through Estimator (STE) with progressive knowledge transfer from dense models, SparseDM halves the computational load (MACs) while preserving—and in some cases improving—generative quality. Experimental results demonstrate a 1.2x real-world speedup on modern NVIDIA GPUs, offering a viable path for deploying heavy diffusion models on resource-constrained devices.

Introduction

While Diffusion Models are the current gold standard for generative tasks, their high latency and memory requirements pose significant challenges for deployment on edge devices. Traditional acceleration methods, such as reducing sampling steps or structural pruning, often result in a catastrophic drop in image quality, as measured by the Fréchet Inception Distance (FID).

SparseDM addresses this by targeting 2:4 structured sparsity, a format where two out of every four weights are non-zero. This pattern is specifically optimized for NVIDIA’s Ampere and Hopper architectures, theoretically offering a 2x speedup. SparseDM is the first framework to successfully apply this fine-grained sparsity to diffusion models without compromising their performance.

The SparseDM Framework

The SparseDM training pipeline is built upon three technical pillars designed to stabilize the learning process and retain the generative "intuition" of dense models.

The SparseDM training and sampling pipeline, illustrating the progressive transfer of sparse masks from a pretrained dense model.

1. Improved Straight-Through Estimator (STE)

Standard STE often causes training instability in sparse networks because it ignores the non-differentiable pruning step during backpropagation. SparseDM introduces a sparse regularization term that pulls underlying dense weights closer to their sparse counterparts. This prevents model collapse and ensures a smoother optimization landscape.

2. Progressive Knowledge Transfer

SparseDM avoids training from scratch. Instead, it gradually transfers knowledge from a pre-trained dense "teacher" model to a sparse "student." This approach decouples the "distribution shift" caused by weight pruning from the shift inherent in the diffusion denoising process, allowing the model to adapt to sparsity incrementally.

3. Hardware-Aware Sparsity

The framework applies 2:4 structured masks to both Convolutional and Linear layers. By aligning with modern GPU kernels, SparseDM ensures that theoretical computational savings translate into actual inference speedups.

Experimental Evaluation

The researchers evaluated SparseDM across diverse architectures (UNet-based DDPM, Transformer-based U-ViT, and DiT) and standard benchmarks:

  • CIFAR10 (32x32) and CelebA (64x64) for low-resolution face and object generation.
  • MS COCO 2014 and ImageNet for high-resolution (256x256) complex scene generation.
Qualitative results across MS-COCO, ImageNet, CIFAR10, and CelebA datasets demonstrate that SparseDM maintains high visual fidelity.

Key Results

  • Efficiency: SparseDM achieved a consistent 50% reduction in MACs across all tested models.
  • Quality Preservation: On CIFAR10, SparseDM actually improved the FID of the U-ViT model from 3.97 (dense) to 3.81 (sparse). In contrast, standard tools like NVIDIA’s Automatic Sparsity (ASP) caused a total collapse on CelebA (FID > 400), whereas SparseDM maintained a high-quality FID of 3.52.
  • Real-world Performance: On NVIDIA A40 GPUs, the sparse models delivered an average inference speedup of 1.2x. The gap between the theoretical 2x and actual 1.2x is attributed to the overhead of managing the 2-bit indices matrix required by CUDA kernels.

Conclusion

SparseDM demonstrates that fine-grained structured sparsity is a powerful tool for optimizing diffusion models. By effectively managing the distribution shifts associated with pruning, the framework enables significant computational savings without sacrificing image quality. Future work will focus on further reducing hardware overhead and extending these techniques to other domains such as 3D point cloud processing.

Summary updated

BibTeX
@misc{wang2024sparsedm,
  author = {Kafeng Wang and Jianfei Chen and He Li and Zhenpeng Mi and Jun Zhu},
  title = {{SparseDM: Toward Sparse Efficient Diffusion Models}},
  year = {2024},
  eprint = {2404.10445},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2404.10445},
}
Figure