feat(moe): DeepEP v2 dispatcher, Torch 2.13 PP, and selectable EP variants - #2930
Open
hemildesai wants to merge 26 commits into
Open
feat(moe): DeepEP v2 dispatcher, Torch 2.13 PP, and selectable EP variants#2930hemildesai wants to merge 26 commits into
hemildesai wants to merge 26 commits into
Conversation
3 tasks
Contributor
Author
|
/ok to test b43f131 |
Contributor
Author
|
/ok to test 5c89be7 |
Contributor
Author
Contributor
Author
|
/ok to test 0df6c8e |
Contributor
|
/ok to test 0d45a92 |
Signed-off-by: hemildesai <hemild@nvidia.com>
Signed-off-by: hemildesai <hemild@nvidia.com>
Signed-off-by: hemildesai <hemild@nvidia.com>
Signed-off-by: hemildesai <hemild@nvidia.com>
Signed-off-by: hemildesai <hemild@nvidia.com>
Signed-off-by: hemildesai <hemild@nvidia.com>
Signed-off-by: hemildesai <hemild@nvidia.com>
Signed-off-by: hemildesai <hemild@nvidia.com>
Signed-off-by: hemildesai <hemild@nvidia.com>
Signed-off-by: hemildesai <hemild@nvidia.com>
Signed-off-by: hemildesai <hemild@nvidia.com>
Move the uv cache off the BuildKit cache mount into the image filesystem and switch UV_LINK_MODE to hardlink so all EP backend venvs share wheel inodes; delete the cache in the same layer (shared inodes survive). Validated on the enroot/pyxis path: the three-backend image is 29.92 GiB versus 29.02 GiB for one backend, with per-backend imports intact. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: hemildesai <hemild@nvidia.com>
DeepEP v2's GIN/GDAKI allocates num_allocated_qps * num_scaleout_ranks QPs per rank; the library default (65/129) is independent of EP size and overflows the NIC QP pool at high scaleout (DOCA_ERROR_FULL, seen at EP256 on 32 nodes). init_deepep_v2_buffer now honors the previously-unused DISPATCHER_NUM_ALLOCATED_QPS env to cap the pool; 0/unset keeps the library default. Validated in isolation: EP256 inits at num_allocated_qps=16. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: hemildesai <hemild@nvidia.com>
Regenerate uv.lock and docker/common/uv-pytorch.lock against the merged pyproject.toml (main + DeepEP v2 deps) using the CONTRIBUTING.md lock flow, resolving the rebase lock conflicts. Picks up main's transformers 5.12.1, simsimd, and stringzilla alongside the selectable EP variant dependencies. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: hemildesai <hemild@nvidia.com>
…pers Match the sibling fused_dispatch/fused_combine convention by spelling out the [num_tokens, hidden_size] / [num_tokens, topk] shapes (and the hidden%256 requirement) for deepep_v2_fused_dispatch/deepep_v2_fused_combine. Addresses review feedback on ambiguous tensor inputs. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: hemildesai <hemild@nvidia.com>
…ad fns Document input/output shapes and axis order for DeepEPV2FusedDispatch and DeepEPV2FusedCombine forward/backward methods (Google-style Args/Returns), addressing review feedback on the per-method tensor contract. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: hemildesai <hemild@nvidia.com>
Signed-off-by: hemildesai <hemild@nvidia.com>
Signed-off-by: hemildesai <hemild@nvidia.com>
Signed-off-by: hemildesai <hemild@nvidia.com>
Signed-off-by: hemildesai <hemild@nvidia.com>
Signed-off-by: hemildesai <hemild@nvidia.com>
Signed-off-by: hemildesai <hemild@nvidia.com>
Signed-off-by: hemildesai <hemild@nvidia.com>
Signed-off-by: hemildesai <hemild@nvidia.com>
Signed-off-by: NeMo Bot <nemo-bot@nvidia.com>
Signed-off-by: hemildesai <hemild@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?
This PR upgrades the MoE stack to DeepEP v2 while retaining selectable DeepEP v1
and HybridEP builds. It adds the DeepEP v2 ElasticBuffer dispatcher, Torch 2.13
pipeline/FSDP synchronization fixes, tuned communication defaults, benchmark and
finetuning recipes, HybridEP JIT-cache reuse, and a selectable CUDA development
image.
The branch includes
mainthrougha664ea4a242883a394c812232ed46b4e426c2472.All 26 commits are signed off.
This replaces the earlier stacked PRs #2850, #2782, #2851, #2853, #2854, and
#2855. Those PRs are closed; this is a standalone PR against
main.Changelog
uvextras for DeepEP v1, DeepEP v2, andHybridEP (
deepep_v1,deepep_v2,hybridep;moeselects v2 by default),with updated dependency pins and lockfiles.
activation-checkpointing support and SM/QP configuration propagated through
dispatch and backward combine.
actual EP process group. Non-PP fixed and packed recipes infer capacity from
local batch size and sequence length during distributed setup; PP uses
microbatch size and sequence length. Unknown dynamic shapes retain a one-time
first-dispatch fallback, and the training loop has no dispatcher-specific
buffer lifecycle.
with the paired combine operation. This prevents non-reentrant checkpoint
unpack from replaying forward combine communication.
Torch 2.13, including final-microbatch reduction without duplicate reduction.
FSDP wrapper for PP1 Qwen3 30B.
finetuning recipes.
hardlink-deduplicated per-backend virtual environments.
Performance
DeepEP v2 pin
The final stack uses Torch 2.13.0, source-built Transformer Engine 2.17.0, and
DeepEP v2 pinned to
af9a0403(
af9a0403188392824fc3057452822235873e0612), the direct parent of upstream099d5f2. The A/B used a DeepEP-only image overlay, leaving Torch, TE, CUDA,NCCL, NVSHMEM, and AutoModel source unchanged.
Cached dispatch-plus-combine forward/backward probes show that the pre-
099d5f2pin recovers communication bandwidth:
dd758cafaf9a0403Pinned end-to-end controls:
dd758cafaf9a0403The full-model Qwen3 235B controls use 33 QPs. An explicit 48-QP run fell to
7.7-9.3% steady-state MFU even though 48 QPs helped the isolated EP group; that
setting oversubscribes the full PP4/DP2 topology. Earlier local benchmark records
labeled 48/65 QPs logged the override but did not append it to the recipe
arguments, so those benchmark runs used the 33-QP backend default.
The Torch 2.13 image source-builds TE against its packaged cuDNN 9.20 and stages
the matching uv-installed cuDNN ahead of the base-image copy. The prebuilt TE
wheel requested an unavailable cuDNN descriptor in fused-attention backward.
Dispatcher comparison
All runs use H100s and non-reentrant activation checkpointing. MFU excludes the
first two warmup iterations.
The original post-rebase Qwen3 235B v2 result was 18.759 s / 26.147% at
20 SM / 33 QP. Besides needing more communication resources, dispatch and
combine independently registered the same mutable handle with non-reentrant
checkpoint saved-tensor hooks. During combine backward, the second registration
forced recomputation through forward combine, adding an extra EP communication
replay per checkpointed layer. The paired handle now reuses the dispatch autograd
context, so recomputation stops after dispatch as it does for the legacy path.
An exact EP32 probe measured 4.7950 ms for the duplicate-save checkpoint path and
3.9740 ms for the paired path, a 17.1% reduction. With the final pin, a 40-SM /
33-QP control reached 17.776 s / 27.592%
(pq5739dj);
48 SM reached 17.724 s / 27.673%. The 0.081-point difference is not material.
Convergence
Qwen3 MoE 30B
HellaSwag, 100 finetuning steps:
Qwen3 MoE 235B
HellaSwag, 100 finetuning steps, PP4 / EP32, LR
1e-5,torch_mmexperts, andGC every 10 steps:
The DeepEP v2 run maintained a stable 30.45 GiB peak through step 99 while its
loss and grad-norm trajectory matched the v1 and HybridEP baselines. A longer
Tulu-3 SFT validation also completed 1000 steps with DeepEP v2, PP4/EP32, and TE
FusedAdam fp32 master weights: loss 0.77 -> approximately 0.50 and grad norm near
0.35 (1mdcfrss).
Numerical parity probes after the backward/checkpoint-replay fix report maximum
differences of 7.8e-3 for dispatcher output, 4.8e-7 for hidden gradients, and
6.1e-5 for router-probability gradients.
Validation
mainata664ea4a2.DeepEP
af9a0403, andElasticBufferimport all pass.782 passed, 30 warnings.119 passed, 28 warnings.218 passed, 45 skipped; the vision AC file passes10/10in isolation.uv lock --check, pre-commit hooks, Ruff, YAML recipe lint, andgit diff --checkpass.controls completed successfully.
Before your PR is "Ready for review"
Pre checks: