Pratham Patel
· 24 min read

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 R2\mathbb{R}^2. Each cluster has a signal direction — a vector that tells us “this is what cluster kk looks like.” The two signal vectors are:

v1=[10],v2=[01]\mathbf{v}_1 = \begin{bmatrix} 1 \\ 0 \end{bmatrix}, \quad \mathbf{v}_2 = \begin{bmatrix} 0 \\ 1 \end{bmatrix}

We have two experts with weight vectors:

wA=[31],wB=[14]\mathbf{w}_A = \begin{bmatrix} 3 \\ 1 \end{bmatrix}, \quad \mathbf{w}_B = \begin{bmatrix} 1 \\ 4 \end{bmatrix}

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 ab=iaibi\mathbf{a} \cdot \mathbf{b} = \sum_i a_i b_i 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 u\mathbf{u} and v\mathbf{v} in Rd\mathbb{R}^d is:

u,v=i=1duivi\langle \mathbf{u}, \mathbf{v} \rangle = \sum_{i=1}^{d} u_i v_i

The angle bracket notation ,\langle \cdot, \cdot \rangle is used interchangeably with the dot notation uv\mathbf{u} \cdot \mathbf{v} — 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 u\mathbf{u} and v\mathbf{v} are orthogonal if their inner product is zero:

uv    u,v=0\boxed{\mathbf{u} \perp \mathbf{v} \quad \iff \quad \langle \mathbf{u}, \mathbf{v} \rangle = 0}

The symbol \perp 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:

v1,v2=1×0+0×1=0\langle \mathbf{v}_1, \mathbf{v}_2 \rangle = 1 \times 0 + 0 \times 1 = 0

The inner product is exactly zero, so v1v2\mathbf{v}_1 \perp \mathbf{v}_2. The two cluster signals are completely independent — a data point’s component along v1\mathbf{v}_1 tells you nothing about its component along v2\mathbf{v}_2.

1.3 Why orthogonality matters for MoE

In Part 3, Chen et al. construct data from KK clusters where all signal vectors {vk}\{\mathbf{v}_k\} and all cluster-center vectors {ck}\{\mathbf{c}_k\} 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 v1\mathbf{v}_1, that learning contributes nothing — positive or negative — to its response to cluster 2’s signal v2\mathbf{v}_2. The expert’s inner product with v1\mathbf{v}_1 can grow without affecting its inner product with v2\mathbf{v}_2. 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:

wA,v1=3×1+1×0=3\langle \mathbf{w}_A, \mathbf{v}_1 \rangle = 3 \times 1 + 1 \times 0 = 3 wA,v2=3×0+1×1=1\langle \mathbf{w}_A, \mathbf{v}_2 \rangle = 3 \times 0 + 1 \times 1 = 1

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:

wB,v1=1×1+4×0=1\langle \mathbf{w}_B, \mathbf{v}_1 \rangle = 1 \times 1 + 4 \times 0 = 1 wB,v2=1×0+4×1=4\langle \mathbf{w}_B, \mathbf{v}_2 \rangle = 1 \times 0 + 4 \times 1 = 4

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 AMk where k=argmaxkvk,wA=argmax(3,1)=1\text{Expert A} \in \mathcal{M}_k \text{ where } k = \arg\max_{k'} \langle \mathbf{v}_{k'}, \mathbf{w}_A \rangle = \arg\max(3, 1) = 1 Expert BMk where k=argmaxkvk,wB=argmax(1,4)=2\text{Expert B} \in \mathcal{M}_k \text{ where } k = \arg\max_{k'} \langle \mathbf{v}_{k'}, \mathbf{w}_B \rangle = \arg\max(1, 4) = 2

Expert A specialises on cluster 1, expert B on cluster 2. The random initialisation of wA\mathbf{w}_A and wB\mathbf{w}_B 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 2\ell_2 norm (for normalising gradients), the \ell_\infty norm (for bounding routing changes), and the Frobenius norm (for normalising gradient matrices). We derive all three.

2.1 The 2\ell_2 norm

