Skip to content

[graph_trainer][aot_fx_trace][graph_pp] Add FSDP collective splitting - #3088

Merged
sanketpurandare merged 1 commit into
mainfrom
sanketpurandare/stack/7
Jul 2, 2026
Merged

sanketpurandare merged 1 commit into
mainfrom
sanketpurandare/stack/7

Conversation

@sanketpurandare

@sanketpurandare sanketpurandare commented Apr 24, 2026 •

Copy link
Copy Markdown
Contributor

Stacked PRs:


[graph_trainer][aot_fx_trace][graph_pp] Add FSDP collective splitting

Add GraphPP extraction for explicit FSDP UNSHARD and REDUCE_GRAD graphs. The splitters use shared FSDP trace-pattern helpers to identify validated all-gather/wait reconstruction chains and reduce-scatter epilogues, keep the no-FSDP forward/backward graphs on the GraphPP flat calling convention, and leave fused edge graphs out of the runtime contract.

Teach the default SAC policy to force-save the same helper-selected unshard output when FSDP runs with reshard_after_forward=False, matching the AutoParallel force-save behavior instead of saving every all-gather target.

Add FSDP split tests for collective extraction, view and split-cat reconstruction, malformed unshard chains, no-op paths, input-source metadata, reduce-grad input naming, and pre-reduce cast placement.

@sanketpurandare
sanketpurandare force-pushed the sanketpurandare/stack/7 branch from 08f80d7 to 8649738 Compare April 24, 2026 19:53
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Apr 24, 2026
@sanketpurandare
sanketpurandare changed the base branch from sanketpurandare/stack/6 to main April 30, 2026 18:15
@sanketpurandare
sanketpurandare force-pushed the sanketpurandare/stack/7 branch from 8649738 to 8a31c87 Compare April 30, 2026 18:15
@sanketpurandare
sanketpurandare changed the base branch from main to sanketpurandare/stack/6 April 30, 2026 18:16
@sanketpurandare
sanketpurandare changed the base branch from sanketpurandare/stack/6 to main April 30, 2026 18:41
@sanketpurandare
sanketpurandare force-pushed the sanketpurandare/stack/7 branch from 8a31c87 to d011a2b Compare April 30, 2026 18:41
@sanketpurandare
sanketpurandare changed the base branch from main to sanketpurandare/stack/6 April 30, 2026 18:41
@sanketpurandare
sanketpurandare changed the base branch from sanketpurandare/stack/6 to main May 4, 2026 03:05
@sanketpurandare
sanketpurandare force-pushed the sanketpurandare/stack/7 branch from d011a2b to 1ffecd4 Compare May 4, 2026 03:05
@sanketpurandare sanketpurandare changed the title Add shared graph PP helpers (ModelWithLoss, shape/input fns) [graph_trainer][aot_fx_trace][graph_pp] split_fsdp_collectives May 4, 2026
@sanketpurandare
sanketpurandare changed the base branch from main to sanketpurandare/stack/6 May 4, 2026 03:06
@sanketpurandare
sanketpurandare changed the base branch from sanketpurandare/stack/6 to main May 4, 2026 04:38
@sanketpurandare
sanketpurandare force-pushed the sanketpurandare/stack/7 branch from 1ffecd4 to e6c5096 Compare May 4, 2026 04:38
@sanketpurandare
sanketpurandare changed the base branch from main to sanketpurandare/stack/6 May 4, 2026 04:39
@sanketpurandare
sanketpurandare force-pushed the sanketpurandare/stack/6 branch from 8f71d5a to b775af6 Compare May 4, 2026 20:03
@sanketpurandare
sanketpurandare force-pushed the sanketpurandare/stack/7 branch from e6c5096 to 8a9c40a Compare May 4, 2026 20:03
sanketpurandare added a commit that referenced this pull request May 4, 2026
stack-info: PR: #3088, branch: sanketpurandare/stack/7
@sanketpurandare
sanketpurandare changed the base branch from sanketpurandare/stack/6 to main May 8, 2026 00:37
@sanketpurandare
sanketpurandare force-pushed the sanketpurandare/stack/7 branch from 8a9c40a to 5a27679 Compare May 8, 2026 00:37
@sanketpurandare
sanketpurandare changed the base branch from main to sanketpurandare/stack/6 May 8, 2026 00:37
@sanketpurandare
sanketpurandare marked this pull request as ready for review June 25, 2026 20:06
submartingales pushed a commit to botcanlearn/torchtitan-upstream that referenced this pull request Jun 25, 2026
Add GraphPP extraction for explicit FSDP UNSHARD and REDUCE_GRAD graphs. The splitters identify validated collective chains, keep the no-FSDP forward/backward graphs on the GraphPP flat ABI, and leave fused edge graphs out of the runtime contract.

