Skip to content

[MoE] Improvement of shared expert overlap, support shared expert overlap for FlexDispatcher - #2207

Merged
yaox12 merged 9 commits into
NVIDIA:mainfrom
Victarry:denliu/deepep_shared_expert_overlap
Apr 14, 2026
Merged

[MoE] Improvement of shared expert overlap, support shared expert overlap for FlexDispatcher#2207
yaox12 merged 9 commits into
NVIDIA:mainfrom
Victarry:denliu/deepep_shared_expert_overlap

Conversation

@Victarry

@Victarry Victarry commented Nov 11, 2025

Copy link
Copy Markdown

What does this PR do ?

Design doc: https://docs.google.com/document/d/1whtnUiw1hpfdkjFss_g5P8fyIT9xBA5XJvmdklFes48/edit?usp=sharing
Changelog:

  • Add shared expert overlap for FlexDispatcher
  • Add stream wait for cases where CUDA_DEVICE_MAX_CONNECTIONS> 1 to prevent shared expert GEMM launched too early.
  • Change fc1 location of shared experts in A2A dispatcher for better overlap.

Contribution process

flowchart LR
    A[Pre-checks] --> B[PR Tests]
    subgraph Code Review/Approval
        C1[Expert Review] --> C2[Final Review]
    end
    B --> C1
    C2 --> D[Merge]
Loading

Pre-checks

  • I want this PR in a versioned release and have added the appropriate Milestone (e.g., Core 0.8)
  • I have added relevant unit tests
  • I have added relevant functional tests
  • I have added proper typing to my code Typing guidelines
  • I have added relevant documentation
  • I have run the autoformatter.sh on my PR

Code review

The following process is enforced via the CODEOWNERS file for changes into megatron/core. For changes outside of megatron/core, it is up to the PR author whether or not to tag the Final Reviewer team.

For MRs into `main` branch

(Step 1): Add PR label Expert Review

(Step 2): Collect the expert reviewers reviews

  1. Attach the Expert Review label when your PR is ready for review.
  2. GitHub auto-assigns expert reviewers based on your changes. They will get notified and pick up your PR soon.

⚠️ Only proceed to the next step once all reviewers have approved, merge-conflict are resolved and the CI is passing.
Final Review might get declined if these requirements are not fulfilled.

(Step 3): Final Review

  1. Add Final Review label
  2. GitHub auto-assigns final reviewers based on your changes. They will get notified and pick up your PR soon.

(Optional Step 4): Cherry-pick into release branch

If this PR also needs to be merged into core_r* release branches, after this PR has been merged, select Cherry-pick to open a new PR into the release branch.

For MRs into `dev` branch The proposed review process for `dev` branch is under active discussion.

MRs are mergable after one approval by either eharper@nvidia.com or zijiey@nvidia.com.

Merging your PR

Any member of core-adlr and core-nemo will be able to merge your PR.

@Victarry Victarry self-assigned this Nov 11, 2025
@Victarry
Victarry requested review from a team as code owners November 11, 2025 09:22
@copy-pr-bot

copy-pr-bot Bot commented Nov 11, 2025

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@kvareddy
kvareddy requested a review from fanshiqing November 11, 2025 09:49
@kvareddy

Copy link
Copy Markdown
Contributor

@fanshiqing can you please take a look at this MR?

@yanring yanring added the Expert Review [deprecated] Apply this label to indicate that your PR is ready for expert review. label Nov 11, 2025
Comment thread megatron/core/transformer/moe/shared_experts.py Outdated
Comment thread megatron/core/transformer/moe/token_dispatcher.py Outdated
@Victarry
Victarry requested review from a team as code owners November 21, 2025 01:36
@jaredcasper jaredcasper added this to the Core 0.16 milestone Nov 21, 2025
@jaredcasper

Copy link
Copy Markdown
Contributor

/ok to test 3e308ac

@Victarry

Copy link
Copy Markdown
Author

/ok to test 6d8961a

@Victarry

Copy link
Copy Markdown
Author

/ok to test c811dde

@Victarry
Victarry requested a review from a team April 10, 2026 08:59
@svcnvidia-nemo-ci svcnvidia-nemo-ci added Approved All necessary approvals have been made and removed Final Review PR is in the "final review" stage labels Apr 13, 2026
@Victarry

Copy link
Copy Markdown
Author

/ok to test 5019ff9

@Victarry
Victarry enabled auto-merge April 13, 2026 12:51
@Victarry
Victarry added this pull request to the merge queue Apr 13, 2026
@svcnvidia-nemo-ci

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started!

You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/24347395503

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 13, 2026
…eplay

During scoped CUDA graph replay (moe_preprocess in scope),
dispatch_preprocess is skipped (decorator returns from tensor store),
so self.probs and self.routing_map are never re-set. The cleanup
added in combine_postprocess sets them to None, causing
combine_preprocess to crash on self.probs.dtype access.

These tensors are small (O(tokens * experts)) and overwritten on the
next dispatch_preprocess call, so the cleanup is unnecessary.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Victarry
Victarry requested a review from a team as a code owner April 14, 2026 07:26
@svcnvidia-nemo-ci svcnvidia-nemo-ci removed the Approved All necessary approvals have been made label Apr 14, 2026
@Victarry

Copy link
Copy Markdown
Author

/ok to test c4e53e9

@yaox12
yaox12 enabled auto-merge April 14, 2026 08:47
@yaox12
yaox12 added this pull request to the merge queue Apr 14, 2026
@svcnvidia-nemo-ci

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started!

You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/24391557545

@svcnvidia-nemo-ci

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started!

You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/24393098522

Merged via the queue into NVIDIA:main with commit ebfa138 Apr 14, 2026
119 of 139 checks passed
yangbofun pushed a commit to xlm-research/Megatron-LM that referenced this pull request May 22, 2026
…rlap for FlexDispatcher (NVIDIA#2207)

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
yhgalaxy pushed a commit to yhgalaxy/Megatron-LM that referenced this pull request Jun 17, 2026
…rlap for FlexDispatcher (NVIDIA#2207)

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: yhgalaxy <yhgalaxy@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Expert Review [deprecated] Apply this label to indicate that your PR is ready for expert review. module: moe

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants