Sinkhorn on a Router, Not Just Softmax

Still 16 November, different notebook: I replaced softmax routing in a tiny tool router with Sinkhorn-Knopp normalization and stopped one expert from eating 94% of traffic.

The setup

Eight "experts" (really small MLP heads), one gating vector per request, temperature (\tau).

Softmax gave:

  • pretty logits
  • collapse toward one head after a week of logs
  • bad tail latency when that head wrapped a slow HTTP tool

The math problem is not classification. It is balancing assignment mass under a capacity constraint.

Sinkhorn in one screen

Given log-scores (G \in \mathbb{R}^{B \times K}):

  1. (P^{(0)} = \exp(G / \tau))
  2. Alternate row and column normalization until (P) is doubly stochastic (or close enough).
  3. Route with rows of (P) as assignment weights.

Intuition: you are projecting onto the Birkhoff polytope's neighborhood. Experts get a floor of probability mass unless their logits are truly awful.

Entropy regularizer on (G) keeps the iteration stable:

[ \mathcal{L}{\text{route}} = \mathcal{L}{\text{task}} + \lambda \sum_{b,k} P_{bk} \log P_{bk} ]

Offline numbers (my run, not a benchmark)

Router p95 latency Top expert share
Softmax 1.8× baseline 94%
Sinkhorn, 8 iters 1.05× baseline 38% max

Quality on held-out tool-correctness dropped 0.3 points. I will take that trade for serving.

Algorithm note

Sinkhorn is (O(B K \cdot \text{iters})). For eight experts and batch 32 on CPU it is noise. Do not put it inside a 2 ms hot path on a robot without profiling; for API routers it is fine.

Why this belongs in a math post

Nobody at a conference says "I improved my agent with linear programming." They say "we added a routing module." The module is applied mathematics. If you only ever reach for softmax, you inherit its failure modes for free.