Dense2MoE: Restructuring Diffusion Transformer to MoE for Efficient Text-to-Image Generation

Youwei Zheng, Yuxi Ren, Xin Xia, Xuefeng Xiao, Xiaohua Xie

TL;DR

This paper introduces Dense2MoE, a novel method to transform dense Diffusion Transformers (DiTs) into efficient Mixture-of-Experts (MoE) models. By strategically replacing Feed-Forward Networks (FFNs) with MoE layers and introducing a "Mixture of Blocks" (MoB) approach, they significantly reduce activated parameters while maintaining high-quality text-to-image generation. This work offers a promising path towards more accessible and computationally feasible diffusion models.

What Problem Does This Paper Address?

Diffusion models, particularly those based on the Transformer architecture (DiTs), have achieved remarkable success in text-to-image generation. However, their impressive performance often comes at the cost of massive parameter counts, leading to substantial computational overhead during inference. This high cost makes these powerful models inaccessible to many users and limits their deployment on resource-constrained devices. While existing methods like pruning aim to reduce model size, they often lead to significant performance degradation. The authors aim to address this by developing a method that achieves parameter efficiency without sacrificing generative quality, drawing inspiration from the success of MoE architectures in large language models.

Methods

Dense2MoE employs a two-pronged approach to sparsify DiTs:

  1. FFN to MoE Transformation: The core idea is to replace the dense Feed-Forward Networks (FFNs) within DiT blocks with Mixture-of-Experts (MoE) layers. Each MoE layer consists of a gating network and multiple "experts" (smaller MLPs). A gating network dynamically selects a subset of experts to process each token, drastically reducing the number of activated parameters in the FFNs. The authors propose an "Enhanced MoE Initialization" strategy that uses Taylor metrics and knowledge distillation to initialize the shared expert with the most crucial weights from the original FFN, followed by distilling the normal experts.
  2. Mixture of Blocks (MoB): Beyond FFNs, the authors introduce a "Mixture of Blocks" (MoB) concept. This approach groups consecutive transformer blocks and allows for dynamic activation of a subset of these blocks based on the input. This effectively sparsifies the model's depth, allowing different samples to traverse different computational paths. MoB is particularly well-suited for diffusion models, where the computational needs can vary significantly across timesteps and prompts.

A key component of their work is a specialized distillation pipeline that orchestrates these transformations. This pipeline involves:

  • Enhanced MoE Initialization: Using Taylor metrics and knowledge distillation to initialize the shared expert.
  • Dense-to-MoE Distillation: Assembling the MoE layers and applying knowledge distillation with load balancing to ensure all experts are trained effectively.
  • Group Feature Distillation: For MoB, they use group feature loss to align the outputs of MoB groups with the teacher model, guiding the distillation process.

Datasets

The authors trained and evaluated their models using a combination of open-source datasets, including:

  • Laion-5B
  • Coyo-700M
  • JourneyDB

For evaluation, they used the MJHQ-30K dataset for visual appeal and human preference, and also employed established benchmarks for assessing semantic alignment:

  • GenEval
  • DPG-Bench
  • T2I-CompBench

Key Insights and Ideas

  • MoE for Diffusion is Viable: The paper demonstrates that the MoE paradigm, highly successful in LLMs, can be effectively adapted to diffusion models for significant parameter reduction.
  • FFNs are Prime Targets for MoE: FFNs constitute a substantial portion of DiT parameters, making them an ideal candidate for MoE conversion, yielding significant efficiency gains.
  • Dynamic Depth (MoB) Matters: Sparsifying the model's depth by dynamically selecting blocks (MoB) offers another avenue for efficiency, especially relevant for the multi-step nature of diffusion.
  • Structured Distillation is Crucial: A carefully designed, multi-stage distillation pipeline is essential for successfully transforming a dense DiT into a sparse MoE/MoB model without losing performance.
  • Expert Specialization is Interpretable: The analysis of expert selection frequencies reveals that experts can specialize based on prompts, timesteps, and spatial locations, offering insights into the model's internal workings.

Key Results

The Dense2MoE approach achieved impressive results:

  • Significant Parameter Reduction: They successfully compressed the 12B FLUX.1 [dev] model to versions with as few as 2.6B activated parameters (FLUX.1-MoE-XS). For instance, FLUX.1-MoE-L, with 5.2B activated parameters, achieved better performance than the original FLUX.1-lite while using 20% fewer FLOPs.
  • Competitive Performance: Even at high compression rates (e.g., 75% reduction), their models (FLUX.1-MoE-S and XS) significantly outperformed existing pruning methods like FLUX-Mini.
  • Preserved Quality: The generated images from their MoE models maintained high quality, comparable to the original dense models, as evidenced by various evaluation metrics like CLIP, IR, and MPS scores.
  • Efficiency Gains: The reduction in activated parameters directly translates to lower computational costs and faster inference.

Limitations and Future Work

  • Distillation Complexity: The proposed distillation pipeline is multi-stage and complex, requiring careful tuning.
  • Expert Specialization Analysis: While they visualized expert specialization, further exploration into how to explicitly control or leverage this specialization could be beneficial.
  • Dynamic Top-K Exploration: The paper briefly touches upon the impact of varying Top-K values for expert activation, suggesting that further research into optimizing this dynamic activation could unlock even greater efficiency and quality trade-offs.

The authors believe their work opens new avenues for exploring efficient generative models and inspires further research into MoE-based diffusion architectures.

Summary updated

BibTeX
@inproceedings{zheng2025dense,
  author = {Youwei Zheng and Yuxi Ren and Xin Xia and Xuefeng Xiao and Xiaohua Xie},
  title = {{Dense2MoE: Restructuring Diffusion Transformer to MoE for Efficient Text-to-Image Generation}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2025},
}
Figure