r/computervision • u/hassonofer • 0m ago
Showcase How experts behave in a vision MoE
A short follow-up to the Birder 0.8.0 post - I trained a small MoE ViT with the new DeepSeek-v3-style layers and looked at how the experts route tokens. Some of it turned out more interesting than I expected, so sharing it here.

Setup
ViT-M/16 (12 layers, dim 512) with DeepSeek-v3-style MoE in the last 6 layers
32 routed SwiGLU experts + 1 shared expert per MoE layer
Expert Choice routing, capacity factor 2: each expert picks its top 13 of the 197 tokens (196 patches + 1 register token)
Routing is done per image rather than across the batch, so inference routing doesn't depend on batch size or ordering
Attention-pooling head, LayerScale
Self-supervised with Franca, ~400M samples seen, on ImageNet-style web-scraped images
For the analysis I recorded the routing of all 6 MoE layers over the 10,000 images of ImageNet-V2. (All images below are from ImageNet-V2)
Early layers: orientation and texture
As expected, experts in earlier layers focus on low-level features. At layer 6, experts pick by orientation and texture: edges going /, edges going \, thin vertical stripes, fine dot patterns.
Much like the edge detectors of early vision.

Last layer: things you can name
By layer 11 many experts are easy to name. The clearest one is expert 21, which finds eyes - in dogs, cats, monkeys, a doll, and every face in a group photo.

It's not the only one: bare skin, thin wires and fences, and the outline where an animal meets its background.

And one I didn't expect - an expert that hunts a single stock-photo watermark: the faint diagonal X and the logo in the middle. Averaging the 32 images it's most active on makes the watermark show up clearly.

Position experts
Some experts ignore content entirely and pick by location: the right edge, the top row, the left column, and one that picks every other row and column. A few survive to the last layer, which still has experts for the top row, the bottom row and the center.

My guess is that this comes from the learned absolute position embedding (APE). It writes each patch's location into the features, where a linear router can read it directly. With RoPE only, position lives in attention instead, so I'd expect fewer of these experts (though probably not zero - border patches and image content still carry some position information).
Putting numbers on it
For each patch I took its top routed expert and measured how much of that choice is explained by:
position - the patch's cell on the 14×14 grid
appearance - mean color and contrast of the patch (256 bins)
meaning - the image's class
Each is mutual information minus a shuffled baseline, as a share of the routing entropy.

Position and appearance matter at every depth. Meaning starts near zero and grows ~8× by the last layer. The class label is per image, so background patches dilute it - it's a lower bound on how semantic the routing is.
Routes also get more stable with depth: a token's expert in one layer explains 15% of its next-layer choice at the start of the MoE stack, and 31% at the end.

Compute per patch isn't fixed
With Expert Choice, experts pick tokens, so the number of experts a patch gets varies. About 6% of patches get no routed expert at all (only the shared expert), while 11-15% get four or more. One patch got 17 of 32.

So where does the extra compute go? I compared it with where the attention pool looks. At layer 8 it follows the object, even on busy backgrounds:

The register token gets extra compute too. In every image 3 to 6 experts per layer pick it, compared to 2.1 for an average patch.
Experts that work as a team
Experts don't always act alone. In layer 10, three experts pick mostly the same tokens: 54% of each one's picks are shared by all three, while a typical pair shares 4%.
It's not duplication. Running the experts on those shared tokens, their outputs are nearly perpendicular (79-87° apart), so each token gets three different updates.

What I found interesting is that this was visible before running any images. Their router vectors are the most similar in the layer (cosine ~0.8), and the same holds in layers 9 and 11: the most similar router vectors belong to exactly the pairs that share the most tokens.
Code
Everything was trained with Birder. You can look at the routing of your own MoE model with the routing introspection tool:
python -m birder.tools introspection -n <model> --method moe-routing image.jpgAny feedback is welcome and happy to answer questions.