TL;DR
This paper introduces MosaicDiff, a novel training-free structural pruning method for diffusion models that aligns pruning strategies with the model's inherent learning dynamics during pretraining. By dividing the diffusion process into stages and applying stage-specific pruning, MosaicDiff achieves significant acceleration without compromising generation quality, outperforming existing methods.
What Problem Does This Paper Address?
Diffusion models, while powerful for generative tasks, are computationally expensive, especially during pretraining and inference. Existing methods for accelerating diffusion models often focus on reducing sampling steps or applying uniform pruning, overlooking a crucial aspect: the varying learning speeds of diffusion models across different stages of their pretraining. This paper argues that this "slow-fast-slow" learning trajectory is a key insight that can be leveraged for more effective acceleration. By ignoring these dynamics, current methods miss opportunities to optimize pruning strategies for better efficiency and robustness.
Methods
MosaicDiff employs a "Divide, Prune, and Conquer" framework:
- Divide: The reverse diffusion process is divided into three stages based on an empirical observation of the model's learning speed, which is analyzed by monitoring the Mean Squared Error (MSE) between intermediate latents and the final output. This division is supported by theoretical analysis of MSE and gradients derived from the noise schedule.
- Prune: For each stage, a second-order structural pruning method is applied. This involves using SNR-aware calibration data to compute Hessian matrices for attention and MLP layers. Saliency scores are derived from these Hessians to prune less important weight columns (e.g., attention heads or neurons). The pruning intensity is adapted based on the stage's learning speed: more aggressive pruning for slow-learning stages and conservative pruning for fast-learning stages.
- Conquer: The pruned sub-networks are merged to form the final accelerated model, ensuring consistency with the original model's trajectory.
A key innovation is the use of "SNR-aware calibration data." This data is generated by adding noise to latents at specific timesteps corresponding to the target stage's SNR range, allowing the pruning process to better reflect the model's behavior at those stages.
Datasets
- ImageNet-1K: Used for training and evaluation on the DiT-XL/2 model.
- MS COCO 2017: Used for quantitative evaluation on the SDXL-base-1.0 model.
Key Insights and Ideas
- Diffusion Pretraining Has Distinct Learning Stages: The paper highlights that diffusion models don't learn uniformly; there are slow, fast, and then slow learning phases. This is analogous to a "slow-fast-slow" trajectory.
- Aligning Pruning with Learning Dynamics is Crucial: Ignoring these learning stages leads to suboptimal pruning. Aggressive pruning can be tolerated in slow stages, while fast stages require more conservative pruning to preserve critical features.
- SNR is a Key Indicator for Stage Importance: The Signal-to-Noise Ratio (SNR) at different timesteps, along with gradient information, can effectively characterize the learning dynamics and inform stage division and pruning strategy.
- Training-Free Acceleration Can Be Significantly Improved: By leveraging insights from pretraining dynamics, even training-free methods can achieve substantial speedups without needing to retrain the model.
Key Results
MosaicDiff demonstrates significant improvements in acceleration and generation quality:
- On DiT-XL/2: Achieves 0.5 pruning sparsity with minimal performance degradation. At 20 sampling steps, it achieves an FID of 3.20, outperforming Diff-Pruning (223.8) and Learning-to-Cache (227.0). It also outperforms the vanilla DiT and DiP-GO at fewer sampling steps with lower MACs.
- On SDXL-base-1.0: Achieves 0.3 pruning sparsity. It consistently outperforms Diff-Pruning and EcoDiff in terms of FID, CLIP, and SSIM, indicating better image quality, text-image alignment, and visual similarity.
- Compatibility: When combined with DeepCache, MosaicDiff further reduces MACs and improves FID. It also shows benefits when integrated with fast samplers like DPM-Solver++.
- Efficiency: The compression process itself is efficient, pruning a full three-stage DiT-XL/2 model in about 30 minutes on an RTX 4090, significantly faster than training-based methods like L2C or DiP-GO.
Limitations and Future Work
- Memory Overhead: The paper acknowledges that storing multiple pruned sub-networks for different stages might introduce slightly more memory overhead.
- Future Work: The authors suggest exploring and optimizing this memory overhead as a direction for future research.
Summary updated