Repository navigation
Conversation
|
The following ciflow label(s) have been added but CI has not been triggered yet because the workflows are awaiting approval:
Once a maintainer approves the workflows (scroll to the bottom of the PR page), the corresponding CI jobs will be triggered automatically. Please ping one of the reviewers if you do not have access to approve and run workflows. |
7288480 to
49e4695
Compare
a053a52 to
fbdc6fd
Compare
Resolve dispatch API conflicts by retaining per-row router scores in metadata. Preserve the main combine SAVE region and the PR-specific overlap/tracing behavior.
Update the compact DeepEP recipe for current model and accelerator-graph configuration fields. Use the selected DeepEP buffer API in activation-rematerialization tests, and correct overlap scheduling validation and FX producer typing. Assisted-by: Codex Signed-off-by: HuangYuwei <[email protected]>
|
Revalidated head Input/loss/grad-norm byte hashes and canonical initial/final model/optimizer state hashes match across all runs. Allocated peak is unchanged; reserved peak increases 0.566 GiB. This is a same-PR feature ablation on one allocation. Updated the description with the protocol, results and scope. |
|
Sorry for the churn, but we are discussing if we should support overlapping on eager trainer (as well). There had been 5 PRs (including yours), and @acisseJZhong is investigating the differences. Will follow up soon.
|
Summary
Following the review of #5263: express the shared-expert / DeepEP-dispatch overlap as a GraphTrainer
graph pass instead of an eager callback. That needs a prerequisite, which is most of this diff: the compact
DeepEP training path has to be traceable by GraphTrainer at all. Today
memory_policy.pyalready listsdeepep.dispatch, but the ops have no fake kernels, the backward runs DeepEP directly, and the combinerelies on an eager-only stream wait.
What changes
torchtitan/distributed/deepep/deepep.py(eager behavior preserved):deepep::op gets a fake kernel; the received row count is an unbacked size (new_dynamic_size()),the same way the all-to-all path exposes data-dependent counts;
dispatch_bwd,combine_bwd) with fake kernels, so a traced jointgraph contains them instead of running DeepEP on fake tensors;
combinewaits for its own communication (the dispatcher synchronized right after it anyway), which atraced graph needs because
sync_combine()was never part of the graph;setup_contextkeeps the handle_id tensor;launch_dispatch+wait_dispatch(DeepEP v2.5defer_epilogue). GraphTrainer configures it automatically before tracing whencompile.deepep_dispatch_overlap=True; the dispatcher has no public split toggle and eager keeps theoriginal unsplit dispatch.
_permute_tokensusesshape[0]instead oflen()so it traces with anunbacked size;
EPBuffer/ElasticBufferimport compatibility (DeepEP v2.5 renamed the buffer); the DeepEP GPU testpatches whichever class the installed DeepEP has.
torchtitan/experiments/graph_trainer:compile.deepep_dispatch_overlapanddeepep_overlap_pass: for each forwardwait_dispatch, every node inthe window up to the combine's consumer that does not depend on the wait, has no side effect and is
computable from pre-launch values (in the common MoE layout: the shared-expert FFN) is scheduled between
the launch and the wait. Forward only, stable topological sort, no node added or changed. Independent of
ep_overlap: DeepEP has one communication buffer, so the second in-flight exchange that chunking needs isnot available, which is why this only sinks waits.
annotate_moe_ep_regionscovers the DeepEPdispatcher, test recipe
graph_trainer_deepseek_v3_debugmodel_deepep, CPU unit tests for the pass, README.Validation (2026-11-14, head
396c047b)Revalidated on one 8×H200 141GB node with native DeepSeek-V3 16B (64 routed experts, top-6, two shared experts), EP8/FSDP8, BF16 compute/FP32 reductions, Flex attention, CUDA graphs off, random initialization, seed 42, deterministic mode and one synthetic 8192-token document per rank. Runtime: PyTorch
2.16.0.dev20261009+cu132, DeepEP 2.5.0 (35 checked source files match93eb6eb), PyTorch-reported NCCL 2.30.7.All arms use this PR's source. A disables the feature; B enables split dispatch but disables only
deepep_dispatch_overlap_pass; C enables both. Three balanced blocks (ABCCBA / BCAACB / CABBAC), 18 fresh-process runs sharing compilation caches, 30 steps each. Timing: median of steps 6–30, taking the maximum synchronized wall time across eight ranks separately for each step.Table values are geometric means of six run medians per arm.
Scope: synchronized native training-step latency, including fetch, forward/backward, optimizer and native metrics/logging; outer barriers and evidence hashing are excluded. Three blocks on one allocation support a small gain for this workload, not broad performance claims. A retains this PR's shared traceability/backward/combine changes, so A→C is a feature ablation, not an unmodified-upstream comparison. Graph evidence confirms the selected path; no new physical-overlap profiler trace was collected.
Not validated: multi-node, TP > 1 with EP, FP8 dispatch, CUDA graphs (the compact path has a host sync),
ep_overlapchunking composed with this pass, or convergence on real data. Upstream GPU CI pins an older DeepEP; the v2.5-only split path was exercised by this experiment.Rebase validation (2026-10-19)
Rebased onto
mainat48bbce4434df. Followed the upstream MoE module move totorchtitan.models.common.moe.token_dispatcher; the DeepEP debug recipe now explicitlyselects
attn_backend="flex"in both builders, matching the upstream GraphTrainer recipes.and codespell hooks passed across the full checkout.
2.16.0.dev20261018using source-defined DeepEP schemas and the real FX scheduling pass. This isolates
graph reordering; no native DeepEP communication or CUDA code was exercised.
maincheckout (no newdiagnostics). A full type-check pass could not be established with the local
dependency set.
The current-head GPU validation is recorded in the November 14 section above.
Single-switch configuration (2026-10-20)
compile.deepep_dispatch_overlapis the only feature switch and defaults toFalse.GraphTrainer automatically selects split dispatch before tracing when it is enabled.
The DeepEP debug recipe uses Flex attention, matching the existing GraphTrainer recipes.
For tuning, hold the model and inputs fixed and compare:
deepep_dispatch_overlap=Falsedeepep_dispatch_overlap=True,disable_passes=["deepep_dispatch_overlap_pass"]deepep_dispatch_overlap=TrueAppend to an existing
disable_passeslist when other passes are already disabled.The original October 12 GPU ON/OFF result (1.16%) isolated the scheduling pass: OFF retained split
dispatch, corresponding to the second row. The November 14 validation above measures all three cases.
2.16.0.dev20261018: three dispatch-configuration cases and thethree existing graph-scheduling tests. This local harness runs the source-defined dispatcher classes,
compile configuration and setup, and real FX pass, with unrelated training infrastructure and native
DeepEP replaced for import/execution. It exercises no CUDA kernels or native communication.
real FX scheduler: disabling only
deepep_dispatch_overlap_passretains split dispatch and theoriginal node order.
its file hooks. Local Pyrefly produced the same 190 diagnostics as the upstream base, with no new
diagnostics. The dependency-limited local type-check does not establish a full type-check pass.
Open questions
stay with HybridEP? The traceability part stands on its own even without the pass.
ep_overlap_pass.pyas a single-chunk mode instead of its own module?Supersedes the eager approach of #5263 if accepted.