Beyond Parameter Count: Implicit Bias in Soft Mixture of Experts

## Abstract

Abstract The traditional viewpoint on Sparse Mixture of Experts (MoE) models is that instead of training a single large expert, which is computationally expensive, we can train many small experts. The hope is that if the total parameter count of the small experts equals that of the singular large expert, then we retain the representation power of the large expert while gaining computational tractability and promoting expert specialization. The recently introduced Soft MoE replaces the Sparse MoE’s discrete routing mechanism with a differentiable gating function that smoothly mixes tokens. While this smooth gating function successfully mitigates the various training instabilities associated with Sparse MoE, it is unclear whether it induces implicit biases that affect Soft MoE’s representation power or potential for expert specialization. We prove that Soft MoE with a single arbitrarily powerful expert cannot represent simple convex functions. This justifies that Soft MoE’s success cannot be explained by the traditional viewpoint of many small experts collectively mimicking the representation power of a single large expert, and that multiple experts are actually necessary to achieve good representation power (even for a fixed total parameter count). Continuing along this line of investigation, we introduce a notion of expert specialization for Soft MoE, and while varying the number of experts yet fixing the total parameter count, we consider the following (computationally intractable) task. Given any input, how can we discover the expert subset that is specialized to predict this input’s label? We empirically show that when there are many small experts, the architecture is implicitly biased in a fashion that allows us to efficiently approximate the specialized expert subset. Our method can be easily implemented to potentially reduce computation during inference.

## 1 Introduction

It has been well established that scaling the size (i.e., parameter count) of models is necessary for state of the art prediction power [, ], but naively scaling the model size is infeasible due to hardware constraints and computational costs. Mixture of Experts (MoE) layers in a model allow one to achieve this goal, while mitigating the increased computational costs for training and inference that accompany a naively larger model. These have been successfully deployed in practice, in a variety of contexts such as language [] and vision [], and MoE layers are considered critical to achieve state of the art performance in today’s models [].{NoHyper}
(^†^†Equal Contribution^⋆)

Figure: Figure 1: Our Algorithm 1 selects a *specialized* subset of the experts to utilize for inference. Given any proportion of $n$ (the total number of experts) to select, its performance uniformly improves with larger $n$.
Refer to caption: extracted/5826971/Figures/mnist_drop_upward_curves.png

The archetypical MoE layer is the Sparse MoE []. Here, each token is only given to a subset of experts, and a router is trained to discretely match a token to its expert subset. Since a single (large) expert can represent complex functions, the traditional viewpoint is that one should partition the large expert into multiple (small) experts, so that the total parameter count of all experts is unchanged. The hope is that the model’s representation power is similar since the total parameter count is the same and since experts can specialize to the tokens they see (rather than all tokens) []. Yet, training and inference are faster, because any single token activates only a subset of experts rather than all of them.

While the Sparse MoE allows scaling of model size, its discrete routing causes optimization issues and load balancing difficulties during training. To tackle these issues, many variants of Sparse MoE have been introduced, such as routing a token to only a single expert [], incorporating linear programs to ensure load balancing [] or having the experts select tokens (instead of tokens selecting experts) []. However, all these approaches remain discrete in nature, and thus suffer from at least some degree of training instability.

To alleviate these issues, the recently introduced Soft MoE [] eschews discrete matching in favor of a smoother approach. It computes for each expert a convex combination of the input tokens, and the expert only sees this convex combination. The final output of the model is then a convex combination of each expert’s output. This approach is fully differentiable, and hence is more stable than the Sparse MoE. This novel Soft MoE architecture has been shown to outperform all other baselines on challenging large scale vision tasks, and can scale to thousands of experts []. Moreover, recent results show that the Soft MoE is a promising avenue towards providing empirical scaling laws for deep reinforcement learning [].

Thus, while the Sparse MoE constructs a discrete mapping between tokens and experts, the Soft MoE computes convex combinations of tokens that are fed to experts, and then computes convex combinations of the expert outputs, which together promote stabler and faster training.

The majority of prior work on MoE focuses on computational issues, such as efficient and stable training. In our paper, we adopt an orthogonal perspective. In particular, it remains unclear whether Soft MoE’s specific manner of combining tokens and experts creates any unexpected implicit architectural biases. Indeed, it is not even clear that its soft gating mechanism preserves the traditional MoE dogma that many small experts have similar representation power to a single large expert with the same total parameter count. It is also unclear whether combining tokens and experts completely destroys the possibility (or discoverability) of expert specialization, which is what one traditionally desires from an MoE (especially in the regime of many experts) [, ]. Thus, we investigate for the existence of such biases, through the lens of *varying the number of experts*. In this paper, we make progress along this line of investigation by making the following contributions:

- •
We prove that the Soft MoE with a single neural network expert, even with arbitrarily many parameters, cannot represent simple convex functions (while empirically we show that multiple experts can). Thus, in contrast to the traditional viewpoint, having multiple experts is actually necessary to have non-trivial representation power in Soft MoE.
- •
We introduce a notion of specialization for Soft MoE. While discovering specialized experts generally seems intractable, we empirically demonstrate that as we increase the number of experts, even while fixing the total parameter count, the architecture is implicitly biased in a manner that allows us to efficiently approximate the specialized expert set (see Figure 1).
- •
Our method for discovering specialized experts can be easily implemented for reducing computation at inference.

These contributions thus show there are benefits to using a large number of small experts relative to a small number of large experts, and notably, these benefits are often non-computational.

## 2 Problem Formulation

### 2.1 Preliminaries

We begin by briefly discussing the Soft MoE architecture []. Throughout our paper, we assume there is a single slot per expert, since this is the most performant setting in practice. Let $X\in\mathbb{R}^{m\times d}$ denote the tokenized input, so that there are $m$ tokens each in $\mathbb{R}^{d}$. The MoE layer is equipped with $n$ experts $\{f_{j}:\mathbb{R}^{d}\to\mathbb{R}^{d}\}_{j=1}^{n}$, each of which is typically implemented as a feedforward network. The router is parameterized by $\Phi\in\mathbb{R}^{d\times n}$. Given an input $X$, the parameters $\Phi$ are used to compute matrices $D(X),C(X)\in\mathbb{R}^{m\times n}$ which are defined elementwise as

$$ $D(X)_{ij}=\frac{\exp\left(\left(X\Phi\right)_{ij}\right)}{\sum_{i^{\prime}=1}^ {m}\exp\left(\left(X\Phi\right)_{i^{\prime}j}\right)}\hskip 14.22636pt\text{ and}\hskip 14.22636ptC(X)_{ij}=\frac{\exp\left(\left(X\Phi\right)_{ij}\right)} {\sum_{j^{\prime}=1}^{n}\exp\left(\left(X\Phi\right)_{ij^{\prime}}\right)}.$ (1) $$

Note that each column of $D(X)$ and each row of $C(X)$ sums to one. With this notation in hand, we formally define the Soft MoE layer below.

###### Definition 1

The Soft MoE is a function $\mathrm{sMoE}^{\Phi}_{\{f_{j}\}_{j=1}^{n}}:\mathbb{R}^{m\times d}\to\mathbb{R}
^{m\times d}$ defined as

$$ $\mathrm{sMoE}^{\Phi}_{\{f_{j}\}_{j=1}^{n}}(X)=C(X)\widetilde{Y}(X)\;\;\text{ where }\;\;\widetilde{Y}(X)=\begin{bmatrix}f_{1}\left((D(X)^{T}X)_{1}\right)\\ \vdots\\ f_{n}\left((D(X)^{T}X)_{n}\right)\end{bmatrix}.$ $$

The Soft MoE thus computes $n$ different convex combinations of the tokens in $X$, where the weights of the $j$th convex combination are given by the $j$th column of $D(X)$. It then applies expert $f_{j}$ to the $j$th convex combination, for each $j=1,2\dots n$. Finally, it computes $m$ different convex combinations of these expert outputs, where the weights of the $i$th convex combination are given by the $i$th row of $C(X)$. Note that each expert processes a single vector in $\mathbb{R}^{d}$, and that $\mathrm{sMoE}$ is differentiable whenever the experts are. This results in more stable training relative to Sparse MoE, where each expert is given a subset of the $m$ tokens via a discrete matching algorithm. The Soft MoE has shown significant empirical success in vision [] and reinforcement learning [].

###### Definition 1

### 2.2 Our Investigation

At a high level, the Sparse MoE is designed with the following principle. Say we desire a model with $b$ total parameters, because we believe that $b$ allows for sufficiently large representation power. Instead of using a single large network ($n=1$) with $b$ parameters, we use $n>1$ smaller experts each with $b/n$ parameters. The hope is that we have similar representation power to the $n=1$ case since the total parameter count is the same, but we have faster computation because each token only activates a small subset of experts [, ]. Moreover, one also hopes that each expert can specialize to the specific type of tokens it sees [, , ].

The Soft MoE is motivated in a similar fashion. It also splits a single large model with $b$ parameters into $n\geq 1$ smaller experts each with $b/n$ parameters, hoping that representation power is unchanged. However, Soft MoE differs significantly from Sparse MoE in how it uses these experts. While Sparse MoE discretely assigns tokens to experts, Soft MoE computes convex combinations of tokens and expert outputs. Due to this significant difference, it is unclear how the original motivations for Sparse MoE apply to Soft MoE.

