Skip to content

[graph_trainer] Replace stable_topological_sort with _move_overlap_nodes - #3419

Merged
IvanKobzarev merged 1 commit into
mainfrom
remove-stable-topo-sort
Jun 11, 2026
Merged

IvanKobzarev merged 1 commit into
mainfrom
remove-stable-topo-sort

Conversation

@IvanKobzarev

@IvanKobzarev IvanKobzarev commented May 22, 2026 •

Copy link
Copy Markdown
Contributor

Replace the two _stable_topological_sort calls in JointManualOverlapScheduler with _move_overlap_nodes from upstream pytorch. This surgically moves only the AG/RS chains instead of re-sorting the entire graph, reducing node displacement from ~97% to ~5% and making the pass composable with downstream graph passes.

  • _manual_bucket_collectives: remove the no-op _stable_topological_sort(graph, {}) call after bucketing — the graph is already valid after manual_bucket_collectives.
  • _manual_reorder_graph: replace _stable_topological_sort(graph, overlap_deps) with _move_overlap_nodes(graph, overlap_deps, bucketed_node_types).

Depends on pytorch PR #184711.
!!! Land only pytorch PR is in nightly

Authored by Claude.

Before vs. After for dsv3_16b
https://www.internalfb.com/intern/diffing/?before_paste_number=2371069081&after_paste_number=2371069207&regex_remove_pattern=&enable_regex_remove=0&strip_empty_lines=0&line_wrap=0&selected_tab=plain_diff

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label May 22, 2026
@SherlockNoMad

Copy link
Copy Markdown
Contributor

…des in fsdp_passes

The joint manual overlap scheduler used `_stable_topological_sort` after bucketing and reordering. The empty-dependency call after bucketing was redundant, and the reordering call displaced most graph nodes even though only AG/RS chains needed movement. Use upstream `_move_overlap_nodes` for the overlap dependencies so only bucketed collective chains move, keeping the pass composable with downstream graph passes.

This depends on PyTorch PR #184711.

Test Plan:
```bash
SKIP=pyrefly-check,lychee-link-checker python -m pre_commit run --show-diff-on-failure --files torchtitan/experiments/graph_trainer/fsdp_passes.py
```

Not run: full `pyrefly-check` pre-commit hook, because it is configured with `pass_filenames: false` and `--remove-unused-ignores`; running it cleanly requires removing an unused suppression in `torchtitan/distributed/spmd_types.py`, which would expand this diff outside graph_trainer.

Not run: graph_trainer debug-model TP=1/TP=8 smoke runs. Local `torch` import currently fails before launch with `undefined symbol: cudaGetDriverEntryPointByVersion, version libcudart.so.12` from the current CUDA runtime/library mismatch.

Authored with Claude.
@IvanKobzarev
IvanKobzarev force-pushed the remove-stable-topo-sort branch from 950b0af to 6b6059d Compare June 11, 2026 09:45
@IvanKobzarev
IvanKobzarev merged commit 07828a4 into main Jun 11, 2026
15 of 18 checks passed
IvanKobzarev pushed a commit to IvanKobzarev/torchtitan that referenced this pull request Jun 17, 2026
…ch#3248)

Squashed from ghstack PR pytorch#3248. Turns on traceable ChunkedCELoss config for
deepseek_v3 and qwen3 to match eager ChunkedLoss memory. Requires pytorch#3419 (+
pytorch nightly w/ pytorch#184711) for bitwise loss parity.

Original: pytorch#3248
ghstack-source-id: 64b6e2c
Pull-Request: pytorch#3614
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/8gpu CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants