Repository navigation
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/199234
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New FailureAs of commit 4a7e02e with merge base 381cc3e ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This was referenced Oct 1, 2026
weifengpy
added a commit
that referenced
this pull request
Oct 1, 2026
This PR was authored with an AI assistant (Claude Code). The description below is AI-generated and is pending author review.
> `shard_placement_fn` can now return `BlockShard`, e.g.
> `BlockShard.split_leading(param.shape, 2)` for MoE expert weights
> `[E, O, I]` with fewer (local) experts than FSDP ranks. Today such weights
> either pad (`Shard(0)` leaves ranks empty) or use `Shard(1)`, which needs
> `O % W == 0` and copies on every all-gather (chunk-cat reassembly) and
> reduce-scatter (gradient reordering).
>
> Inside `FSDPParam`, a `BlockShard` parameter is handled as `Shard(0)` on its
> merged view `(prod(shape[:k]), *shape[k:])`: chunking, padding, and the
> sharded/padded sizes use the merged view, and the internal `fsdp_placement`
> is `Shard(0)`, so all-gather and reduce-scatter take the existing dim-0 path
> with no reordering copies. Only the DTensor wrapper (sharded param, sharded
> grad, and the post-forward reshard) carries `BlockShard`. The one place that
> needs the merged view explicitly is reduce-scatter padding:
> `_default_reduce_scatter_input_fn` views each `BlockShard` gradient as the
> merged shape before padding sizes are computed, since padding dim 0 of
> `[E, O, I]` would pad whole experts instead of merged rows.
>
> Expert-parallel parameters are supported too, as torchtitan lays them out:
> `(R, Shard(0))` DTensors on a full `(efsdp, ep)` mesh with
> `dp_mesh_dims=DataParallelMeshDims(shard="efsdp")` (spmd-mesh path), or EP
> DTensors on a separate mesh (TP/EP path). FSDP chunks the merged rows of the
> local experts and writes `BlockShard` on the DP shard dim instead of
> `_StridedShard`, giving `(BlockShard, Shard(0))`; `BlockShard` applies after
> the `Shard(0)` by definition. The final sharded spec is validated, so
> unsupported compositions (e.g. TP `Shard(1)`, several DP shard dims, DDP)
> raise `NotImplementedError`, as do spmd_types params and tensor subclasses
> with FSDP extensions.
>
> Test Plan
>
> ```
> python test/distributed/_composable/fsdp/test_fully_shard_block_shard.py
> python test/distributed/_composable/fsdp/test_fully_shard_dtensor.py
> python test/distributed/_composable/fsdp/test_fully_shard_init.py
> NCCL_NVLS_ENABLE=0 python test/distributed/_composable/fsdp/test_fully_shard_training.py TestFullyShardShardPlacementFnMultiProcess TestFullyShardShardPlacementFnMultiThread TestFullyShard1DTrainingCore
> ```
>
> The 1D tests use 3 experts over 4 ranks, so merged rows cross expert
> boundaries and the last rank is short: init, meta-device init
> (`trunc_normal_` after `fully_shard`), training parity (AdamW `foreach=True`
> and `clip_grad_norm_`) for `reshard_after_forward` in `{True, False, 2}` and
> HSDP, no reassembly copies, and state dict / DCP / full-state-dict broadcast
> round trips. The expert-parallel tests build torchtitan's layout on a
> `(efsdp, ep)` mesh with 3 local experts per EP rank and check init, training
> parity, and checkpointing. Removing the merged-view reshape in
> `_default_reduce_scatter_input_fn` makes the parity tests fail. The EP tests
> reuse one mesh per process: on this base commit, a second `fully_shard` with
> a new but equal spmd mesh in the same process raises "Expected param's
> DTensor mesh to be the same mesh passed to fully_shard", with or without
> `BlockShard`. (`NCCL_NVLS_ENABLE=0` avoids an unrelated NVLS "NCCL split
> failed" error on the 8-GPU test host.)
ghstack-source-id: e84c2c4
Pull-Request: #199234
Contributor
Author
|
cc @thomasw21 |
weifengpy
added a commit
that referenced
this pull request
Oct 6, 2026
This PR was authored with an AI assistant (Claude Code). The description below is AI-generated and is pending author review. > `shard_placement_fn` can now return `BlockShard`, e.g. > `BlockShard.split_leading(param.shape, 2)` for MoE expert weights > `[E, O, I]` with fewer (local) experts than FSDP ranks. Today such weights > either pad (`Shard(0)` leaves ranks empty) or use `Shard(1)`, which needs > `O % W == 0` and copies on every all-gather (chunk-cat reassembly) and > reduce-scatter (gradient reordering). > > Inside `FSDPParam`, a `BlockShard` parameter is handled as `Shard(0)` on its > merged view `(prod(shape[:k]), *shape[k:])`: chunking, padding, and the > sharded/padded sizes use the merged view, and the internal `fsdp_placement` > is `Shard(0)`, so all-gather and reduce-scatter take the existing dim-0 path > with no reordering copies. Only the DTensor wrapper (sharded param, sharded > grad, and the post-forward reshard) carries `BlockShard`. The one place that > needs the merged view explicitly is reduce-scatter padding: `foreach_reduce` > views each `BlockShard` gradient as the merged shape before calling the > reduce-scatter input function, since padding dim 0 of `[E, O, I]` would pad > whole experts instead of merged rows. The input function only receives shard > dims (#197204), so viewing the gradient first also covers #197701's native > copy-in and any function installed with `set_reduce_scatter_input_fn`. > > Expert-parallel parameters are supported too, as torchtitan lays them out: > `(R, Shard(0))` DTensors on a full `(efsdp, ep)` mesh with > `dp_mesh_dims=DataParallelMeshDims(shard="efsdp")` (spmd-mesh path), or EP > DTensors on a separate mesh (TP/EP path). FSDP chunks the merged rows of the > local experts and writes `BlockShard` on the DP shard dim instead of > `_StridedShard`, giving `(BlockShard, Shard(0))`; `BlockShard` applies after > the `Shard(0)` by definition. The final sharded spec is validated, so > unsupported compositions (e.g. TP `Shard(1)`, several DP shard dims, DDP) > raise `NotImplementedError`, as do spmd_types params and tensor subclasses > with FSDP extensions. > > Test Plan > > ``` > python test/distributed/_composable/fsdp/test_fully_shard_block_shard.py > python test/distributed/_composable/fsdp/test_fully_shard_dtensor.py > python test/distributed/_composable/fsdp/test_fully_shard_init.py > NCCL_NVLS_ENABLE=0 python test/distributed/_composable/fsdp/test_fully_shard_training.py TestFullyShardShardPlacementFnMultiProcess TestFullyShardShardPlacementFnMultiThread TestFullyShard1DTrainingCore > ``` > > The 1D tests use 3 experts over 4 ranks, so merged rows cross expert > boundaries and the last rank is short: init, meta-device init > (`trunc_normal_` after `fully_shard`), training parity (AdamW `foreach=True` > and `clip_grad_norm_`) for `reshard_after_forward` in `{True, False, 2}` and > HSDP, no reordering copies, and state dict / DCP / full-state-dict broadcast > round trips. The expert-parallel tests build torchtitan's layout on a > `(efsdp, ep)` mesh with 3 local experts per EP rank and check init, training > parity, and checkpointing. Removing the merged-view reshape in > `foreach_reduce` makes the parity tests fail. The EP tests > reuse one mesh per process: on this base commit, a second `fully_shard` with > a new but equal spmd mesh in the same process raises "Expected param's > DTensor mesh to be the same mesh passed to fully_shard", with or without > `BlockShard`. (`NCCL_NVLS_ENABLE=0` avoids an unrelated NVLS "NCCL split > failed" error on the 8-GPU test host.) ghstack-source-id: 8f85fc5 Pull-Request: #199234
weifengpy
added a commit
that referenced
this pull request
Oct 6, 2026
This PR was authored with an AI assistant (Claude Code). The description below is AI-generated and is pending author review. > `shard_placement_fn` can now return `BlockShard`, e.g. > `BlockShard.split_leading(param.shape, 2)` for MoE expert weights > `[E, O, I]` with fewer (local) experts than FSDP ranks. Today such weights > either pad (`Shard(0)` leaves ranks empty) or use `Shard(1)`, which needs > `O % W == 0` and copies on every all-gather (chunk-cat reassembly) and > reduce-scatter (gradient reordering). > > Inside `FSDPParam`, a `BlockShard` parameter is handled as `Shard(0)` on its > merged view `(prod(shape[:k]), *shape[k:])`: chunking, padding, and the > sharded/padded sizes use the merged view, and the internal `fsdp_placement` > is `Shard(0)`, so all-gather and reduce-scatter take the existing dim-0 path > with no reordering copies. Only the DTensor wrapper (sharded param, sharded > grad, and the post-forward reshard) carries `BlockShard`. The one place that > needs the merged view explicitly is reduce-scatter padding: `foreach_reduce` > views each `BlockShard` gradient as the merged shape before calling the > reduce-scatter input function, since padding dim 0 of `[E, O, I]` would pad > whole experts instead of merged rows. The input function only receives shard > dims (#197204), so viewing the gradient first also covers #197701's native > copy-in and any function installed with `set_reduce_scatter_input_fn`. > > Expert-parallel parameters are supported too, as torchtitan lays them out: > `(R, Shard(0))` DTensors on a full `(efsdp, ep)` mesh with > `dp_mesh_dims=DataParallelMeshDims(shard="efsdp")` (spmd-mesh path), or EP > DTensors on a separate mesh (TP/EP path). FSDP chunks the merged rows of the > local experts and writes `BlockShard` on the DP shard dim instead of > `_StridedShard`, giving `(BlockShard, Shard(0))`; `BlockShard` applies after > the `Shard(0)` by definition. The final sharded spec is validated, so > unsupported compositions (e.g. TP `Shard(1)`, several DP shard dims, DDP) > raise `NotImplementedError`, as do spmd_types params and tensor subclasses > with FSDP extensions. > > Test Plan > > ``` > python test/distributed/_composable/fsdp/test_fully_shard_block_shard.py > python test/distributed/_composable/fsdp/test_fully_shard_dtensor.py > python test/distributed/_composable/fsdp/test_fully_shard_init.py > NCCL_NVLS_ENABLE=0 python test/distributed/_composable/fsdp/test_fully_shard_training.py TestFullyShardShardPlacementFnMultiProcess TestFullyShardShardPlacementFnMultiThread TestFullyShard1DTrainingCore > ``` > > The 1D tests use 3 experts over 4 ranks, so merged rows cross expert > boundaries and the last rank is short: init, meta-device init > (`trunc_normal_` after `fully_shard`), training parity (AdamW `foreach=True` > and `clip_grad_norm_`) for `reshard_after_forward` in `{True, False, 2}` and > HSDP, no reordering copies, and state dict / DCP / full-state-dict broadcast > round trips. The expert-parallel tests build torchtitan's layout on a > `(efsdp, ep)` mesh with 3 local experts per EP rank and check init, training > parity, and checkpointing. Removing the merged-view reshape in > `foreach_reduce` makes the parity tests fail. The EP tests > reuse one mesh per process: on this base commit, a second `fully_shard` with > a new but equal spmd mesh in the same process raises "Expected param's > DTensor mesh to be the same mesh passed to fully_shard", with or without > `BlockShard`. (`NCCL_NVLS_ENABLE=0` avoids an unrelated NVLS "NCCL split > failed" error on the 8-GPU test host.) ghstack-source-id: f744e93 Pull-Request: #199234
weifengpy
added a commit
that referenced
this pull request
Oct 6, 2026
This PR was authored with an AI assistant (Claude Code). The description below is AI-generated and is pending author review. > `shard_placement_fn` can now return `BlockShard`, e.g. > `BlockShard.split_leading(param.shape, 2)` for MoE expert weights > `[E, O, I]` with fewer (local) experts than FSDP ranks. Today such weights > either pad (`Shard(0)` leaves ranks empty) or use `Shard(1)`, which needs > `O % W == 0` and copies on every all-gather (chunk-cat reassembly) and > reduce-scatter (gradient reordering). > > Inside `FSDPParam`, a `BlockShard` parameter is handled as `Shard(0)` on its > merged view `(prod(shape[:k]), *shape[k:])`: chunking, padding, and the > sharded/padded sizes use the merged view, and the internal `fsdp_placement` > is `Shard(0)`, so all-gather and reduce-scatter take the existing dim-0 path > with no reordering copies. Only the DTensor wrapper (sharded param, sharded > grad, and the post-forward reshard) carries `BlockShard`. The one place that > needs the merged view explicitly is reduce-scatter padding: `foreach_reduce` > views each `BlockShard` gradient as the merged shape before calling the > reduce-scatter input function, since padding dim 0 of `[E, O, I]` would pad > whole experts instead of merged rows. The input function only receives shard > dims (#197204), so viewing the gradient first also covers #197701's native > copy-in and any function installed with `set_reduce_scatter_input_fn`. > > Expert-parallel parameters are supported too, as torchtitan lays them out: > `(R, Shard(0))` DTensors on a full `(efsdp, ep)` mesh with > `dp_mesh_dims=DataParallelMeshDims(shard="efsdp")` (spmd-mesh path), or EP > DTensors on a separate mesh (TP/EP path). FSDP chunks the merged rows of the > local experts and writes `BlockShard` on the DP shard dim instead of > `_StridedShard`, giving `(BlockShard, Shard(0))`; `BlockShard` applies after > the `Shard(0)` by definition. The final sharded spec is validated, so > unsupported compositions (e.g. TP `Shard(1)`, several DP shard dims, DDP) > raise `NotImplementedError`, as do spmd_types params and tensor subclasses > with FSDP extensions. > > Test Plan > > ``` > python test/distributed/_composable/fsdp/test_fully_shard_block_shard.py > python test/distributed/_composable/fsdp/test_fully_shard_dtensor.py > python test/distributed/_composable/fsdp/test_fully_shard_init.py > NCCL_NVLS_ENABLE=0 python test/distributed/_composable/fsdp/test_fully_shard_training.py TestFullyShardShardPlacementFnMultiProcess TestFullyShardShardPlacementFnMultiThread TestFullyShard1DTrainingCore > ``` > > The 1D tests use 3 experts over 4 ranks, so merged rows cross expert > boundaries and the last rank is short: init, meta-device init > (`trunc_normal_` after `fully_shard`), training parity (AdamW `foreach=True` > and `clip_grad_norm_`) for `reshard_after_forward` in `{True, False, 2}` and > HSDP, no reordering copies, and state dict / DCP / full-state-dict broadcast > round trips. The expert-parallel tests build torchtitan's layout on a > `(efsdp, ep)` mesh with 3 local experts per EP rank and check init, training > parity, and checkpointing. Removing the merged-view reshape in > `foreach_reduce` makes the parity tests fail. The EP tests > reuse one mesh per process: on this base commit, a second `fully_shard` with > a new but equal spmd mesh in the same process raises "Expected param's > DTensor mesh to be the same mesh passed to fully_shard", with or without > `BlockShard`. (`NCCL_NVLS_ENABLE=0` avoids an unrelated NVLS "NCCL split > failed" error on the 8-GPU test host.) ghstack-source-id: f744e93 Pull-Request: #199234
weifengpy
added a commit
that referenced
this pull request
Oct 7, 2026
This PR was authored with an AI assistant (Claude Code). The description below is AI-generated and is pending author review. > `shard_placement_fn` can now return `BlockShard`, e.g. > `BlockShard.split_leading(param.shape, 2)` for MoE expert weights > `[E, O, I]` with fewer (local) experts than FSDP ranks. Today such weights > either pad (`Shard(0)` leaves ranks empty) or use `Shard(1)`, which needs > `O % W == 0` and copies on every all-gather (chunk-cat reassembly) and > reduce-scatter (gradient reordering). > > Inside `FSDPParam`, a `BlockShard` parameter is handled as `Shard(0)` on its > merged view `(prod(shape[:k]), *shape[k:])`: chunking, padding, and the > sharded/padded sizes use the merged view, and the internal `fsdp_placement` > is `Shard(0)`, so all-gather and reduce-scatter take the existing dim-0 path > with no reordering copies. Only the DTensor wrapper (sharded param, sharded > grad, and the post-forward reshard) carries `BlockShard`. The one place that > needs the merged view explicitly is reduce-scatter padding: `foreach_reduce` > views each `BlockShard` gradient as the merged shape before calling the > reduce-scatter input function, since padding dim 0 of `[E, O, I]` would pad > whole experts instead of merged rows. The input function only receives shard > dims (#197204), so viewing the gradient first also covers #197701's native > copy-in and any function installed with `set_reduce_scatter_input_fn`. > > Expert-parallel parameters are supported too, as torchtitan lays them out: > `(R, Shard(0))` DTensors on a full `(efsdp, ep)` mesh with > `dp_mesh_dims=DataParallelMeshDims(shard="efsdp")` (spmd-mesh path), or EP > DTensors on a separate mesh (TP/EP path). FSDP chunks the merged rows of the > local experts and writes `BlockShard` on the DP shard dim instead of > `_StridedShard`, giving `(BlockShard, Shard(0))`; `BlockShard` applies after > the `Shard(0)` by definition. The final sharded spec is validated, so > unsupported compositions (e.g. TP `Shard(1)`, several DP shard dims, DDP) > raise `NotImplementedError`, as do spmd_types params and tensor subclasses > with FSDP extensions. > > Test Plan > > ``` > python test/distributed/_composable/fsdp/test_fully_shard_block_shard.py > python test/distributed/_composable/fsdp/test_fully_shard_dtensor.py > python test/distributed/_composable/fsdp/test_fully_shard_init.py > NCCL_NVLS_ENABLE=0 python test/distributed/_composable/fsdp/test_fully_shard_training.py TestFullyShardShardPlacementFnMultiProcess TestFullyShardShardPlacementFnMultiThread TestFullyShard1DTrainingCore > ``` > > The 1D tests use 3 experts over 4 ranks, so merged rows cross expert > boundaries and the last rank is short: init, meta-device init > (`trunc_normal_` after `fully_shard`), training parity (AdamW `foreach=True` > and `clip_grad_norm_`) for `reshard_after_forward` in `{True, False, 2}` and > HSDP, no reordering copies, and state dict / DCP / full-state-dict broadcast > round trips. The expert-parallel tests build torchtitan's layout on a > `(efsdp, ep)` mesh with 3 local experts per EP rank and check init, training > parity, and checkpointing. Removing the merged-view reshape in > `foreach_reduce` makes the parity tests fail. The EP tests > reuse one mesh per process: on this base commit, a second `fully_shard` with > a new but equal spmd mesh in the same process raises "Expected param's > DTensor mesh to be the same mesh passed to fully_shard", with or without > `BlockShard`. (`NCCL_NVLS_ENABLE=0` avoids an unrelated NVLS "NCCL split > failed" error on the 8-GPU test host.) ghstack-source-id: 4073922 Pull-Request: #199234
This was referenced Oct 21, 2026
Open
3 of 4 tasks
weifengpy
added a commit
that referenced
this pull request
Nov 16, 2026
…n on the shared engine (AI-assisted) - [x] Passes lint (`spin fixlint`) - [x] Added/updated tests - [x] Updated documentation where applicable - [ ] Included benchmark results ## Linked issue or supporting maintainer > No linked issue; the author has write access. Ports #199234 onto the engine stack. ## BC-breaking? > No. `shard_placement_fn` may also return `BlockShard`, which raised before. ## Summary (human written only) > _Placeholder for the author._ ## Agent details (AI-generated) Drafted with an AI assistant at the author's request. A draft for discussion, not ready for review or merge. **Problem.** MoE expert weights `[E, O, I]` with fewer (local) experts than FSDP ranks either pad whole experts with `Shard(0)`, which leaves ranks empty, or use `Shard(1)`, which needs `O % W == 0` and reorders on every all-gather and reduce-scatter. #199234 let `shard_placement_fn` return `BlockShard` (added by the previous commit): FSDP shards, gathers and reduces `Shard(0)` of the merged view `(prod(shape[:k]), *shape[k:])`, and only the DTensors carry `BlockShard`. It was written against FSDP2's own `FSDPParam` storage and `foreach_reduce`, which this stack deleted: a `fully_shard` group is now an engine bucket that stores, gathers and reduces each parameter's `ParamSource.data` with the engine's `Shard`, and `FSDPParam` is only the parameter's DTensor representation. **What.** The merged view lives in FSDP2's frontend; the engine (`torch/distributed/fsdp/_flex_shard`) is unchanged. In review order: 1. `_fsdp_param.py`, `FSDPParam._init_sharded_param`: a `BlockShard` from `shard_placement_fn` is kept in `_block_shard`, and the bucket gets `Shard(0)` (`fsdp_placement`) of the merged view of the parameter's data (the local tensor of a DTensor parameter): `shard_source`, the `ParamSource.data` that the bucket chunks, is that view, `_merged_size` its size and `sharded_size` its chunk. The sharded spec has `BlockShard` on the DP shard mesh dim where `Shard(0)` or `_StridedShard` would be, on the plain, TP/EP-mesh and spmd-mesh paths, and is validated with `_validate_block_shard_placements`, so unsupported compositions raise `NotImplementedError` as in #199234: TP's `Shard(1)`, several DP shard mesh dims, DDP, spmd_types parameters and parameters with all-gather extensions. 2. `_fsdp_engine.py`, `FSDPParamRepresentation`: the hooks through which the engine hands a parameter's data to and from modules map between the merged view and the parameter's shape. `unsharded_param` views the gathered merged rows as the parameter's (local) shape before wrapping them; `unsharded_grad` and `unsharded_local` give the reduce the merged view of the gradient and of the unsharded parameter, whose shape the zeros of a missing gradient take. So the reduce-scatter pads merged rows, not whole experts. 3. `_fsdp_common.py` and `_fully_shard.py`: `resolve_shard_placement` accepts `BlockShard`; the `shard_placement_fn` docs. **Why this layer.** `Shard(0)` of the merged view is a layout that the engine's `Shard` already implements. Handing the bucket the merged view as the parameter's data, and mapping it back in the representation hooks, which already convert between the bucket's tensors and what modules see, needs no new engine contract and no `BlockShard` case in the engine: chunking and padding, the all-gather copy-out, the reduce-scatter copy-in, `reshard_after_forward=int` (a flat chunk of the gathered bytes), HSDP's all-reduce and accumulation, and re-homing after `to_empty()` take the dim-0 path as for any `Shard(0)` parameter. The engine's own `BlockShard` placement (a count of whole blocks per rank) is a different layout, outside FSDP2's collectives. #199234's post-forward `(Replicate(), BlockShard)` DTensor has no counterpart here: after forward, the engine registers the sharded parameters again, which carry `BlockShard`. ### Test Plan ``` python -m pytest test/distributed/_composable/fsdp/test_fully_shard_block_shard.py python -m pytest test/distributed/_composable/fsdp/test_fully_shard_init.py python -m pytest test/distributed/_composable/fsdp/test_fully_shard_training.py -k "ShardPlacementFn or 1DTrainingCore" python -m pytest test/distributed/_composable/fsdp/test_fully_shard_state_dict.py python -m pytest test/distributed/_composable/fsdp/test_fully_shard_comm.py python -m pytest test/distributed/_composable/fsdp/test_fully_shard_engine.py python -m pytest test/distributed/_composable/fsdp/test_fully_shard_dtensor.py spin lint -- --take RUFF,PYFMT,FLAKE8,PYREFLY <changed files> spin lint -- --take TEST_LINTER,TESTOWNERS,TEST_HAS_MAIN test/distributed/_composable/fsdp/test_fully_shard_block_shard.py ``` `test_fully_shard_block_shard.py` ports #199234's tests. 1D, with 3 experts over 4 ranks so that merged rows cross expert boundaries and the last rank is short: init (each rank holds its chunk of the merged rows); meta-device init (`trunc_normal_` after `fully_shard` draws the values of `Shard(0)` on the merged view, and the next forward uses them); training parity (AdamW `foreach=True`, `clip_grad_norm_`) for `reshard_after_forward` in {True, False, 2} and HSDP, against an unsharded reference and, bit for bit (losses, local gradients and parameters, norms), against a model that stores each expert weight as its merged view with the default `Shard(0)`; the dim-0 collectives (all-gather outer sizes of 1, reduce-scatter inputs that are merged-row gradients with shard dim 0); state dict, DCP and full-state-dict broadcast round trips; HSDP accumulation without the all-reduce while an expert weight is unused; and the errors for blocks that are not trailing dims, TP's `Shard(1)` and several DP shard dims. Expert parallelism, with 6 experts over 2 EP ranks so that the 15 merged rows of each EP rank's `w1` split 8 and 7 over 2 efsdp ranks, in both of torchtitan's layouts (EP DTensors on the `(efsdp, ep)` mesh with `dp_mesh_dims=DataParallelMeshDims(shard="efsdp")`, and EP DTensors on the ep mesh with FSDP on the efsdp mesh): init, training parity for `reshard_after_forward` in {True, False}, and DCP and full-state-dict broadcast. Without the merged view in `unsharded_grad`, the parity tests fail (88 of `w1`'s 120 gradient elements differ); without it in `unsharded_local`, the HSDP accumulation test fails (the reduce-scatter output of the zeros does not match the size of the accumulated output). Results on 4 GB300s, main bba8f39, one file at a time (the whole FSDP2 suite at this revision: 479 passed, with the same `alloc_from_pg` failure): `test_fully_shard_block_shard.py` 20 passed; `test_fully_shard_init.py` 46 passed; `test_fully_shard_training.py -k "ShardPlacementFn or 1DTrainingCore"` 14 passed; `test_fully_shard_state_dict.py` 11 passed; `test_fully_shard_engine.py` 7 passed; `test_fully_shard_dtensor.py` 10 passed; `test_fully_shard_comm.py` 202 passed and 1 failed, `test_fully_shard_alloc_from_pg`, which asserts that NCCL logs no buffer registrations and fails the same way without this commit (the NCCL on this host logs them). Lint is clean. The whole FSDP2 suite at this commit (4x GB300): 478 passed, 8 deselected (they need 8 GPUs), and the same `test_fully_shard_alloc_from_pg` failure. This PR was authored with an AI assistant (Claude). ghstack-source-id: c7591f1 Pull-Request: #204901
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.
Stack from ghstack (oldest at bottom):
This PR was authored with an AI assistant (Claude Code). The description below is AI-generated and is pending author review.