Balancing Expert Utilization in Mixture-of-Experts Layers Embedded in CNNs

Svetlana Pavlitskaya, Christian Hubschneider, Lukas Struppek, J. Marius Zöllner

Abstract

This work addresses the problem of unbalanced expert utilization in sparsely-gated Mixture of Expert (MoE) layers, embedded directly into convolutional neural networks. To enable a stable training process, we present both soft and hard constraint-based approaches. With hard constraints, the weights of certain experts are allowed to become zero, while soft constraints balance the contribution of experts with an additional auxiliary loss. As a result, soft constraints handle expert utilization better and support the expert specialization process, hard constraints mostly maintain generalized experts and increase the model performance for many applications. Our findings demonstrate that even with a single dataset and end-to-end training, experts can implicitly focus on individual sub-domains of the input space. Experts in the proposed models with MoE embeddings implicitly focus on distinct domains, even without suitable predefined datasets. As an example, experts trained for CIFAR-100 image classification specialize in recognizing different domains such as sea animals or flowers without previous data clustering. Experiments with RetinaNet and the COCO dataset further indicate that object detection experts can also specialize in detecting objects of distinct sizes.

Introduction

In the pursuit of more capable deep learning models, the standard approach has been to increase network density, which unfortunately leads to a linear scaling of computational requirements (FLOPs). Sparsely-gated Mixture-of-Experts (MoE) architectures provide a solution by decoupling model capacity from computation. By activating only a small subset of "experts" for any given input, these models can maintain a large parameter count while keeping inference costs manageable.

While MoEs have seen massive success in Transformer-based Natural Language Processing, their integration into Convolutional Neural Networks (CNNs) for computer vision has been hindered by training instabilities. The most prominent issue is the "dying expert" problem, where the gating mechanism converges to a state where only a few experts are utilized, leaving others untrained and redundant. This paper explores methods to balance expert utilization and investigates the resulting semantic and scale-based specialization that emerges in vision tasks.

Methodology: ResBlock-MoE and Balancing Constraints

The authors propose the ResBlock-MoE layer, where each expert is implemented as a standard residual block. This allows for seamless integration into existing CNN architectures like ResNet-18 and RetinaNet. The routing of inputs is handled by a gating network. Two gating designs were tested: GAP-FC, which uses Global Average Pooling followed by a Fully Connected layer, and Conv-GAP-FC, which adds a 3x3 convolutional layer to capture local spatial features before the pooling stage.

Overview of the ResBlock-MoE architecture. The gating network routes inputs to specific experts, which naturally learn to specialize in semantic domains like flowers or animals.

To combat the dying expert problem, the study introduces and compares several balancing constraints:

  • Soft Constraints: These involve auxiliary losses added to the primary objective. The Importance Loss penalizes variance in expert utilization across a batch. A novel KL-Divergence Loss treats the gate's output as a probability distribution and encourages it to match a uniform distribution, ensuring all experts are considered.
  • Hard Constraints: These methods, such as Relative and Mean Importance, actively manipulate the weights of over-utilized experts during the training process, forcing the gating network to explore and utilize under-performing experts.

Results and Expert Specialization

Experiments on the CIFAR-100 dataset revealed that MoE-enhanced models can outperform standard baselines. For instance, a 4-expert MoE using a Mean Importance constraint achieved an accuracy of 73.10%, surpassing the ResNet-18 baseline of 72.62%. More importantly, the researchers observed significant "natural specialization." Without any explicit labels or pre-clustering, experts learned to handle specific semantic categories. One expert might focus on "flowers," while another handles "marine animals" or "household furniture."

Visualization of the input space partitioning by the gating network across four experts, demonstrating implicit specialization.

In object detection tasks using RetinaNet on the COCO dataset, a different form of specialization emerged: scale specialization. Experts at different levels of the feature pyramid specialized in detecting objects of specific sizes (small, medium, or large). This suggests that MoE layers can capture fundamental structural properties of the data.

The study also highlights a trade-off: soft constraints like KL-divergence lead to the highest levels of specialization and interpretability, whereas hard constraints tend to produce better raw performance but result in more "generalized" experts that behave similarly to standard layers.

Conclusion and Future Work

This research demonstrates that MoE layers can be effectively embedded in CNNs to provide both performance gains and model interpretability through expert specialization. While balancing constraints are essential for stable training, the "dying expert" problem remains a challenge as the number of experts scales up. Future directions include exploring training regimes where experts are initialized or fine-tuned on specific sub-datasets to further leverage the benefits of specialization. Additionally, improving the robustness of MoE training to hyperparameter variations remains a key area for development.

Summary updated

Abstract

This work addresses the problem of unbalanced expert utilization in sparsely-gated Mixture of Expert (MoE) layers, embedded directly into convolutional neural networks. To enable a stable training process, we present both soft and hard constraint-based approaches. With hard constraints, the weights of certain experts are allowed to become zero, while soft constraints balance the contribution of experts with an additional auxiliary loss. As a result, soft constraints handle expert utilization better and support the expert specialization process, hard constraints mostly maintain generalized experts and increase the model performance for many applications. Our findings demonstrate that even with a single dataset and end-to-end training, experts can implicitly focus on individual sub-domains of the input space. Experts in the proposed models with MoE embeddings implicitly focus on distinct domains, even without suitable predefined datasets. As an example, experts trained for CIFAR-100 image classification specialize in recognizing different domains such as sea animals or flowers without previous data clustering. Experiments with RetinaNet and the COCO dataset further indicate that object detection experts can also specialize in detecting objects of distinct sizes.
BibTeX
@inproceedings{pavlitskaya2022balancing,
  author = {Svetlana Pavlitskaya and Christian Hubschneider and Lukas Struppek and J. Marius Zöllner},
  title = {{Balancing Expert Utilization in Mixture-of-Experts Layers Embedded in CNNs}},
  booktitle = {IJCNN},
  year = {2022},
  url = {https://openreview.net/forum?id=gY3L8qBFN7},
}
Figure