[MCore] Enable dense routing maps for Flex dispatch - #6615
Open
harryzhou2000 wants to merge 6 commits into
Open
Conversation
6 tasks
harryzhou2000
marked this pull request as ready for review
August 18, 2026 07:51
harryzhou2000
marked this pull request as draft
August 18, 2026 08:38
harryzhou2000
force-pushed
the
hhanyu/dense-routing-main
branch
from
August 18, 2026 11:26
bcffee8 to
891ed5f
Compare
harryzhou2000
marked this pull request as ready for review
August 18, 2026 11:28
YangFei1990
self-requested a review
August 18, 2026 15:57
harryzhou2000
force-pushed
the
hhanyu/dense-routing-main
branch
3 times, most recently
from
August 24, 2026 08:58
950322c to
b5e7e9e
Compare
Signed-off-by: Harry Zhou <hhanyu@nvidia.com>
Signed-off-by: Harry Zhou <hhanyu@nvidia.com>
Signed-off-by: Harry Zhou <hhanyu@nvidia.com>
Signed-off-by: Harry Zhou <hhanyu@nvidia.com>
Signed-off-by: Harry Zhou <hhanyu@nvidia.com>
harryzhou2000
force-pushed
the
hhanyu/dense-routing-main
branch
from
August 26, 2026 03:08
b5e7e9e to
23a3d24
Compare
Signed-off-by: Harry Zhou <hhanyu@nvidia.com>
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 ?
Enable MCore Flex dispatchers to consume Transformer Engine's direct dense top-k routing indices whenever the selected backend requires dense metadata and the installed TE exposes the optional
topk_indicesoutput buffer.DeepEP and NCCL-EP now request
int64 [num_tokens, topk]indices automatically. HybridEP now usesmoe_hybridep_routing_map_mode, which defaults to"indices"; set it to"bool"to force the boolean map. Index mode usesint16only when the installed backend reports dense-routing support and falls back to bool above theint16expert limit or when support is unavailable. Non-Flex dispatchers and older TE combinations preserve the bool router-output path, and dispatcher compatibility paths reconstruct indices when a dense consumer requires them.The dispatcher managers accept both representations, so direct TE output avoids reconstructing indices with
torch.topkwhile compatibility paths remain intact. Dense padding routes remain-1, expert-TP expansion preserves invalid routes, and expert-bias counts are accumulated from the selected indices.This main-targeted change contains the conflict-resolved behavior needed alongside #5515 and #6114: packed-input padding-mask scatter/shape validation, representation-aware HybridEP padding exclusion, and correct expert-bias counts for both sparse maps and dense indices.
Companion dev PR: #6614.
Testing
"bool"is restored; a missing legacy field keeps"indices").moe_hybridep_routing_map_mode="bool"and"indices"using upstream HybridEP. The indices case validates the direct denseint16 [num_tokens, topk]path from TE through MCore into HybridEP.git diff --check, Ruff, andpy_compilepassed. All five commits have SSH signatures andSigned-off-bytrailers.Real DeepEP and NCCL-EP transport were not rerun in this validation. Their dense representation selection and compatibility-manager paths remain covered by focused tests.
Issue tracking
For PRs from open-source community contributors:
Linked issue: Related to #5515 and #6114
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.