moe-balance -- load balancing, collapse, and why experts starve
Splitting a layer into many specialist sub-networks only pays off if the work spreads across them. Auxiliary-loss mode mixes a skewed router toward even traffic: lambda 0 leaves the skew, lambda 1 is uniform, and dragging a bar rescales that mix. Selection-bias mode adds a per-expert offset used only to choose the top few specialists. The combine weight is the softmax of the raw scores of the specialists that were chosen, the auxiliary weight is 0, an overloaded specialist bias decreases by the step, and an underloaded specialist bias increases by the step. In selection-bias mode both compare panes are that bias route.
Interactive page: the MoE balance problem over a whole batch. λ mixes the router preference toward an even target. Whether an expert starves is read off the bars after that mix and after a drag. Anchor: A6 MoE variant; Family D, companion to moe-routing (which shows a single token's top-k routing). See MoE.
What it shows
A batch of T tokens is dispatched to E experts as a load histogram (the bars flow smoothly as the routing changes). A balance knob λ interpolates the effective routing:
λ = 0(no balance loss): the mix is the router's raw preference. An expert starves when its bar is under the line. λ = 0 does not force that on every seed.λ = 1(strong balance loss): the mix weight is the even targetT/E. With the drag left at 1, no expert is under the starvation line. A drag rescales those bars, and a drag can starve an expert.
Also shown:
- capacity + drops: each expert holds
≈ factor · T/E; tokens routed to a full expert are dropped (red overflow). Drag the capacity line. - load-balance aux loss
E · Σₑ fₑ·Pₑ(fₑ= load fraction,Pₑ= router prob), the coefficient of variation, and the starved-expert count. - shared expert (toggle): an always-on expert (DeepSeek-MoE style) that absorbs common patterns so the routed experts can specialize.
Drag any expert's bar up or down to shift load onto or off it -- the other experts rebalance, and the aux loss, capacity drops, and starved count respond live. Drag the capacity line to trade drops for compute; move λ to watch the collapse flatten out; hover any bar. The bars ease to their targets.
Render tier
T1 (Canvas2D bars + capacity line + the live fill; no heatmap needed).
Wiring
layout.mount + controls (E, lam, shared, cap, seed) + animate (bars ease to their targets via api.t) + onPointer bar drag (shift load) capacity-line drag (routes through controls.set) + hover. ?lam / ?cap / ?shared / ?shift / ?hover hooks. Source: page.js.