Only p_i (mean softmax routing probability) receives gradients, f_i is a hard dispatch count blocked by top-k.
Imagine the router keeps two records: a wish list (soft probabilities p_i) and a receipt (hard counts f_i of what actually happened). Training can only adjust the wish list, the receipt is a done deal after top-k picks experts. So the balancing loss teaches the router through p_i, not f_i.
Detailed answer & concept explanation~6 min readEverything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
6 min: formula + gradient paths + distractor analysis + straight-through contrast + z-loss mention.
Real products, models, and research that use this idea.
- Switch Transformer backprops aux loss through p_i, the standard reference implementation.
- Open-source MoE trainers (Megablocks, fairseq MoE) follow the same f_i detached, p_i trained pattern.
- Router z-loss in Gemma 2 MoE also trains router weights directly for logit stability.
What an interviewer would ask next. Try answering before peeking at the approach.
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Assuming f_i backpropagates through top-k via straight-through estimator.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.