Mathematical Prerequisites for Mixture of Experts — Part 3
Building the math foundations you need for understanding why MoEs work — orthogonality, vector norms, asymptotic notation, Lipschitz continuity, and dispatch entropy — all derived step by step with one consistent example.
In Part 3 of the Mixture of Experts series, we examine why experts specialize instead of collapsing, what role nonlinearity plays, and how training unfolds in three stages. The mathematics is different from Parts 1 and 2 — instead of Gaussian likelihoods and load balancing losses, we need tools for measuring vector alignment, bounding how functions change, reading theorem statements that describe asymptotic behaviour, and quantifying how sharply a router dispatches tokens. By the end of this post, you will have every mathematical tool required to follow Part 3 from the first theorem to the last.
We assume you have read the prerequisites for Part 1 (where we built softmax, Gaussian densities, Bayes’ theorem, and the mixture log-likelihood) and Part 2 (where we built top-k masking, the coefficient of variation, indicator functions, and the dot-product loss). We also assume you have seen the definition of entropy from the Foundation Prior prerequisites. We will not re-derive any of those here. Instead, we build five new tools — each one earning its place by being directly used in Part 3.
The Running Example
We have 2 clusters of data in . Each cluster has a signal direction — a vector that tells us “this is what cluster looks like.” The two signal vectors are:
We have two experts with weight vectors:
The question we will answer throughout this post: does expert A “prefer” cluster 1 or cluster 2? Does expert B? How do we measure preference, distance, sensitivity, and routing sharpness? Each section builds one tool for answering these questions, and each tool will be used in Part 3.
1. Orthogonality
In the Part 2 prerequisites, we defined the dot product and showed that it measures alignment between two vectors. Here we need a stronger concept: what happens when two vectors have zero alignment?
1.1 The inner product as alignment
The inner product (another name for the dot product) of two vectors and in is:
The angle bracket notation is used interchangeably with the dot notation — they mean the same thing. Part 3 uses the angle bracket notation throughout, so we adopt it here.
When the inner product is large and positive, the vectors point in similar directions. When it is large and negative, they point in opposite directions. When it is zero, the vectors are completely unrelated — neither one tells you anything about the other. This last case has a name.
1.2 Definition of orthogonality
Two vectors and are orthogonal if their inner product is zero:
The symbol means “is orthogonal to.” In two dimensions, orthogonal vectors are perpendicular — they meet at a right angle. In higher dimensions, the geometric intuition is the same: orthogonal vectors have no component along each other’s direction.
Numerical check
Let us verify that our signal vectors are orthogonal:
The inner product is exactly zero, so . The two cluster signals are completely independent — a data point’s component along tells you nothing about its component along .
1.3 Why orthogonality matters for MoE
In Part 3, Chen et al. construct data from clusters where all signal vectors and all cluster-center vectors are orthogonal to each other. This is the key structural assumption that makes the theory work.
Why? Because orthogonal signals do not interfere. If an expert learns to respond to cluster 1’s signal , that learning contributes nothing — positive or negative — to its response to cluster 2’s signal . The expert’s inner product with can grow without affecting its inner product with . This clean separation is what allows different experts to specialise on different clusters without competing.
1.4 Expert alignment with clusters
Now let us compute which cluster each expert aligns with. Expert A’s alignment with each signal:
Expert A has inner product 3 with cluster 1 and inner product 1 with cluster 2. It aligns more strongly with cluster 1.
Expert B’s alignment:
Expert B has inner product 1 with cluster 1 and inner product 4 with cluster 2. It aligns more strongly with cluster 2.
This is precisely the mechanism from Part 3’s Lemma 5.2: each expert is assigned to the cluster whose signal vector has the largest inner product with the expert’s weights. Using the argmax notation from the Part 2 prerequisites:
Expert A specialises on cluster 1, expert B on cluster 2. The random initialisation of and determined this assignment — different initial weights would have produced a different grouping. This is the symmetry-breaking mechanism from Part 3: all experts start from the same initialisation distribution, but their specific random draws determine which cluster they align with.
2. Vector Norms
In Part 3, three different ways of measuring vector and matrix size appear: the norm (for normalising gradients), the norm (for bounding routing changes), and the Frobenius norm (for normalising gradient matrices). We derive all three.
2.1 The norm
The norm (also called the Euclidean norm) of a vector is its length — the distance from the origin to the point the vector represents:
This is the Pythagorean theorem generalised to dimensions. In two dimensions, , which is the hypotenuse of a right triangle with legs and .
Numerical check
Expert B’s weight vector is longer than expert A’s. The norm tells us the overall magnitude of the weights, regardless of direction.
For the signal vectors:
Both signal vectors have norm 1. A vector with norm equal to 1 is called a unit vector. Unit vectors encode pure direction with no magnitude. In Part 3, the signal vectors are unit vectors — they represent the direction of each cluster’s signal, with a separate scalar ( or ) controlling the magnitude.
2.2 Unit vectors and normalisation
Given any nonzero vector , we can create a unit vector pointing in the same direction by dividing by the norm:
This operation is called normalisation. The hat notation denotes “the unit vector in the direction of .”
Numerical check
Verify the norm: . The normalised vector has length 1 but points in the same direction as .
In Part 3, normalised gradient descent divides the gradient by its norm before updating the weights. This is the same operation: it keeps the direction of the gradient but sets its magnitude to 1, ensuring all experts update at the same speed.
2.3 The norm
The norm (also called the max norm or supremum norm) of a vector is the largest absolute value among its entries:
Where the norm aggregates all entries (via squaring and summing), the norm cares only about the single largest entry. It answers: what is the worst-case component?
Numerical check
Compare with the norms: vs. . The norm is always less than or equal to the norm (the max of the absolute values cannot exceed the root-sum-of-squares). This relationship between norms is called a norm equivalence — different norms give different numbers, but they are always within a bounded ratio of each other.
The norm is used in Part 3’s Lemma 5.1 (the Lipschitz bound on routing probabilities) because it measures the worst-case change across any single expert’s routing probability: is the largest change in routing probability for any single expert.
2.4 The Frobenius norm
The Frobenius norm extends the norm from vectors to matrices. For a matrix with entries :
The idea is identical to the norm: square every entry, sum them all, and take the square root. The only difference is that the entries are arranged in a grid (matrix) rather than a line (vector). If you “unroll” the matrix into a single long vector by stacking its columns, the Frobenius norm equals the norm of that vector.
Numerical check
Suppose during training, the gradient of the loss with respect to expert A’s weights is:
The Frobenius norm is:
In Part 3’s normalised gradient descent, the update rule divides the gradient by this norm:
The normalised gradient is:
Verify: . The normalised gradient has Frobenius norm 1 — exactly the matrix analogue of a unit vector. Every expert takes a step of the same size regardless of how many data points contributed to its gradient. This is normalised gradient descent, the third key technique in Part 3.
3. Asymptotic Notation
Part 3 states its theorems using asymptotic notation — symbols that describe how quantities grow as the problem gets large, without committing to exact constants. Theorem 4.2 alone contains , , and . We define each one.
3.1 Why we need this
Consider the statement from Theorem 4.2: “With experts… the test error is .” Without understanding the notation, this is unreadable. With it, the statement becomes precise: the number of experts must grow proportionally to , and the test error vanishes as the dimension grows. Every symbol has a specific meaning.
We will use the following concrete function to illustrate all four symbols:
This is a function of (think of as the problem dimension or dataset size). As grows, we want to characterise how grows without worrying about the exact coefficients.
3.2 Big-: upper bound on growth
We write and say ” is big-O of ” if grows at most as fast as , up to a constant factor. Formally:
The constant absorbs the leading coefficient and all lower-order terms. The threshold means we only care about large — the bound does not need to hold for tiny values.
Numerical check
We claim . To verify, we need to find and such that for all .
For : and , so . This gives and .
Let us verify at a specific value. At : . And . Indeed .
At : . And . Indeed .
So . The big- says: “this function grows like or slower, ignoring constant factors.”
3.3 Big-: lower bound on growth
We write and say ” is big-Omega of ” if grows at least as fast as :
Big- is the mirror image of big-: it provides a floor rather than a ceiling.
Numerical check
We claim . Since and for all , we have . This gives and .
At : . The lower bound holds.
In Part 3, the statement that a single expert has error on other clusters means: no matter how the expert is trained, its error on clusters it has not specialised on is at least proportional to . The error cannot be made arbitrarily small — it has a floor.
3.4 Big-: tight bound
We write and say ” is big-Theta of ” if grows at exactly the same rate as :
Big- combines both bounds: is sandwiched between and for large . It is the tightest characterisation.
Numerical check
We showed that with and with . Therefore . For all large :
The function grows exactly like : the and terms become negligible relative to .
In Part 3, "" means the number of experts must scale proportionally to — not much more, not much less. Fewer experts and the proof fails; more are unnecessary.
3.5 Little-: strictly slower growth
We write and say ” is little-o of ” if grows strictly slower than :
Little- is stronger than big-. Big- allows to grow at the same rate as (the ratio can approach a nonzero constant). Little- requires the ratio to approach zero — becomes negligible compared to .
Numerical check
Consider and . We claim , meaning :
The limit is zero, confirming . The linear function becomes negligible compared to the quadratic.
But is not :
The limit is 3, not 0. So but .
The most important use in Part 3 is the statement that the test error is . Since means “strictly slower than the constant function 1”:
That is literally it: means “approaches zero.” The test error vanishes as the problem dimension grows. This is how Part 3 encodes “nearly zero test error” in mathematical notation.
4. Lipschitz Continuity
Part 3’s Technique 1 (stability by smoothing) rests on a property of the noisy router: small changes in gating outputs cause only small changes in routing probabilities. This property has a name.
4.1 Motivation
Imagine the gating network produces scores for two experts, and these are converted to routing probabilities via softmax (with noise). Now suppose we perturb the gating scores slightly to . We changed the input by a small amount. The question is: how much can the output change?
If the output can change by an arbitrarily large amount in response to a tiny input change, the system is unstable — training would be chaotic. If the output change is bounded by a multiple of the input change, the system is stable. This is the idea behind Lipschitz continuity.
4.2 Definition
A function is Lipschitz continuous with constant if:
The constant is called the Lipschitz constant. It bounds the ratio of output change to input change. A function with a small Lipschitz constant changes slowly; a function with a large Lipschitz constant can change quickly — but never faster than times the input change.
The norms can be any norms — , , or others. The choice of norm affects the value of but not the concept. In Part 3, the norm is used on both sides.
4.3 A simple example
Consider the scalar function . For any two inputs and :
So is Lipschitz with constant . The output always changes by exactly twice the input change.
Numerical check
Take and :
The bound is tight: .
4.4 A non-Lipschitz example
Consider . For inputs and :
The factor grows without bound as and increase. There is no fixed constant that works for all and — we would need for every pair, which is impossible with a single constant. So is not globally Lipschitz.
Numerical check
Take and :
The ratio is . Now take and :
The ratio is . The ratio keeps growing — no fixed can bound it. The function amplifies small perturbations more and more as increases.
4.5 The Lipschitz bound in Part 3
Part 3’s Lemma 5.1 states that the noisy routing function satisfies:
This is a Lipschitz bound with constant , using the norm on both sides. Let us unpack what it says using our running example.
Suppose we have experts. The Lipschitz constant is . Now suppose the gating outputs change by:
meaning no single gating score changes by more than . Then the routing probabilities change by at most:
No single expert’s routing probability changes by more than . This is the stability guarantee: small perturbations in the gating network produce bounded changes in routing. Without noise, routing would be determined by argmax, which can switch discontinuously from one expert to another — a tiny change in gating scores could cause a complete routing change (from probability 1 to probability 0). The noise smooths this out, making the routing function Lipschitz.
Numerical check
Suppose the original gating outputs are and the perturbed outputs are . The input change is:
If the actual routing probabilities change from to , the output change is:
Check the bound: . The bound holds with room to spare — the actual change () is much smaller than the worst case (). The bound is conservative, but what matters is that it exists: it guarantees that routing can never change dramatically in response to a small gating perturbation.
5. Dispatch Entropy
Part 3 uses dispatch entropy as the primary metric for measuring how sharply the router dispatches tokens to experts. Low dispatch entropy means each token goes to essentially one expert (sharp routing); high dispatch entropy means tokens are spread across many experts (diffuse routing). We build this from the entropy definition in the Foundation Prior prerequisites.
5.1 Entropy recap
Entropy measures how uncertain a probability distribution is. For a discrete distribution over outcomes:
where we use the convention (the limit of as is ). Entropy is always non-negative: .
Two extreme cases define the range:
- Minimum entropy: when one probability is 1 and the rest are 0. The outcome is certain.
- Maximum entropy: when all probabilities are equal ( for all ). The outcome is maximally uncertain.
5.2 Dispatch entropy for a single token
When the router produces routing probabilities for a token , the dispatch entropy for that token is:
This measures how concentrated the routing decision is. If the router is confident — sending the token almost entirely to one expert — the dispatch entropy is near zero. If the router is uncertain — spreading the token across all experts — the dispatch entropy is near .
Numerical check
Suppose the router produces probabilities for a token routed between experts:
Computing each term:
Now suppose the router is completely uncertain, :
And . The uniform distribution achieves maximum entropy, as expected.
For a perfectly sharp routing, :
The three cases in order: (sharp) (mostly one expert) (uniform). Entropy increases as routing becomes more diffuse.
5.3 Average dispatch entropy
Part 3 reports a single dispatch entropy number for the entire model, not for individual tokens. This is the average dispatch entropy across all tokens in the test set:
This averages the per-token dispatch entropy over all tokens in the batch .
Numerical check
Suppose we have tokens with routing probabilities:
| Token | ||
|---|---|---|
| 1 | ||
| 2 | ||
| 3 | ||
| 4 |
Let us verify token 1 explicitly: and . So .
The average dispatch entropy:
5.4 Interpreting dispatch entropy in Part 3
In Part 3, the experimental results show:
| Model | Dispatch Entropy |
|---|---|
| MoE (linear) | 1.300 |
| MoE (nonlinear) | 0.098 |
With experts, the maximum possible entropy is (using natural log). The linear MoE’s dispatch entropy (1.300) is close to the maximum — the router is nearly uniform, spreading tokens across all experts with little discrimination. The nonlinear MoE’s dispatch entropy (0.098) is close to zero — the router sends each token to essentially one expert.
This is the quantitative signature of expert specialisation. An entropy of 0.098 means the routing distribution is extremely sharp — on average, the router is nearly certain about which expert should process each token. An entropy of 1.300 means the router has barely learned to distinguish between experts. The difference between 0.098 and 1.300 is the difference between a specialised MoE and a glorified ensemble.
Summary
We have built five tools for Part 3. Orthogonality () ensures that cluster signals do not interfere, allowing experts to specialise on one cluster without degrading performance on another — the structural assumption underlying Chen et al.’s data model. Three vector norms measure size in different ways: the norm gives overall length and enables normalisation to unit vectors, the norm gives worst-case component magnitude, and the Frobenius norm extends to matrices — all three appear in the normalised gradient descent technique and the Lipschitz stability bound. Asymptotic notation (, , , ) lets us read theorem statements that describe how quantities scale: for tight bounds, for lower bounds, and for “vanishes as the problem grows.” Lipschitz continuity bounds how much a function’s output can change relative to its input, and the Lipschitz constant of the noisy router is what makes training stable — small gating perturbations cannot cause catastrophic routing changes. Dispatch entropy measures routing sharpness on a scale from 0 (deterministic) to (uniform), and the near-zero dispatch entropy of nonlinear MoEs is the quantitative proof that experts have truly specialised.
With these tools in hand, we are ready for Part 3, where we examine why experts specialise, why nonlinearity is essential, and how the three training stages — exploration, router learning, and generalisation — produce a working MoE from random initialisation.
Previous: Attention Residuals: Replacing Fixed Skip Connections with Learned Depth-Wise Attention
Next: Mixture of Experts from Scratch — Part 3
Enjoyed this post?
Subscribe to get notified when I publish new posts. No spam, unsubscribe anytime.