Repository navigation
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/200986
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (1 Unrelated Failure)As of commit 5e9fa90 with merge base 0e73fc6 ( 🟡 GREEN LIGHT - PR requires human review:
reason: BROKEN TRUNK - The following job failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This was referenced Oct 14, 2026
weifengpy
added a commit
that referenced
this pull request
Oct 15, 2026
> AI-assisted implementation and summary prepared with Claude Code, split out of #200034 at the author's request. > > A size-1 shard mesh, e.g. HSDP with one rank per shard group, and `replicate()` skip the all-gather and copy each parameter's all-gather inputs into its outputs directly. Since #160135 that copy has read only `all_gather_inputs[0]` into a single output, so the `fsdp_post_all_gather` of an all-gather extension with several payloads received only the first one, and extensions with zero payloads raised an `IndexError`. It now copies every payload: uint8 payloads bytewise into outputs of other dtypes, as the multi-rank path does, and payloads of an unchanged dtype that are smaller than on their first call into a prefix of their output. A non-uint8 payload whose dtype and size both change still fails in `copy_` (a one-element one is broadcast), as on main, and a payload count that differs from that of the first call with payloads raises an error. Copying bytes whenever the dtype changes would accept such payloads too, but would silently reinterpret values that main casts or rejects. The version-counter and inference-mode handling now applies to every output. > > Test Plan: > ```bash > python test/distributed/_composable/fsdp/test_fully_shard_comm.py -k TestFullyShardCollectiveCopies -k TestFullyShardCollectiveOps > python test/distributed/_composable/fsdp/test_fully_shard_extensions.py > python test/distributed/_composable/fsdp/test_fully_shard_training.py -k TestFullyShardWorldSize1 > python test/distributed/_composable/test_replicate_training.py > ``` > All pass on B200s. On main, `test_all_gather_extension_smaller_payload` fails with `ValueError: not enough values to unpack (expected 2, got 1)` because only the first payload gets an output, and `test_all_gather_extension_single_rank_no_payloads` fails with the `IndexError`. ghstack-source-id: 4937e13 Pull-Request: #200986
weifengpy
marked this pull request as ready for review
October 15, 2026 05:23
weifengpy
added a commit
that referenced
this pull request
Oct 15, 2026
## BC-breaking? > No, except on a size-1 shard mesh: a payload count that changes after the first call with payloads now raises, where main kept only the first payload, and a payload of an unchanged dtype that shrinks to one element fills one element of its output, where main broadcast it. ## Summary (human written only) <!-- Author: add your own summary line here before marking this PR ready for review --> ## Agent details (if applicable) > AI-assisted implementation and summary prepared with Claude Code, split out of #200034 at the author's request. > > A size-1 shard mesh, e.g. HSDP with one rank per shard group, and `replicate_with_fsdp.replicate()` skip the all-gather and copy each parameter's all-gather inputs into its outputs directly. Since #160135 that copy has read only `all_gather_inputs[0]` into a single output, so the `fsdp_post_all_gather` of an all-gather extension with several payloads received only the first one, and extensions with zero payloads raised an `IndexError`. It now copies every payload: uint8 payloads into all the bytes of outputs of other dtypes, as main already did for the first payload, and payloads of an unchanged dtype that are smaller than on their first call into a prefix of their output, where main raised in `copy_` or, for a one-element payload, broadcast it. A payload whose dtype and size both change still fails in `copy_`, as on main, unless it has one element, which is broadcast; for a uint8 payload smaller than its typed output, filling a byte prefix instead, as the multi-rank path does with a resize warning, would silently put fp8 bytes into the typed weight of ROCm TransformerEngine, which sends one after a first all-gather outside fp8 autocast. A payload count that differs from that of the first call with payloads raises an error. Copying bytes whenever the dtype changes would accept such payloads too, but would silently reinterpret values that main casts or rejects. The version-counter and inference-mode handling now applies to every output. > > Test Plan: > ```bash > python test/distributed/_composable/fsdp/test_fully_shard_comm.py -k TestFullyShardCollectiveCopies -k TestFullyShardCollectiveOps > python test/distributed/_composable/fsdp/test_fully_shard_extensions.py > python test/distributed/_composable/fsdp/test_fully_shard_training.py -k TestFullyShardWorldSize1 > python test/distributed/_composable/test_replicate_training.py > ``` > All pass on B200s. On main, `test_all_gather_extension_smaller_payload` fails with `ValueError: not enough values to unpack (expected 2, got 1)` because only the first payload gets an output, and `test_all_gather_extension_single_rank_no_payloads` fails with the `IndexError`. ghstack-source-id: 5218685 Pull-Request: #200986
weifengpy
added a commit
that referenced
this pull request
Oct 15, 2026
## BC-breaking? > No, except on a size-1 shard mesh, where main copied only the first payload: a payload count that changes after the first call with payloads, or a later payload that grows or changes both dtype and size, now raises, and a payload of an unchanged dtype that shrinks to one element fills one element of its output, where main broadcast or dropped it. ## Summary (human written only) <!-- Author: add your own summary line here before marking this PR ready for review --> ## Agent details (if applicable) > AI-assisted implementation and summary prepared with Claude Code, split out of #200034 at the author's request. > > A size-1 shard mesh, e.g. HSDP with one rank per shard group, and `replicate_with_fsdp.replicate()` skip the all-gather and copy each parameter's all-gather inputs into its outputs directly. Since #160135 that copy has read only `all_gather_inputs[0]` into a single output, so the `fsdp_post_all_gather` of an all-gather extension with several payloads received only the first one, and extensions with zero payloads raised an `IndexError`. It now copies every payload: uint8 payloads into all the bytes of outputs of other dtypes, as main already did for the first payload, and payloads of an unchanged dtype that are smaller than on their first call into a prefix of their output, where main raised in `copy_` or, for a one-element payload, broadcast it. A non-uint8 payload whose dtype and size both change, or a uint8 payload smaller than its typed output, still fails in `copy_`, as on main, unless it has one element, which is broadcast; filling a byte prefix for the latter, as the multi-rank path does with a resize warning, would silently put fp8 bytes into the typed weight of ROCm TransformerEngine, which sends one after a first all-gather outside fp8 autocast. Copying bytes whenever the dtype changes would accept such payloads too, but would silently reinterpret values that main casts or rejects. A payload count that differs from that of the first call with payloads raises an error. The version-counter and inference-mode handling now applies to every output. > > Test Plan: > ```bash > python test/distributed/_composable/fsdp/test_fully_shard_comm.py -k TestFullyShardCollectiveCopies -k TestFullyShardCollectiveOps > python test/distributed/_composable/fsdp/test_fully_shard_extensions.py > python test/distributed/_composable/fsdp/test_fully_shard_training.py -k TestFullyShardWorldSize1 > python test/distributed/_composable/test_replicate_training.py > ``` > All pass on B200s. On main, `test_all_gather_extension_smaller_payload` fails with `ValueError: not enough values to unpack (expected 2, got 1)` because only the first payload gets an output, and `test_all_gather_extension_single_rank_no_payloads` fails with the `IndexError`. ghstack-source-id: 5218685 Pull-Request: #200986
weifengpy
added a commit
that referenced
this pull request
Oct 15, 2026
## BC-breaking? > No, except on a size-1 shard mesh, where main copied only the first payload: a payload count that changes after the first call with payloads, or a later payload that grows or fails in `copy_` as described below, now raises, and a payload of an unchanged dtype that shrinks to one element fills one element of its output, where main broadcast or dropped it. ## Summary (human written only) <!-- Author: add your own summary line here before marking this PR ready for review --> ## Agent details (if applicable) > AI-assisted implementation and summary prepared with Claude Code, split out of #200034 at the author's request. > > A size-1 shard mesh, e.g. HSDP with one rank per shard group, and `replicate_with_fsdp.replicate()` skip the all-gather and copy each parameter's all-gather inputs into its outputs directly. Since #160135 that copy has read only `all_gather_inputs[0]` into a single output, so the `fsdp_post_all_gather` of an all-gather extension with several payloads received only the first one, and extensions with zero payloads raised an `IndexError`. It now copies every payload: uint8 payloads into all the bytes of outputs of other dtypes, as main already did for the first payload, and payloads of an unchanged dtype that are smaller than on their first call into a prefix of their output, where main raised in `copy_` or, for a one-element payload, broadcast it. A non-uint8 payload whose dtype and size both change, or a uint8 payload smaller than its typed output, still fails in `copy_`, as on main, unless it has one element, which is broadcast; filling a byte prefix for the latter, as the multi-rank path does with a resize warning, would silently put fp8 bytes into the typed weight of ROCm TransformerEngine, which sends one after a first all-gather outside fp8 autocast. Copying bytes whenever the dtype changes would accept such payloads too, but would silently reinterpret values that main casts or rejects. A payload count that differs from that of the first call with payloads raises an error. The version-counter and inference-mode handling now applies to every output. > > Test Plan: > ```bash > python test/distributed/_composable/fsdp/test_fully_shard_comm.py -k TestFullyShardCollectiveCopies -k TestFullyShardCollectiveOps > python test/distributed/_composable/fsdp/test_fully_shard_extensions.py > python test/distributed/_composable/fsdp/test_fully_shard_training.py -k TestFullyShardWorldSize1 > python test/distributed/_composable/test_replicate_training.py > ``` > All pass on B200s. On main, `test_all_gather_extension_smaller_payload` fails with `ValueError: not enough values to unpack (expected 2, got 1)` because only the first payload gets an output, and `test_all_gather_extension_single_rank_no_payloads` fails with the `IndexError`. ghstack-source-id: 5218685 Pull-Request: #200986
anshul-si
approved these changes
Oct 16, 2026
Contributor
Author
|
@pytorchmergebot merge |
Collaborator
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
pytorchmergebot
pushed a commit
that referenced
this pull request
Oct 20, 2026
Keep the original AG/RS preparation and copying as defaults. > AI-assisted implementation and summary prepared with Codex and Claude Code for the requested change above. > > FSDP now prepares each collective copy separately from executing it, so the next PR can register native copies. To review, start with `Note [All-gather output fn]` and `Note [Reduce-scatter input fn]` in `_fsdp_collectives.py` and `AllGatherInput` in `_fsdp_api.py`, then read `_AllGatherOutputLayout`, `_get_extension_all_gather_inputs` and `_get_all_gather_output_layouts` in `_fsdp_param.py`, then `foreach_all_gather_copy_out` and `foreach_reduce` in `_fsdp_collectives.py`, then the tests. > > For the all-gather, every parameter records a layout per payload: the size that `fsdp_post_all_gather` receives the output viewed as, and the number of rows over which the copy-out concatenates the ranks' chunks. That number is the product of the dims before the gather dim, the padded sharded parameter's for Tensor payloads, or 1 when a flat copy suffices, as for a single rank, an empty payload or a post-forward shard. `foreach_all_gather_copy_out` reads those layouts, allocates the outputs, and calls an all-gather output fn with plain tensors and sizes. For the reduce-scatter, `foreach_reduce` sizes the buffer from the padded sharded parameter sizes and calls a reduce-scatter input fn that returns the copy-in to run once the buffer is allocated. The two Notes document both contracts, and the callbacks stay plain `Callable`s so their signatures can still change. 2.15 ships the private hooks that #197372 added with their earlier signatures. The callbacks keep those hooks' names, and FSDP passes their sizes and world size by keyword, so a callback written for the earlier signatures fails loudly rather than being ignored or misreading its arguments. The default callbacks keep the original split, rank reassembly and chunk-cat copies, and reassemble typed tensors also when the all-gather buffer holds bytes. > > The two PRs below fix resharding to a smaller mesh after forward and make a size-1 shard mesh copy every extension payload, smaller ones of an unchanged dtype into a prefix. Here, post-forward shards get a flat layout, which replaces the flat copy that the post-forward fix adds to main's copy-out. > > `fsdp_pre_all_gather` may now return `AllGatherInput` records that declare each payload's concatenation dim, independent of the parameter's shard dim. This PR keeps them in the private `_fsdp_api` module, and #197701 exports them from `torch.distributed.fsdp.experimental`. Their `dim` is required, since a default would silently gather differently from a plain tensor of a Shard(i>0) parameter, and may be any integer except a tensor. Their number, element counts and dtypes must stay fixed across calls so FSDP can reuse their outputs. Tensor payloads are still flattened with `view(-1)` and passed viewed as `(-1, *size[1:])`, and may become uint8 byte views of their whole outputs or, for parameters with a single row, i.e. whose dims before the shard dim multiply to 1, such as Shard(0) ones, shrink after their first call, keeping nonzero trailing dims, and fill a prefix of their output. Those of other Shard(i>0) parameters are read as rows of the padded sharded parameter: with more than one shard rank, main required its element count, and they may now instead keep only its dims before the shard dim, e.g. packed uint8 rows or byte views from the first call, or be empty. FSDP checks the payloads before the collective and caches the result for up to four combinations of their kinds, dims, sizes and dtypes, so payloads that alternate between shapes, like MXFP8 tensors that send rowwise data in forward and columnwise data in backward, are not checked again on every all-gather. > > Alternatives: FSDP doesn't detect payloads that move the shard dim to dim 0, as torchtitan's quantized tensors do, since a shape-based check would also reject reshapes that keep the rows, which main accepts; those payloads still come back permuted, as on main, until they return `AllGatherInput(dim=0)`. Shard(i>0) Tensor payloads that keep only the leading dims are accepted rather than rejected because they are copied correctly and get the `(-1, *size[1:])` view that main gives every Shard(i>0) Tensor payload. The copy-out checks each output's element count instead of catching the error of a mismatched view, which costs about 0.1 us per output but saves about 13 us per output of a shrunk payload. The layout cache empties when it fills, which bounds it for payloads whose sizes keep changing. > > On CPU, measured with an out-of-tree A/B harness over 1000 to 3000 parameters, a Shard(0) copy-out costs about 0.15 to 0.3 us more per parameter than on main, also when the all-gather buffer holds bytes, while a Shard(1) copy-out costs about 5 to 8 us less, and the reduce-scatter about 1 to 1.5 us less. At 1000 parameters, extension inputs cost about 0.15 us more per parameter and all-gather with one payload and about 0.25 to 0.5 us with two, also when they alternate between shapes, but about 10 to 25 us more with the garbage collector on (5 to 9 us with it off) when their sizes change on every call or alternate among more than four combinations, which FSDP then checks again. > > Release notes: the private `FSDPParamGroup._all_gather_output_fn` and `_prepare_reduce_scatter_inputs` callbacks take new signatures, and callbacks written for 2.15's raise a `TypeError`. Extension payloads that FSDP cannot copy now raise a `ValueError` that names the parameter before the collective: > - a changed payload count, for which main raised a `RuntimeError` after the collective, or, on a size-1 shard mesh, an unnamed `ValueError` from `zip`; > - a payload larger than on its first call, which main copied as wrong data with an out= resize warning, or, on a size-1 shard mesh, failed on in `copy_`; > - a dtype change other than to uint8, for which main raised a `RuntimeError` after the collective in a uniform-dtype group, copied the bytes, wrongly if they grew or, for Shard(i>0) parameters with several rows, shrank, when the group gathered bytes, or, on a size-1 shard mesh, cast silently if its element count was unchanged, broadcast it if it had one element, and otherwise failed in `copy_`; > - a uint8 payload smaller than its typed output, which main copied into a prefix of the output's bytes, or reassembled with ranks mixed up for Shard(i>0) parameters with several rows, with an out= resize warning, or, on a size-1 shard mesh, failed on in `copy_`; ROCm TransformerEngine sends one after a first all-gather outside fp8 autocast, and then computed with fp8 bytes in a typed weight; > - Tensor payloads whose trailing dims cannot view their output, which main failed on, and, with more than one shard rank, nonempty Tensor payloads of Shard(i>0) parameters with several rows that are not uint8 payloads of typed outputs and have neither the padded sharded element count nor its dims before the shard dim, which main failed on after the collective on a first call and, on later calls, treated like the size and dtype changes above and below; > - Tensor payloads that shrink of Shard(i>0) parameters with several rows, which main reassembled with ranks mixed up, or, on a size-1 shard mesh, copied into a prefix of their output. > > Three of these break cases that main handled. When the group gathered bytes, main copied a payload whose dtype changed byte for byte if its bytes stayed the same, e.g. fp8 e4m3 to e5m2 next to fp32 scales or a typed payload after a byte view, and, for parameters with a single row, into a prefix with a resize warning if they shrank. Returning uint8 byte views of the whole outputs keeps those whose bytes stay the same working. On a size-1 shard mesh, main also cast a payload whose dtype changed to one other than uint8, but not its element count, into the first call's dtype, exactly when representable, and copied shrinking Tensor payloads of Shard(i>0) parameters with several rows into a prefix, which FSDP now rejects on every mesh since more shard ranks would mix up their rows. The padded-size check for unevenly sharded parameters now raises a `ValueError` instead of an `AssertionError`, and also runs on ranks without padding, so payloads that lack the padded size everywhere, e.g. flattened ones, fail on every rank. An extension that returns its unpadded local shard still passes on ranks whose shard needs no padding, which then hang, as before. > > Fixed: payloads with a zero-size trailing dim, which failed in `view(-1, 0)` (since #122908) or, for Shard(i>0) parameters with more than one shard rank, in the rank reassembly, and now get an explicit leading size; Tensor payloads that shrink, of Shard(0) parameters and of Shard(i>0) ones with a single row, which main resized with a deprecation warning; and, with more than one shard rank, Tensor payloads of the latter without the padded sharded element count on their first call, which main failed on after the collective and which are now copied flat. > > Test Plan: > ```bash > python test/distributed/_composable/fsdp/test_fully_shard_extensions.py > python test/distributed/_composable/fsdp/test_fully_shard_comm.py -k TestFullyShardCollectiveOps -k TestFullyShardCollectiveCopies -k TestFullyShardDefaultAllGatherOutputFn > python test/distributed/_composable/fsdp/test_fully_shard_memory.py -k test_unsharded_grads_freed_after_copy_in > python test/distributed/_composable/fsdp/test_fully_shard_mixed_precision.py -k test_reduce_dtype -k test_grad_dtype -k test_compute_dtype > python test/distributed/_composable/fsdp/test_fully_shard_training.py -k test_train_parity_single_group -k test_inference -k test_share_comm_context > python test/distributed/_composable/fsdp/test_fully_shard_state_dict.py -k test_dp_state_dict_save_load > ``` > All pass on B200s. Before this PR, `test_all_gather_extension_shard_dim1_byte_views` fails for byte views from the first call, and `test_all_gather_extension_smaller_payload` and `test_all_gather_extension_uneven_sharding` fail because the errors they expect are new. > > Each new check also fails when the code it covers is removed or broken, as checked with mutants: the prefix slice, the skip of empty all-gathers, the layout cache's key and bound, `del copy_in`, the keyword-only sizes, the payload and dim checks, the rows rule's restriction to several ranks and rows, the `replicate()` mesh guard, the flat post-forward layout, the empty layouts of an extension without payloads and the restriction of byte buffers to uint8. Pull Request resolved: #200034 Approved by: https://github.com/anshul-si ghstack dependencies: #200985, #200986
pytorchmergebot
pushed a commit
that referenced
this pull request
Oct 20, 2026
## BC-breaking? > No: adds an experimental setter and module; FSDP's default copies are unchanged. ## Summary (human written only) better perf for Shard(1)/Shard(2) to unblock torchtitan EFSDP sharding ## Agent details (if applicable) > AI-assisted implementation and summary prepared with Codex and Claude Code. > > Add an `FSDPModule.set_reduce_scatter_input_fn` setter, and call the native all-gather copy-out (`fsdp::_all_gather_copy_out_`, #197204) and reduce-scatter copy-in (`fsdp::chunk_cat_mixed_dtype` with `num_leading_dims`, #200179) through `torch.distributed.fsdp.experimental`, which exports `AllGatherInput`, `all_gather_output_fn_with_native_copy` and `reduce_scatter_input_fn_with_native_copy`. The original intermediate copies remain the defaults. The all-gather copy-out has no setter here: #199726 installs it through `set_all_gather_layout` as `DefaultAllGatherLayout(all_gather_output_fn_with_native_copy)`; until then, the tests here install it through the private `FSDPParamGroup._all_gather_output_fn` hook. > > The all-gather op copies within one dtype, so its callback copies mixed-dtype groups as bytes, and it requires exact output sizes, so the callback uses the default copy-out for groups with a Tensor payload smaller than its cached output. The reduce-scatter copy-in takes mixed gradient dtypes, such as a deferred bf16 Shard(1) weight gradient next to an fp32 norm gradient, so it needs no dtype fallback; noncontiguous gradients sharded on a nonzero dim still use the chunk-and-concatenate reorder. > > Native copying writes contiguous tensors without intermediate buffers and benefits wide CUDA tensors with small outer_size, such as Shard(1) over [2,F,D]. Its CPU time, GPU time and metadata memory grow with a group's total outer size, and strided collective buffers take a slower path, so the documentation recommends benchmarking the target workload. > > Test Plan: > ```bash > python test/distributed/_composable/fsdp/test_fully_shard_comm.py -k test_strided_allocation -k test_reduce_scatter_input_fn_setter -k TestFullyShardNativeReduceScatterInputFn > python test/distributed/_composable/fsdp/test_fully_shard_extensions.py -k test_all_gather_input_layouts -k test_all_gather_extension_smaller_payload > python test/distributed/_composable/fsdp/test_fully_shard_mixed_precision.py -k test_reduce_dtype -k test_native_copy_in_mixed_grad_dtypes > python test/distributed/_composable/fsdp/test_fully_shard_training.py -k test_train_parity_single_group -k test_inference > python test/test_public_bindings.py -k test_correct_module_names > ``` > All pass on this revision. `test_native_copy_in_mixed_grad_dtypes` fails if the callback falls back to the default copy-in for mixed gradient dtypes, `test_strided_allocation` if a copy reorders its input, `test_reduce_scatter_input_fn_setter` if the setter ignores `recurse` or `None`, `test_all_gather_input_layouts` if the native all-gather copy falls back to the default one, and `test_all_gather_extension_smaller_payload` if it has no fallback for smaller payloads. > > Measured on one B200 with world-size-8 layouts (copies only, native time / default time): a [2, 8192, 4096] Shard(1) group copies out in 0.53x GPU and 0.41x CPU time and copies in in 0.38 to 0.45x GPU and 0.67 to 0.70x CPU time; Shard(1) experts [2/8, 1408, 2048] x3 copy out in 0.36 to 0.51x GPU time; native copies of contiguous tensors also skip the intermediate buffers, lowering a Shard(1)/Shard(2) group's peak memory by about 24 to 830 MB. Groups with many rows before the shard dim are slower: Shard(2) experts copy out in 1.7 to 1.8x GPU time and up to 5.6x CPU time, and a Llama-8B block's Shard(1) parameters (outer size 43010) copy out in 0.74 to 0.78x GPU but 3.2 to 4.4x CPU time, which is why the documentation recommends benchmarking. Pull Request resolved: #197701 Approved by: https://github.com/anshul-si ghstack dependencies: #200985, #200986, #200034
majing921201
pushed a commit
to majing921201/pytorch
that referenced
this pull request
Nov 16, 2026
pytorch#200986) ## BC-breaking? > No, except on a size-1 shard mesh, where main copied only the first payload: a payload count that changes after the first call with payloads, or a later payload that grows or fails in `copy_` as described below, now raises, and a payload of an unchanged dtype that shrinks to one element fills one element of its output, where main broadcast or dropped it. ## Summary (human written only) <!-- Author: add your own summary line here before marking this PR ready for review --> ## Agent details (if applicable) > AI-assisted implementation and summary prepared with Claude Code, split out of pytorch#200034 at the author's request. > > A size-1 shard mesh, e.g. HSDP with one rank per shard group, and `replicate_with_fsdp.replicate()` skip the all-gather and copy each parameter's all-gather inputs into its outputs directly. Since pytorch#160135 that copy has read only `all_gather_inputs[0]` into a single output, so the `fsdp_post_all_gather` of an all-gather extension with several payloads received only the first one, and extensions with zero payloads raised an `IndexError`. It now copies every payload: uint8 payloads into all the bytes of outputs of other dtypes, as main already did for the first payload, and payloads of an unchanged dtype that are smaller than on their first call into a prefix of their output, where main raised in `copy_` or, for a one-element payload, broadcast it. A non-uint8 payload whose dtype and size both change, or a uint8 payload smaller than its typed output, still fails in `copy_`, as on main, unless it has one element, which is broadcast; filling a byte prefix for the latter, as the multi-rank path does with a resize warning, would silently put fp8 bytes into the typed weight of ROCm TransformerEngine, which sends one after a first all-gather outside fp8 autocast. Copying bytes whenever the dtype changes would accept such payloads too, but would silently reinterpret values that main casts or rejects. A payload count that differs from that of the first call with payloads raises an error. The version-counter and inference-mode handling now applies to every output. > > Test Plan: > ```bash > python test/distributed/_composable/fsdp/test_fully_shard_comm.py -k TestFullyShardCollectiveCopies -k TestFullyShardCollectiveOps > python test/distributed/_composable/fsdp/test_fully_shard_extensions.py > python test/distributed/_composable/fsdp/test_fully_shard_training.py -k TestFullyShardWorldSize1 > python test/distributed/_composable/test_replicate_training.py > ``` > All pass on B200s. On main, `test_all_gather_extension_smaller_payload` fails with `ValueError: not enough values to unpack (expected 2, got 1)` because only the first payload gets an output, and `test_all_gather_extension_single_rank_no_payloads` fails with the `IndexError`. Pull Request resolved: pytorch#200986 Approved by: https://github.com/anshul-si ghstack dependencies: pytorch#200985
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.
Stack from ghstack (oldest at bottom):
BC-breaking?
Summary (human written only)
Agent details (if applicable)