6.1.5 · D5Scaling & Efficient Architectures

Question bank — Sparse routing and gating networks

1,573 words7 min readBack to topic

This is a self-test bank for Sparse routing and gating networks. Each line is a Question ::: Answer reveal. Cover the answer, commit to a response out loud with justification, then reveal. If your reason differs from the given one — even when your yes/no matches — treat it as a miss and revisit the parent note.


True or false — justify

Adding more experts (with fixed) increases the compute cost per token.
False. Active compute is — it depends on , not . Growing adds parameters (and a tiny gating cost) but each token still runs through only experts.
A Mixture-of-Experts layer has more total parameters than a dense layer but similar active compute.
True. That is the entire selling point: massive parameter store, constant per-token FLOPs. This is why MoE is a form of Conditional Computation.
The softmax in the gating network is there mainly to make routing sparse.
False. Softmax makes scores into a differentiable probability distribution so gradients can flow; sparsity comes afterwards from the separate top- selection step.
If the gating network sends every token to the same expert, training will still converge to a good balanced model on its own.
False. This is expert collapse — the favoured expert improves, gets chosen more, and the others starve. Without a load-balancing pressure the imbalance is self-reinforcing.
The coefficient of variation of the load is what the Switch Transformer actually minimizes during backprop.
False. CV is a monitoring metric only — it is computed through the discrete top- and is not differentiable. The optimized surrogate is .
In the Switch auxiliary loss , gradients flow through both and .
False. Only (mean gate probability) is differentiable; (fraction of tokens dispatched) comes from the hard top- and is treated as a detached constant.
Expert Choice routing still needs an auxiliary load-balancing loss.
False. In Expert Choice each expert grabs exactly its top- tokens, so balance is structural — guaranteed by construction, not learned.
Soft MoE removes the discontinuity of top- by having experts process weighted mixtures of all tokens.
True. There is no arg-max or top- anywhere, so the whole layer is differentiable and balanced by construction, at the cost of computing slot mixtures.
Switch Transformer's means each token gets less per-token capacity than a router.
True. One expert per token is maximally sparse — cheaper and easier to balance, but less capacity blended per token. Switch trades this off by scaling to 1000+.
The gating network sees gradient signal about experts it did not select.
False (for vanilla top-). Non-selected experts contribute nothing to the output, so they and their gate scores get zero gradient — the source of the "broken gradients" trap in the parent note.

Spot the error

"With and , we store 2 experts and simulate the other 126."
Backwards. We store all 128 experts (full parameter capacity) and only compute 2 of them per token. Sparsity is in the compute, not the storage.
"The auxiliary loss is minimized when one expert takes all the tokens, since that's the clearest routing."
Wrong. is minimized (value ) exactly at uniform routing, . Concentration on one expert makes the product large.
"Expert Choice guarantees every token gets processed by exactly experts."
Not guaranteed. It guarantees every expert processes exactly tokens. A low-affinity token may be picked by fewer than experts (or dropped), because experts choose tokens, not the reverse.
"Soft MoE's dispatch matrix has shape because there are slots per expert."
Wrong shape. Each expert owns its own block of slots, so total slots are and is . Every expert needs its own dedicated slot columns.
"Renormalizing the top- gates (dividing by their sum) changes which experts are selected."
No. Renormalization happens after TopK on the already-chosen set — it rescales weights so they sum to 1 but never alters membership of the selected set.
"Because gating cost is , doubling roughly doubles the layer's total FLOPs."
Wrong. Gating cost is tiny compared to expert FFNs ; doubling barely moves total active compute, which is dominated by the experts.
"Switch's single loss and Shazeer's two squared-CV terms optimize opposite objectives."
Wrong. Both push toward uniform expert usage; Switch's product form is just a simpler, later refinement of the same balancing idea.

Why questions

Why do we apply softmax before top- rather than just picking the largest raw logits?
The softmax gives a normalized, differentiable weight to each selected expert so the combination is a proper convex mix and gradients to the gate are well-scaled; raw logits have no bounded scale.
Why is CV a good diagnostic even though it's a bad loss?
It is scale-invariant and hits exactly 0 when all loads are equal, making it a clean human-readable imbalance gauge — but it is computed through the non-differentiable top-, so you cannot backprop through it.
Why does the Switch loss carry the factor ?
It keeps regardless of how many experts you have. Without it the sum of tiny terms would shrink as you add experts, weakening the balancing pressure.
Why does MoE pair naturally with Model Parallelism?
Different experts are independent sub-networks that can live on different devices; a token only activates of them, so you shard experts across hardware and route tokens to the device holding their chosen expert.
Why can a token be dropped in token-choice routing but (ideally) not in Expert Choice?
Token-choice experts have a fixed capacity ; if too many tokens pick the same expert, the overflow is dropped. Expert Choice fills each expert to exactly by construction, so capacity is never overrun.
Why does the parent note call the hospital receptionist a metaphor for the gating network and not the experts?
The receptionist only routes — decides which specialist to send you to — mirroring producing routing scores. The specialists (experts ) do the actual work.
Why is sparse routing relevant to modelling a Long-tail Distribution of inputs?
Rare input types can get their own specialist expert that only fires for them, giving the tail dedicated capacity without inflating the compute paid on common inputs.

Edge cases

(single expert): what does the MoE layer reduce to?
A plain dense FFN. With one expert, always, top- is trivial, and — there is nothing to route.
(select all experts): is this still "sparse" routing?
No. Every expert fires for every token, so active compute is — a dense weighted ensemble, the opposite of the sparsity we wanted.
Two experts tie for the top score in Switch (): what happens?
The arg-max must break the tie by a fixed rule (e.g. lowest index). It is a measure-zero event in continuous logits but must be handled deterministically for reproducible routing.
A batch where all tokens legitimately want the same expert: does the balancing loss hurt accuracy?
Potentially yes — the auxiliary loss will pressure the gate away from the "correct" concentration. That is why is kept small: balance is a soft regularizer, not a hard constraint.
Expert Choice with capacity not an integer: what must you do?
Round (typically down or via a capacity factor) — a fractional slot count is meaningless, so implementations floor/ceil and accept slight over/under-provisioning.
Empty batch or tokens in Expert Choice: can every expert fill slots?
No. If there are fewer tokens than total slots, some experts sit idle or reuse tokens; can be below 1, so the "exactly tokens each" guarantee degrades at tiny batch sizes.
Gate probabilities nearly uniform (untrained network at step 0): why is this actually the desired balanced starting point but still a problem?
Uniform gates mean maximal balance (good) but zero specialization — experts are interchangeable, so early training must break symmetry before any expert can become a useful specialist.
Recall One-line summary to lock in

Sparse routing = full parameter store, -expert compute; softmax for gradients, top- for sparsity, and a detached-, differentiable- auxiliary loss (or structural Expert-Choice / differentiable Soft-MoE) to stop expert collapse.