Skip to content

[Refactor] Move eleven more MoE models to LayerCommunicator.ffn_exit - #40871

Merged
ch-wan merged 1 commit into
mainfrom
cheng/refactor/communicator-ffn-exit-models
Sep 23, 2026
Merged

ch-wan merged 1 commit into
mainfrom
cheng/refactor/communicator-ffn-exit-models

Conversation

@ch-wan

@ch-wan ch-wan commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

This PR is part of a stack (oldest at bottom):

Motivation

Follow-up to #40870: eleven more MoE decoder layers repeat the same FFN-exit sequence that LayerCommunicator.ffn_exit now owns.

Modifications

Bailing (MoE, MoE-linear, V3), GLM4-MoE-Lite, GPT-OSS, Laguna, MiMo-V2, MiniMax-M2, Qwen3-Next, Sarvam-MoE and SDAR-MoE wrap their FFN call in ffn_exit and finish with ffn_exit.finish, instead of calling the two decision methods, publishing the flags and marking or postprocessing the output themselves. The now-unused get_forward imports and the comments that described the removed calls are dropped.

  • Sarvam-MoE's dense layers keep their manual all-reduce between the FFN and the exit; it reads the decision from ffn_exit.
  • Qwen3-Next used to ask for reduce-scatter before fusion. Both are side-effect-free reads and should_use_reduce_scatter does not read the token count, so ffn_exit's order changes neither result nor the fusion check's short-circuit order under torch.compile.

No behavior change.

Accuracy Tests

Parent vs this PR on H200, four greedy prompts submitted one at a time, 32 new tokens, bit-exact comparison of text / token ids / every logprob / top-5, with a per-rank decision log:

Configuration Result Decisions exercised
Ling-3.0-tiny (Bailing-V3) TP2 identical fuse true and false
GLM-4.7-Flash TP2 identical fuse true and false
GLM-4.7-Flash TP2, DP attention 2 identical reduce-scatter in decode and extend
gpt-oss-20b TP2 identical fuse true and false
MiniMax-M2.5 (FP8) TP4 identical fuse true and false
Qwen3-Next-80B-A3B-Instruct-FP8 TP2 (SGLANG_ENABLE_JIT_DEEPGEMM=0) identical fuse true and false

A CPU dispatch comparison runs the real decoder forward of all 12 decoder classes with stubbed submodules, communicator methods and collectives over fuse × reduce-scatter (60 cases): identical except Qwen3-Next's decision call order, and identical after swapping those two calls. unit/layers + unit/models: every existing case keeps its status.

Speed Tests and Profiling

Same per-layer eager overhead as #40870 (about +0.4 µs); CUDA graph replay does not run this code.

Checklist

Review and Merge Process

  1. Ping Merge Oncalls to start the process. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • Common commands include /tag-and-rerun-ci, /tag-run-ci-label, /rerun-failed-ci
  4. After green CI and required approvals, ask Merge Oncalls or people with Write permission to merge the PR.

CI States

Latest PR Test (Base): 🚫 Run #35924184275
Latest PR Test (Extra): 🚫 Run #35924183829
Latest PR Test (AMD ROCm 10): 🚫 Run #35924184474

@ch-wan ch-wan added run-ci-extra CI: also run the extra suite (requires run-ci) bypass-fail-fast CI: a failing job no longer aborts its siblings (lint still gates) parallel-stages CI: stages dispatch together instead of waiting on each other labels Sep 23, 2026
@ch-wan
ch-wan marked this pull request as ready for review September 23, 2026 07:28
@ch-wan
ch-wan requested a review from Jiminator as a code owner September 23, 2026 07:28
@ch-wan

ch-wan commented Sep 23, 2026

Copy link
Copy Markdown
Collaborator Author

/tag-and-rerun-ci

Base automatically changed from cheng/refactor/communicator-boundary-decision to main September 23, 2026 21:43
Bailing (MoE, MoE-linear, V3), GLM4-MoE-Lite, GPT-OSS, Laguna, MiMo-V2,
MiniMax-M2, Qwen3-Next, Sarvam-MoE and SDAR-MoE now wrap their FFN call in
`LayerCommunicator.ffn_exit` and finish with `ffn_exit.finish`, instead of
calling the two decision methods, publishing the flags and marking or
postprocessing the output themselves.

Sarvam-MoE's dense layers keep their manual all-reduce between the FFN and
the exit; it reads the decision from `ffn_exit`. Qwen3-Next used to ask for
reduce-scatter before fusion; both decisions are side-effect-free reads, so
`ffn_exit`'s order does not change either result.

No behavior change.
@ch-wan
ch-wan force-pushed the cheng/refactor/communicator-ffn-exit-models branch from 8324a3b to d7de194 Compare September 23, 2026 21:43
@ch-wan
ch-wan merged commit ab0c31b into main Sep 23, 2026
29 of 34 checks passed
@ch-wan
ch-wan deleted the cheng/refactor/communicator-ffn-exit-models branch September 23, 2026 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bypass-fail-fast CI: a failing job no longer aborts its siblings (lint still gates) parallel-stages CI: stages dispatch together instead of waiting on each other run-ci CI: run the baseline test suite on this PR run-ci-extra CI: also run the extra suite (requires run-ci)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant