Repository navigation
MoE routing analysis and metrics capture - #5220
Merged
mathemakitten merged 30 commits intoJul 7, 2026
Merged
Conversation
Contributor
|
This PR has been automatically converted to draft because all PRs must start as drafts. When you are ready for review, click Ready for Review to begin the review process. This will:
See the contribution guide for more details. |
svcnvidia-nemo-ci
marked this pull request as draft
June 8, 2026 19:04
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
1 of 6 tasks
Signed-off-by: Helen Ngo <helenn@nvidia.com>
Signed-off-by: Helen Ngo <helenn@nvidia.com>
Signed-off-by: Helen Ngo <helenn@nvidia.com>
Signed-off-by: Helen Ngo <helenn@nvidia.com>
Signed-off-by: Helen Ngo <helenn@nvidia.com>
Signed-off-by: Helen Ngo <helenn@nvidia.com>
Signed-off-by: Helen Ngo <helenn@nvidia.com>
Signed-off-by: Helen Ngo <helenn@nvidia.com>
Phlip79
approved these changes
Jul 1, 2026
cuichenx
approved these changes
Jul 2, 2026
maanug-nv
reviewed
Jul 2, 2026
Contributor
There was a problem hiding this comment.
wouldn't LoggerConfig make more sense for these settings?
kvareddy
approved these changes
Jul 6, 2026
Signed-off-by: Helen Ngo <helenn@nvidia.com>
deepakn94
approved these changes
Jul 7, 2026
Contributor
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/28890461242 |
sidsingh-nvidia
pushed a commit
to sidsingh-nvidia/Megatron-LM
that referenced
this pull request
Jul 9, 2026
Signed-off-by: Helen Ngo <helenn@nvidia.com> Signed-off-by: Siddharth Singh <sidsingh@nvidia.com>
jon-barker
pushed a commit
to jon-barker/Megatron-LM
that referenced
this pull request
Jul 10, 2026
Signed-off-by: Helen Ngo <helenn@nvidia.com> Signed-off-by: Jon Barker <jbarker@aws-cmh-slurm-1-vscode-02.cm.cluster>
sidsingh-nvidia
pushed a commit
to sidsingh-nvidia/Megatron-LM
that referenced
this pull request
Jul 13, 2026
Signed-off-by: Helen Ngo <helenn@nvidia.com>
chochowski
pushed a commit
to chochowski/Megatron-LM
that referenced
this pull request
Jul 20, 2026
Signed-off-by: Helen Ngo <helenn@nvidia.com> Signed-off-by: mchochowski <mchochowski@nvidia.com>
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do ?
RouterTracerclass that captures per-layer top-K routing decisions via forward hooks on TopKRouter modules, writing one JSONL record per (step, layer, rank). Works identically for training and inference.tools/moe_routing/with two analysis scripts that work on traces from either training or inference:analyze_routing_concentration.py— per-layer expert activation frequency, top-N coverage curves, and a heatmap of hot experts vs layers.analyze_routing_predictability.py— applies layer L's router weights to L_prev's hidden states and measures cosine/Spearman similarity between predicted and actual per-expert token-count distributions. High scores here are the affirmative signal that distributional routing is predictable one layer ahead.Notes on usability
--cuda-graph-impl nonewhen collecting traces.analyze_routing_predictability.pyrequires--moe-routing-trace-capture-hidden-statesand--moe-routing-trace-dump-weightsat collection time.Follow-up items
megatron/training/activation_logging.pyhas a generic_register_hooks(model, module_types, hook_factory)utility that walks model chunks and registers forward hooks.RouterTracer.register_hooksdoes the same thing with a loop. These can be consolidated with a shared helper intocore/, but requires some more work to unify the hook registration pattern (_register_hooksinactivation_logging.pydoes not currently live in core).Issue tracking
For PRs from open-source community contributors:
Linked issue:
Contribution process
Pre-checks
Code review
Feel free to message or comment @NVIDIA/mcore-oncall to help accelerate your merge into main. The less complex your PR is, the faster it will be approved and merged!
All PRs start as draft. If you open a non-draft PR, it will be automatically converted to draft.
Step 1: Mark PR as "Ready for Review"
.github/CODEOWNERS.Final Review might get declined if these requirements are not fulfilled.
Step 2: Final Review
For PRs that change
megatron/core, once all expert reviewers have approved, theFinal Reviewlabel is applied automatically and final reviewers are assigned.For PRs outside
megatron/core, this step is skipped.Step 3: Approved
Once all required reviewers have approved, the
Approvedlabel is applied automatically.Merge
Any member of mcore-engineers will be able to merge your PR.