As one example of how Soft MoE might deviate from the original motivations for Sparse MoE, consider the extreme case when $n=1$. Here, Sparse MoE’s router trivially routes all tokens to the expert, and so classical results show that Sparse MoE can represent arbitrary continuous functions [, ]. But in Soft MoE, the gating function is non-trivial even in $n=1$, and so it is possible that Soft MoE has poor representation power even when the expert is very powerful. If this were true, then it would challenge the conventional wisdom that Soft MoE’s empirical success with $n>1$ smaller experts (each with $b/n$ parameters) is simply because they mimic (albeit computationally efficiently) the representation power of a single large expert (with $b$ parameters). Instead, it would suggest that Soft MoE has some implicit bias that enables its practical success. To this end, we ask the following question.

*Q1: Can a large single expert in Soft MoE represent simple functions?*

Our motivation for this question has thus far primarily been scientific. Nevertheless, we believe this question is also practically relevant, since there are empirical results in reinforcement learning (RL) which show that Soft MoE with a single expert can outperform traditional neural network architectures []. Indeed, a negative answer to Q1 would imply that there are implicit biases in Soft MoE that assist in its improved empirical performance.

As a second example of how Soft MoE might deviate from the original motivations for Sparse MoE, consider the following. Since Soft MoE combines all tokens before feeding them to an expert, and since it combines all experts to produce its final output, it is natural to wonder whether this prohibits expert specialization. Indeed, this limitation is acknowledged in the seminal work []. We thus ask the following question.

*Q2: Is there a notion of expert specialization in Soft MoE, and if so, can it be efficiently discovered?*

The remainder of this paper is devoted to answering Q1 (in Section 3) and Q2 (in Section 4).

## 3 Representation Failure of a Single Expert

In this section, we answer Q1 from Section 2.2. We first recall the definition of Lipschitz functions.

###### Definition 2

A function $h:\mathbb{R}^{k_{1}}\to\mathbb{R}^{k_{2}}$ is $L$-Lipschitz if $\|h(x)-h(y)\|_{2}\leq L\|x-y\|_{2}$ for all $x,y\in\mathbb{R}^{k_{1}}$.

Recall that any neural network is Lipschitz []. Our main result shows that Soft MoE with a single Lipschitz expert $f$ is incapable of representing simple target functions. This result holds even when this expert $f$ is arbitrarily powerful (and possibly non-parametric). It also holds when the output of the Soft MoE layer is passed to an arbitrarily powerful Lipschitz function $g$ (as would be the case in a practical implementation, since the MoE would be a layer that prepends a powerful neural network function, rather than a standalone layer). Below we formally state our result.

###### Theorem 1

Fix any $m\geq 2$, $d\geq 1$ and $n=1$. Define the target function $t:\mathbb{R}^{m\times d}\to\mathbb{R}$ as $t(X)=\|X\|_{2}$. Assume the existence of $\Phi\in\mathbb{R}^{d\times 1}$, $f:\mathbb{R}^{d}\to\mathbb{R}^{d}$ and $g:\mathbb{R}^{m\times d}\to\mathbb{R}$ such that

$$ $\left|t(X)-g\left(\mathrm{sMoE}^{\Phi}_{f}(X)\right)\right|\leq\max\left\{1,t( X)/20\right\}\text{ for all }X\in\mathbb{R}^{m\times d}.$ $$

Then there are no $L_{f},L_{g}\geq 0$ such that $f$ is $L_{f}$-Lipschitz and $g$ is $L_{g}$-Lipschitz.

The proof is deferred to Appendix A. Let us discuss this result.

Notion of Approximation. The theorem says that we cannot approximate $t$ over $X\in\mathbb{R}^{m\times d}$, up to an error that scales as $\max\{1,t(X)/20\}$. While the domain is unbounded, which is slightly non-standard, our approximation error is also unbounded since we allow it to scale with $t(X)$ (unlike traditional results which require approximation to within a fixed constant tolerance). Indeed, it is trivial that the constant function zero can approximate $t(X)$ over all of $\mathbb{R}^{d}$ up to an error of $t(X)$. Our notion of error is only slightly smaller than this.

Residual Connections. In a practical implementation, one would use residual connections so that the function $g$ would typically receive both $X$ and $\mathrm{sMoE}^{\Phi}_{f}(X)$ as input instead of just $\mathrm{sMoE}^{\Phi}_{f}(X)$. In such a setting, our result would of course not apply, since one could use $g$ alone to approximate $t(X)$, while completely ignoring $\mathrm{sMoE}^{\Phi}_{f}(X)$. Nevertheless, we believe it is worth studying the setting without residual connections, because if $g$ did not leverage $\mathrm{sMoE}^{\Phi}_{f}(X)$, then there would be no point of using a Soft MoE layer at all.

Benign Target. The target function $t$ is extremely benign. Indeed, it is convex and $1$-Lipschitz. So it a priori seems intuitive to try and approximate it with a Lipschitz expert $f$ and subsequent Lipschitz architecture $g$. Yet, we cannot approximate $t$ even when $f,g$ have arbitrarily large Lipschitz constants. This is in stark contrast to the classical neural network approximation literature, where relatively simple feedforward networks can represent arbitrary continuous functions [, ].

Permutation Invariant Target. Let $\sigma:\mathbb{R}^{m\times d}\to\mathbb{R}^{m\times d}$ be any function that permutes the rows of its input. It is easily shown that $\sigma$ commutes with $\mathrm{sMoE}^{\Phi}_{\{f_{j}\}_{j=1}^{n}}$. This implies that one cannot represent target functions that vary based on permutations of their input’s rows. A result which relied on this property would not be very satisfying, since in practice this issue is handled by adding positional encoding to the input []. However, our target function $t$ satisfies $t(\sigma(X))=t(X)$ for any permutation function $\sigma$. Indeed, an examination of the proof in Appendix A shows that the result hinges on the particular manner in which tokens are combined before being passed to the expert.

Normalizing Input. In practice, one may normalize the input $X$ before passing it to the Soft MoE, and in this case Theorem 1 is trivially inapplicable. Nevertheless, since the performance with or without normalization is typically very comparable [], we believe the result remains interesting.

Multiple Experts. We are unable to prove a theorem for the ability of multiple experts to represent $t$. In Appendix B, however, we show empirically that increasing the number of experts leads to monotonic performance improvement for representing $t$, even when the total expert parameter count is fixed.

Theorem 1 (and the experiment in Appendix B) thus provides a negative answer to Q1 raised in Section 2.2. It therefore challenges the conventional wisdom that Soft MoE’s empirical success with $n>1$ smaller experts (each with $b/n$ parameters) is simply because they mimic the representation power of a single large expert (with $b$ parameters). Instead, it suggests that Soft MoE has implicit biases that assist in its improved performance. A precise characterization of these biases and their role in this improvement is beyond our paper’s scope. Nevertheless, we view our result as a stepping stone towards understanding and potentially furthering the true power of Soft MoE. Indeed, recent results show that Soft MoE with even a single expert can outperform traditional architectures []. Our Theorem 1 shows that this improvement cannot be because of improved representation power.

###### Definition 2

###### Theorem 1

## 4 Specialization of Experts

In this section, we tackle Q2 from Section 2.2.

### 4.1 What Does Specialization Mean?

We begin by noting that since the Soft MoE combines tokens before feeding them to experts, it seems a priori unlikely that experts specialize, as acknowledged in the seminal work []. Indeed, it is unclear what it even means for an expert to specialize; for instance it seems difficult to consider specialization of an expert to a subset of tokens.

Instead, our notion of specialization is whether there exists, for any input $X\in\mathbb{R}^{m\times d}$, an $X$-dependent (relatively small) subset of experts that are sufficient to accurately predict the label for that input $X$. Recall from Definition 1 that the output of the Soft MoE layer is $C(X)\widetilde{Y}(X)$, where $\widetilde{Y}(X)\in\mathbb{R}^{n\times d}$ stores the output of expert $i$ in row $i$. Hence, zeroing out a row $i$ of $\widetilde{Y}(X)$ means that expert $i$ does not contribute anything to the final prediction. If we can zero out many rows of $\widetilde{Y}(X)$ without affecting the final prediction, then the remaining experts can be understood to have specialized to the input $X$, since this means that only these remaining experts were actually required to make an accurate prediction, and these experts did not require contributions from the other zeroed out experts. By contrast, if zeroing out rows of $\widetilde{Y}(X)$ changes the prediction, then this indicates a lack of expert specialization, since the knowledge required to predict correctly on $X$ was non-trivially spread out across each of the $n$ experts.

### 4.2 Does Specialization Exist?

To test whether specialization occurs, we consider the following small experiment. For $n\in\{4,8,16\}$ we train a simple neural network that comprises of a Soft MoE layer with $n$ experts, followed by a linear prediction head, on the MNIST dataset []. The experts in the MoE are each (identical architecture) MLP with one hidden layer and ReLU activation, and we denote the number of parameters in a single expert to be $d_{E,n}$. As we increase $n$, we decrease the width of each expert (i.e. the number of units in the hidden layer), so that the total (i.e., summed over all experts) number of parameters $nd_{E,n}$ is constant for all values of $n$. By holding the total number of expert parameters constant, we keep the total expressivity constant, and thus ensure that we do not bias the results for larger numbers of experts. See Appendix D.1 for further details of this experimental setup.

We train each network, and for the sake of a fair comparison across $n$, we select for each $n$ a model that has $\approx 97.5\%$ test accuracy. We emphasize that our aim is to investigate the impact of $n$ on expert specialization, thus we need to first ensure that each setting of $n$ achieves the same test performance. Then, for each of the $n$ models and each test datapoint $X$ we do the following: (a) we use an exhaustive search to identify whether there exists an expert subset of size $k=n/4$ that predicts the label for $X$ correctly (b) we randomly zero out $3n/4$ rows of $\widetilde{Y}(X)$, so we are only predicting using a random set of $k=n/4$ experts, and check whether it predicts the label for $X$ correctly. For both settings, we compute the average prediction accuracy over all $10,000$ test points. Note for both settings that the number of expert parameters involved in prediction is invariant to the number of experts $n$.

The first row of Table 1 shows that expert specialization occurs, especially for larger $n$ (even though each of the experts for larger $n$ are smaller in parameter count).
Figure 5 in Appendix D.1 shows that the best $k$-subsets identified are diverse, indicating the expert subsets are indeed specialized to the input.
However, the exhaustive search used to generate this result is generally intractable for larger models. It is also not useful for prediction in the wild, since this procedure requires knowledge of the label of each test point $X$. Moreover, the second row of Table 1 shows that we cannot hope to find the best subset simply via random selection.

**Table 1: Results for experiment in Section 4.2, where a subset of the experts of size $k=n/4$ was used to predict the labels. For the Random subset results, we report the mean and standard deviation over 10 random seeds.**
|  | $n=4$ | $n=8$ | $n=16$ |
| --- | --- | --- | --- |
| Best $k$-Subset Accuracy (%) | $94.69$ | $99.90$ | $100.00$ |
| Random $k$-Subset Accuracy (%) | $46.57\pm 0.44$ | $51.95\pm 0.46$ | $58.94\pm 0.34$ |

### 4.3 An Algorithm For Best Expert Selection

The results of the experiment in Section 4.2 demonstrate the existence of expert specialization, albeit in a small experiment. However, the same results show that identifying the best subset of experts cannot be done as simply as via random selection. Since identifying the true best subset of $k$ experts ostensibly has $\Omega\left(\binom{n}{k}\right)$ computational complexity, it is of interest to discover an efficient algorithm which can rapidly approximate the best subset, especially before moving on to larger experiments. Beyond our current motivations of checking for the existence of expert specialization, such an algorithm could also be useful at inference time to reduce computational expense without loss in accuracy (see Section 4.5).

To this end, we recall from Definition 1 that given an input $X$, the final output of the Soft MoE is $C(X)\widetilde{Y}(X)$, i.e. row $i$ of the final output is a convex combination of the rows of $\widetilde{Y}(X)$ where the combination weights are given by row $i$ of $C(X)$. So a natural attempt to identify the most important experts are those given the most weight by $C(X)$. Algorithm 1 formalizes this intuition.

Figure: Algorithm 1 Best Expert Subset Selection

Note that Algorithm 1 is computationally efficient, requires no separate training, and can be implemented in just a few lines of code. We also note that it can be easily adapted to handle a batched input in a vectorized fashion (see Appendix C). Its output $\widehat{Y}(X)\in\mathbb{R}^{n\times d}$ equals $\widetilde{Y}(X)$ on $k$ rows, and is zero in the other $n-k$ rows. Thus, Algorithm 1 can be used to identify a performant subset of experts at inference time, and then construct the final Soft MoE output by only doing a forward pass through $k$ experts instead of all $n$ experts. In the regime of many large experts, this can yield computational advantages at inference time, and we explore this further in Section 4.5.

Figure: (a) MNIST
Refer to caption: extracted/5826971/Figures/mnist_k_n_upward_curves_with_random.png

### 4.4 Empirical Performance of Algorithm 1

In line with the experimental setup assumed by the seminal work [], we demonstrate the efficacy of Algorithm 1 on a suite of image classification tasks. We provide results across a wide range of model scales and architectures, including architectures beyond the ViT model class that was used to introduce Soft MoE.

#### 4.4.1 Experimental Setup

We experiment on 4 datasets: MNIST, CIFAR10, CIFAR100 [] and ImageNet-1k []. For MNIST, we use the same experimental setup as in Section 4.2. Recall that the network used is very simple, and consists entirely of a Soft MoE layer and a prediction head. This small network has merely 318K total parameters, of which 307K are expert parameters. As a more practical setting, we use the Astroformer-1 architecture [] for CIFAR10 and CIFAR100. This hybrid transformer-convolutional architecture achieves excellent performance on these datasets without leveraging extra training data. We modify Astroformer-1 by replacing the MLPs in the transformer blocks with Soft MoE layers, analogous to the standard practice that is followed in ViTs []. This model is larger, and has 180M total parameters, of which 150M are expert parameters.
Finally, we adopt the same Soft MoE variant of the ViT architecture [] used by the seminal work [] on the ImageNet-1k dataset. Specifically, it replaces the MLPs in the latter half of the encoder blocks of the ViT Base model with Soft MoE layers.
This is the largest architecture we consider, and it has 513M total parameters, of which 454M are expert parameters.
Due to compute constraints, scaling up our experimental protocol further (either with external pretraining data or larger model sizes) is infeasible. Nevertheless, our setup spans a range of model architecture types and scales, as well as several canonical datasets.
We defer further details of the various architectures and their modifications to Appendix D.2.

For each dataset and associated network architecture, we do the following.
We train a suite of models where each model has a different $n$ (total number of experts) in each Soft MoE layer. Each model is trained *from scratch* without utilizing any external data.
As discussed in Section 4.2, when we increase $n$ we correspondingly decrease the number of parameters in each expert, to ensure the total expert expressivity is (roughly) constant. After training each network, we select for each $n$ a model that has the same test accuracy (as discussed in Section 4.2, this is important because we are investigating the impact of varying $n$ on Algorithm 1’s test performance, and so we must ensure the original networks have similar test performance). For each of these trained networks and various values of $k$, we then evaluate Algorithm 1’s performance on the test set. Concretely, we compute the test accuracy of using the $k$ experts found by Algorithm 1 for each datapoint in the test set, and compare this to the test accuracy of randomly selecting $k$ experts for each datapoint in the test set.

#### 4.4.2 Experimental Results

In Figures 2 and 3 we depict, for each dataset and various choices of $k$, the performance of Algorithm 1 relative to the random selection scheme. We make two main observations.

The first observation is that Algorithm 1’s accuracy may deteriorate (relative to using all experts) when $k<n$ and $n$ is small. But if $n$ is big, then Algorithm 1’s accuracy is often very close to that of using all the experts, even when $k\ll n$. For instance, on MNIST, using the $k=n/2$ experts selected by Algorithm 1 gives nearly the same performance as using all experts when $n\geq 64$, but has poor performance when $n\leq 8$. This shows that as $n$ increases, Algorithm 1 is better poised to discover specialized experts, even though the number of expert parameters is invariant to $n$. While we do not have a formal explanation for why this phenomenon occurs, we believe it is an instance of the implicit bias that exists in Soft MoE. Concretely, the experts found by Algorithm 1 for input $X$ are those which are assigned the highest weight by $C(X)$. Our result thus shows that as $n$ increases, the Soft MoE trains in a manner such that the $C(X)$ matrix is more informative for which experts are useful in correctly predicting the label of $X$, even though such a property is not explicitly enforced during training! Since the role of $C(X)$ is ultimately just to adaptively combine expert outputs, this implicit bias is very benign. A different view of the same results in Figure 2(a) is provided in Figure 1.

The second observation is that Algorithm 1’s test performance dominates that of random selection. And often, Algorithm 1 is far better than random selection, as is particularly evident in CIFAR10 and ImageNet-1k, where random selection is very poor (see Figure 2). There are instances where random selection has decent accuracy, such as in CIFAR100 (see Figure 3). So to further validate our result, we use the following statistic to measure how much better Algorithm 1 is relative to random selection. We first compute the standard deviation of the random selection test accuracies (which were obtained by averaging over 10 random seeds). Our statistic is then the number of standard deviations by which Algorithm 1 exceeds the mean random selection accuracy. When this statistic is large, it means that Algorithm 1 found an expert subset whose performance is statistically significantly larger than that of the typical random expert subset. The results are shown in Table 2 where we observe very large values for this statistic. This shows that our Algorithm 1 significantly outperforms random selection for CIFAR100, even though random selection has decent performance on this dataset. Analogous tables for the other datasets are provided in Appendix D.3.

Figure: Figure 3: Results for CIFAR100 experiments from Section 4.4.
Refer to caption: extracted/5826971/Figures/cifar100_heuristic_and_drop_large_font_wide.png

### 4.5 Faster Inference via Algorithm 1

In practice, one typically trains a very large model (with many Soft MoE layers, each with many experts) a single time, then the model is deployed and repeatedly utilized for inference.
It is thus of great interest to speed up computation through Soft MoE modules, since this leads to faster inference. Algorithm 1 is well suited for this purpose. The preceding sections show that when the number of experts $n$ is large, then Algorithm 1 can rapidly and cheaply find a small subset of experts that can predict any datapoint with minimal expected accuracy loss. So it can potentially be used for faster inference through the Soft MoE.

A full examination of the usefulness of Algorithm 1 for faster inference is beyond the scope of our paper. A proper analysis would require massive industry-scale models, and would also be very application specific because it would depend on the type and number of devices used for inference, as well as the extent of distributed computing and per-device parallelization. We lack the compute capacity to do such a thorough study. Nevertheless, it is immediate that in the regime of many large experts, where a forward pass through an expert has non-trivial cost, Algorithm 1 should save computation since its overhead is relatively negligible. As a simple example to show the potential of Algorithm 1 for faster inference, we consider the same ViT architecture from Section 4.4 with 8 total experts, but with each expert being much larger, such that the whole model has 2.32B parameters, of which 2.27B parameters are in the experts. We measure the total wall clock time elapsed during a forward pass through the 6 Soft MoE layers, where each layer will only utilize $k$ experts as prescribed by Algorithm 1. The results are presented in Table 3, and show that smaller values of $k$ yield significant speedups. See Appendix D.4 for further details on this experiment.

**Table 3: Wall clock time of performing a single forward pass (of random data) through the 6 Soft MoE layers using Algorithm 1, with either a single datapoint or a batch of 100 datapoints. The unit of all values are milliseconds. For each batch size, we report the mean and standard deviation over 100 trials.**
|  | $k=n$ | $k=3n/4$ | $k=n/2$ | $k=n/4$ |
| --- | --- | --- | --- | --- |
| batch = 1 | $21.50\pm 0.20$ | $19.46\pm 0.23$ | $14.75\pm 0.35$ | $9.96\pm 0.19$ |
| batch = 100 | $99.03\pm 0.28$ | $78.26\pm 0.51$ | $78.86\pm 0.36$ | $51.69\pm 0.79$ |

## 5 Related Work

Mixture of Experts. Our work falls squarely in the literature on MoEs, which originated several decades ago [, ] and has been revived as the Sparse MoE []. Nevertheless, there is a significant difference between our investigation and the majority of past work. The majority of past work in MoE focuses primarily on computational considerations, such as (in the context of Sparse MoE) routing a token to only a single expert for efficiency [], and ensuring load balancing by incorporating linear programs [] or having the experts select tokens [] or re-routing dropped tokens []. Indeed, the Soft MoE [] was recently introduced to address the various training instabilities suffered by Sparse MoE, and performs very well in applications like vision [], RL [] and audio processing []. By contrast, our investigation begins with a more fundamental question – what are the implicit biases that occur as a result of Soft MoE’s particular manner of combining tokens and expert outputs?
While analogous fundamental investigations of the gating function do exist in the context of Sparse MoEs [, ] and some of its variants [, ], to the best of our knowledge this line of investigation is novel in Soft MoE.

Expert Specialization. The use of MoE layers in a network is often motivated by the desire for expert specialization, since this implies a more efficient use of the network parameters. To our knowledge, all prior work on expert specialization has been conducted in the context of Sparse MoE. While some studies demonstrate that expert specialization may occur for Sparse MoE [, ], others show that specialization is often limited and requires architectural innovations [, , ]. These innovations are different than Soft MoE, where it is not even a priori clear what expert specialization means. Indeed, the seminal work acknowledges this limitation []. In our paper, we offer a notion of expert specialization in Soft MoE, and show not only that it occurs but can be efficiently detected.

Sparse Activation & Pruning. Our work is also related to the literature on sparsely activating or pruning a network, since our Algorithm 1 can be viewed as a form of pruning at inference. For instance, there is work on using RL to conditionally activate only certain units in a generic network for faster training and inference [], pruning CNN kernels for efficient inference [], and developing adaptive computation modules for transformers []. While a complete survey of this vast area is beyond the current scope
[], we emphasize that our form of pruning is entirely specific to Soft MoE, since it relies on the $C(X)$ matrix. It can be used with or without many other types of pruning.

## 6 Discussion

Limitations. Our work has a number of limitations. While our Theorem 1 is a negative result for a single expert’s representation power, we are unable to prove a corresponding positive result for multiple experts (although in Appendix B we provide empirical evidence for increased representation power as the number of experts increases). A different limitation is that we are unable to provide a thorough analysis of the extent to which Algorithm 1 can reduce computation at inference (due to a lack of compute capacity). We believe both limitations provide exciting directions for future work.

Conclusion. In this paper, we studied the Soft Mixture of Experts architecture. We eschewed the traditional viewpoint of scaling expert parameter count in a manner that allows efficient training and inference. Instead, we adopted an orthogonal perspective, and studied implicit biases that arise from Soft MoE’s particular manner of combining token and expert outputs. We showed that even with an arbitrarily powerful single expert, Soft MoE cannot represent simple convex functions, thus showing that good representation power is predicated on having multiple experts. We also introduced a notion of expert specialization for Soft MoE, and provided an algorithm that efficiently discovers specialized experts when the number of experts is large. Overall, our analysis (both theoretical and empirical) highlights non-traditional reasons for why using many smaller experts is preferable to using fewer larger experts, even when the total expert parameter count remains fixed.

## Appendix A Proof of Theorem 1

Here, we formally prove Theorem 1. Assume for the sake of contradiction that there exist $\Phi\in\mathbb{R}^{d\times 1}$, $f:\mathbb{R}^{d}\to\mathbb{R}^{d}$ and $g:\mathbb{R}^{m\times d}\to\mathbb{R}$ such that

$$ $\left|t(X)-g\left(\mathrm{sMoE}^{\Phi}_{f}(X)\right)\right|\leq\max\left\{1,t( X)/20\right\}\text{ for all }X\in\mathbb{R}^{m\times d},$ (2) $$

where $f$ is $L_{f}$-Lipschitz and $g$ is $L_{g}$-Lipschitz. Via the $L_{g}$-Lipschitz property and via Definition 1, we know for any $A,B\in\mathbb{R}^{m\times d}$ that

$$ $\displaystyle\left|g\left(\mathrm{sMoE}^{\Phi}_{f}(B)\right)-g\left(\mathrm{ sMoE}^{\Phi}_{f}(A)\right)\right|$ $\displaystyle\leq L_{g}\left|\mathrm{sMoE}^{\Phi}_{f}(B)-\mathrm{sMoE}^{\Phi}_ {f}(A)\right|$ $\displaystyle=L_{g}\left\|C(B)\widetilde{Y}(B)-C(A)\widetilde{Y}(A)\right\|_{2}$ $\displaystyle=L_{g}\left\|\begin{bmatrix}1\\ 1\\ \vdots\\ 1\end{bmatrix}\left(\widetilde{Y}(B)-\widetilde{Y}(A)\right)\right\|_{2}$ $\displaystyle=L_{g}\sqrt{m}\left\|\widetilde{Y}(B)-\widetilde{Y}(A)\right\|_{2}.$ $$

Now again using Definition 1 and applying the $L_{f}$-Lipschitz property, we obtain from the above inequality that

$$ $\displaystyle\left|g\left(\mathrm{sMoE}^{\Phi}_{f}(B)\right)-g\left(\mathrm{ sMoE}^{\Phi}_{f}(A)\right)\right|$ $\displaystyle\leq L_{g}\sqrt{m}\left\|\widetilde{Y}(B)-\widetilde{Y}(A)\right \|_{2}$ (3) $\displaystyle=L_{g}\sqrt{m}\left\|f\left(D(B)^{T}B\right)-f\left(D(A)^{T}A \right)\right\|_{2}$ $\displaystyle\leq L_{g}L_{f}\sqrt{m}\left\|D(B)^{T}B-D(A)^{T}A\right\|_{2}.$ $$

We now breakup the remainder of the proof into disjoint and exhaustive cases based on the sign of the first entry of $\Phi$, and in each case we show a contradiction.

We begin with the case where $\Phi_{1}>0$. Define $A\in\mathbb{R}^{m\times d}$ to be the matrix which is all zeros, except $A_{11}=a$ and $A_{21}=-a$ for a value of $a>0$ that is yet to be specified. Then $A\Phi\in\mathbb{R}^{m\times 1}$ is a vector of all zeros except that its first entry is $a\Phi_{1}>0$ and its second entry is $-a\Phi_{1}<0$. By the definition of the matrix $D$ in Section 2.1, this implies for large $a>0$ that

$$ $D(A)_{i}=\begin{cases}1-\Omega\left(m\exp(-a)\right)\text{ if }i=1\\ \mathcal{O}\left(\exp(-a)\right)\text{ if }i>1\end{cases}.$ $$

Now define $B\in\mathbb{R}^{m\times d}$ to be the matrix which is all zeros, except $B_{11}=a$ for the aforementioned value of $a>0$ that is yet to be specified. Then $B\Phi\in\mathbb{R}^{m\times 1}$ is a vector of all zeros except that its first entry is $a\Phi_{1}>0$. By the definition of the matrix $D$ in Section 2.1, this implies for large $a>0$ that

$$ $D(B)_{i}=\begin{cases}1-\Omega\left(m\exp(-a)\right)\text{ if }i=1\\ \mathcal{O}\left(\exp(-a)\right)\text{ if }i>1\end{cases}.$ $$

Let $A_{1},B_{1}$ denote the first column of $A,B$. Leveraging continuity of the absolute value, we thus obtain that

$$ $\displaystyle\lim_{a\to\infty}\left\|D(B)^{T}B-D(A)^{T}A\right\|_{2}$ $\displaystyle=\lim_{a\to\infty}\left|D(B)^{T}B_{1}-D(A)^{T}A_{1}\right|$ (4) $\displaystyle=\left|\lim_{a\to\infty}\left(D(B)^{T}B_{1}-D(A)^{T}A_{1}\right)\right|$ $\displaystyle=0.$ $$

Note via definition of $t$ that $t(A)-t(B)=(\sqrt{2}-1)a$. Now recalling Eq. (2) and Eq. (3), we know for large $a>0$ that

$$ $\displaystyle(\sqrt{2}-1)a$ $\displaystyle=t(A)-t(B)$ $\displaystyle\leq\left|g\left(\mathrm{sMoE}^{\Phi}_{f}(B)\right)-g\left( \mathrm{sMoE}^{\Phi}_{f}(A)\right)\right|+\max\left\{1,t(B)/20\right\}+\max \left\{1,t(A)/20\right\}$ $\displaystyle\leq L_{g}L_{f}\sqrt{m}\left\|D(B)^{T}B-D(A)^{T}A\right\|_{2}+a/5.$ $$

This implies that

$$ $a/10\leq L_{g}L_{f}\sqrt{m}\left\|D(B)^{T}B-D(A)^{T}A\right\|_{2}.$ $$

Taking the limit as $a\to\infty$ on either side of the above equation, and using Eq. (4), yields a contradiction.

We now consider the case where $\Phi_{1}<0$. The proof for this case is completely symmetric to the proof for the case of $\Phi_{1}>0$, and so it is omitted.

We now consider the final case of $\Phi_{1}=0$. Define $B\in\mathbb{R}^{m\times d}$ to be the matrix of all zeros, except $B_{11}=a$ for a value of $a>0$ that is yet to be specified. Define $A\in\mathbb{R}^{m\times d}$ to be the matrix of all zeros, except $A_{11}=A_{21}=a/2$ for the aforementioned value of $a>0$. Then since $A\Phi=B\Phi=0$, we have

$$ $D(A)=D(B)=\begin{bmatrix}1/m\\ 1/m\\ \vdots\\ 1/m\end{bmatrix}.$ $$

Let $A_{1},B_{1}$ denote the first column of $A,B$. The above equality implies that

$$ $\left\|D(B)^{T}B-D(A)^{T}A\right\|_{2}=\left|D(B)^{T}B_{1}-D(A)^{T}A_{1}\right |=\frac{a}{m}-\left(\frac{a}{2m}+\frac{a}{2m}\right)=0.$ $$

Note via definition of $t$ that $t(B)-t(A)=(1-1/\sqrt{2})a$. Now recalling Eq. (2) and Eq. (3), we know for large $a>0$ that

$$ $\displaystyle(1-1/\sqrt{2})a$ $\displaystyle=t(B)-t(A)$ $\displaystyle\leq g\left(\mathrm{sMoE}^{\Phi}_{f}(B)\right)-g\left(\mathrm{ sMoE}^{\Phi}_{f}(A)\right)+\max\left\{1,t(B)/20\right\}+\max\left\{1,t(A)/20\right\}$ $\displaystyle\leq L_{g}L_{f}\sqrt{m}\left\|D(B)^{T}B-D(A)^{T}A\right\|_{2}+a/10$ $\displaystyle=a/10.$ $$

Thus we have arrived at a contradiction in each of the three cases. This completes the proof. $\blacksquare$

## Appendix B Can Soft MoE with Multiple Experts Represent ∥ ⋅ ∥ 2 \|\cdot\|_{2} ∥ ⋅ ∥ start_POSTSUBSCRIPT 2 end_POSTSUBSCRIPT ?

Our Theorem 1 shows that Soft MoE with a single expert cannot represent the function $t$ defined as $t(X)=\|X\|_{2}$, even when the expert is arbitrarily powerful. However, it leaves open the possibility that Soft MoE with multiple experts could represent this function $t$. In this section, we provide a simple experiment to empirically check this. We consider the same problem of learning the function $t$, and we train a suite of Soft MoE models, each with a different number of experts, $n$, where $n\in\{1,2,5,10\}$. As always (and as subsequently discussed), we fix the total expert parameter count.

We consider the input $X\in\mathbb{R}^{10}$, where $X\sim\mathcal{N}(0,5I)$. For an input vector $X$, the label $y$ was set to $\|X\|_{2}$. Each batch of data is newly generated from this data distribution. We do two experiments with two different tokenization strategies. Concretely, the input was tokenized into either $X\in\mathbb{R}^{5\times 2}$ or $X\in\mathbb{R}^{2\times 5}$, i.e. 5 tokens each with dimension 2, or 2 tokens each with dimension 5, by partitioning the 10 elements of an input vector in order of their dimension index.

In the spirit of Theorem 1, the Soft MoE models considered consisted only of a Soft MoE layer, and a non-trainable summation prediction head. Therefore, given an input matrix $X\in\mathbb{R}^{m\times d}$ (i.e., $m$ tokens each with dimension $d$), it is passed directly to the Soft MoE layer. Each expert was a two layer MLP that had input and output of dimension $d$ and a single hidden layer with dimension $10d/n$. Thus, the number of expert parameters in each model was always constant at $20d^{2}$, regardless of the number of experts $n$ in the model. The output from the Soft MoE layer was then summed to produce the final scalar prediction from the model. Each model was trained with a batch size of $10,000$, with the Adam optimizer using default hyperparameters and learning rate of $1e\text{-}3$ over 500 epochs.

Figure 4 shows the loss curves from the 2 settings of token dimensions considered. We note that because each training batch is newly generated from the data distribution, the loss curves represent both the train and test loss. The blue curve with $n=1$ shows that having 1 large expert is unable to lower the loss and learn the L2 norm function, and thus provides empirical support for Theorem 1.

Figure: Figure 4: Loss curves in training Soft MoE models to learn the L2 norm function
Refer to caption: extracted/5826971/Figures/norm_loss_patch_2_5.png

Notably, however, using more than one expert significantly reduces the loss, even though the number of expert parameters in each model was held constant. Indeed, we see in Figure 4 that increasing the number of experts seems to monotonically improve performance, even though the expert parameter count is fixed. This result therefore challenges the conventional wisdom that Soft MoE’s empirical success with $n>1$ smaller experts (each with $b/n$ parameters) is simply because they mimic the representation power of a single large expert (with $b$ parameters). Instead, it suggests that the Soft MoE has implicit biases, that assist in its improved performance.

## Appendix C Additional Algorithm Details

We provide an example implementation of a batched version of Algorithm 1 where we assume we are given an input batch of size $b$.
In describing each step, we will use PyTorch[] APIs, but we note that analogous functionalities to efficiently handle batch computation are readily available in other packages, such as NumPy[], TensorFlow[], or JAX[].

Figure: Algorithm 2 Best Expert Subset Selection for Batch of Inputs

## Appendix D Details of Empirical Experiments

### D.1 Details of Experiments in Section 4.2

For this experiment on MNIST, the models used consisted of a single Soft MoE layer followed by a linear prediction head. Tables 4 and 5 provide a summary of the model and training procedure. To elaborate further, each model is trained with the Adam optimizer [] using default optimizer parameters for 15 epochs.
We trained with the standard train set of $60,000$ datapoints and used the test set of $10,000$ datapoints for evaluation.
Each setting of $n$ (number of experts) reached $\approx 97.5\%$ test accuracy after 15 epochs.
During a forward pass of the model, each input image is tokenized into 4 patches, each of dimension $1\times 14\times 14$. Thus the input is $X\in\mathbb{R}^{4\times 196}$, i.e. $4$ tokens, each of dimension $196$. For a network with $n$ experts, a single expert is an MLP with one hidden layer and ReLU activation, where the input and output are each 196 dimensional, and the number of hidden units is $196\times 4/n$. While we trained a suite of 9 models with $n\in\{2^{1},2^{2},2^{3},2^{4},2^{5},2^{6},2^{7},2^{8},2^{9}\}$, the experiment in Section 4.2 uses 3 of these models with $n\in\{2^{2},2^{3},2^{4}\}$.

Note that the results in Table 1 show that for $n=8$ and $n=16$ the best $n/4$ expert subset actually predicts slightly better than just using the original network, i.e. utilizing all the experts. This is not too surprising, given that MNIST is relatively simple and our Soft MoE network is very overparameterized, and so exhaustively searching over many subnetworks can easily yield improved performance.

**Table 4: Model details for MNIST experiments in Sections 4.2 and 4.4.**
| Model Feature | Used Value |
| --- | --- |
| Raw Input Size | $1\times 28\times 28$ |
| Input Resizing | None |
| Soft MoE Input Size | $1\times 28\times 28$ |
| Patch Size | $1\times 14\times 14$ |
| Total Model Parameters | $318$K |
| Total Expert Parameters | $307$K |
| Number of Soft MoE Layers | 1 |
| Parameters per Expert | $307$K $/n$ |
| Models Trained | $n\in\{2^{1},2^{2},2^{3},2^{4},2^{5},2^{6},2^{7},2^{8},2^{9}\}$ |

**Table 5: Key hyperparameter settings for MNIST experiments in Sections 4.2 and 4.4.**
| Hyperparameter | Used Value |
| --- | --- |
| Batch Size | $256$ |
| Epochs | $15$ |
| Optimizer | Adam |
| LR | $1e\text{-}3$ |
| LR Scheduling | None: Constant LR |
| Epochs | $15$ |

Figure: Figure 5: Each bar presents the number of unique subsets of experts of size $k=n/4$ that were used to produce the highest accuracy, for each setting of the total number of experts $n$.
Refer to caption: extracted/5826971/Figures/mnist_number_of_unique_subsets.png

In Figure 5, we display the number of unique subsets of the experts that were used to produce the best $k$-subset accuracies in Table 1. Since there are $10,000$ datapoints in the test set and $\binom{n}{k}$ total number of unique subsets, each bar is capped at $\min\{10,000,\binom{n}{k}\}$.

As there are few combinations of expert subsets of size $k=n/4$ with low $n$, all subset combinations are required to produce the best accruacies when $n$ is low, but they still do not achieve perfect accuracies, as indicated in the first row of Table 1. The number of unique subsets grows with $n$, which indicates an increase in the diversity of experts used per datapoint, and thus more degree of specialization of the experts to each input $X$ (following our notion of specialization from Section 4.1).

### D.2 Details of Experiments in Section 4.4

The MNIST experiment in this section re-used the models that were trained from Section 4.2. In this set of experiments, we used all 9 models, each with a different number of experts.

For the CIFAR10 experiment, we trained a suite of Soft MoE models with different numbers of experts $n$ by taking the Astroformer-1 model as backbone and replacing the MLPs of the transformer blocks with a Soft MoE layer. The Astroformer model assumes the “C-C-C-T” architecture, where “C” stands for convolution and “T” stands for transformer. The transformer stage consists of 2 transformer blocks, each of which has a feedforward network. We replace this feedforward network with a Soft MoE layer. An input image of size $3\times 96\times 96$ (channel $\times$ height $\times$ width) is processed by the “C” stages into a tensor of size $768\times 3\times 3$ when it reaches the first “T” stage. Following standard practice in tokenizing images via patches, we treat each height-width location as a token, and thus create $9$ total tokens (or patches), each with dimension 768. Each expert is a 2-layer MLP with inputs and outputs that are both 768 dimensional, and the number of hidden units is $768*64/n$. A summary of the model features are provided in Table 6.

**Table 6: Model details for CIFAR10 and CIFAR100 experiments in Section 4.4.**
| Model Feature | Used Value |
| --- | --- |
| Raw Input Size | $3\times 32\times 32$ |
| Resized Input Size | $3\times 96\times 96$ |
| Soft MoE Input Size | $768\times 3\times 3$ |
| Patch Size | $768\times 1\times 1$ |
| Base Model Architecture | Astroformer-1 |
| Total Model Parameters | $180$M |
| Total Expert Parameters | $150$M |
| Number of Soft MoE Layers | 2 |
| Parameters per Expert | $150$M$/2n$ |
| Models Trained | CIFAR10: $n\in\{2^{1},2^{2},2^{3},2^{4},2^{5},2^{6},2^{7}\}$ |
| CIFAR100: $n\in\{2^{1},2^{3},2^{4},2^{6},2^{7}\}$ |  |

**Table 7: Key hyperparameters used for CIFAR10 and CIFAR100 experiments in Section 4.4.**
| Hyperparameter | Used Value |
| --- | --- |
| Batch Size | $800$ |
| Gradient Accumulation Steps | 1 |
| Epochs | $500$ |
| Optimizer | AdamW |
| LR Scheduler | Cosine |
| Base LR | $3e\text{-}4$ |
| LR Cycle Decay | $1e\text{-}2$ |
| LR K Decay | $1$ |
| Warmup LR | $1e\text{-}5$ |
| Epochs | $500$ |
| Warmup Epochs | $5$ |
| Mixup | $0.8$ |
| Label Smoothing | 0.1 |
| Dropout Rate | 0.1 |

One additional modification we had to make to this architecture
was that there are no residual connections from directly before Soft MoE to directly after Soft MoE. All of the other residuals connections between other blocks were retained. We made this design choice because we found that our Soft MoE variant of Astroformer trains in a manner that essentially ignores expert outputs and only relies on the residual connections (i.e., the expert outputs are negligible compared to the residual portion). Such a scenario biases the results, since the remainder of the network makes predictions without relying on the Soft MoE layer at all, and we thus cannot assess Algorithm 1. While this may be an artifact of hyperparameter settings that are not optimized for our Soft MoE variant models, we did not have the compute surplus to perform an exhaustive search over hyperparameters and utilized those that were provided with the model implementation and code.

