Repository navigation
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/197500
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (2 Unrelated Failures)As of commit f3d32c9 with merge base 3fda599 ( UNSTABLE - The following jobs are marked as unstable, possibly due to flakiness on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
wuyl1
pushed a commit
to wuyl1/pytorch
that referenced
this pull request
Sep 30, 2026
> AI-assisted implementation prepared with Codex. > > Extract the existing preparation, metadata collection, backend allocation, > and rank-major copy-in into a default callback. Add recursive registration > through FSDPModule.set_all_gather_input_fn. Stream dependencies, collective > launch, output processing, and the world-size-one shortcut are unchanged. > > The existing input/output storage aliasing contract is retained. Backend > layout integration and borrowed-output lifetime changes are separate work. > > Test Plan > > Exact training parity and recursive/local dispatch pass on two GPUs: > ```bash > CUDA_VISIBLE_DEVICES=0,1 python test/distributed/_composable/fsdp/test_fully_shard_training.py TestFullyShard1DTrainingCore.test_all_gather_input_fn TestFullyShardShareCommContext.test_share_comm_context -v > ``` > > Existing all-gather, Inductor forward and compiled-autograd tests pass. > All 64 original/extracted packing comparisons match bytes, metadata, > allocator arguments, storage aliases and rank offsets. Lint passes. > The threaded-PG all-gather fixture emits its existing > pg_flight_recorder_hooks teardown error after passing its assertions. ghstack-source-id: 79c72e8 Pull-Request: pytorch#197500
weifengpy
added a commit
that referenced
this pull request
Oct 5, 2026
…t hook and add an input hook > AI-assisted draft prepared with Claude Code for the all-gather contract discussion on #188276. It is one of three alternatives, #199720 (option 1), #199721 (option 2) and #199726 (option 3), and is not ready for review. > > This keeps the stack's tensor-only hooks as the all-gather contract and extends them to cover what #188276's MORI SDMA backend needs. `AllGatherOutputFn` may now return one tensor per output instead of writing into `outputs`. When the comm sets `AllGather.reuses_output_storage` and the group is eligible (every payload has outer size 1 and the buffer dtype, and no parameter is post-forward, a DTensor, an extension, or under compiled autograd), FSDP adopts the returned views as the parameters' all-gather outputs on their first all-gather, so later gathers are zero-copy. Otherwise FSDP copies the returned tensors into its own outputs. A new tensor-only `AllGatherInputFn`, set with `FSDPModule.set_all_gather_input_fn`, packs the collective input; it reworks #197500 without its `AllGatherInput` name, which #197204 now uses for payload records. From #188276 this ports `AllGather.release_output()` and its call sites, the output ownership flag, honoring the outputs' storage offset in the unsharded parameters, the version-counter guards, and holding the collective input until the copy-out. It drops the `AllGatherLayout` object model. > > A zero-copy backend is three separately installed pieces (comm, input function, output function) that agree on the layout through the backend's own state, and adopted storage stays allocated across reshard, as in #188276. On the default path, `_to_sharded` now discards a pending all-gather and `_unsharded_param` is always an attribute. Review the contracts and adoption in `_fsdp_collectives.py` first, then ownership and release in `_fsdp_param.py` and `_fsdp_param_group.py`, then the setters in `_fully_shard.py`. The tests port #188276's pure-PyTorch parameter-contiguous backend and its end-to-end parity tests onto the hooks. > > Test Plan (local build, 4 B200 GPUs): > ```bash > python test/test_public_bindings.py -k test_correct_module_names > python test/distributed/_composable/fsdp/test_fully_shard_comm.py -v > python test/distributed/_composable/fsdp/test_fully_shard_training.py -v -k test_train_parity_single_group -k test_inference -k test_train_parity_multi_group > python test/distributed/_composable/fsdp/test_fully_shard_extensions.py -v > python test/distributed/_composable/fsdp/test_fully_shard_mixed_precision.py -v -k test_reduce_dtype > ``` > All pass except `test_fully_shard_alloc_from_pg`, which fails the same way on the parent commit. ghstack-source-id: 68dc861 Pull-Request: #199720
Contributor
|
Looks like this PR hasn't been updated in a while so we're going to go ahead and mark this as |
This branch has not been deployed
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.
"add the input hook" as only refactor of existing logic. then integration with #188276 can be a follow up later