Soft Merging of Experts with Adaptive Routing

Mohammed Muqeeth, Haokun Liu, Colin Raffel

In the quest for more efficient and modular neural networks, researchers have long looked to Mixture of Experts (MoE) models. These models consist of several "expert" subnetworks, with a "router" deciding which expert should process a given input. While MoE models promise to decouple a model's total parameter count from its computational cost, they have a notorious Achilles' heel: the routing decision is usually discrete and non-differentiable, making them incredibly difficult to train.

A new paper from researchers at UNC Chapel Hill and the University of Toronto, titled "Soft Merging of Experts with Adaptive Routing (SMEAR)," proposes a clever workaround. Instead of choosing which expert to send the data to, why not just blend the experts themselves?

TL;DR

SMEAR replaces the non-differentiable "discrete routing" in Mixture of Experts models with a fully differentiable "soft merging" approach. By computing a weighted average of expert parameters for each input, SMEAR enables standard gradient-based training while maintaining the computational efficiency of a single-expert model.

What Problem Does This Paper Address?

Standard MoE models use conditional computation: for any given input, only a subset of the model's parameters is active. This is usually achieved by a router that makes a hard choice (e.g., "Send this token to Expert 2").

Because this choice is discrete, you can't backpropagate through it. To train the router, engineers must rely on complex gradient estimation techniques like REINFORCE or the Gumbel-Softmax trick. These methods are often unstable, high-variance, and frequently result in models that underperform simple hand-designed heuristics (like "Tag Routing," where you manually assign tasks to specific experts).

The challenge is to create a routing mechanism that is fully differentiable (so it's easy to train) but doesn't blow up the computational budget (by running every expert for every input).

Figure 1: The discrete routing decisions commonly used in models that route activations among experts require the use of gradient estimation (left). We propose SMEAR (right), which uses a given router’s distribution to average the parameters of the corresponding experts and then routes the input through a single merged expert. SMEAR achieves better performance than models with discrete routing, can be trained with standard backpropagation, and does not incur significant additional computational costs.

Methods

The authors introduce SMEAR (Soft Merging of Experts with Adaptive Routing). Here’s how it works:

  1. The Router: For a given input, a lightweight routing network produces a probability distribution over $N$ experts.
  2. The Merge: Instead of picking one expert, SMEAR computes a weighted average of the parameters of all experts based on the router's distribution.
  3. The Execution: The input is passed through this single "merged expert."

This approach relies on the observation that neural network parameters can often be averaged (merged) without losing their capabilities, provided they share the same architecture.

Why is this efficient? If you averaged the outputs of all experts (Ensemble Routing), you would have to run $N$ forward passes, which is $N$ times more expensive. By averaging the parameters first, you only perform one forward pass. As long as the input sequence is long (many tokens) and the number of experts is modest, the cost of averaging the weights is negligible compared to the cost of the actual computation.

Datasets

The authors evaluated SMEAR across two different modalities:

  • Natural Language Processing (NLP): Fine-tuning a T5.1.1 Base model on the GLUE benchmark (8 diverse language understanding tasks).
  • Computer Vision: Fine-tuning a ResNet18 on DomainNet, a collection of object recognition datasets spanning six distinct domains (e.g., clipart, sketches, real photos).

Key Insights and Ideas

  • Differentiability is the "Secret Sauce": The primary reason MoE models struggle isn't the architecture, but the training signal. By making the entire routing process differentiable, SMEAR allows the router to learn much more effective strategies than noisy gradient estimators.
  • The Efficiency Sweet Spot: SMEAR is particularly effective when routing decisions are made at the example level rather than the token level. In this setup, the overhead of merging parameters happens once per image or sentence, making it nearly as fast as a standard single-expert model.
  • Specialization Emerges Naturally: Qualitative analysis showed that SMEAR doesn't just "blur" the experts. Instead, the router learns to use specific experts for specific types of data (e.g., one expert for regression tasks, another for similarity tasks), even without being told which task is which.

Key Results

SMEAR consistently outperformed both heuristic routing and state-of-the-art learned routing baselines.

  • NLP Performance: On T5-GLUE, SMEAR achieved a 2.7% improvement over the strong "Tag Routing" baseline and outperformed the best gradient estimator (REINFORCE).
  • Vision Performance: On ResNet-DomainNet, SMEAR outperformed all other routing strategies, including a parameter-matched single-expert baseline by 1.2%.
  • Speed vs. Accuracy: As shown in the figure below, SMEAR occupies a "Pareto optimal" position, offering accuracy comparable to expensive ensembling methods but at the inference speed of discrete routing models.
Figure 2: Average accuracy and inference speed (in examples processed per second) for models using different routing approaches on our T5-GLUE and ResNet-DomainNet settings. Routing approaches are grouped by color; groups are (in order of the legend) our method (SMEAR), methods that do not use adaptive routing (1× compute, 1× parameters, Adamix, and Hash), methods that make use of metadata (Tag and Latent Skills), methods that learn adaptive routing (Top-k, ST-Gumbel, REINFORCE, DSelect-k, and Soft MoE), and methods that ensemble expert outputs (Ensemble). We omit Hash routing from the plots because its poor performance (66.9% on T5-GLUE and 52.4% on ResNet-DomainNet) hampers readability. Exact numerical results for all methods and standard deviation across five runs are provided in appendix F.

Limitations and Future Work

While SMEAR is a powerful tool for fine-tuning, the authors note a few areas for further exploration:

  • Per-Token Routing: Currently, SMEAR is most efficient when routing entire examples. Applying it to per-token routing (common in massive LLMs like GPT-4) would be computationally expensive because the parameters would need to be re-merged for every single token.
  • Scaling Up: The experiments focused on fine-tuning existing models. It remains to be seen how SMEAR performs when training massive models from scratch.
  • Advanced Merging: The paper uses simple weighted averaging. Future work could explore more sophisticated merging techniques, such as Fisher-weighted averaging or aligning features before merging.

SMEAR represents a significant step toward making modular, expert-based neural networks as easy to train as their dense counterparts, potentially opening the door for more flexible and adaptable AI systems.

Summary updated

Abstract

Sparsely activated neural networks with conditional computation learn to route their inputs through different "expert" subnetworks, providing a form of modularity that densely activated models lack. Despite their possible benefits, models with learned routing often underperform their parameter-matched densely activated counterparts as well as models that use non-learned heuristic routing strategies. In this paper, we hypothesize that these shortcomings stem from the gradient estimation techniques used to train sparsely activated models that use non-differentiable discrete routing decisions. To address this issue, we introduce Soft Merging of Experts with Adaptive Routing (SMEAR), which avoids discrete routing by using a single "merged" expert constructed via a weighted average of all of the experts' parameters. By routing activations through a single merged expert, SMEAR does not incur a significant increase in computational costs and enables standard gradient-based training. We empirically validate that models using SMEAR outperform models that route based on metadata or learn sparse routing through gradient estimation. Furthermore, we provide qualitative analysis demonstrating that the experts learned via SMEAR exhibit a significant amount of specialization. All of the code used in our experiments is publicly available.
BibTeX
@misc{muqeeth2023soft,
  author = {Mohammed Muqeeth and Haokun Liu and Colin Raffel},
  title = {{Soft Merging of Experts with Adaptive Routing}},
  year = {2023},
  eprint = {2306.03745},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2306.03745},
}
Figure