Dynamic Mixture of Experts: An Auto-Tuning Approach for Efficient Transformer Models

Yongxin Guo, Zhenglin Cheng, Xiaoying Tang, Zhaopeng Tu, Tao Lin

TL;DR

DynMoE is a novel Mixture-of-Experts (MoE) framework that eliminates the need for manual hyperparameter tuning by automatically determining both the total number of experts and the number of experts activated per token. By treating expert selection as a dynamic, multi-label problem, it achieves state-of-the-art efficiency and competitive performance across vision, language, and multi-modal tasks while activating significantly fewer parameters.

The "Tuning Tax" of Sparse Mixture of Experts

Sparse Mixture of Experts (SMoE) has become a cornerstone for scaling Transformer models efficiently. By routing each input token to only a few "experts" (sub-networks), SMoEs keep computational costs manageable even as total parameter counts explode.

However, SMoEs suffer from a significant "tuning tax." Their performance is highly sensitive to two hyperparameters: $K$ (the total number of experts) and $k$ (the number of experts activated per token, usually "top-$k$"). Finding the optimal $(K, k)$ configuration typically requires expensive ablation studies and grid searches. Furthermore, standard SMoEs use a fixed $k$ for every token, ignoring the fact that some tokens are inherently more complex than others and might benefit from more (or fewer) experts.

Performance fluctuation based on K and k choices, and the efficiency of DynMoE compared to other models.

Introducing Dynamic Mixture of Experts (DynMoE)

To address these limitations, the authors introduce Dynamic Mixture of Experts (DynMoE), which features two primary innovations:

1. Top-Any Gating

Instead of forcing a fixed $k$, DynMoE treats expert selection as a multi-label classification problem. Each expert has a trainable threshold. If a token's affinity for an expert exceeds that threshold, the expert is activated. This allows the model to dynamically adjust the compute per token—complex tokens might trigger multiple experts, while simpler ones might trigger only one.

The Top-Any Gating mechanism allows tokens to autonomously decide which experts to activate based on learned thresholds.

2. Adaptive Expert Adjustment

DynMoE starts with an initial set of experts and dynamically adds or removes them during training:

  • Adding: If the model identifies tokens that don't strongly match any existing experts, it initializes a new expert using those "unmatched" token embeddings.
  • Removing: If an expert goes unused for a certain period, it is pruned to maintain efficiency.

To ensure this flexibility doesn't lead to "expert collapse" (where all tokens pick the same expert), the authors introduce a Sparse and Simple Gating Loss. This auxiliary loss encourages diversity among expert representations and prevents weights from exploding.

Experimental Validation

The authors validated DynMoE across three major domains:

  • Vision: DomainBed benchmark (including PACS, VLCS, OfficeHome, and DomainNet).
  • Language: GLUE benchmark (COLA, MRPC, QNLI, MNLI, RTE) using BERT-large.
  • Vision-Language: A suite of 11 benchmarks including VQA-v2, GQA, ScienceQA, and MM-Vet, using backbones like StableLM, Qwen, and Phi-2.

Key Insights and Results

  • Superior Efficiency: On vision-language tasks, DynMoE-LLaVA activated approximately 15% fewer parameters than the standard MoE-LLaVA while maintaining or exceeding its accuracy.
  • Auto-Tuning Success: DynMoE consistently outperformed the average performance of various fixed $(K, k)$ configurations and matched the performance of the best manually tuned models without the search overhead.
  • Compute Where It's Needed: DynMoE naturally allocates more "expertise" to difficult tokens. The authors observed that average activation counts ($k$) vary significantly across different layers and tasks.
  • Layer-wise MoE Necessity: Visualizations reveal that MoE structure is most beneficial in the bottom layers of a model. In the top layers (closest to the output), tokens tend to converge on a single shared expert, suggesting that full MoE treatment might be redundant at the top of the stack.
  • Hardware Performance: In real-world testing on an A100 GPU, DynMoE achieved higher throughput and lower latency than standard top-2 gating implementations, proving that the theoretical efficiency translates to wall-clock speedups.

Limitations and Future Work

While DynMoE is a major step toward "set-and-forget" MoE training, the authors note a few areas for improvement:

  • Implementation Bottlenecks: The current adaptive process and gating logic are not yet fully optimized at the CUDA kernel level, meaning there is still some overhead compared to highly specialized static kernels.
  • Memory Management: Currently, all experts (active or inactive) reside in GPU memory. Future versions could implement expert offloading to further reduce the memory footprint.
  • Dynamic Depth: The authors suggest exploring "layer skipping" in conjunction with dynamic experts to create even more elastic models.

Summary updated

BibTeX
@inproceedings{guo2025dynamic,
  author = {Yongxin Guo and Zhenglin Cheng and Xiaoying Tang and Zhaopeng Tu and Tao Lin},
  title = {{Dynamic Mixture of Experts: An Auto-Tuning Approach for Efficient Transformer Models}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=T26f9z2rEe},
}
Figure