Elamur Research

On the Benefits of Learning to Route in Mixture-of-Experts Models

Paper · 2023 · Nishanth Dikkala, Nikhil Ghosh, Raghu Meka et al.

Summary

A mixture-of-experts network has several sets of weights available for a prediction. A component called the router chooses which experts to use for a given input. Because only a small selection of experts runs, the network can draw on a large pool of weights without applying all of them every time. What advantage does learning the selection rule offer the network? Dikkala and Panigrahy pose this question. A fixed rule already makes different weights available for different inputs. Training the router could give those weights a more useful division of work by bringing together examples that call for the same computation.

The authors test this idea with data whose structure they know in advance. They draw inputs from separated Gaussian clouds and give each cloud its own target vector or prediction rule. Learned routers tend to send examples from the same cloud to a particular expert or a small group of experts. Shuffling which input coordinates the trained router weights act on weakens that pattern. With flexible enough experts, frozen and trainable routers both allow the networks to fit their training examples closely, but the trainable router gives better predictions on fresh samples. When the authors add coordinates that have the same noise distribution in every cloud, training also shifts the router’s weights toward the coordinates that distinguish the clouds.

The results are more varied when several components contribute to the same input. In the dictionary-learning task, freezing the router can preserve the achieved test loss in one setting. Training it helps in a harder setting, although shuffling its coordinates leaves the reported concentration measure unchanged. The T5 experiments on mC4 likewise depend on the setup. Training the router improves pretraining accuracy in a deliberately narrow architecture, while the learned and frozen versions of the wider T5-Base configuration give close accuracies. A frozen router inside T5 still receives representations from trainable layers, so the surrounding network retains some control over where tokens go.

The theory examines conditions that make specialization possible. With a penalty on the first layer’s weights, the authors argue that a predictor can discard independent Gaussian directions irrelevant to its target. For a balanced mixture of separated Gaussians, they give an argument for cluster-specific experts when router weights start from sampled inputs. In a separate analysis, the initial weights are small and random, and the analysis considers two truncated Gaussian components that form a symmetric pair. Across the experiments and theory, learned routing has its clearest benefit when the input contains recognizable information about which rule should apply. Predictive gains are easier to establish than recovery of the underlying structure when several rules contribute to one input or when the router operates on representations that can themselves change.

Deep dive: On the Benefits of Learning to Route in Mixture-of-Experts Models

The paper tests when learned routing helps mixture-of-experts networks, from controlled clustering tasks to T5 pretraining on mC4. · about 38 minutes to read

The problem and its context

What an expert layer can gain from choosing well

The paper starts from the cost of increasing the size of a neural network. It describes a line of research in which larger networks built around the Transformer and attention can improve prediction quality while requiring more computation. Work on scaling laws studies how quality changes as resources grow. Conditional computation approaches the resource question from the other direction. It changes how much of the available network participates in a prediction. The paper introduces this setting through prior work on Transformer architecture and scaling. Attention Is All You Need

An expert layer is a way to implement conditional computation. Each expert has its own weights and can learn its own function. A dense layer applies shared weights to the inputs it receives. An expert layer can select different weights for different inputs while restricting the number of expert computations performed on any particular example. The paper identifies the Switch Transformer as a prominent use of this arrangement. It also situates sparse expert layers in work on large neural systems and on image processing. GShard · Scaling Vision with Sparse Mixture of Experts

There are two reasons this arrangement might help. The first is that the entire network has more weights available across its inputs than the active path for an individual prediction uses. A fixed hash can already spread inputs across several sets of weights. The second is that training might discover which inputs are worth handling together. Imagine a collection of input clouds, with a different rule for computing the target in each cloud. If examples from one cloud tend to reach the same expert, that expert sees repeated evidence about the same rule. A fixed partition could split a cloud among several experts and give each of them examples governed by other rules as well.

This distinction matters when comparing expert networks with dense baselines. If the dense architecture is too small to fit the training data, an advantage for the sparse expert architecture could reflect its larger supply of weights. The authors use the term overparameterized operationally for settings in which a network can drive its training loss close to zero. Once both routing conditions can fit the observed examples, the comparison moves to a different question. Which network has learned a function that also works on new draws from the same distribution? In the paper, the dense comparison helps assess the resource tradeoff. The comparison between trainable and frozen routers asks what the assignment rule contributes within an expert architecture.

Why routing is difficult to observe

An experiment that finds lower prediction error has evidence that an intervention helped. Discovering how it helped requires more information. In natural text, for example, the groups a router might find useful are seldom given to the experimenter. A regularity visible in the selected tokens may describe their content, the computation an expert is learning, or an incidental feature of the representation. The paper describes earlier efforts to find patterns in router behavior and emphasizes the difficulty of interpreting them with complex data.

The authors give themselves a way to evaluate a proposed division of work by generating some of their own data. They know which process produced an example and can choose whether that process also controls the target. For a Gaussian mixture with component-specific labels, they can check whether an assignment follows component membership, then ask whether permitting the router to learn also improves prediction. Tasks with more than one component per input weaken the premise that there is a straightforward assignment to recover. They give the experimental design a way to test where the first explanation stops being satisfactory.

Earlier studies approached routing from several angles. Some sought to balance the workload received by the experts. Others investigated how to make the selection process compatible with training, including reinforcement learning and smoother ways to select experts. Fixed strategies included hashing by token, using locality-sensitive hashes to encourage similar inputs to share a destination, and assigning inputs according to language. The paper reports that Clark and colleagues found that token hashing scaled less favorably than trainable routing. A comparison with frozen router parameters inside a trainable network raises an additional issue because the representation sent to that router may change. BASE Layers

The theoretical predecessors also motivate the choice of data. As the authors describe it, Chen and colleagues used a purpose-built distribution to prove an advantage for expert networks and studied convolutional layers. Their language experiments used representations obtained from a separate network. Dikkala and Panigrahy work with established clustering problems such as Gaussian mixtures, use fully connected expert layers in their main theoretical treatment, and also run pretraining with routers inside a T5 architecture. The paper places these questions alongside earlier theory on sparsely activated networks. Its own inquiry centers on conditions that make assignments intelligible, the consequences of allowing the router to train, and what can be proved about the resulting specialization.

The method, step by step

How the router and experts make a prediction

An expert layer has two jobs. The router turns an input into scores, one for each expert. The experts compute candidate predictions. A score can determine which prediction survives or how much each prediction contributes to a mixture. In a simple cluster experiment, the input to both parts is the observed vector, and the target comes from a rule tied to its source. The component identity is available for evaluation because the authors generated the example. The prediction loss supplies the training signal.

A linear router gives each expert a weight vector. It scores that expert by taking a dot product, which multiplies corresponding coordinates of the input and the weight vector and adds the products. An input that lines up well with the vector can receive a high score. The router applies softmax to the complete set of scores to obtain relative weights. Softmax gives the highest score the largest probability and makes the probabilities sum to one. The scores are relative in the sense that increasing an expert’s score affects its share of the total available weight.

Training and evaluating routing on clustered inputs

The steps in order.

Training and evaluating routing on clustered inputsStep 1: Sample an input from the mixture1. Sample an input from the mixtureStep 2: Build its target using the generating component2. Build its target using the generating componentStep 3: Score the experts for the input3. Score the experts for the inputStep 4: Turn scores into routing probabilities4. Turn scores into routing probabilitiesStep 5: Combine expert outputs to predict the target5. Combine expert outputs to predict the targetStep 6: Update experts and any trainable router6. Update experts and any trainable routerStep 7: Check predictions and routing on new inputs7. Check predictions and routing on new inputs

The linear router is written as follows.

R(x) = softmax(Wx)

x is the input vector, W contains the router weights, and the product Wx collects the expert scores. softmax transforms those scores into probabilities, and R(x) denotes the resulting vector.

For the basic synthetic tasks, training uses weighted expert outputs and evaluation selects the expert with the highest score. The hard choice is expressed by the following rule.

j = arg maxᵢ (Wx)ᵢ

i indexes experts, x is the input, and W is the router matrix. The subscript on (Wx)ᵢ picks out the score for expert i. The operation arg max returns the index attaining the maximum, so j is the chosen expert. The paper calls this top-1 routing. The token sequence experiments retain soft weights, and the T5 expert layers make a top-2 selection.

The type of expert determines where a task can be solved. A constant expert learns a vector and returns that same vector for every input it receives. Its output can change during training as its parameters are updated. At prediction time, all the variation across examples comes from the choice of expert. A linear expert can apply its own coefficients to the input. A multilayer perceptron, or MLP, is a feedforward neural network whose nonlinear layers let it learn more complicated rules. In the frozen-router comparison, this added flexibility lets an expert handle multiple kinds of examples within the region the fixed gate gives it.

The constant-expert architecture used in the many-component analysis makes the soft combination particularly easy to describe.

f(x) = ∑ᵢ pᵢ(x)uᵢ

f(x) is the predicted vector for input x. The index i runs over the experts, and ∑ᵢ adds their contributions. pᵢ(x) is the probability that the softmax router gives expert i on that input. uᵢ is its learned output vector. A contribution has more influence on the prediction when the router gives it more probability. In the analysis, this is also the link through which a training example has a stronger effect on some experts than on others.

Making the source of each input observable

A spherical Gaussian is a distribution whose spread is the same in every direction around its center. In a Gaussian mixture, the data generator chooses a component and draws a point from that component. A balanced mixture gives every component the same probability of being chosen. For the basic tasks the components are well separated, making it possible to use the input to infer where it came from. The paper describes separation through a condition on each pair of centers.

∥μ₁ − μ₂∥₂ ≥ c max{σ₁, σ₂}√d

μ₁ and μ₂ are the two centers, and ∥·∥₂ is the Euclidean norm, so the left side is their distance. σ₁ and σ₂ are the spherical scale parameters in the paper’s notation. max selects the larger one. d is the dimension of the input and √d its square root. The constant c specifies the required level of separation, and ≥ gives the lower bound on the center distance. A comparison of this form is made for distinct components.

The simplest generator uses 64 spherical Gaussians in 24 dimensions. Each Gaussian is given a random target vector of dimension 10. Thus two nearby examples can have different targets when their generating components differ, and two examples from the same component have the same target even if their input vectors differ. The authors vary the supply of training examples while keeping the expert count equal to the component count. They also vary the expert count with a large supply of training data. The latter experiment exploits a simple constraint. Once the network selects a single constant expert per prediction, it can return only the vectors those experts have learned.

For a separate comparison with a frozen router, the authors keep the constant targets but replace the constant experts with depth-3 MLPs. An MLP expert can learn to predict different targets for different inputs that arrive at its gate. That gives the frozen condition a way to solve the training task even if its regions cut across the Gaussian clouds. The main comparison can then focus on prediction beyond the training examples. Dense MLPs provide further comparisons at the scale of a single expert and at the scale of the whole expert network.

The next Gaussian task changes the target function itself. Each component receives a coefficient vector, and the generator first subtracts the component center from a sampled input before computing its target.

y = wᵀ(x − μ)

y is the scalar target, w is the component’s randomly chosen coefficient vector, and x is the sampled input. μ is the center of the component that generated it. The superscript ᵀ transposes the vector for the dot product. Centering makes the output depend on variation within the Gaussian. The authors explain that applying the linear rule to uncentered inputs would make outputs within a component close to constant, weakening the change they want to study. The network uses a linear router and depth-3 MLP experts.

The authors also embed the 64 clouds in a 240-dimensional space. Only the original 24 coordinates distinguish components. The remaining 216 have independent Gaussian noise with the same distribution in every component. This construction creates an assignment problem with a known informative subspace, meaning a set of directions that contains the information used to tell the groups apart. The authors can evaluate the prediction error and inspect whether the fitted router uses those directions. A single aggregate error would leave open how the network dealt with the added coordinates.

Changing what defines a group

The mixture of subspaces groups examples by the directions in which they vary. The authors randomly choose 64 subspaces, each of rank 8. For each example, they draw a Gaussian vector restricted to one subspace and add a spherical Gaussian noise vector that can extend across all dimensions. The added noise is smaller in norm than the restricted sample in the setup. The regression target depends on the noise and on a coefficient vector chosen for the originating subspace.

y = wᵀϵ

y is the target, w is the coefficient vector associated with the chosen subspace, and ϵ is the added noise vector. The superscript ᵀ makes the multiplication a dot product. The network sees the sum of the restricted draw and ϵ. The target therefore asks it to use the group-dependent rule on a part of the observed input that was added during generation.

A linear scoring rule is unsuitable for the intended assignment by subspace. An input can vary on either side of the origin along the directions that identify its group. The authors use a depth-3 MLP as the router, and each of the 64 experts is also a depth-3 MLP. Freezing this router leaves the nonlinear architecture in place while holding its weights fixed. This extends the comparison to a different kind of grouping and a different form of router.

The CIFAR-100 experiment gives the gate and the experts different information. An input has an image and a randomly drawn vector. The target rule depends on the class of the image. Each class gets a coefficient vector, which the generator applies to the random part of the input.

y = wᵢᵀv

y is the regression target, i is the image’s class, wᵢ is the random coefficient vector assigned to that class, and v is the other input vector. The superscript ᵀ denotes the dot product. The image carries information about which calculation is required, and v supplies the argument of that calculation.

A convolutional neural network, or CNN, reads the image and routes to the experts. It sees only the image. The 200 experts are depth-3 MLPs that get both the random vector and the CNN activation immediately before its final layer. Giving the experts this intermediate representation lets them use image information when the CNN is frozen. The source of the images is real, while the use of class to select a regression rule is an experimental choice that makes the relevant structure known.

Moving from separate tokens to combined inputs

The tokenized Gaussian task puts several Gaussian samples into the same example while keeping each sample individually accessible to the router. The generator draws each token from a balanced mixture of 32 Gaussian components. The centers are chosen in 32 dimensions. Sequence length varies, and the generating component at each position selects the vector used to compute that position’s contribution to the target.

y = ∑ᵢ₌₁ˢ w(gᵢ)ᵀxᵢ

y is the scalar target for the sequence. s is the sequence length, i is a position, and xᵢ is the token vector at that position. gᵢ identifies its component, and w(gᵢ) is that component’s coefficient vector. The superscript ᵀ denotes the dot product. The sum adds the contributions from the first position through the last.

The quadratic variant squares each component-specific contribution before adding it.

y = ∑ᵢ₌₁ˢ (w(gᵢ)ᵀxᵢ)²

y is again the sequence target, s the sequence length, and i the position. xᵢ is the token, gᵢ is its generating component, and w(gᵢ) provides the linear coefficients. The superscript ᵀ forms the dot product, ² squares that term, and the sum combines the results over the sequence. The position-specific operations happen before aggregation. This changes how readily a common prediction rule can approximate the target.

The network applies its router separately to each token and uses softmax weights to combine the expert outputs for that token. The experts are single-layer linear functions. The dense comparator has 2 fully connected layers, which the authors use to account for the expert architecture’s routing layer when comparing depth. The series of experiments varies the number of positions and the kind of target while preserving the availability of individual tokens.

The dictionary-learning experiment changes that availability. A dictionary here is a collection of underlying components called atoms. Each atom gives the center of a spherical Gaussian. The data generator selects components, samples from the selected Gaussians, and adds the samples, so the router receives a combined vector. The main discussion mentions 2 or 3 contributing atoms. The detailed runs use 2 components selected without replacement and specify a regression target for that setting.

y = (wᵢ + wⱼ)ᵀx

y is the scalar target. i and j index the two chosen components, with randomly drawn coefficient vectors wᵢ and wⱼ. x is the sum of their sampled vectors. The superscript ᵀ takes the dot product of the added coefficient vectors with the observed input. The detailed task therefore uses coefficients from both components in a rule applied to the combined vector.

The first detailed setting uses 32 Gaussian centers in 32 dimensions and 32 linear experts. The authors compare it with a dense network that has 2 fully connected layers and a rectified linear activation between them. The activation lets the network represent nonlinear functions of the input. A depth-1 dense network is another comparator. In the harder setting, the component count rises to 128 and the expert count remains 32. Each atom may contribute to many different pairs. The resulting input has more than one meaningful source, and the task leaves open whether an expert should specialize in a recurring atom, a combination, or another useful partition of the input.

How training and evaluation measure different things

The clustered experiments give the gate and the experts separate learning rates, which determine the size of their parameter updates. In the Gaussian runs with constant experts, Adam uses 3.2e-3 for the router and 3.2e-4 for the experts. In the Gaussian runs with depth-3 MLP experts, stochastic gradient descent uses .9 momentum, with rates of 1e-1 for the router and 1e-2 for the experts. The subspace runs use Adam with rates of 3.2e-3 and 1e-3 for the router and experts, respectively. The reported hidden layer width in the Gaussian MLP and subspace comparisons is 96. The authors give the gate a larger learning rate to reduce the chance that flexible experts first fit the examples in their initial routing regions, before the gate has learned to group them usefully.

