feat(moe): add--freq and --collect-routing, train predictor of experts
Merged
HO
6mo ago+1120+1120+0123456789012345678901234567890123456789-5-5-0123456789
Add expert frequency tracking and binary routing data collection for training MLP expert predictors.
New features:
- --freq: prints per-layer expert frequency analysis at shutdown
- --collect-routing
New files:
- server/src/common/moe_routing_collector.{h,cpp}: thread-safe binary writer for per-token routing decisions
- scripts/train_predictor.py: MLP/linear predictor training script (ported from StreamMoE, supports CUDA, mlp/linear/cross variants)
Binary format per sample:
[int32 layer_idx, int32 K, float32[n_embd] hidden, int32[K] experts]
Hooks added in qwen35moe pipelined decode (cached + dynamic paths), qwen35moe prefill, laguna hybrid decode, and laguna hybrid prefill.
Tested: 1K tokens , Qwen3.6-35B-A3B
| Model | top-4 Hit | top-8 Hit | top-16 Hit |
|---|---|---|---|
| linear | 34.9% | 53.5% | 69.2% |
| mlp-cross | 38.5% | 59.7% | 75.5% |
| baseline | 19.4% | - | - |
the mlp-cross predictor achieves 2x the baseline with only 1K token of training data.