Add FSDP split tests for collective extraction, no-op paths, input-source metadata, and reduce-grad input naming.

stack-info: PR: pytorch/torchtitan#3088, branch: sanketpurandare/stack/7
@sanketpurandare sanketpurandare linked an issue Jun 26, 2026 that may be closed by this pull request
@sanketpurandare
sanketpurandare marked this pull request as draft June 26, 2026 07:30
@sanketpurandare
sanketpurandare changed the base branch from sanketpurandare/stack/6 to main June 26, 2026 07:30
@sanketpurandare
sanketpurandare force-pushed the sanketpurandare/stack/7 branch from 14923e5 to 35d8e14 Compare June 26, 2026 07:30
@sanketpurandare
sanketpurandare changed the base branch from main to sanketpurandare/stack/6 June 26, 2026 07:31
@sanketpurandare
sanketpurandare marked this pull request as ready for review June 26, 2026 07:31
return result


def find_fsdp_unshard_output(param_placeholder: fx.Node) -> fx.Node | None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i kinda wonder, the 'find' pattern makes sense if you're trying to generalize across frontends, but if that's the case i'd ask whether we are general enough here, or if this pass would need to handle additional allgather bindings (e.g. torchcomms) or consider cases like a dtype conversion, transpose, or other op between the allgather and wait.

if we're ok specializing on simple-fsdp, i wonder if we should just tag the nodes with some metadata and here we just look for the tags. we could even advertise our own tags from this pass as a contract that various fsdp implementations can apply to their nodes e.g. just these tags (unshard_start, unshard_wait) would probably be enough to generalize?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The chain is general, it passes through cast, views and all_gather, waits and split-cat logic. I think the graph's trainer's fsdp particularly does relay on c10 all_gather-wait_tensor including bucketing. When we add support for other backends we can revisit.

@sanketpurandare
sanketpurandare force-pushed the sanketpurandare/stack/7 branch from 35d8e14 to e77a8ef Compare June 30, 2026 15:40
@sanketpurandare
sanketpurandare force-pushed the sanketpurandare/stack/6 branch from cd8d8c4 to 7115eb9 Compare June 30, 2026 15:40
@sanketpurandare
sanketpurandare force-pushed the sanketpurandare/stack/6 branch from 7115eb9 to f4628cf Compare June 30, 2026 16:25
@sanketpurandare
sanketpurandare force-pushed the sanketpurandare/stack/7 branch from e77a8ef to a6b658b Compare June 30, 2026 16:25
@sanketpurandare
sanketpurandare force-pushed the sanketpurandare/stack/6 branch from f4628cf to 2d9fe15 Compare June 30, 2026 16:28
@sanketpurandare
sanketpurandare force-pushed the sanketpurandare/stack/7 branch from a6b658b to 5e43112 Compare June 30, 2026 16:28
submartingales pushed a commit to botcanlearn/torchtitan-upstream that referenced this pull request Jun 30, 2026
Add GraphPP extraction for explicit FSDP UNSHARD and REDUCE_GRAD graphs. The splitters use shared FSDP trace-pattern helpers to identify validated all-gather/wait reconstruction chains and reduce-scatter epilogues, keep the no-FSDP forward/backward graphs on the GraphPP flat calling convention, and leave fused edge graphs out of the runtime contract.

Teach the default SAC policy to force-save the same helper-selected unshard output when FSDP runs with reshard_after_forward=False, matching the AutoParallel force-save behavior instead of saving every all-gather target.

Add FSDP split tests for collective extraction, view and split-cat reconstruction, malformed unshard chains, no-op paths, input-source metadata, reduce-grad input naming, and pre-reduce cast placement.

stack-info: PR: pytorch/torchtitan#3088, branch: sanketpurandare/stack/7
@sanketpurandare
sanketpurandare force-pushed the sanketpurandare/stack/6 branch from 2d9fe15 to 2cb2d67 Compare June 30, 2026 18:29
@sanketpurandare
sanketpurandare force-pushed the sanketpurandare/stack/7 branch from 5e43112 to cfef45c Compare June 30, 2026 18:29
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.

[graph_trainer] Graph-PP RFC

3 participants