Avoid collective token preparation for AutoEP DeepEP - #8423
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: yh0903 <helloyu0903@gmail.com>
Aggregate retained routing-score gradients by layer and compare stable invariants across equivalent DeepEP reductions. Keep exact route checks and numerical parity for router parameters, expert gradients, and optimizer deltas. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: yh0903 <helloyu0903@gmail.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: yh0903 <helloyu0903@gmail.com>
Cover externally initialized lazy process groups, preserve one-time initialization, and strengthen cleanup gradient and actual FP32-master update checks with discriminating numerical controls. Signed-off-by: yh0903 <helloyu0903@gmail.com>
Signed-off-by: yh0903 <helloyu0903@gmail.com>
bb04f76 to
91cf688
Compare
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 91cf688f8c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| # An externally initialized process group may still have a lazy | ||
| # NCCL communicator. DeepEP needs it before constructing its team; | ||
| # the removed split-count collective used to initialize it for us. | ||
| dist.barrier(group=self.ep_group, device_ids=[tokens.device.index]) |
There was a problem hiding this comment.
Add the mandatory sign-off trailer
This is a one-parent, non-merge commit, but its commit message contains no Signed-off-by: trailer. The repository requires every non-merge commit to carry one, so the commit does not satisfy the project’s contribution requirements and must be recreated with --signoff.
AGENTS.md reference: AGENTS.md:L6-L8
Useful? React with 👍 / 👎.
At step 1, Adam's bias correction makes every updated parameter's delta equal to +/-lr regardless of its gradient's magnitude. With the shared config's default lr=1e-4, the correct delta is smaller than the parameter_deltas comparison's atol=5e-4, so that check could not have told a correct update apart from a missing or wrong-signed one. Override lr to 1e-2 for this test only; the update is applied once, after every value under comparison is already captured, so nothing else here depends on its old magnitude. Review comment from tohtana on deepspeedai#8423. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: yh0903 <helloyu0903@gmail.com>
|
Good catch, thank you @tohtana. Confirmed the math: at step 1, Adam's bias correction makes every updated parameter's delta equal to Fixed in the latest commit by overriding |
tohtana
left a comment
There was a problem hiding this comment.
Thank you for the update! Looks good to me.
Signed-off-by: Masahiro Tanaka <tanaka.masahiro@gmail.com>
Summary
_deepep_route, before collective-backend token preparation.[T*K,H]routed-input expansion, score preparation, split-count all-to-all, and D2H split materialization.This is an opt-in backend cleanup: the default standard communication path and EP1 path are unchanged.
Compatibility:
autoep_non_moecompile is unchanged.Testing Done
Correctness:
Performance, fixed-routing Qwen3-30B-A3B, EP16, TP1, BF16, activation checkpointing on, no profiler:
115.01 ms -> 109.05 ms, a5.18%improvement.682.86 ms -> 665.42 ms, a2.55%improvement.42.50,25.32,9.56, and18.56 ms.23.98 ms, with 95% CI[1.82, 46.14] ms.0.00682; p95 did not regress.+2.2 MiB / +22 MiB, within the no-regression gate.Profiling:
-1.69%, within run-to-run noise.Matched DeepEP V2 context (same-allocation paired blocks; not a merge gate):
eb688c4a...with the same DeepEP01dc3aaa..., ElasticBuffer V2, NCCL 2.30.4, 12 SMs, 16 QPs, fixed routing, data, and checkpointing semantics.38.62,67.21,80.91, and62.18 ms.62.23 ms, with 95% CI[34.20, 90.26] ms; pooled medians were649.76 msfor AutoEP and714.45 msfor Megatron, an AutoEP speedup of9.06%.0.00593.0.63 GiBmore allocated and2.77 GiBmore reserved memory.766.67 msversus716.22 msfor Megatron, so AutoEP was about7.0%slower by arithmetic mean.32/80steps over800 msversus0/80for Megatron; only3/80crossed one second. The repeated slow steps dominate full-run throughput and remain unexplained.Follow-up fixed-routing instrumentation localizes those repeated slow steps:
633.17and638.05 ms) but slower means (754.56and747.22 ms), with16/40measured steps over800 ms.+281 msand+248 msin the two arms); backward and optimizer medians were effectively unchanged.+382.07 msdispatch versus+1.12 msexpert compute,-3.43 mscombine, and+3.94 msrouter.14-15ranks wait about233-357 ms, while one late-arriving rank spends only about0.55-0.74 msin dispatch. The late rank's preceding MoE/combine work is normally only1.5-3.0 ms, placing most of the originating delay in the uninstrumented non-MoE forward region between MoE layers; one observed case accumulated the delay in the router call itself.16893.88 ms, versus16894.84 msfrom summing the 20 recorded critical-step times. The step measurements therefore account for the full measured training window; the mean/median reversal is not an omitted gap between steps.260-435 ms, after which the remaining ranks waited in the next dispatch. This pattern is inconsistent with a specific DeepEP or transformer kernel regression.933.08 -> 557.31 ms, p951740.38 -> 581.60 ms, and steps over800 ms11/20 -> 0/20. The measured-window mean was557.24 ms, matching the recorded557.31 ms. This comparison used separate allocations, so a same-allocation paired confirmation is still required before treating the magnitude as final.The same-allocation AutoEP-only confirmation is now complete. A dual-warm
default -> managed -> managed -> defaultblock used full measured-window timing:688.57 msmean,535.13 msmedian,1072.52 msmedian p95,11/40steps over800 ms, and4/40over one second.python_gc_policy="disable_during_training":526.42 msmean,522.89 msmedian,551.12 msmedian p95, and no steps over800 ms.166.37and157.92 ms; the paired mean was162.14 ms, with 95% CI[108.45, 215.84] ms.0.00266and0.01439.The opt-in engine-managed policy is isolated in Draft PR #8451. It is independent of this PR's DeepEP local-preparation cleanup.
Rewriting or overlapping DeepEP dispatch would optimize the waiting point rather than the source of the tail.
Natural-routing same-allocation context:
67.03,55.87,80.45, and101.26 ms.76.15 ms, with 95% CI[45.10, 107.21] ms; pooled medians were686.49 msfor AutoEP and760.23 msfor Megatron, an AutoEP speedup of9.70%.0.00970.793.65 msversus801.08 msfor Megatron, only a0.93%average-time advantage despite the larger median signal.28/80steps over800 msversus14/80for Megatron, and9/80over one second versus2/80; only one AutoEP step exceeded twice its arm median.9.84%median, but indexed expert variation had a64.72%median and rank-receive variation had a46.46%median. The two frameworks therefore see similar load-shape distributions assigned to different expert/rank identities.🤖 Generated with GitHub Copilot CLI