moe-routing -- router, top-k experts, load balancing

A mixture-of-experts layer replaces the single per-word network with many smaller ones, called experts, plus a small scoring network — the router — that reads each word and picks the two it judges best suited. Only those two run, so the model can hold an enormous amount of knowledge while doing a fraction of the work for any one word. The catch is that each expert can only take so many words per run before it is full, and a word sent to a full expert simply gets nothing back from it — if both of its choices are full it skips the layer entirely. So a router with favourites does not merely waste capacity, it quietly discards work.

Interactive page: how a Mixture-of-Experts layer routes each token to a few experts -- router logits → softmax gate → top-k selection → per-expert load, capacity, and dropped tokens. Anchor: A6 MLP / MoE variant (the gated-MLP sublayer replaced by routed experts); Family D ( MoE).

What it shows

A small router (gating network) scores every token against every expert: router_logits [N × E] → softmax per token → gate weights. Each token is sent to its top-k experts (usually k=2). The heatmap is that softmax; the top-k choice outlines experts and does not renormalize their gates.

Drag any router-gate cell to re-score a token and watch the load (and drops) shift; hover a gate cell or an expert bar for its detail; step the transport to route token by token (auto-plays + loops).

Render tier

T2 (WebGL2 heatmap for the gate matrix; Canvas2D for the load bars, capacity line, routing arrows, and the balance readout).

Wiring

layout.mount + controls (N, E, k, capacity, seed) + an N-step Transport (route token by token) + onPointer gate-cell drag + hover. ?step / ?drag / ?cap / ?hover hooks. Source: page.js.