LAPTOP-Diff: Layer Pruning and Normalized Distillation for Compressing Diffusion Models

Dingkun Zhang, Sijia Li, Chen Chen, Qingsong Xie, Haonan LuarXiv 2024 · DOI

Abstract

Stable Diffusion Models (SDMs) have achieved remarkable success in text-to-image generation but suffer from high computational costs due to their massive parameter counts. We present LAPTOP-Diff, an automated framework for compressing SDMs using a one-shot layer pruning strategy and normalized feature distillation. Our approach replaces manual layer removal with a mathematically grounded optimization process, achieving a 50% reduction in model size with significantly lower performance degradation than existing state-of-the-art methods.

Introduction

The deployment of large-scale diffusion models like SDXL on consumer hardware is limited by their multi-billion parameter U-Net architectures. Traditional compression techniques, such as "handcrafted" layer removal, are often suboptimal and difficult to scale. LAPTOP-Diff addresses these limitations by automating the pruning process and introducing a novel distillation technique to maintain high image quality while reducing latency.

Methodology

One-Shot Layer Pruning

LAPTOP-Diff treats layer pruning as a combinatorial optimization problem. By identifying an "additivity property" in SDMs—where the combined error of removing multiple layers approximates the sum of individual errors—the authors can efficiently calculate layer importance in a single pass. This importance is then used to solve a 0-1 Knapsack problem to select the optimal sub-structure for a given parameter budget. Notably, the automated process tends to remove more layers from the encoder stages, confirming that the decoder handles the majority of the generative workload.

Normalized Feature Distillation

To recover performance after pruning, the model undergoes knowledge distillation. Standard distillation often fails due to "distillation imbalance," where layers with large feature map magnitudes dominate the loss. LAPTOP-Diff introduces a re-weighting strategy that normalizes loss terms based on the teacher's feature map norms, ensuring balanced learning across all layers and preventing numerically dominant features from drowning out critical signals.

Results

Quantitative Performance

Evaluation on human-preference benchmarks (HPS v2, PickScore, ImageReward) shows that LAPTOP-Diff outperforms previous state-of-the-art methods. At 50% compression, the model experienced only a 4.0% decline in PickScore, compared to 8.2% for the handcrafted SSD-1B model. Furthermore, the compressed models achieved significant inference speedups: the 50% compressed SDXL model was 33% faster, while a 72% compressed version achieved a 48% speedup.

Qualitative Analysis

Qualitative results indicate that the compressed models maintain high visual fidelity. The 1.3B parameter student model produces images that are nearly indistinguishable from the 2.6B parameter teacher.

Figure 1: High-fidelity generation of a violin with flowers.

As shown in Figure 6, the model maintains consistent quality across a diverse set of prompts, from realistic portraits to surreal concepts, demonstrating that the automated pruning does not sacrifice the model's creative breadth.

Figure 6: Diverse generation examples from LAPTOP-Diff.

Conclusion

LAPTOP-Diff offers a principled and automated approach to diffusion model compression. By leveraging the additivity of layer distortions and addressing distillation imbalances, it enables the creation of efficient, high-quality models suitable for a wider range of hardware. While the distillation phase remains computationally expensive, the resulting speedups and quality preservation mark a significant step forward in making generative AI more accessible. Future research will explore applying these techniques to other components of the diffusion pipeline, such as text encoders and VAEs.

Summary updated

BibTeX
@misc{zhang2024laptop,
  author = {Dingkun Zhang and Sijia Li and Chen Chen and Qingsong Xie and Haonan Lu},
  title = {{LAPTOP-Diff: Layer Pruning and Normalized Distillation for Compressing Diffusion Models}},
  year = {2024},
  eprint = {2404.11098},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2404.11098},
}
Figure