Prediction loss measures how closely outputs reproduce the targets on the distribution. A routing statistic measures how strongly examples from each known component tend to share expert assignments. The paper calls this average sparsity per cluster. It first averages the probability vectors within a cluster and then calculates entropy, a measure of how spread out those probabilities are. A sharp assignment for each example can still yield a dispersed cluster average if examples in the cluster favor different experts. The order of operations is what makes this a measure of agreement within a group.

S = Eᵢ∈[k] H(Eₓ∈Cᵢ R(x))

S denotes the routing statistic. k is the number of components, [k] is the set of their indices, and i selects a component. Cᵢ denotes the distribution for component i. x is a draw from that distribution and R(x) is its vector of routing probabilities. The inner E averages the probability vectors within the component. H evaluates their entropy, and the outer E averages the entropy across components. Lower values indicate more concentrated assignments on the reporting scale used in the experiments.

The diagnostic is repeated after shuffling the input coordinates of a fitted linear router. The authors permute columns of the router matrix, so the gate applies the same learned weight values to a different ordering of input features.

S′ = Eᵢ∈[k] H(Eₓ∈Cᵢ R′(x))

S′ is the shuffled-router statistic, and R′(x) is the probability vector after the column permutation. x is drawn from Cᵢ, the distribution of component i. The set [k] indexes the k components. H is entropy and the two E operators average within and across components, respectively. The shuffle preserves weight magnitudes and changes their correspondence with features. Its purpose is to test how much concentration depends on where the learned weights point. The frozen router is a separate comparison. Its initial weights are held fixed while the rest of the predictor trains, allowing the authors to measure the consequences for prediction.

Putting the gate inside T5

The language experiment uses T5X to pretrain T5 on Common Crawl mC4. The T5-Base configuration described by the authors has a Transformer encoder and decoder with 12 layers each. Its representation dimension is 768, and its hidden dimension is 2048. It uses 12 attention heads of dimension 64. The sparse implementation spaces 3 expert layers evenly among the 12 layers and selects the top-2 experts for a token. The expert capacity factor, a setting that regulates the allocation of work to experts, is 1.25 in training and 2 in evaluation. Pretraining uses Adam for 500k steps, and the paper measures next-token prediction accuracy. Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer

The main comparison narrows the representation dimension to 32 and the hidden dimension to 256. It includes a dense T5 and sparse T5 configurations with trainable and frozen gates. The paper also compares the gate conditions at the wider setting and varies the number of experts in the narrower one.

The width intervention follows from where the gate sits. In the synthetic tasks with a router directly on the input, holding the gate fixed preserves its scoring rule on that input. In a Transformer, the gate operates on the output of earlier layers. A training update to those layers can move a token’s representation into a different routing region even with the same gate weights. Narrowing the surrounding architecture is intended to restrict the network’s capacity to make such adjustments. The experiment evaluates what training the gate itself contributes under that constraint.

What the mathematical arguments assume

The first analysis concerns the directions used by the initial layer of a predictor. The input has a projection into a relevant subspace, and the target is a function of that projection. The remaining directions carry independent Gaussian noise. The theorem studies a network that sends an affine transformation of the input to an otherwise general downstream function.

f(b,W,U; x) = gᵤ(Wx + b)

f(b,W,U; x) denotes the prediction on x at the specified parameter values. W is the first-layer matrix, b is its bias or additive offset, and U denotes the parameters of the downstream function gᵤ. The semicolon in the notation separates parameters from the input. This setup can represent a first layer that computes router scores, and the theorem is formulated for the more general affine interface.

L(b, W, U) = Eₓ ℓ(y(x), f(b,W,U; x)) + λ₁∥W∥² + λ₂∥U∥²

L is the regularized expected loss. Eₓ averages over inputs x. ℓ evaluates the discrepancy between the target y(x) and prediction f(b,W,U; x). W and b parameterize the first transformation, while U parameterizes the downstream function. The squared norms penalize the magnitudes of W and U, with positive coefficients λ₁ and λ₂. A local minimum is a setting of the parameters whose objective cannot be improved by a sufficiently small change.

The conclusion is that each row of W lies in the relevant subspace at a local minimum of this objective. The proof splits the input into signal and independent noise. It shrinks the weights on the noise, then introduces a Gaussian offset chosen to reproduce the original distribution of the affine representation. Independence allows this comparison to preserve the joint distribution with the signal. Since the expected prediction loss is an average over the new offsets, the proof chooses an offset that gives loss at most equal to the original average and incorporates it into the bias. Shrinking the noise weights reduces the penalty. This uses a property of the Gaussian distribution: independent Gaussian terms can be combined to restore the contribution removed by shrinking. The claim is about the directions in the first-layer matrix at a local minimum, a different object from the predictive error of a finite training run.

The next analysis considers the constant-target Gaussian task. It first uses a simplified architecture to connect expert prediction with k-means. When the vectors that make the predictions are also the vectors by which inputs are routed, the network can send each input to its nearest vector. If the target is the input itself and the loss is squared distance, the objective measures exactly the distortion measured by k-means. Changing the expert vectors then changes the centers used for assignment as well as the outputs. The paper notes that gradient descent with the same step size takes the same steps on the shared objective.

The general analysis separates the router vectors from the expert outputs. The target for a component is a fixed vector and can differ from its center. The authors assume a balanced mixture of separated spherical Gaussians in high dimension. The sample count in the theorem is given by the following expression.

n = Θ(dk log k)

n counts the training samples in the statement, d is the dimension of the input, and k is the number of components. log denotes a logarithm. Θ specifies the order of growth up to constant factors. The paper uses an expert count of order k log k and initializes each router row with a randomly selected training example. The use of samples makes the gate data-dependent at initialization.

The probability argument has two stages. First, the sample-based initialization should contain an example from each Gaussian. The authors invoke the coupon collector argument, which describes how repeated random draws from a finite collection eventually cover its members. Second, the proof associates each expert with the component that supplied its initial router row. The geometry is intended to give a fresh example most of its routing probability within the corresponding group of experts. Those experts then receive most of the update signal from that example. The router learning rate is kept small so that the initial grouping can persist while the expert outputs move toward the targets. The argument describes further increases in router weight norms as sharpening the established assignments. Its mechanism depends on the coverage and geometry of the initialization as well as on the subsequent updates.

A separate analysis uses a balanced pair of spherical Gaussians truncated around the means +z and −z, with z of unit length and truncation radius below 1. Truncation restricts each component to points inside the specified radius, giving the pair disjoint supports. Their targets are +v and −v. The architecture ties the expert vectors together as opposite outputs. Its gate uses a sigmoid, a function that maps a scalar score to a probability.

p(x) = Sigmoid(wᵀx)

p(x) is the routing probability for the expert that outputs u, x is the input, and w is the router vector, with ᵀ denoting the dot product. Sigmoid maps the score to a value between zero and one. The second expert receives the remaining probability.

f(x) = (2p(x) − 1)u

f(x) is the resulting prediction, p(x) is the first expert’s probability, and u is its learned output vector. The other expert outputs −u. The factor 2p(x) − 1 is the coefficient left after adding the two oppositely signed expert contributions.

The proof uses population gradients, meaning gradients of the expected loss under the data distribution, and starts the router and expert vectors at small random values. It takes the expert learning rate to be much larger than the router’s. This lets it analyze the expert vector as tracking the least-squares choice for the current gate.

u⋆(w) = v Eₓ∈G[q(x)] / Eₓ∈G[q(x)²]

u⋆(w) is the minimizing expert vector for router weights w. v is the target vector of the component denoted by G. Each Eₓ∈G averages over inputs x from that component. q(x) is the coefficient 2p(x) − 1 in the prediction, where p(x) is the sigmoid routing probability. The denominator averages its square, and the ratio scales the target vector.

Reflection through the origin exchanges the components and reverses the sign of the coefficient on u. This symmetry reduces the loss analysis to one side. The authors analyze a part of the router update that turns the weights toward the line through the means. Along that line they examine how increasing the norm sharpens the sigmoid, so predictions approach the component targets. The stated convergence result aligns the router direction with the center direction up to sign, lets the router norm grow without bound, and takes the expert output to the target up to the corresponding sign. The sign reflects which of the two equivalent experts receives the positive component.

Experiments and results

Separated components with distinct targets

In the constant-vector task with 64 Gaussian components, supplying more training data brings test loss towards 0 when there are as many constant experts as components. With abundant samples and fewer than 64 experts, test loss stays above 0. A network that emits the vector of its chosen constant expert has too few vectors to cover the targets in that part of the sweep. When the expert count reaches 64, test loss drops close to 0. This is a result about both the capacity required by the task and the ability of training to find a useful assignment at that capacity.

The reported cluster sparsity measure in this experiment approaches 1 as the sample supply grows. The authors interpret this end of their scale as concentration on an individual expert. The shuffled router gives higher values. The observed performance of the directly trained network is also stronger than the expert count in the proof would lead one to require as a sufficient condition. The experiment succeeds with an expert for each cluster, while the sample-initialized coverage argument allows a logarithmic factor in the expert supply.

With depth-3 MLP experts, the constant-target comparison gives the frozen router a better chance to fit its assigned examples. The paper reports training loss near zero for the networks in this comparison. The test loss remains lower for the trainable router, and the trained router’s cluster statistic again indicates much stronger concentration than the shuffled version. The agreement between the loss and assignment evidence is particularly informative here. Training the gate improves prediction when the frozen network is already flexible enough to fit the training data, and the resulting assignments track the component structure that defines the targets.

The dense comparators show how the choice of resource match affects the outcome. The smaller MLP matches the parameter count of one expert and is used as a comparator at similar computation. The larger one matches the total parameter count of the expert network and requires more computation. The authors give the dense comparators an extra layer to account for the router layer. In the MLP expert experiment, the trainable expert network beats the smaller dense MLP and slightly trails the larger one. The paper also identifies an overparameterized comparison in which the large dense predictor beats the expert alternative. Useful specialization within a sparse layer can coexist with a lower test loss from a larger active computation.

In the 240-dimensional Gaussian variant, the expert network reaches a test loss of 0.01. The paper uses 1 for the trivial reference loss and 0 for perfect prediction in that setting. The score for the share of router weight in the informative directions is .1 at initialization, .84 after training without weight decay, and .9 after adding weight decay. The authors report no loss of predictive performance from adding it. A low error here shows that the added noise is manageable. The change in the projection score gives separate evidence about what the router learns to emphasize.

With a different centered linear target in each Gaussian component, increasing the samples per cluster again drives down test loss. The learned router outperforms the frozen version, and its assignments concentrate on a small set of experts for a typical component. The concentration improves as the sample count increases. Shuffling fails to reproduce that improvement. The result extends the Gaussian finding to a case where assigning an input to an expert is only part of the prediction. The expert itself must also respond to variations within the selected component.

The mixture-of-subspaces experiment reports a predictive advantage for the learned nonlinear router over the frozen one across a broad range of training-set sizes. In this task the underlying group specifies the directions of the restricted draw, and the target depends on the noise added to that draw. The comparison therefore tests learned routing in a geometry where a linear assignment would be unsuitable. The curves establish a recurring loss advantage under this design. The paper discusses that advantage across the sweep without giving a numerical endpoint in its discussion.