To train our Soft MoE variant of the Astroformer-1 models, we followed the exact same training procedure as that provided in the Astroformer paper [] and their public codebase(^1^11[https://github.com/Rishit-dagli/Astroformer](https://github.com/Rishit-dagli/Astroformer)), with the exception of the input resizing and base learning rate. While there are many hyperparameter settings that were set by default when we used their codebase and commands, we provide a summary of a few key settings in Table 7. We trained with the standard train set of $50,000$ datapoints and used the test set of $10,000$ datapoints for evaluation. Training was halted as soon as the model crossed $95\%$ test accuracy, which was typically well before the total number of epochs.

For the CIFAR100 experiment, we used the exact same model and training code as that of CIFAR100. In our trials of training the base Astroformer-1 model (i.e. without any MoE layers or modifications), the model converges to $\approx 80\%$ test accuracy over 500 epochs of training, and our Soft MoE variants of Astroformer-1 also converged to $\approx 80\%$ test accuracy using the same training procedure and code.

For the ImageNet-1k experiment, we used the same model architecture as that used by the seminal paper that proposed Soft MoE []. Specifically, we used the Soft MoE adaptation of the ViT Base model, with the only difference being that the expert MLPs are of different sizes, depending on the number of experts, $n$. We defer exact details of the architecture by referring the reader to the Soft MoE paper [] and previous works on ViTs [], but we re-iterate a few key features of the architecture here in text and in Table 8. Our model is based on the ViT Base model with patch size $16\times 16$. This model consists of 12 encoder blocks in total, where each encoder block consists of an attention layer followed by an MLP. The MLP of the last 6 out of 12 encoder blocks have been replaced with a Soft MoE layer, where each expert is a 2-layer MLP. The input and output of each expert MLP is 768-dimensional, and there is one hidden layer of dimension $768*64/n$. In implementing these models, we relied on a publicly available PyTorch implementation of Soft MoE variant of ViT(^2^22[https://github.com/bwconrad/soft-moe](https://github.com/bwconrad/soft-moe)).

**Table 8: Model details for ImageNet-1k experiments in Section 4.4.**
| Model Feature | Used Value |
| --- | --- |
| Raw Input Size | $3\times 224\times 224$ |
| Input Resizing | None |
| Patch Size | $3\times 16\times 16$ |
| Soft MoE Input Size | $197\times 768$ |
| Base Model Architecture | ViT Base |
| Total Model Parameters | $513$M |
| Total Expert Parameters | $454$M |
| Number of Soft MoE Layers | 6 |
| Parameters per Expert | $454$M$/6n$ |
| Models Trained | $n\in\{2^{1},2^{3},2^{4},2^{6},2^{7}\}$ |

**Table 9: Key hyperparameters settings for ImageNet-1k experiments in Section 4.4.**
| Hyperparameter | Used Value |
| --- | --- |
| Batch Size | $512$ |
| Gradient Accumulation Steps | 1 |
| Epochs | 800 |
| Optimizer | FusedLAMB |
| LR Scheduler | Cosine |
| Base LR | $3e\text{-}3$ |
| Warmup LR | $1e\text{-}6$ |
| Epochs | $500$ |
| Warmup Epochs | $5$ |
| Random Erase Prob | 0.0 |
| Mixup | $0.8$ |
| Cutmix | $1.0$ |
| Label Smoothing | 0.0 |
| Dropout Rate | 0.0 |
| Weight Decay | 0.05 |

Since there are no publicly available pretrained weights for the Soft MoE variant of ViT models, we had to train each model from scratch. We relied on the DeiT (Data-efficient Image Transformers) [, ] training procedure and code, since our compute constraints made pretraining on a large corpus of data infeasible. Specifically, we used the “‘DeiT-III”’ training procedure, which is publicly available (^3^33[https://github.com/facebookresearch/deit/blob/main/README_revenge.md](https://github.com/facebookresearch/deit/blob/main/README_revenge.md)). We used the same command that was used to train the “deit_base_patch16_LS” model on ImageNet-1k with just one change: we trained without resizing the inputs from 224 to 192. A few key hyperparameter settings used are listed in Table 9.

We trained with the standard train set of $1.3$M datapoints and used the validation set of $50,000$ datapoints for evaluation. The DeiT-III code and provided command can train the original ViT Base model (i.e. without any MoE layers or modifications) to $\approx 81\%$ validation accuracy over 800 training epochs. Our Soft MoE ViT models are able to reach $\approx 79\%$ validation accuracy within 800 epochs. We note that this code and the hyperparameters set are highly optimized for training original ViT models, thus it is not surprising that our models are not able to reach or exceed the validation accuracy of the original ViT model.

We had access to 8 NVIDIA A6000 GPUs to train all of our models.

### D.3 Additional Results for Section 4.4.2

This section provides additional results for the experiments discussed in Section 4.4.2. Specifically, we provide the number of standard deviations by which the accuracy of Algorithm 1 exceeds the mean accuracy of random expert subset selection. While Section 4.4.2 provides the results for CIFAR100, we repeat the result here for completeness, and provide the full set of results for MNIST (Table 10), CIFAR10 (Table 11), CIFAR100 (Table 12), and ImageNet-1k (Table 13).

**Table 10: MNIST - number of standard deviations that the performance of Algorithm 1 is above the mean performance of Random expert set selection. For the Random selection, we used 10 random seeds to obtain its mean and standard deviation.**
|  | $n$ |  |  |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| $2^{1}$ | $2^{2}$ | $2^{3}$ | $2^{4}$ | $2^{5}$ | $2^{6}$ | $2^{7}$ | $2^{8}$ | $2^{9}$ |  |
| $k=n/2$ | $25.79$ | $33.61$ | $22.95$ | $25.39$ | $23.33$ | $26.47$ | $22.98$ | $10.19$ | $18.70$ |
| $k=n/4$ | - | $0.00$ | $16.33$ | $45.83$ | $38.89$ | $49.00$ | $37.15$ | $31.33$ | $29.44$ |
| $k=n/8$ | - | - | $11.81$ | $28.24$ | $46.78$ | $38.78$ | $50.46$ | $42.34$ | $66.90$ |

**Table 11: CIFAR10 - number of standard deviations that the performance of Algorithm 1 is above the mean performance of Random expert set selection. For the Random selection, we used 10 random seeds to obtain its mean and standard deviation.**
|  | $n$ |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- |
| $2^{1}$ | $2^{2}$ | $2^{3}$ | $2^{4}$ | $2^{5}$ | $2^{6}$ | $2^{7}$ |  |
| $k=5$ | - | - | $1.73$ | $0.95$ | $3.88$ | $7.25$ | $25.90$ |
| $k=4$ | - | - | $1.99$ | $2.51$ | $4.74$ | $15.12$ | $46.92$ |
| $k=3$ | - | $0.53$ | $3.47$ | $7.81$ | $12.28$ | $21.53$ | $88.96$ |
| $k=2$ | - | $4.05$ | $12.26$ | $15.17$ | $24.26$ | $42.77$ | $176.57$ |
| $k=1$ | $3.22$ | $20.40$ | $33.14$ | $35.48$ | $70.75$ | $83.71$ | $234.04$ |

**Table 12: CIFAR100 - number of standard deviations that the performance of Algorithm 1 is above the mean performance of Random expert set selection. For the Random selection, we used 10 random seeds to obtain its mean and standard deviation.**
|  | $n$ |  |  |  |  |
| --- | --- | --- | --- | --- | --- |
| $2^{1}$ | $2^{3}$ | $2^{4}$ | $2^{6}$ | $2^{7}$ |  |
| $k=n/2$ | $6.23$ | $6.73$ | $1.89$ | $3.47$ | $2.49$ |
| $k=n/4$ | - | $7.31$ | $6.34$ | $4.56$ | $4.50$ |
| $k=n/8$ | - | $21.22$ | $28.20$ | $13.96$ | $5.74$ |

**Table 13: ImageNet-1k - number of standard deviations that the performance of Algorithm 1 is above the mean performance of Random expert set selection. For the Random selection, we used 10 random seeds to obtain its mean and standard deviation.**
|  | $n$ |  |  |  |  |
| --- | --- | --- | --- | --- | --- |
| $2^{1}$ | $2^{3}$ | $2^{4}$ | $2^{6}$ | $2^{7}$ |  |
| $k=n/2$ | $2.23$ | $6.72$ | $1.63$ | $24.54$ | $35.50$ |
| $k=n/4$ | - | $20.71$ | $14.06$ | $38.89$ | $32.11$ |
| $k=n/8$ | - | $31.88$ | $20.21$ | $35.04$ | $60.38$ |

### D.4 Details of Experiments in Section 4.5

For this experiment, we consider the same Soft MoE variant of the ViT Base architecture as those used in Section 4.4, but with larger experts to make the total parameter count larger. Specifically, each of the Soft MoE layers has 8 experts, each of which are 2 layer MLP with input and output dimensions of $768$ and a hidden layer with $768*40$ units. The whole model has 2.32B parameters, of which 2.27B parameters are in the experts.

The data used for the forward pass was generated from a standard normal distribution. The experiment was done on a single NVIDIA GeForce RTX 2080 Ti GPU. Latency was measured by first performing $100$ warmup forward passes, then synchronizing CUDA, then measuring the elapsed wall clock time during the next $100$ forward passes plus the end of another synchronization of CUDA. The reported figures in Table 3 are based on these latter $100$ forward passes. While this experiment is simple and relatively small-scale, a proper analysis would require industry-scale models, and would be dependent on the hardware and the extent of distributed computing and per-device parallelization, as discussed in Section 4.5. We lack the compute capacity to perform such a thorough study.

## Peer Reviews

confidence: 4
contribution: 1
initial_rating: 3
presentation: 2
questions: Traditional analyses for specialisation/interpretability typically study the sparsity of the routing vector or the mass given to the top fraction (say) 10 percent,  over the duration of training. Would such an analysis be relevant here as well?
soundness: 1
strengths: The paper gives a good summary of the soft MoE model and sets up notation in a clear way. The notion of specialization is interesting. The proposed algorithm for selecting experts is simple and intuitive.
summary: The paper theoretically analyses a recently introduced model known as soft Mixture of experts. It makes the claim that multiple experts are not just a tool for improving computational performance and perform a crucial role in shaping the representation power of the model architecture. The paper also introduces a notion of expert specialization for this architecture. It claims that empirically, based on this notion, most data points are taken care of by specialized experts, i.e. only a small fraction of the experts (dependent on the input) are sufficient to correctly classify the input.
weaknesses: Section 3 on the representation failure of a single expert is quite trivial and obvious. Each expert essentially sees X only through a single d-dimensional linear projection, and hence any function of X that uses all of X in a non-linear manner clearly cannot be represented by a single expert regardless of how complex the expert is. Mutiple experts can potentially overcome this because they would each look at different projections.

Section 4 results on specialization are also quite weak. Choosing experts for each input separately can lead to an obviously absurd conclusion as follows. Having 10 experts each of whom predict a single class constantly would be considered highly specialised.

The proposed algorithm 1 is literally just picking the experts with the highest weight for each example, and is the first common sense thing that a practitioner looking to reduce inference complexity would do. The novelty of this approach is very minimal.

---

confidence: 4
contribution: 2
initial_rating: 3
presentation: 2
questions: - **Q1.** How does Algorithm 1 compare to the Token Choice and Expert Choice methods mentioned in the original SoftMoE paper?
soundness: 2
strengths: The paper considers important and relevant questions regarding implicit biases in Soft MoEs, particularly regarding expert specialization. I find these questions relevant and interesting for the ML community.
summary: This paper explores implicit biases in Soft Mixture of Experts (Soft MoE) models, challenging traditional assumptions about their representation power and specialization. Unlike prior MoE work focused on computational efficiency, this paper investigates whether the Soft MoE’s continuous gating mechanism disrupts specialization. In particular, the main contributions are as follows:

- **Single Expert Limitation:** Proving that a Soft MoE with one large expert cannot approximate $t(X) = ||X||_2$, claiming that multiple experts are essential for effective representation.

- **Expert Specialization:** Demonstrating that adding more experts introduces an implicit bias toward specialized subsets for specific inputs.

- **Efficient Inference:** Proposing a method to select specialized experts during inference.
weaknesses: - **W1. SoftMoE Formulation**: The SoftMoE formulation presented in Section 2 of this paper differs from that of the original SoftMoE paper [1]. In the original formulation, each expert processes $p$ slots, making $ \Phi \in \mathbb{R}^{d \times (n \cdot p)}$ and $C(X) \in \mathbb{R}^{m \times (n \cdot p)}$. However, in this paper, the parameter $p$ is not included. Notably, setting $p=1$ in the original formulation results in an incomparability with other papers using SoftMoE, where $p$ is recognized as a significant hyperparameter. Furthermore, in line 243, the authors cite [2], claiming that this work demonstrates that even a single-expert SoftMoE can outperform traditional architectures. This comparison is inaccurate, as $p$ is not set to 1. Specifically, after reviewing the code, I observed that $p \approx m/n$; see lines 55-64 in this GitHub file: [Link](https://github.com/google/dopamine/blob/master/dopamine/labs/moes/architectures/softmoe.py).

- **W2. Theoretical Contribution**: I don't find the results presented in Theorem 1 insightful.

    - **W2.1. Trivial Result**: Ignoring $p$ (the number of slots) in the SoftMoE formulation leads to a trivial outcome for $n=1$. Here, matrix $C(X)$ becomes an **all-one vector of size $m$** instead of a matrix of size $m \times p$, resulting in **identical output tokens** and thereby ignoring any temporal information in the tokens, effectively replacing them with a fixed token. This trivializes the ineffectiveness of SoftMoE with $n=1$, which is not the case when $p > 1$.

    - **W2.2. Notion of Approximation**: The notion of approximation presented by the authors is non-standard. I encourage the authors to provide references or pointers to similar approaches in the literature to clarify this aspect.

    - **W2.3. Proof Technique**: After reviewing Appendix A, I noticed that the proof relies on a special case where a contradiction arises as matrix norms approach infinity. This is acknowledged by the authors in Section 3, where they mention that normalizing the input makes the results from Theorem 1 inapplicable.

- **W3. Lack of comparison for Algorithm 1:** The paper lacks a comparison with the sparse routing mechanism considered in the original SoftMoE paper [1] (cf. Section 3.2). (Correct me if I am wrong)

---

References:  
[1] Puigcerver, Joan, et al. "From sparse to soft mixtures of experts." arXiv preprint arXiv:2308.00951 (2023).  
[2] Obando-Ceron, Johan, et al. "Mixtures of experts unlock parameter scaling for deep RL." arXiv preprint arXiv:2402.08609 (2024).

---

confidence: 4
contribution: 3
initial_rating: 6
presentation: 4
questions: - **Extension to Multiple Slots per Expert**: From a technical standpoint, are there any challenges preventing the authors from considering only a single slot per expert? If multiple slots $p$, where $p \ge 2$, are considered, would Theorem 1 and the related results still hold? The same question applies to the benign target $t(X) = ||X||_2$: does the result hold only for this specific function, or can it be extended to more general target functions?

- **Multiple Experts Results**: I believe the experiment in Appendix B can be explained by leveraging the approximation properties of functions through mixture of experts models as they relate to the number of experts, as discussed in [1, 2, 3, 4, 5]. At a minimum, the authors should provide a more detailed discussion and/or comparisons with the mentioned references to offer greater insights into how using multiple experts significantly reduces the loss, even when the number of expert parameters in each model is kept constant.

References:

[1] Mendes, E. F., \& Jiang, W. (2012). On convergence rates of mixtures of polynomial experts. Neural computation, 24(11), 3025-3051.

[2] Jiang, W., \& Tanner, M. A. (1999, January). Hierarchical mixtures-of-experts for generalized linear models: some results on denseness and consistency. In Seventh International Workshop on Artificial Intelligence and Statistics. PMLR. 

[3] Nguyen, H. D., Lloyd-Jones, L. R., \& McLachlan, G. J. (2016). A universal approximation theorem for mixture-of-experts models. Neural computation, 28(12), 2585-2593.

[4] Nguyen, H. D., Nguyen, T., Chamroukhi, F.,\& McLachlan, G. J. (2021). Approximations of conditional probability density functions in Lebesgue spaces via mixture of experts models. Journal of Statistical Distributions and Applications, 8, 1-15.

[5] Nguyen, H. D., Chamroukhi, F., \& Forbes, F. (2019). Approximation results regarding the multiple-output Gaussian gated mixture of linear experts model. Neurocomputing, 366, 208-214.
soundness: 3
strengths: - The originality lies in the paper’s creative approach, combining established concepts in expert modeling with a critical examination of representational limitations, as demonstrated by Theorem 1 and the empirical evidence in Appendix B. 

- This work has practical significance for advancing the design of scalable MoE models. By addressing the limitations in single-expert representational capacity, the paper opens up discussions on how architectural adjustments, such as multiple experts or efficient selection of subsets, can improve performance and reduce computational costs. These insights are valuable for both researchers and practitioners interested in efficient, scalable solutions for high-dimensional applications in MoE architectures.
summary: This paper explores the Soft Mixture of Experts (Soft MoE) architecture, concentrating on its inherent biases and constraints in representational power. Through rigorous theoretical and empirical analyses, the authors show that a single expert within the Soft MoE framework is insufficient to represent even basic convex functions, highlighting the need for multiple experts to achieve optimal performance. The paper presents Theorem 1, which formally substantiates these limitations, and supports it with synthetic data experiments, illustrating that increasing the number of experts enhances performance. Additionally, the authors introduce an efficient method (Algorithm 1: Best Expert Subset Selection) for selecting specialized expert subsets, designed to reduce computational demands in large-scale applications while maintaining model efficacy.
weaknesses: - **Clarity in Methodological Exposition:** Certain aspects of the methodology, such as the approach for selecting the number of experts $k$ for prediction in real applications, would benefit from more detailed and clearer explanations.

- **Clarity in Technical Proof Exposition:** Including a proof sketch at the beginning of Appendix A would enhance readability and provide a clearer roadmap for understanding the technical details. Additionally, a more detailed explanation of why the equalities in lines 711-716 hold would further improve clarity and support the reader's comprehension of the argument. Clarification is needed regarding the notation for norms: are $|\cdot|$ and $\| \cdot \|_2$ intended to represent the same norm?

- **Limited Theoretical Analysis for Multi-Expert Configurations:** Although the paper offers theoretical insights into the limitations of a single expert, it does not extend the theoretical framework to cover multiple-expert $n$ or multiple-slot configurations. A more detailed analysis of how increasing the number of experts impacts scalability, convergence, or approximation accuracy would enhance the strength of the claims presented.

- **Notation Section**: The manuscript would benefit from a dedicated notation section to clarify certain symbols that may be unclear, such as the norm $|\cdot|$ or $\| \cdot \|_2$ for matrices and vectors. Providing a notation section would enhance readability and ensure that readers can follow the mathematical expressions consistently throughout the paper.

- **More Accurate References:** **Lines 040 and 549-550**: The correct citation should be: "Yasaman Bahri, Ethan Dyer, Jared Kaplan, Jaehoon Lee, and Utkarsh Sharma (2024). Explaining neural scaling laws. Proceedings of the National Academy of Sciences, 121(27), e2311878121." **Lines 073 and 633-635**: The correct citation should be: "Johan Obando-Ceron, Ghada Sokar, Timon Willi, Clare Lyle, Jesse Farebrother, Jakob Foerster, Gintare Karolina Dziugaite, Doina Precup, and Pablo Samuel Castro. Mixtures of experts unlock parameter scaling for deep RL, 2024. Proceedings of the 41st International Conference on Machine Learning, PMLR 235:38520-38540, 2024." **Lines 073 and 571-574**: The correct citation should be: "Damai Dai, Chengqi Deng, Chenggang Zhao, R. X. Xu, Huazuo Gao, Deli Chen, Jiashi Li, Wangding Zeng, Xingkai Yu, Y.Wu, Zhenda Xie, Y. K. Li, Panpan Huang, Fuli Luo, Chong Ruan, Zhifang Sui, and Wenfeng Liang. Deepseekmoe: Towards ultimate expert specialization in mixture-of-experts language models, 2024. In Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 1280–1297, Bangkok, Thailand. Association for Computational Linguistics."

---

confidence: 4
contribution: 2
initial_rating: 5
presentation: 3
questions: 1. What are the challenges of generalizing the result in Theorem 1 to the setting when the target function is assumed to belong to some class of convex functions rather than selected specifically?

2. What are the challenges of theoreticall show that the soft mixture of multiple small experts with a fixed parameter count can represent a simple target function?
soundness: 3
strengths: 1. The comparison between using a single large expert versus using multiple smaller experts is of interest and provide a useful insight into designing the optimal MoE structure. Additionally, the algorithm for selecting the subset of specialized experts in an input potentially helps reduce the computation burden. 

2. The presentation of this paper is good (except for the statement of Theorem 1), which makes it easy to follow.

3. The theoretical proofs and experiments are conducted in a careful way.
summary: In this paper, the authors investigate the representation power of the soft Mixture-of-Experts (MoE) model when using a single large expert versus when using multiple smaller experts, and then explore the expert specialization in this model. In particular, they theoretically demonstrate that the soft mixture of a single expert cannot represent simple target functions, while they empirically show that the soft mixture of multiple smaller experts with the same parameter count is capable of this task. Thus, they claim that even for a fixed parameter count, using multiple experts is necessary for achieving a good representation power rather than just help reduce the computational overheads as in the principle of traditional sparse MoE. Subsequently, they introduce the definition of expert specialization for the soft MoE and propose an algorithm to choose the best subset of experts (including a quarter of the original number of experts) specializing in predicting the label of an input.
weaknesses: 1. The result in Theorem 1 is not really solid as the upper bound still hinges upon the input value. Moreover, since the authors choose a specific target function rather than consider an arbitrary convex function, I am quite skeptical about the generalization of the result. Additionally, the way this theorem is stated confuse me when I first read it. I think the writing of the statement could be improved.

2. The paper lacks the theoretical proof for the result that the soft mixture of multiple small experts is capable of representing simple target functions, which weakens the contribution of this paper considerably. Personally, the experiments on the synthetic data in Appendix B for empirically showing this result is not sufficient to convince me. 

3. The principle of the proposed algorithm for choosing the best subset of important experts based on their weights in the matrix $C(X)$ seems to be reasonable. However, I believe that the claim that this algorithm can help reduce computation at inference would be more convincing if the experiments are conducted on bigger model and dataset.

Meta-review: In the paper, the authors provide a theoretical analysis of the soft Mixture of Experts (MoE) model. They demonstrate that the usage of multiple experts not only enhances computational performance but also fundamentally shapes the representational power of the model. Furthermore, the authors also prove empirically that the experts are well-specialized. 

After the rebuttal, there have remained several weaknesses of the current paper: (1) Some of the theoretical results are obvious, weak, and trivial (e.g., the results in Section 3 or Section 4, etc.). (2) The proposed algorithm lacks novelty and is not convincing. (3) The writing of the paper requires major revision.

Given the above weaknesses of the paper, I recommend rejecting the paper at the current stage. The authors are encouraged to incorporate the suggestions and feedback of the reviewers into the revision of their manuscript.

Decision: Reject