maxtext icon indicating copy to clipboard operation
maxtext copied to clipboard

Measure routing mismatch for Qwen models

Open xuefgu opened this issue 6 months ago • 1 comments

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-review label.
  • [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.

xuefgu avatar Jun 03 '26 23:06 xuefgu