ToMoE: Converting Dense Large Language Models to Mixture-of-Experts through Dynamic Structural Pruning

Shangqian Gao, Ting Hua, Reza Shirkavand, Chi-Heng Lin, Zheng Tang, Zhengao Li, Longge Yuan, Fangyi Li, Zeyu Zhang, Alireza Ganjdanesh, Qian Lou, Jie Xu, Yen-Chang Hsu · DOI · OpenReview

TL;DR

This paper introduces ToMoE, a novel method to efficiently transform dense Large Language Models (LLMs) into Mixture-of-Experts (MoE) models by leveraging dynamic structural pruning. ToMoE achieves this without requiring any weight updates to the original LLM, outperforming state-of-the-art pruning and MoE techniques across various benchmarks and models.

What Problem Does This Paper Address?

Large Language Models (LLMs) are computationally demanding, making their deployment on resource-constrained devices challenging. Traditional pruning methods reduce model size by permanently removing parameters, which often leads to significant performance degradation. While MoE models offer a solution by activating only a subset of parameters, converting dense LLMs to MoE models typically requires extensive fine-tuning or complex expert construction. This paper addresses the need for an efficient method to convert dense LLMs into MoE models that preserves performance without costly fine-tuning, by uncovering inherent "experts" within dense models.

Methods

ToMoE employs a dynamic structural pruning approach to convert dense LLMs into MoE models. The core idea is to identify and extract experts that are implicitly present within the MLP layers of dense models. This is achieved through a unified, single-stage process that jointly optimizes the routing mechanism and expert configurations.

Key techniques include:

  • Dynamic Structural Pruning: This method makes pruning decisions based on input-dependent metrics, aligning with the conditional computation nature of MoE.
  • Top-K Routing and Static Pruning for MHA Layers: For Multi-Head Attention (MHA) layers, ToMoE uses top-K routing and static pruning along the head dimension. This ensures consistent head dimensions across tokens during inference, facilitating parallel processing.
  • Top-1 Expert Routing for MLP Layers: MLP layers are transformed into MoE layers using top-1 expert routing.
  • Hypernetwork for Expert Embeddings: A hypernetwork is used to generate expert embeddings, introducing inter-layer dependencies and accelerating the learning process.
  • Joint Optimization: The method jointly optimizes routing modules and expert configurations through a regularized optimization problem, leveraging differentiable operations.
  • Regularization: ToMoE incorporates several regularization terms:
  • Union of Experts Regularization: Encourages the union of experts to be close to the original model's capacity.
  • Parameter Regularization: Controls the number of active parameters within a predefined budget.
  • Load Balancing Regularization: Ensures uniform load distribution across experts.
  • Self-Knowledge Distillation: ToMoE utilizes self-knowledge distillation, freezing the original model's parameters and using its outputs to guide the training of the new MoE modules, avoiding the need for an extra teacher model.

Datasets

The paper uses the following datasets for training and/or evaluation:

  • WikiText: Used for language modeling tasks.
  • Alpaca: Used for training.
  • Code-Alpaca: Used for training.
  • Mixed Dataset: A combination of WikiText, Alpaca, and Code-Alpaca (1:1:1 ratio) is used for training.
  • Zero-shot tasks: PIQA, WinoGrande, HellaSwag, ARC-e, ARC-C.
  • Additional tasks for consistency: 32-shot BoolQ, SciQ, 5-shot WinoGrande, 25-shot ARC-c, 10-shot HellaSwag, TruthfulQA, and 5-shot MMLU.

Key Insights and Ideas

  • Implicit Experts in Dense Models: The paper's core insight is that dense LLMs inherently contain "experts" within their MLP layers that can be uncovered without fine-tuning. This challenges the notion that MoE models require explicit expert construction from scratch.
  • Dynamic Pruning for MoE Conversion: Leveraging dynamic structural pruning, which is input-dependent, provides a natural mechanism for routing tokens to specific experts, bridging the gap between pruning and MoE.
  • Unified Optimization: Jointly optimizing routing and expert construction in a single stage leads to more effective MoE models compared to methods that separate these processes.
  • No Fine-Tuning Required: The ability to convert dense LLMs to MoE models without any weight updates to the original model is a significant practical advantage, drastically reducing training costs.
  • Semantic Specialization of Experts: Visualizations suggest that ToMoE-generated experts might encode more distinct semantic meanings compared to experts in MoE models trained from scratch, potentially leading to better interpretability.

Key Results

  • State-of-the-Art Performance: ToMoE consistently outperforms state-of-the-art structural pruning and MoE construction techniques across various LLMs (Phi-2, LLaMA-2, LLaMA-3, Qwen-2.5) and tasks.
  • Perplexity Improvements: On WikiText, ToMoE achieves the lowest perplexity among compared methods, even with significantly fewer active parameters. For example, on LLaMA-2 7B with 50% active parameters, ToMoE achieved a perplexity of 8.36, outperforming other methods.
  • Zero-Shot Performance: ToMoE consistently achieves the best average zero-shot performance across models and tasks, often surpassing baselines by a significant margin. For instance, on LLaMA-2 7B with 60% active parameters, ToMoE was 3.14 times better than ModeGPT.
  • Efficient Training: The conversion process is efficient, with training costs comparable to or lower than regular structural pruning methods, and crucially, without requiring fine-tuning of the original LLM weights.
  • Inference Throughput: Converted MoE models achieve higher inference throughput due to reduced active parameters, with ToMoE showing competitive throughput compared to other MoE models.

Limitations and Future Work

  • Expert Size Uniformity: While ToMoE aims for uniform expert utilization through load balancing, the paper notes that the resulting expert sizes tend to converge to the maximum size among them. This is a direct result of the regularization design, which penalizes the largest expert less.
  • Semantic Role of Experts: While visualizations suggest semantic specialization, further investigation is needed to fully understand the precise semantic roles of ToMoE experts.
  • Future Work: The paper suggests that the pseudo-MoE approach, which resembles dense model training, can be more time-efficient than conventional MoE training when active parameter counts are relatively large. The authors also highlight the potential for ToMoE to be used for efficient inference and further exploration of expert specialization.

Summary updated

BibTeX
@article{gao2026tomoe,
  author = {Shangqian Gao and Ting Hua and Reza Shirkavand and Chi-Heng Lin and Zheng Tang and Zhengao Li and Longge Yuan and Fangyi Li and Zeyu Zhang and Alireza Ganjdanesh and Qian Lou and Jie Xu and Yen-Chang Hsu},
  title = {{ToMoE: Converting Dense Large Language Models to Mixture-of-Experts through Dynamic Structural Pruning}},
  journal = {Trans. Mach. Learn. Res.},
  year = {2026},
}
Figure