Abstract
The Sparse Mixture of Experts (SMoE) has been widely employed to enhance the efficiency of training and inference for Transformer-based foundational models, yielding promising results. However, the performance of SMoE heavily depends on the choice of hyper-parameters, such as the number of experts and the number of experts to be activated (referred to as top-k), resulting in significant computational overhead due to the extensive model training by searching over various hyper-parameter configurations. As a remedy, we introduce the Dynamic Mixture of Experts (DynMoE) technique. DynMoE incorporates (1) a novel gating method that enables each token to automatically determine the number of experts to activate. (2) An adaptive process automatically adjusts the number of experts during training. Extensive numerical results across Vision, Language, and Vision-Language tasks demonstrate the effectiveness of our approach to achieve competitive performance compared to GMoE for vision and language tasks, and MoE-LLaVA for vision-language tasks, while maintaining efficiency by activating fewer parameters.
Introduction
Sparse Mixture of Experts (SMoE) has become a standard technique for scaling Transformers efficiently. By replacing dense layers with multiple "experts" and only activating a few (usually the "top-$k$") for each token, researchers can build massive models with manageable computational costs. However, SMoEs suffer from a significant "tuning tax": developers must manually decide the total number of experts ($K$) and the number of activated experts ($k$). As shown in the paper's experiments, picking suboptimal values can lead to a 1-3% drop in accuracy. Finding the "sweet spot" usually requires exhaustive ablation studies—a luxury few can afford as models grow to billions of parameters. Dynamic Mixture of Experts (DynMoE) addresses this by allowing the model to figure out these configurations on its own during training.
Methods
DynMoE introduces two primary innovations to eliminate manual tuning:
Top-Any Gating
Instead of forcing every token to use exactly $k$ experts, DynMoE treats routing as a multi-label classification problem. It calculates a similarity score between a token and each expert. If the score exceeds a trainable, per-expert threshold ($G$), that expert is activated. This allows "easy" tokens to use one expert and "complex" tokens to use many, or even none if they don't match existing experts.
Adaptive Training Process
The model starts with a set number of experts and dynamically adjusts during training:
- Adding Experts: If tokens consistently fail to trigger any existing experts, the model initializes a new expert using the embeddings of those "unhandled" tokens as a seed.
- Removing Experts: If an expert goes unused for a certain number of iterations, it is pruned to maintain efficiency.
To prevent the model from simply activating every expert to lower loss, the authors introduce a Sparse and Simple Gating Loss. This auxiliary loss encourages experts to be diverse (orthogonal) and keeps the gating weights numerically stable.
Results and Insights
The authors validated DynMoE across three major domains: Vision (DomainBed), Language (GLUE), and Vision-Language (MoE-LLaVA framework).
Performance and Efficiency
DynMoE consistently matches or outperforms well-tuned traditional MoE models while being more efficient. In vision-language tasks, DynMoE-LLaVA (using StableLM-1.6B) activated 15% fewer parameters than the standard MoE-LLaVA while achieving higher accuracy on benchmarks like VQA-v2 and GQA. On the GLUE language benchmark, DynMoE outperformed the average of various fixed $(K, k)$ configurations, proving it can find a high-performing state without manual grid searching.
Key Insights
- Token Flexibility: The "top-any" approach reveals that fixed $k$ is suboptimal. Some tokens are inherently more specialized and benefit from more (or fewer) experts than others.
- Layer-wise Specialization: MoE structures are most beneficial in the bottom layers of a network. In the top layers, tokens tend to converge on the same experts, suggesting dense layers might suffice at the end of the pipeline.
Limitations and Future Work
While DynMoE is a major step toward "self-driving" MoEs, some hurdles remain. Currently, all experts (active or inactive) remain in GPU memory, necessitating an expert-offloading system for trillion-parameter scaling. Additionally, the "top-any" routing is implemented in standard PyTorch; custom CUDA kernels could further reduce routing latency. Finally, the authors suggest exploring "layer skipping" in conjunction with DynMoE to create models dynamic in both width and depth.
Summary updated