The 2\ell_2 norm (also called the Euclidean norm) of a vector is its length — the distance from the origin to the point the vector represents:

w2=i=1dwi2\boxed{\|\mathbf{w}\|_2 = \sqrt{\sum_{i=1}^{d} w_i^2}}

This is the Pythagorean theorem generalised to dd dimensions. In two dimensions, w2=w12+w22\|\mathbf{w}\|_2 = \sqrt{w_1^2 + w_2^2}, which is the hypotenuse of a right triangle with legs w1w_1 and w2w_2.

Numerical check

wA2=32+12=9+1=103.162\|\mathbf{w}_A\|_2 = \sqrt{3^2 + 1^2} = \sqrt{9 + 1} = \sqrt{10} \approx 3.162 wB2=12+42=1+16=174.123\|\mathbf{w}_B\|_2 = \sqrt{1^2 + 4^2} = \sqrt{1 + 16} = \sqrt{17} \approx 4.123

Expert B’s weight vector is longer than expert A’s. The 2\ell_2 norm tells us the overall magnitude of the weights, regardless of direction.

For the signal vectors:

v12=12+02=1,v22=02+12=1\|\mathbf{v}_1\|_2 = \sqrt{1^2 + 0^2} = 1, \quad \|\mathbf{v}_2\|_2 = \sqrt{0^2 + 1^2} = 1

Both signal vectors have norm 1. A vector with 2\ell_2 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 (α\alpha or β\beta) controlling the magnitude.

2.2 Unit vectors and normalisation

Given any nonzero vector w\mathbf{w}, we can create a unit vector pointing in the same direction by dividing by the norm:

w^=ww2\boxed{\hat{\mathbf{w}} = \frac{\mathbf{w}}{\|\mathbf{w}\|_2}}

This operation is called normalisation. The hat notation w^\hat{\mathbf{w}} denotes “the unit vector in the direction of w\mathbf{w}.”

Numerical check

w^A=110[31]=[0.9490.316]\hat{\mathbf{w}}_A = \frac{1}{\sqrt{10}} \begin{bmatrix} 3 \\ 1 \end{bmatrix} = \begin{bmatrix} 0.949 \\ 0.316 \end{bmatrix}

Verify the norm: 0.9492+0.3162=0.900+0.100=1.000=1\sqrt{0.949^2 + 0.316^2} = \sqrt{0.900 + 0.100} = \sqrt{1.000} = 1. The normalised vector has length 1 but points in the same direction as wA\mathbf{w}_A.

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 \ell_\infty norm

The \ell_\infty norm (also called the max norm or supremum norm) of a vector is the largest absolute value among its entries:

w=maxiwi\boxed{\|\mathbf{w}\|_\infty = \max_{i} |w_i|}

Where the 2\ell_2 norm aggregates all entries (via squaring and summing), the \ell_\infty norm cares only about the single largest entry. It answers: what is the worst-case component?

Numerical check

wA=max(3,1)=3\|\mathbf{w}_A\|_\infty = \max(|3|, |1|) = 3 wB=max(1,4)=4\|\mathbf{w}_B\|_\infty = \max(|1|, |4|) = 4

Compare with the 2\ell_2 norms: wA2=3.162\|\mathbf{w}_A\|_2 = 3.162 vs. wA=3\|\mathbf{w}_A\|_\infty = 3. The \ell_\infty norm is always less than or equal to the 2\ell_2 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 \ell_\infty 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: pp^\|\mathbf{p} - \hat{\mathbf{p}}\|_\infty is the largest change in routing probability for any single expert.

2.4 The Frobenius norm

The Frobenius norm extends the 2\ell_2 norm from vectors to matrices. For a matrix M\mathbf{M} with entries MijM_{ij}:

MF=ijMij2\boxed{\|\mathbf{M}\|_F = \sqrt{\sum_{i} \sum_{j} M_{ij}^2}}

The idea is identical to the 2\ell_2 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 2\ell_2 norm of that vector.

Numerical check

Suppose during training, the gradient of the loss with respect to expert A’s weights is:

WAL=[0.60.20.30.4]\nabla_{\mathbf{W}_A} \mathcal{L} = \begin{bmatrix} 0.6 & -0.2 \\ 0.3 & 0.4 \end{bmatrix}

The Frobenius norm is:

WALF=0.62+(0.2)2+0.32+0.42=0.36+0.04+0.09+0.16=0.650.806\|\nabla_{\mathbf{W}_A} \mathcal{L}\|_F = \sqrt{0.6^2 + (-0.2)^2 + 0.3^2 + 0.4^2} = \sqrt{0.36 + 0.04 + 0.09 + 0.16} = \sqrt{0.65} \approx 0.806

In Part 3’s normalised gradient descent, the update rule divides the gradient by this norm:

WA(t+1)=WA(t)ηWALWALF\mathbf{W}_A^{(t+1)} = \mathbf{W}_A^{(t)} - \eta \cdot \frac{\nabla_{\mathbf{W}_A} \mathcal{L}}{\|\nabla_{\mathbf{W}_A} \mathcal{L}\|_F}

The normalised gradient is:

10.806[0.60.20.30.4]=[0.7440.2480.3720.496]\frac{1}{0.806} \begin{bmatrix} 0.6 & -0.2 \\ 0.3 & 0.4 \end{bmatrix} = \begin{bmatrix} 0.744 & -0.248 \\ 0.372 & 0.496 \end{bmatrix}

Verify: 0.7442+0.2482+0.3722+0.4962=0.554+0.062+0.138+0.246=1.000=1\sqrt{0.744^2 + 0.248^2 + 0.372^2 + 0.496^2} = \sqrt{0.554 + 0.062 + 0.138 + 0.246} = \sqrt{1.000} = 1. 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 Θ()\Theta(\cdot), Ω()\Omega(\cdot), and o()o(\cdot). We define each one.

3.1 Why we need this

Consider the statement from Theorem 4.2: “With M=Θ(KlogKloglogd)M = \Theta(K \log K \log \log d) experts… the test error is o(1)o(1).” Without understanding the notation, this is unreadable. With it, the statement becomes precise: the number of experts must grow proportionally to KlogKloglogdK \log K \log \log d, 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:

f(n)=3n2+5n+2f(n) = 3n^2 + 5n + 2

This is a function of nn (think of nn as the problem dimension or dataset size). As nn grows, we want to characterise how ff grows without worrying about the exact coefficients.

3.2 Big-OO: upper bound on growth

We write f(n)=O(g(n))f(n) = O(g(n)) and say ”ff is big-O of gg” if ff grows at most as fast as gg, up to a constant factor. Formally:

f(n)=O(g(n))    there exist constants C>0 and n0 such that f(n)Cg(n) for all nn0\boxed{f(n) = O(g(n)) \quad \iff \quad \text{there exist constants } C > 0 \text{ and } n_0 \text{ such that } f(n) \leq C \cdot g(n) \text{ for all } n \geq n_0}

The constant CC absorbs the leading coefficient and all lower-order terms. The threshold n0n_0 means we only care about large nn — the bound does not need to hold for tiny values.

Numerical check

We claim f(n)=3n2+5n+2=O(n2)f(n) = 3n^2 + 5n + 2 = O(n^2). To verify, we need to find CC and n0n_0 such that 3n2+5n+2Cn23n^2 + 5n + 2 \leq C \cdot n^2 for all nn0n \geq n_0.

For n1n \geq 1: 5n5n25n \leq 5n^2 and 22n22 \leq 2n^2, so 3n2+5n+23n2+5n2+2n2=10n23n^2 + 5n + 2 \leq 3n^2 + 5n^2 + 2n^2 = 10n^2. This gives C=10C = 10 and n0=1n_0 = 1.

Let us verify at a specific value. At n=3n = 3: f(3)=3(9)+5(3)+2=27+15+2=44f(3) = 3(9) + 5(3) + 2 = 27 + 15 + 2 = 44. And 1032=9010 \cdot 3^2 = 90. Indeed 449044 \leq 90.

At n=100n = 100: f(100)=30,000+500+2=30,502f(100) = 30{,}000 + 500 + 2 = 30{,}502. And 101002=100,00010 \cdot 100^2 = 100{,}000. Indeed 30,502100,00030{,}502 \leq 100{,}000.

So 3n2+5n+2=O(n2)3n^2 + 5n + 2 = O(n^2). The big-OO says: “this function grows like n2n^2 or slower, ignoring constant factors.”

3.3 Big-Ω\Omega: lower bound on growth

We write f(n)=Ω(g(n))f(n) = \Omega(g(n)) and say ”ff is big-Omega of gg” if ff grows at least as fast as gg:

f(n)=Ω(g(n))    there exist constants c>0 and n0 such that f(n)cg(n) for all nn0\boxed{f(n) = \Omega(g(n)) \quad \iff \quad \text{there exist constants } c > 0 \text{ and } n_0 \text{ such that } f(n) \geq c \cdot g(n) \text{ for all } n \geq n_0}

Big-Ω\Omega is the mirror image of big-OO: it provides a floor rather than a ceiling.

Numerical check

We claim f(n)=3n2+5n+2=Ω(n2)f(n) = 3n^2 + 5n + 2 = \Omega(n^2). Since 5n05n \geq 0 and 202 \geq 0 for all n0n \geq 0, we have 3n2+5n+23n23n^2 + 5n + 2 \geq 3n^2. This gives c=3c = 3 and n0=0n_0 = 0.

At n=100n = 100: f(100)=30,5023×10,000=30,000f(100) = 30{,}502 \geq 3 \times 10{,}000 = 30{,}000. The lower bound holds.

In Part 3, the statement that a single expert has error Ω(1/K)\Omega(1/K) 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 1/K1/K. The error cannot be made arbitrarily small — it has a floor.

3.4 Big-Θ\Theta: tight bound

We write f(n)=Θ(g(n))f(n) = \Theta(g(n)) and say ”ff is big-Theta of gg” if ff grows at exactly the same rate as gg:

f(n)=Θ(g(n))    f(n)=O(g(n)) and f(n)=Ω(g(n))\boxed{f(n) = \Theta(g(n)) \quad \iff \quad f(n) = O(g(n)) \text{ and } f(n) = \Omega(g(n))}

Big-Θ\Theta combines both bounds: ff is sandwiched between cg(n)c \cdot g(n) and Cg(n)C \cdot g(n) for large nn. It is the tightest characterisation.

Numerical check

We showed that f(n)=O(n2)f(n) = O(n^2) with C=10C = 10 and f(n)=Ω(n2)f(n) = \Omega(n^2) with c=3c = 3. Therefore f(n)=Θ(n2)f(n) = \Theta(n^2). For all large nn:

3n23n2+5n+210n23n^2 \leq 3n^2 + 5n + 2 \leq 10n^2

The function grows exactly like n2n^2: the 5n5n and 22 terms become negligible relative to 3n23n^2.

In Part 3, "M=Θ(KlogKloglogd)M = \Theta(K \log K \log \log d)" means the number of experts must scale proportionally to KlogKloglogdK \log K \log \log d — not much more, not much less. Fewer experts and the proof fails; more are unnecessary.

3.5 Little-oo: strictly slower growth

We write f(n)=o(g(n))f(n) = o(g(n)) and say ”ff is little-o of gg” if ff grows strictly slower than gg:

f(n)=o(g(n))    limnf(n)g(n)=0\boxed{f(n) = o(g(n)) \quad \iff \quad \lim_{n \to \infty} \frac{f(n)}{g(n)} = 0}

Little-oo is stronger than big-OO. Big-OO allows ff to grow at the same rate as gg (the ratio can approach a nonzero constant). Little-oo requires the ratio to approach zero — ff becomes negligible compared to gg.

Numerical check

