Explain Mixture-of-Experts Routing and the Load-Balancing Auxiliary Loss

Last updated: November 29, 2026

Quick Overview

Explain how a sparse mixture-of-experts layer routes tokens to experts, why routing collapses without a balancing loss, and how expert capacity and token dropping work, with a small routing implementation.

Google
Machine Learning
Machine Learning Engineer
Google
November 29, 2026
Machine Learning Engineer
Onsite
Machine Learning
Hard

0

0

0 solved


Explain how a sparse mixture-of-experts layer routes tokens to experts, why routing collapses without a balancing loss, and how expert capacity and token dropping work, with a small routing implementation.

Google has a long line of sparse expert models (GShard, Switch Transformer, and MoE variants of Gemini), so modeling and TPU systems interviews often go deep on routing. The interviewer looks for the math of the auxiliary loss, the systems reason for capacity limits, and awareness of training instabilities.

What the Interviewer Expects
  • Describes the router as a learned softmax over experts with top-k selection
  • Explains why total parameters grow while per-token FLOPs stay roughly constant
  • Explains collapse: a few experts get all tokens and the rest never train
  • Writes the Switch-style balancing loss and what each factor means
  • Explains capacity factor, token dropping, and the residual path
  • Mentions router z-loss or other stability tricks and expert parallelism communication
Key Topics to Cover
Mixture of experts
Load balancing loss
Expert capacity
Sparse models
Expert parallelism
How to Approach This
  1. Understand the bias-variance trade-off. High training accuracy but low test accuracy signals overfitting.
  2. Choose evaluation metrics carefully based on the problem. Accuracy alone is often insufficient.
  3. Feature engineering is often more impactful than model selection.
  4. Know when to use tree-based models (tabular data) vs neural networks (unstructured data).
  5. Handle class imbalance with SMOTE, class weights, or appropriate loss functions.
Possible Follow-up Questions
  • Why is the fraction of tokens term non-differentiable, and how does the loss still work?
  • What capacity factor would you choose for training versus inference?
  • How does expert-choice routing avoid dropping tokens?
  • How does all-to-all communication cost scale with the number of expert shards?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Explore ML Interview Prep
Sample Answer
Clarify

An MoE layer replaces the dense MLP with EE expert MLPs and a router WrW_r. Each token's hidden state hh gives router probabilities p=softmax(Wrh)p = \text{softmax}(W_r h); the token goes to its top-kk experts...

Approach

Without a constraint, the router is self-reinforcing: experts that receive tokens get better, attract higher router scores, and receive more tokens, while others starve. The Switch auxiliary loss is $...


Submit Your Answer
Markdown supported