Image-conditioned regression

On the CIFAR-100-based task, the network must recover a class-dependent regression rule from the image and apply it to the paired vector. The loss is .55 when the CNN router trains and .80 when it is frozen. The figures are reported losses for the constructed regression, whose output is a scalar. The classes determine how the targets are generated instead of serving as the outputs of the task.

Trainable and frozen CNN routing on CIFAR-100 regression, reported loss

Allowing the image router to train yields lower regression loss.

Trainable and frozen CNN routing on CIFAR-100 regression, reported lossFrozen CNN router: .80Frozen CNN router.80Trainable CNN router (this paper): .55Trainable CNN router (this paper).55
The numbers
System or settingloss
Frozen CNN router.80
Trainable CNN router (this paper).55

The experts in both cases have the paired vector and image features from the CNN. The comparison shows the value of training the image-dependent part of this architecture under that arrangement. Since the intermediate features also enter the expert computations, the end-to-end loss captures changes to those features as well as changes to the routing decisions.

Sequence length and the form of the target

The tokenized experiment measures mean squared error, or MSE, which averages the squared discrepancy between predicted and target outputs. For the linear target at sequence length 4, the learned-router network with 32 linear experts gives an MSE of 0.0016. The dense network with 2 layers gives 0.0044, and the 32-expert frozen-router network gives 0.0046. At length 8, the learned-router MSE is 0.0017, the dense MSE is 0.0021, and the frozen-router MSE is 0.0020. At length 16, both the trainable expert network and the dense network give 0.0015. The frozen alternative gives 0.0027.

The authors account for the changing comparison with the dense network through the additive linear target. Longer sequences can contain draws from more of the components. A common linear rule can then approximate the average contribution to the total more effectively. This account is consistent with the dense comparator matching the trainable expert network at length 16. The frozen-router network still has higher error at that length, so the answer to whether training the router helps depends on which comparator is used.

The assignment statistic remains sensitive to the learned weights at every listed length. At sequence length 4, the reported sparsity is 13 for the learned router, 14.29 after shuffling the fitted router, and 28.52 for the frozen router. At length 8, those values are 14.14, 15.41, and 28.51. At length 16, they are 14.29, 15.6, and 28.53. The trained gate continues to distinguish the components to some degree even when the dense comparator can approximate the final scalar equally well. The two measurements respond to different properties of the system.

In the quadratic sequence task, the expert network with 32 experts obtains MSE of 0.0075, and the dense comparator obtains 0.018. The trained router’s sparsity is 8.8, compared with 11.5 after shuffling. The authors interpret the lower trained value as evidence that the gate learned information about the component directions. The change from a linear to a quadratic contribution at each token gives the expert system a stronger predictive advantage in the reported comparison and makes preserving per-token distinctions more valuable to the aggregate result.

Overlapping components in the dictionary task

In the main discussion of the dictionary-learning task, a dense comparison gives test loss of 0.19 while the expert predictor gives 0.03. Freezing the expert router at initialization can also give test loss of 0.03 in that account. The paper’s detailed experiment with 32 components in 32 dimensions reports MSE of 0.041 for the expert network and 0.043 for the dense comparator with 2 fully connected layers. A depth-1 dense comparator gives 0.19 in the detailed experiment. These reports show how much the dense baseline’s flexibility matters. The main discussion and the detailed results give different expert-loss values, so their values are best read in their respective comparisons.

The harder experiment has 128 candidate components and holds the number of linear experts at 32. The learned-router network gives an MSE of 0.23, the dense comparator gives 0.26, and the frozen-router network gives 0.38. The learned-router and shuffled sparsity measurements are both 3.01 in this setting. Training the gate therefore improves the measured prediction even though this particular assignment diagnostic gives the same value after shuffling.

Predictors on the dictionary task with 128 components, mean squared error

The trainable router yields the lowest error in the harder dictionary setting.

Predictors on the dictionary task with 128 components, mean squared errorFrozen router with 32 experts: 0.38Frozen router with 32 experts0.38Dense predictor: 0.26Dense predictor0.26Trainable router with 32 experts (this paper): 0.23Trainable router with 32 experts (thispaper)0.23
The numbers
System or settingMSE
Frozen router with 32 experts0.38
Dense predictor0.26
Trainable router with 32 experts (this paper)0.23

The best error in the harder setting remains well above a near-perfect fit. The authors treat it as a case where the gate learns something that improves the prediction, with substantial scope left for a better solution. The experiment provides different evidence from the separated Gaussian tasks, where an expert can receive essentially all its examples from the same component and solve them using one target rule.

Pretraining accuracy on mC4

In the narrowed T5 comparison, the sparse architecture with a frozen router outperforms the dense architecture at similar floating-point operation counts. The sparse architecture whose router can train improves on the frozen version. The paper shows these results as pretraining accuracy curves. It also reports a recurring advantage for learned routing when varying the total number of experts at the narrow width. The measured outcome concerns prediction during pretraining on mC4.

At the wider T5-Base configuration, the learned-router accuracy is 70.34% and the frozen-router accuracy is 70.27%. The authors characterize these results as close. The wider comparison is consistent with earlier layers being able to adapt how they present tokens to a fixed router. In the narrowed comparison, the larger advantage from training the router appears under a deliberate restriction of the representation and hidden dimensions.

Learned and frozen routing in T5-Base on mC4, next-token pretraining accuracy

The wider T5 configuration gives close accuracies under learned and frozen routing.

Learned and frozen routing in T5-Base on mC4, next-token pretraining accuracyFrozen router: 70.27Frozen router70.27Trainable router (this paper): 70.34Trainable router (this paper)70.34
The numbers
System or settingaccuracy %
Frozen router70.27
Trainable router (this paper)70.34

The two widths answer related questions about the same architectural intervention. The narrow experiment shows that training the gate has predictive value when the network has less capacity to reshape its inputs. The wider experiment shows how little accuracy changes when router training is removed in the full setting studied. The paper offers the trainable upstream layers as an explanation for that difference. The accuracy observations themselves measure the whole network’s response to freezing its router.

What the ablations show

What changes when the router is frozen

Freezing a gate is useful as a controlled comparison only in light of what the experts can do with the resulting assignments. With constant experts and constant targets, a frozen gate can send different target vectors to the same expert. That expert has no way to reconcile them by looking more closely at the input, since it must return the same vector every time. Replacing the constant experts with MLPs changes both routing conditions so that an expert can implement a more complicated predictor inside its assigned region. The frozen and trainable versions can then both bring the training loss close to zero.

Under those conditions, the lower test loss for the trainable gate is evidence about generalization. A gate that groups examples well can make the expert’s training examples more informative about future inputs it will see. The concentration measurements support this interpretation because they track the known source of the relevant target rule. Training loss alone would give little way to distinguish the learned division of work from a flexible predictor that fits the particular mixture of training samples landing in each fixed region.

When the expert network is compared with dense predictors, the baseline change asks a different question. Matching an active expert gives a comparison at a similar computational scale. Matching all expert parameters gives the dense system more weights available to each prediction. These controls reveal why the paper keeps separate the gain from making many parameters available in total and the gain from learning how to assign them. The dense network can use the greater computation to achieve a lower error, while learned assignments still matter among the expert systems.

What shuffling reveals about concentration

Column shuffling is performed after a linear gate has been fitted. The operation retains the values in each router row, including its norm, and changes their relation to the data coordinates. This matters because a gate with large scores can produce very confident probabilities. Confident probabilities reflect the dominance of some scores, while the trained-versus-shuffled comparison asks whether that dominance depends on weights that align with the data.

For the basic Gaussian tasks, the advantage over shuffling supports the authors’ account that the learned directions help organize inputs by component. The noise-coordinate experiment checks that account more directly. Its reported score uses the projection of each router weight vector into the subspace that actually distinguishes the groups.

A = (∑ᵢ ∥wᵢ′∥₂) / (∑ᵢ ∥wᵢ∥₂)

A is the alignment score. i indexes experts, wᵢ is the associated router vector, and wᵢ′ is its projection onto the informative coordinates. ∥·∥₂ is Euclidean length. The numerator sums the projected lengths, and the denominator sums the full lengths, using ∑ᵢ to add over the expert indices. Higher values indicate greater alignment with the informative directions. The increase after training without weight decay shows that fitting the prediction task itself already favors those directions. The higher score with weight decay is consistent with the regularization argument, which makes an exact statement about local minima under its own assumptions.

Concentration within each cluster leaves open the possibility that many clusters share the same expert. The authors inspect how similar the router row norms are across experts to look for one form of collapse. Their statistic compares the average of squared norms with the square of the average norm.

B = Eᵢ[∥Mᵢ∥²] / (Eᵢ[∥Mᵢ∥])²

B denotes the ratio. Mᵢ is the router weight row associated with expert i, ∥·∥ denotes its norm, ² denotes squaring, and Eᵢ averages over experts. The ratio is 1 if all the row norms are equal. The authors give the expert count as its value if a single row has a non-zero norm. At the largest dataset point in the MLP expert comparison, the learned router has a ratio of 1.025 with 64 experts. This makes an explanation based on overwhelmingly large weights for very few experts less plausible. Actual destinations also depend on the directions of the rows and the distribution of inputs, so weight norms provide an indirect check.

What changes when a group ceases to have a single source

In the linear sequence task, the learned router’s advantage over the dense comparator shrinks as the sequences get longer, even while the learned router continues to concentrate more strongly by component than its shuffled version. This separates recovery of some interpretable structure from the practical need for that structure. The quadratic task changes how each token contributes before aggregation, and the stronger prediction comparison there is consistent with preserving those distinctions being more valuable.

The dictionary groupings offer another test. In the 32-component experiment, the learned and shuffled router both have sparsity of 4.5 in the concentration comparison. The authors suggest that large weight norms can account for the low value. They also change the groups over which probabilities are aggregated. Across samples drawn from different pairs of Gaussians, they report a sparsity value of 8.1. Holding one Gaussian fixed and varying the other gives 6.4. The router’s assignments are more concentrated when one source recurs, which gives some evidence of sensitivity to a shared component. The equal learned and shuffled values nevertheless leave weak evidence for recovery of the underlying directions by the main diagnostic.

The harder configuration keeps the expert supply fixed while increasing the number of candidate components. The MSE penalty from freezing the gate becomes clear in that setting, while the trained and shuffled concentration statistics still agree. This case is useful because the predictive comparison and the diagnostic can no longer be read as measuring the same gain. A router can learn a partition that improves a regression without producing the kind of source-specific assignments that the authors observe for separated Gaussian clouds.

What changing width tests in T5

A frozen gate in the middle of T5 still responds to movements in representation space. Training earlier layers can move a token across a boundary between experts. The authors narrow both the representation and hidden dimensions to limit this possible adaptation. At the narrower setting, changing a gate from frozen to trainable improves pretraining accuracy across the expert counts examined. At the wider setting, the accuracies are close. The comparison makes the ability of earlier layers to compensate a plausible explanation for the width dependence.

Width also controls the kinds of representations and predictions the whole architecture can learn. The experiment observes an interaction between router training and width, while the proposed mechanism concerns how the earlier layers use the extra capacity. The sparse frozen-router network’s advantage over the dense network in the narrow setup also shows that some gain is available before the gate is allowed to train. That condition still has a larger pool of expert weights and trainable representations feeding the gates. The further comparison within the sparse architecture measures the additional benefit of relaxing the router constraint.

Limitations

Limits identified by the authors

The authors highlight the difference between the clean clustering experiments and realistic inputs. A Gaussian component chosen by the generator gives a known grouping, and the corresponding target rule makes that grouping relevant to prediction. Natural observations can combine several concepts, and the relationship between those concepts can involve varying degrees of overlap. The paper asks whether future routing systems could recover a hierarchy or more general graph of related concepts. Its proofs treat much simpler structures.

Dictionary learning begins to expose this limitation within the controlled experiments. Even though the component centers and target construction are known, the router gets only their combined input. The assignment statistics supply weaker evidence of recovery, and the harder task still has appreciable prediction error with a trained router. The authors describe more capable designs for this setting as an open problem. Their focus throughout is on routers that use softmax scores, and the related-work discussion identifies alternatives outside that focus.

The language experiment makes a related tradeoff. Narrowing T5 is part of the authors’ attempt to separate what the gate learns from what trainable layers before it can accomplish. The paper explicitly acknowledges that implicit routing can persist at the narrow width and that such a restricted architecture makes direct generalization to ordinary Transformer configurations difficult. Some of the T5 runs also require substantial computation. The accuracy results concern the particular pretraining task the authors run.

The theoretical analyses use population gradients for clarity. The authors suggest that concentration arguments could help extend the analysis to sample gradients when sufficiently many observations are available. They also suggest that the Gaussian specialization results might extend beyond equally weighted components. Their stated many-component argument uses a balanced, separated mixture, sample-based router initialization, and a learning rate chosen to preserve the useful assignments during specialization. The argument with small random initialization treats the separate symmetric, truncated case with tied experts and faster expert updates. Those assumptions are part of what gives each argument its scope.

Limits visible in the setup and measurements

Sparsity measures concentration of a group’s average routing probabilities. It leaves questions about which computation an expert learned and whether distinct groups systematically receive distinct experts. The column shuffle tests the role of feature alignment, and the row-norm statistic checks one way in which a few experts might dominate. Neither quantity directly records how a group’s prediction would change under reassignment to another expert. The strongest Gaussian interpretation therefore comes from considering the assignment evidence together with the known target rules and the test loss.

The scale of the routing statistic also calls for care. The definition uses entropy, while the discussion describes a value approaching 1 as single-expert assignment and sometimes interprets dictionary values as effective numbers of experts. The reported comparisons support the ordering described by the authors, with smaller values indicating greater concentration. The bare values provide limited information about literal counts of assigned experts or about how entropy was transformed for a particular display.

In the CIFAR-100 regression, training the CNN can improve the image features supplied directly to the experts as well as alter which experts receive an input. The loss comparison measures the combined effect of training that part of the architecture. A separate intervention would be needed to estimate the benefit of changing only the assignments while preserving the intermediate image features. The task’s real images extend the experiment beyond fully synthetic vectors, while the class-specific linear target remains part of its construction.

The language measurements have a similar identification problem. Freezing gate parameters is a direct intervention. Measuring how upstream layers compensate would require observations of their representations or of resulting changes in token assignments under controlled conditions. Narrowing the network changes both its possible compensation and its general capacity. The paper reports next-token pretraining accuracy and uses similar floating-point operation counts for its main dense comparison. These measurements establish the reported prediction comparison under that resource criterion. Downstream task quality, direct timings, and the magnitude of implicit routing remain outside the measurements presented.

There are also differences between what the theoretical mechanisms explain and what their assumptions establish. In the first-layer argument, the offset comparison shows how a penalty can favor removing weights on independent Gaussian directions. For a claim about a local minimum, the alternative parameters must be arbitrarily close to the originals. The written proof chooses an offset with favorable loss, and does not separately bound how close that offset is as the shrinkage goes to zero. In the many-component argument, the initialization gives a coverage mechanism, while converting separation in distance into concentration under dot-product scores requires control of those scores. The chosen high-dimensional setup and small router updates are important to the interpretation of the specialization argument. These are points at which the proofs’ reasoning is more specific than the general intuition that clustering should help routing.

The experiments provide their clearest evidence at the level of the question each control measures. On separated components with known rules, both prediction and routing support specialization. In the dictionary task, the larger loss from freezing can be measured even when evidence of source recovery is weak. In T5, accuracy measures the value of training an internal router within a given architecture, with the representations it receives remaining part of that architecture’s response.

What came after

No later citing work is available for discussion. The paper itself leaves open whether a router can recover a hierarchy or graph of partly overlapping concepts, and whether a different routing design could reuse components when their contributions are combined in one input. The dictionary task gives a concrete test for that question. A later result could measure prediction error alongside evidence that assignments follow recurring components across different combinations.

Cite

Cite as Nishanth Dikkala, Nikhil Ghosh, Raghu Meka, Rina Panigrahy, Nikhil Vyas and Xin Wang. 2023. On the Benefits of Learning to Route in Mixture-of-Experts Models. Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing.

The paper itself, not this page. BibTeX from the library's record of the work. DOI 10.18653/v1/2023.emnlp-main.583

@inproceedings{dikkala2023benefits,
  title = {{On the Benefits of Learning to Route in Mixture-of-Experts Models}},
  author = {Nishanth Dikkala, Nikhil Ghosh, Raghu Meka, Rina Panigrahy, Nikhil Vyas and Xin Wang},
  booktitle = {Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  doi = {10.18653/v1/2023.emnlp-main.583},
  url = {https://doi.org/10.18653/v1/2023.emnlp-main.583}
}

↑ back to top

This page in Markdown https://md.research.elamur.ai/free/en/papers/dikkala-2023-benefits-learning-route-mixture-experts/