Consider g(n)=n2g(n) = n^2 and h(n)=nh(n) = n. We claim h(n)=o(g(n))h(n) = o(g(n)), meaning n=o(n2)n = o(n^2):

limnnn2=limn1n=0\lim_{n \to \infty} \frac{n}{n^2} = \lim_{n \to \infty} \frac{1}{n} = 0

The limit is zero, confirming n=o(n2)n = o(n^2). The linear function becomes negligible compared to the quadratic.

But 3n2+5n+23n^2 + 5n + 2 is not o(n2)o(n^2):

limn3n2+5n+2n2=limn(3+5n+2n2)=3\lim_{n \to \infty} \frac{3n^2 + 5n + 2}{n^2} = \lim_{n \to \infty} \left(3 + \frac{5}{n} + \frac{2}{n^2}\right) = 3

The limit is 3, not 0. So f(n)=O(n2)f(n) = O(n^2) but f(n)o(n2)f(n) \neq o(n^2).

The most important use in Part 3 is the statement that the test error is o(1)o(1). Since o(1)o(1) means “strictly slower than the constant function 1”:

limdtest error1=limdtest error=0\lim_{d \to \infty} \frac{\text{test error}}{1} = \lim_{d \to \infty} \text{test error} = 0

That is literally it: o(1)o(1) means “approaches zero.” The test error vanishes as the problem dimension dd 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 h=[2.0,1.0]\mathbf{h} = [2.0, 1.0] for two experts, and these are converted to routing probabilities p\mathbf{p} via softmax (with noise). Now suppose we perturb the gating scores slightly to h^=[2.1,1.0]\hat{\mathbf{h}} = [2.1, 1.0]. 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 f:RdRmf: \mathbb{R}^d \to \mathbb{R}^m is Lipschitz continuous with constant LL if:

f(x)f(y)Lxyfor all x,y\boxed{\|f(\mathbf{x}) - f(\mathbf{y})\| \leq L \cdot \|\mathbf{x} - \mathbf{y}\| \quad \text{for all } \mathbf{x}, \mathbf{y}}

The constant LL 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 LL times the input change.

The norms can be any norms — 2\ell_2, \ell_\infty, or others. The choice of norm affects the value of LL but not the concept. In Part 3, the \ell_\infty norm is used on both sides.

4.3 A simple example

Consider the scalar function f(x)=2xf(x) = 2x. For any two inputs xx and yy:

f(x)f(y)=2x2y=2xy|f(x) - f(y)| = |2x - 2y| = 2|x - y|

So ff is Lipschitz with constant L=2L = 2. The output always changes by exactly twice the input change.

Numerical check

Take x=3x = 3 and y=3.1y = 3.1:

f(3)f(3.1)=66.2=0.2|f(3) - f(3.1)| = |6 - 6.2| = 0.2 Lxy=2×33.1=2×0.1=0.2L \cdot |x - y| = 2 \times |3 - 3.1| = 2 \times 0.1 = 0.2

The bound is tight: 0.20.20.2 \leq 0.2.

4.4 A non-Lipschitz example

Consider g(x)=x2g(x) = x^2. For inputs xx and yy:

g(x)g(y)=x2y2=x+yxy|g(x) - g(y)| = |x^2 - y^2| = |x + y| \cdot |x - y|

The factor x+y|x + y| grows without bound as xx and yy increase. There is no fixed constant LL that works for all xx and yy — we would need Lx+yL \geq |x + y| for every pair, which is impossible with a single constant. So g(x)=x2g(x) = x^2 is not globally Lipschitz.

Numerical check

Take x=100x = 100 and y=100.1y = 100.1:

g(100)g(100.1)=10,00010,020.01=20.01|g(100) - g(100.1)| = |10{,}000 - 10{,}020.01| = 20.01 xy=0.1|x - y| = 0.1

The ratio is 20.01/0.1=200.120.01 / 0.1 = 200.1. Now take x=1000x = 1000 and y=1000.1y = 1000.1:

g(1000)g(1000.1)=1,000,0001,000,200.01=200.01|g(1000) - g(1000.1)| = |1{,}000{,}000 - 1{,}000{,}200.01| = 200.01

The ratio is 200.01/0.1=2000.1200.01 / 0.1 = 2000.1. The ratio keeps growing — no fixed LL can bound it. The function x2x^2 amplifies small perturbations more and more as xx increases.

4.5 The Lipschitz bound in Part 3

Part 3’s Lemma 5.1 states that the noisy routing function satisfies:

pp^M2hh^\|\mathbf{p} - \hat{\mathbf{p}}\|_\infty \leq M^2 \|\mathbf{h} - \hat{\mathbf{h}}\|_\infty

This is a Lipschitz bound with constant L=M2L = M^2, using the \ell_\infty norm on both sides. Let us unpack what it says using our running example.

Suppose we have M=2M = 2 experts. The Lipschitz constant is M2=4M^2 = 4. Now suppose the gating outputs change by:

hh^=0.05\|\mathbf{h} - \hat{\mathbf{h}}\|_\infty = 0.05

meaning no single gating score changes by more than 0.050.05. Then the routing probabilities change by at most:

pp^4×0.05=0.20\|\mathbf{p} - \hat{\mathbf{p}}\|_\infty \leq 4 \times 0.05 = 0.20

No single expert’s routing probability changes by more than 0.200.20. 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 h=[2.0,1.0]\mathbf{h} = [2.0, 1.0] and the perturbed outputs are h^=[2.05,1.0]\hat{\mathbf{h}} = [2.05, 1.0]. The input change is:

hh^=max(2.02.05,1.01.0)=max(0.05,0)=0.05\|\mathbf{h} - \hat{\mathbf{h}}\|_\infty = \max(|2.0 - 2.05|, |1.0 - 1.0|) = \max(0.05, 0) = 0.05

If the actual routing probabilities change from p=[0.731,0.269]\mathbf{p} = [0.731, 0.269] to p^=[0.738,0.262]\hat{\mathbf{p}} = [0.738, 0.262], the output change is:

pp^=max(0.7310.738,0.2690.262)=max(0.007,0.007)=0.007\|\mathbf{p} - \hat{\mathbf{p}}\|_\infty = \max(|0.731 - 0.738|, |0.269 - 0.262|) = \max(0.007, 0.007) = 0.007

Check the bound: 0.0074×0.05=0.200.007 \leq 4 \times 0.05 = 0.20. The bound holds with room to spare — the actual change (0.0070.007) is much smaller than the worst case (0.200.20). 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 p=[p1,p2,,pM]\mathbf{p} = [p_1, p_2, \ldots, p_M] over MM outcomes:

H(p)=i=1MpilogpiH(\mathbf{p}) = -\sum_{i=1}^{M} p_i \log p_i

where we use the convention 0log0=00 \log 0 = 0 (the limit of plogpp \log p as p0p \to 0 is 00). Entropy is always non-negative: H(p)0H(\mathbf{p}) \geq 0.

Two extreme cases define the range:

  • Minimum entropy: H=0H = 0 when one probability is 1 and the rest are 0. The outcome is certain.
  • Maximum entropy: H=logMH = \log M when all probabilities are equal (pi=1/Mp_i = 1/M for all ii). The outcome is maximally uncertain.

5.2 Dispatch entropy for a single token

When the router produces routing probabilities p(x)\mathbf{p}(x) for a token xx, the dispatch entropy for that token is:

H(p(x))=i=1Mpi(x)logpi(x)\boxed{H(\mathbf{p}(x)) = -\sum_{i=1}^{M} p_i(x) \log p_i(x)}

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 logM\log M.

Numerical check

Suppose the router produces probabilities p=[0.9,0.1]\mathbf{p} = [0.9, 0.1] for a token routed between M=2M = 2 experts:

H=(0.9ln0.9+0.1ln0.1)H = -(0.9 \ln 0.9 + 0.1 \ln 0.1)

Computing each term:

0.9ln0.9=0.9×(0.105)=0.0950.9 \ln 0.9 = 0.9 \times (-0.105) = -0.095 0.1ln0.1=0.1×(2.303)=0.2300.1 \ln 0.1 = 0.1 \times (-2.303) = -0.230 H=(0.095+(0.230))=(0.325)=0.325H = -(-0.095 + (-0.230)) = -(-0.325) = 0.325

Now suppose the router is completely uncertain, p=[0.5,0.5]\mathbf{p} = [0.5, 0.5]:

H=(0.5ln0.5+0.5ln0.5)=(2×0.5×(0.693))=(0.693)=0.693H = -(0.5 \ln 0.5 + 0.5 \ln 0.5) = -(2 \times 0.5 \times (-0.693)) = -(-0.693) = 0.693

And log2=0.693\log 2 = 0.693. The uniform distribution achieves maximum entropy, as expected.

For a perfectly sharp routing, p=[1.0,0.0]\mathbf{p} = [1.0, 0.0]:

H=(1.0ln1.0+0ln0)=(0+0)=0H = -(1.0 \ln 1.0 + 0 \ln 0) = -(0 + 0) = 0

The three cases in order: H=0H = 0 (sharp) <0.325< 0.325 (mostly one expert) <0.693< 0.693 (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:

Hˉ=1TxBH(p(x))\boxed{\bar{H} = \frac{1}{T} \sum_{x \in \mathcal{B}} H(\mathbf{p}(x))}

This averages the per-token dispatch entropy over all TT tokens in the batch B\mathcal{B}.

Numerical check

Suppose we have T=4T = 4 tokens with routing probabilities:

Tokenp\mathbf{p}HH
1[0.95,0.05][0.95, 0.05](0.95ln0.95+0.05ln0.05)=0.199-(0.95 \ln 0.95 + 0.05 \ln 0.05) = 0.199
2[0.10,0.90][0.10, 0.90](0.10ln0.10+0.90ln0.90)=0.325-(0.10 \ln 0.10 + 0.90 \ln 0.90) = 0.325
3[0.99,0.01][0.99, 0.01](0.99ln0.99+0.01ln0.01)=0.056-(0.99 \ln 0.99 + 0.01 \ln 0.01) = 0.056
4[0.05,0.95][0.05, 0.95](0.05ln0.05+0.95ln0.95)=0.199-(0.05 \ln 0.05 + 0.95 \ln 0.95) = 0.199

Let us verify token 1 explicitly: 0.95ln0.95=0.95×(0.051)=0.0490.95 \ln 0.95 = 0.95 \times (-0.051) = -0.049 and 0.05ln0.05=0.05×(2.996)=0.1500.05 \ln 0.05 = 0.05 \times (-2.996) = -0.150. So H=(0.049+(0.150))=0.199H = -(-0.049 + (-0.150)) = 0.199.

The average dispatch entropy:

Hˉ=0.199+0.325+0.056+0.1994=0.7794=0.195\bar{H} = \frac{0.199 + 0.325 + 0.056 + 0.199}{4} = \frac{0.779}{4} = 0.195

5.4 Interpreting dispatch entropy in Part 3

In Part 3, the experimental results show:

ModelDispatch Entropy
MoE (linear)1.300
MoE (nonlinear)0.098

With M=4M = 4 experts, the maximum possible entropy is log4=1.386\log 4 = 1.386 (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 (u,v=0\langle \mathbf{u}, \mathbf{v} \rangle = 0) 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 2\ell_2 norm gives overall length and enables normalisation to unit vectors, the \ell_\infty norm gives worst-case component magnitude, and the Frobenius norm extends 2\ell_2 to matrices — all three appear in the normalised gradient descent technique and the Lipschitz stability bound. Asymptotic notation (OO, Ω\Omega, Θ\Theta, oo) lets us read theorem statements that describe how quantities scale: Θ\Theta for tight bounds, Ω\Omega for lower bounds, and o(1)o(1) for “vanishes as the problem grows.” Lipschitz continuity bounds how much a function’s output can change relative to its input, and the M2M^2 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 logM\log M (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.