Repository navigation
Conversation
phu0ngng
requested review from
ksivaman,
ptrendx and
timmoon10
as code owners
November 20, 2026 16:56
Contributor
Confidence Score: 5/5
[Medium impact] The latest changes appear safe to merge, with no new blocking defect established. SummaryAdds
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart LR
D["EP dispatch"] --> F1["FC1 + SwiGLU"]
F1 --> F2["FC2"]
F2 --> C["EP combine"]
C --> B2["Backward dispatch + FC2 backward"]
B2 --> B1["FC1 input gradient"]
B1 --> W["Optional FC1 weight gradient"]
W --> BC["Backward combine"]
B1 --> BC
Reviews (27) · Last reviewed commit: "[Common] Run the EP dispatch backward un..." · Reviewed by Greptile |
phu0ngng
force-pushed
the
feat/moe-overlap-ops-main
branch
from
November 20, 2026 17:15
82d9201 to
7c92f4a
Compare
phu0ngng
force-pushed
the
feat/moe-overlap-ops-main
branch
from
November 21, 2026 00:20
7c92f4a to
6e27c25
Compare
phu0ngng
marked this pull request as draft
November 21, 2026 03:38
phu0ngng
force-pushed
the
feat/moe-overlap-ops-main
branch
from
November 23, 2026 18:43
ff21bae to
be1df76
Compare
phu0ngng
force-pushed
the
feat/moe-overlap-ops-main
branch
from
November 24, 2026 05:01
be1df76 to
a279351
Compare
phu0ngng
marked this pull request as ready for review
November 24, 2026 05:05
dinodeep
added a commit
to dinodeep/TransformerEngine
that referenced
this pull request
Nov 25, 2026
The overlap path no longer rejects TE checkpoint names. The forward tags the
residuals of the fused dispatch+FC1 call (routing state, received tokens and
their MXFP8 scales, received routing weights, per-expert counts, the FC1
output and, for BF16, the SwiGLU output) with checkpoint_name; the wo name
tags nothing because the overlap backward does not read FC2's output. Under a
names-based remat policy JAX rebuilds unsaved residuals by re-running only the
fused dispatch+FC1 call; FC2+combine is never re-run (no separate recompute
path).
A re-run dispatch can place the received rows in a different order, so mixing
saved and rebuilt residuals corrupts the gate and input gradients (measured:
relative error ~1). Every fused-call residual therefore carries all given
names (dispatch, wi_0, wi_1), nested, and is saved when the policy saves any
of them: a mixed policy saves all of them, otherwise all are rebuilt.
_MoEBlock gains wi_0/wi_1/wo_checkpoint_name (forwarded to moe()).
Tests (tests/jax/test_te_ep_moe.py, 4x GB300, EP2xFSDP2, unfused mode):
test_ep_remat_policy over BF16/MXFP8 x policies {wo saved (MaxText custom
remat), nothing saved, dispatch+wo, wi+wo}: overlap loss and gradients match
the un-rematerialized flag-off step; compiled HLO has 2x
te_ep_dispatch_gemm_fwd_ffi when no fused-call name is saved (1x otherwise)
and 1x each other overlap call. The flag-off path is checked only with
everything rematerialized: with saved residuals and a re-run dispatch it shows
the same row-order mismatch (pre-existing, not changed here).
`-k "overlap or remat or checkpoint"`: 63 passed, 29 skipped.
DeepSeek-V3 MaxText proxy (4x GB300, EP4, 1 dense + 4 MoE layers, FP8 dense
+ MXFP8 MoE, pdb 6 x seq 4096, GA 2, custom remat: dispatch and moe_mlpwi
remat, moe_mlpwo saved): the compiled train step has
te_ep_dispatch_gemm_fwd_ffi x16, te_ep_combine_gemm_fwd_ffi x8 and each
backward call x8 (4 layers x 2 microbatches: dispatch+FC1 re-run once per
layer, FC2+combine not re-run). With the overlap on (+ native layouts) vs
off: step 0.991 vs 1.090 s (-9.0%), LHS estimate 98.2 vs 107.7 GiB, peak
159.5 vs 169.7 GiB, losses within 0.004 over 24 steps.
Depends on upstream PR NVIDIA#3906.
Signed-off-by: Deep Patel <[email protected]>
dinodeep
added a commit
to dinodeep/TransformerEngine
that referenced
this pull request
Nov 25, 2026
NCCL EP allocates a group's handle scan scratch lazily, on the first handle init or import. In a MaxText train step (XLA command buffers with CUSTOM_CALL) the first overlap call that imports a handle ran inside a CUDA graph capture, and the allocation failed: "EP combine_gemm_fwd failed: CUDA error nccl_ep.cc:4370 'operation not permitted when stream is capturing'". nvte_ep_overlap_compile, which already runs at trace time once per layer configuration, now opens and closes a handle for the layer configuration (EPBackend::warm_handle_scratch) so the scratch exists before any captured call. No behaviour change otherwise. Measured (4x GB300, DeepSeek-V3 proxy, 1 dense + 4 MoE layers, EP4, FP8 + MXFP8 MoE, pdb 6, GA 2, command buffers incl. CUSTOM_CALL): before, arm B failed at the first step; after, it runs (step 0.983 s, same as with CUSTOM_CALL removed from the command buffers). Depends on upstream PR NVIDIA#3906. Signed-off-by: Deep Patel <[email protected]>
ptrendx
reviewed
Nov 25, 2026
ptrendx
reviewed
Nov 25, 2026
| .. envvar:: NVTE_MOE_OVERLAP | ||
|
|
||
| :Type: ``str`` (directory) | ||
| :Default: unset (overlap off) |
Member
There was a problem hiding this comment.
Why having default off? If the NCCL EP version and the cuDNN version is right, we should try to default to the overlap, no?
Collaborator
Author
There was a problem hiding this comment.
Because there is no IB support yet in TE 3.0.
I would prefer to have it off by default for now, until the support matrix is completed.
ptrendx
reviewed
Nov 25, 2026
Comment on lines
+165
to
+166
| TODO(phuonguyen): once the CuTeDSL kernels are upstreamed into cuDNN, this should take a plain | ||
| 0/1 (or false/true) toggle instead of a directory path. |
Member
There was a problem hiding this comment.
Leaving a comment here as well to make sure that this TODO is not forgotten.
ptrendx
reviewed
Nov 25, 2026
ptrendx
reviewed
Nov 25, 2026
ptrendx
reviewed
Nov 25, 2026
ptrendx
reviewed
Nov 25, 2026
ptrendx
reviewed
Nov 25, 2026
ptrendx
reviewed
Nov 25, 2026
ptrendx
reviewed
Nov 25, 2026
ptrendx
reviewed
Nov 25, 2026
…SL backend and align the native call helper Signed-off-by: Phuong Nguyen <[email protected]>
…ive each transport direction its own quantizer Signed-off-by: Phuong Nguyen <[email protected]>
…e config leaves it unset Signed-off-by: Phuong Nguyen <[email protected]>
…unches with shared per-direction helpers Signed-off-by: Phuong Nguyen <[email protected]>
…t threads completes Signed-off-by: Phuong Nguyen <[email protected]>
…rminism modes Signed-off-by: Phuong Nguyen <[email protected]>
…XFP8 branches of the FusedMoE support reasons Signed-off-by: Phuong Nguyen <[email protected]>
… cuDNN version guard Signed-off-by: Phuong Nguyen <[email protected]>
…ative EP overlap calls Signed-off-by: Phuong Nguyen <[email protected]>
… stream rule, workspace alignment and SM support Signed-off-by: Phuong Nguyen <[email protected]>
…uration Signed-off-by: Phuong Nguyen <[email protected]>
… the dprob view in the EP dispatch GEMM Signed-off-by: Phuong Nguyen <[email protected]>
Signed-off-by: Phuong Nguyen <[email protected]>
…ions to the SM 10.7 MXFP8 combine GEMM Signed-off-by: Phuong Nguyen <[email protected]>
…GEMM Signed-off-by: Phuong Nguyen <[email protected]>
… int64 only on the MoE overlap path Signed-off-by: Phuong Nguyen <[email protected]>
…ithout input gradients cannot stall its peers Signed-off-by: Phuong Nguyen <[email protected]>
…ush tile in the EP overlap launcher Signed-off-by: Phuong Nguyen <[email protected]>
…launcher Signed-off-by: Phuong Nguyen <[email protected]>
… tests into test_ep_gemm.py Signed-off-by: Phuong Nguyen <[email protected]>
… the FusedMoE comments Signed-off-by: Phuong Nguyen <[email protected]>
…overlap budgets to ep_initialize as arrays Signed-off-by: Phuong Nguyen <[email protected]>
…d MLP keeps int32 offsets Signed-off-by: Phuong Nguyen <[email protected]>
…e weights against a zero-start reference Signed-off-by: Phuong Nguyen <[email protected]>
…kernel Signed-off-by: Phuong Nguyen <[email protected]>
…spatch writes the layout Signed-off-by: Phuong Nguyen <[email protected]>
zhongbozhu
reviewed
Dec 4, 2026
This branch has not been 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.
Description
Adds
FusedMoE, a fusedMoeDispatch -> GroupedLinear -> ScaledSwiGLU -> GroupedLinear -> MoeCombineop. The NCCL EP dispatch overlaps FC1 and the combine overlaps FC2, in forward and backward. Weight gradients are computed inside the backward calls. Supports BF16 and MXFP8 (E4M3) on Blackwell (SM 10.0, 10.3) and Rubin (SM 10.7), with fixed-capacity CUDA graphs and eager receive sizing.Type of change
Changes
ep_gemm.h(nvte_ep_dispatch_gemm_fwd/bwd,nvte_ep_combine_gemm_fwd/bwd, workspace query). Readiness flags are one peralignmentrows for the dispatch and one per 1024 hidden columns (or the whole row) for the combine, wired to the NCCL EP signal API (needs NCCL EP >= 0.3.0). A single reset kernel prepares each call's scratch.common/CuTeDSL/ep_gemmloads the grouped GEMMs from the directory inNVTE_MOE_OVERLAP, an external kernel tree meant to move into cuDNN. RequiresNVTE_ENABLE_CUTEDSL_BACKEND=1andNVTE_WITH_CUTEDSL=1at build time.tex.ep_*_gemm_*bindings, which check that all operands are CUDA tensors on the current device, andops/fused/moe_overlap.py, registered with the fuser. One forward serves both recipes through small per-recipe operand classes. A frozen FC1 or FC2 weight skips its weight-gradient preparation and saved inputs. With the overlap enabled, a window that cannot be fused raises with the reason instead of silently running unfused.NVTE_MOE_OVERLAPindocs/envvars.rst, andexamples/pytorch/ep/bench/bench_moe_overlap.pyfor fwd/bwd timing.Dependencies:
Checklist: