Skip to content

Fix DeepGEMM Mega MoE under expert parallelism - #49428

Merged
vasqu merged 3 commits into
mainfrom
megamoe-ep-dispatch
Oct 16, 2026
Merged

vasqu merged 3 commits into
mainfrom
megamoe-ep-dispatch

Conversation

@IlyasMoutawwakil

@IlyasMoutawwakil IlyasMoutawwakil commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

🤗 Transformers CI

Since DeepSeek-V4 declares ep_dispatch_experts, the Mega MoE override left that rule in place: token dispatch wrapped the Mega MoE experts and called them without a process group, so tp_size=ep_size runs raised on the first forward. The older ep_router + moe_tp_experts plan was never applied either, since the override renamed both styles and the mixin matched neither.

Mega MoE dispatches inside its kernel, so it takes over the experts rule (ep_dispatch_experts -> megamoe_experts), runs on the TP group like masked EP, and requires ep_size == tp_size.

What does this PR do?

Fixes # (issue)

Code Agent Policy

The Transformers repo is currently being overwhelmed by a large number of PRs and issue comments written by
code agents. These often are low-quality, or fix extremely minor issues that occur rarely or never in practice.
As a result, we're instituting a rule that first-time contributors should not use code agents to submit PRs or issues.
We'd also ask autonomous "OpenClaw"-like agents not to open any PRs or issues.

Issues/PRs from first-time contributors that violate this rule will probably just be closed without review, and we
might block you, especially if you open more than one or appear to be deliberately ignoring this. We especially do not
want new contributors to jump in on random issues to contribute an agent-written fix. This creates lots of noise
for reviewers and other users and will almost certainly get you blocked.

For more information, please read CONTRIBUTING.md.

  • (First-time contributors only): I confirm that this PR description and code is not written by an LLM or code agent

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline and the
    Pull Request checks?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes according to the guidelines?
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

Since DeepSeek-V4 declares `ep_dispatch_experts`, the Mega MoE override left that rule in place: token dispatch
wrapped the Mega MoE experts and called them without a process group, so `tp_size=ep_size` runs raised on the first
forward. The older `ep_router` + `moe_tp_experts` plan was never applied either, since the override renamed both
styles and the mixin matched neither.

Mega MoE dispatches inside its kernel, so it takes over the experts rule (`ep_dispatch_experts` ->
`megamoe_experts`), runs on the TP group like masked EP, and requires `ep_size == tp_size`.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@IlyasMoutawwakil
IlyasMoutawwakil marked this pull request as ready for review October 8, 2026 13:03
@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@vasqu
vasqu requested review from 3outeille and ArthurZucker and removed request for Rocketknight1 and ydshieh October 8, 2026 13:45

@ArthurZucker ArthurZucker left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@IlyasMoutawwakil
IlyasMoutawwakil added this pull request to the merge queue Oct 16, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 16, 2026
@IlyasMoutawwakil
IlyasMoutawwakil added this pull request to the merge queue Oct 16, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 16, 2026
@IlyasMoutawwakil
IlyasMoutawwakil added this pull request to the merge queue Oct 16, 2026
@ArthurZucker ArthurZucker added the for patch Tag issues / labels that should be included in the next patch label Oct 16, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: finegrained_fp8

@github-actions

Copy link
Copy Markdown
Contributor

CI recap

Dashboard: View test results in Grafana
Latest run: 38892026053:1
Result: failure | Jobs: 15 | Tests: 202,230 | Failures: 2 | Duration: 15h 38m

@vasqu
vasqu disabled auto-merge October 16, 2026 11:27
@vasqu
vasqu merged commit eb943c2 into main Oct 16, 2026
111 of 113 checks passed
@vasqu
vasqu deleted the megamoe-ep-dispatch branch October 16, 2026 11:27
vasqu added a commit that referenced this pull request Oct 16, 2026
Since DeepSeek-V4 declares `ep_dispatch_experts`, the Mega MoE override left that rule in place: token dispatch
wrapped the Mega MoE experts and called them without a process group, so `tp_size=ep_size` runs raised on the first
forward. The older `ep_router` + `moe_tp_experts` plan was never applied either, since the override renamed both
styles and the mixin matched neither.

Mega MoE dispatches inside its kernel, so it takes over the experts rule (`ep_dispatch_experts` ->
`megamoe_experts`), runs on the TP group like masked EP, and requires `ep_size == tp_size`.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Anton Vlasjuk <73884904+vasqu@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

for patch Tag issues / labels that should be included in the next patch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants