[3/N][dtensor] Strided Sharding offset calculation util#132391
Closed
XilunWu wants to merge 6 commits intogh/XilunWu/92/basefrom
Closed
[3/N][dtensor] Strided Sharding offset calculation util#132391XilunWu wants to merge 6 commits intogh/XilunWu/92/basefrom
XilunWu wants to merge 6 commits intogh/XilunWu/92/basefrom
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/132391
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 7d064d6 with merge base da32021 ( FLAKY - The following job failed but was likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This was referenced Aug 1, 2024
cc H-Huang awgu kwen2501 wanchaol fegin fduwjj wz337 wconstab d4l3k c-p-i-o [ghstack-poisoned]
Contributor
Author
|
@XilunWu has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
wanchaol
reviewed
Aug 2, 2024
cc H-Huang awgu kwen2501 wanchaol fegin fduwjj wz337 wconstab d4l3k c-p-i-o Differential Revision: [D60606115](https://our.internmc.facebook.com/intern/diff/D60606115) [ghstack-poisoned]
**Summary** 1. change `compute_local_shape_and_global_offset` to correctly compute shape and offset for strided sharding placement (currently it only handles 2D and some 3D+ sharding). 2. Add a new property `num_shards_map` to `DTensorSpec` denoting how many shards each tensor dimension has. This is necessary for constructing `_StridedShard` placement when we call `distribute_tensor(dtensor_tp, dp_device_mesh, [Shard(0)])` and the `split_factor` argument will just be the number of shards on that sharding tensor dim. **Test** `test/distributed/_tensor/test_utils.py` cc H-Huang awgu kwen2501 wanchaol fegin fduwjj wz337 wconstab d4l3k c-p-i-o Differential Revision: [D60606115](https://our.internmc.facebook.com/intern/diff/D60606115) [ghstack-poisoned]
Contributor
Author
|
@XilunWu has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
**Summary** 1. change `compute_local_shape_and_global_offset` to correctly compute shape and offset for strided sharding placement (currently it only handles 2D and some 3D+ sharding). 2. Add a new property `num_shards_map` to `DTensorSpec` denoting how many shards each tensor dimension has. This is necessary for constructing `_StridedShard` placement when we call `distribute_tensor(dtensor_tp, dp_device_mesh, [Shard(0)])` and the `split_factor` argument will just be the number of shards on that sharding tensor dim. **Test** `test/distributed/_tensor/test_utils.py` cc H-Huang awgu kwen2501 wanchaol fegin fduwjj wz337 wconstab d4l3k c-p-i-o Differential Revision: [D60606115](https://our.internmc.facebook.com/intern/diff/D60606115) [ghstack-poisoned]
wanchaol
approved these changes
Aug 6, 2024
Collaborator
wanchaol
left a comment
There was a problem hiding this comment.
lgtm, have one more comment, please address before landing
**Summary** 1. change `compute_local_shape_and_global_offset` to correctly compute shape and offset for strided sharding placement (currently it only handles 2D and some 3D+ sharding). 2. Add a new property `num_shards_map` to `DTensorSpec` denoting how many shards each tensor dimension has. This is necessary for constructing `_StridedShard` placement when we call `distribute_tensor(dtensor_tp, dp_device_mesh, [Shard(0)])` and the `split_factor` argument will just be the number of shards on that sharding tensor dim. **Test** `test/distributed/_tensor/test_utils.py` cc H-Huang awgu kwen2501 wanchaol fegin fduwjj wz337 wconstab d4l3k c-p-i-o Differential Revision: [D60606115](https://our.internmc.facebook.com/intern/diff/D60606115) [ghstack-poisoned]
pytorchmergebot
pushed a commit
that referenced
this pull request
Aug 7, 2024
**Test** `pytest test/distributed/_composable/fsdp/test_fully_shard_training.py` `pytest test/distributed/_composable/fsdp/test_fully_shard_state_dict.py` `pytest test/distributed/checkpoint/fsdp/test_fsdp_dsd.py` `pytest test/distributed/_composable/fsdp/test_fully_shard_init.py` Pull Request resolved: #131408 Approved by: https://github.com/fegin ghstack dependencies: #126697, #130239, #132391
pytorchmergebot
pushed a commit
that referenced
this pull request
Aug 8, 2024
…rrect full_tensor() result (#130760) Fixes issue #129229 #129206 **Summary** 1. Have `FSDP` choose `_StridedShard` placement for FSDP+TP sharding 2. Added a parity test to FSDP to ensure that FSDP+TP sharding (i.e. strided) and simply TP sharding (i.e. non-strided) has the same `full_tensor()` result 3. Re-enabled the tests that were disabled in #129519 **test** `pytest test/distributed/_composable/fsdp/` `pytest test/distributed/_composable/test_composability/test_2d_composability.py` `pytest test/distributed/checkpoint/fsdp/test_fsdp_dsd.py` Differential Revision: [D60606114](https://our.internmc.facebook.com/intern/diff/D60606114) Pull Request resolved: #130760 Approved by: https://github.com/wanchaol, https://github.com/fegin, https://github.com/wz337 ghstack dependencies: #126697, #130239, #132391, #131408
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):
Summary
compute_local_shape_and_global_offsetto correctly compute shape and offset for strided sharding placement (currently it only handles 2D and some 3D+ sharding).num_shards_maptoDTensorSpecdenoting how many shards each tensor dimension has. This is necessary for constructing_StridedShardplacement when we calldistribute_tensor(dtensor_tp, dp_device_mesh, [Shard(0)])and thesplit_factorargument will just be the number of shards on that sharding tensor dim.Test
test/distributed/_tensor/test_utils.pycc @H-Huang @awgu @kwen2501 @wanchaol @fegin @fduwjj @wz337 @wconstab @d4l3k @c-p-i-o