Repository navigation
[SimpleFSDP] Fix HSDP placement mismatch in _distribute_dtensor - #2329
Conversation
|
Hi @SongyuanZhao! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
| ) | ||
|
|
||
| # HSDP case needs 2 placements for 2D outer_mesh | ||
| current_placements = (Replicate(),) * len(dp_placements) |
There was a problem hiding this comment.
This makes sense to me because the outer_mesh used below should be 2d mesh in HSDP case.
I wonder if why this test HSDP(2,2) TP2 didn't captures it?
https://github.com/pytorch/torchtitan/blob/main/torchtitan/experiments/simple_fsdp/tests/integration_tests.py#L183
There was a problem hiding this comment.
I believe this is primarily because the sizes of dp_replica and dp_shard are identical.
First, a 1D placement is passed in while the device_mesh is 2D. In this case, sharding is performed along mesh_dim 0 (dp_replica), so calling _distribute_dtensor does not trigger an error.
Second, although sharding is performed on the incorrect dimension, the resulting shape remains correct because dp_replica == dp_shard. Consequently, the subsequent execution proceeds without errors.
…rch#2329) The current_spec and target_spec in _distribute_dtensor were only providing one placement for HSDP's 2D outer_mesh, causing a dimension mismatch. Fixed by using (Replicate(),) * len(dp_placements) to automatically generate the correct number of placements matching the mesh dimensionality: - 1 placement for FSDP/DDP (1D mesh) - 2 placements for HSDP (2D mesh) --------- Co-authored-by: ZhaoSongyuan <[email protected]>
…rch#2329) The current_spec and target_spec in _distribute_dtensor were only providing one placement for HSDP's 2D outer_mesh, causing a dimension mismatch. Fixed by using (Replicate(),) * len(dp_placements) to automatically generate the correct number of placements matching the mesh dimensionality: - 1 placement for FSDP/DDP (1D mesh) - 2 placements for HSDP (2D mesh) --------- Co-authored-by: ZhaoSongyuan <[email protected]>
The current_spec and target_spec in _distribute_dtensor were only providing
one placement for HSDP's 2D outer_mesh, causing a dimension mismatch.
Fixed by using (Replicate(),) * len(dp_placements) to automatically generate
the correct number of placements matching the mesh dimensionality: