Measure routing mismatch for Qwen models
Description
This PR implements MoE routing mismatch measurement during training. It compares the model's natural routing decisions with forced_routed_experts passed to the model call, and logs the average mismatch rate.
Crucially, this PR only measures the mismatch and does not force the routing. The model's natural routing is still used for the actual computation.
The changes are only scoped to Qwen3 and Qwen3.5. More model support should be added at a later time.
Tests
Unit tests.
Checklist
Before submitting this PR, please make sure (put X in square brackets):
- [X] I have performed a self-review of my code. For an optional AI review, add the
gemini-reviewlabel. - [X] I have necessary comments in my code, particularly in hard-to-understand areas.
- [X] I have run end-to-end tests tests and provided workload links above if applicable.
- [X] I have made or will make corresponding changes to the doc if needed, including adding new documentation pages to the relevant Table of Contents (toctree directive) as explained in our documentation.
Codecov Report
:x: Patch coverage is 50.72464% with 68 lines in your changes missing coverage. Please review.
:loudspeaker: Thoughts on this report? Let us know!