Skip to content

Conversation

kwen2501
Copy link
Contributor

@kwen2501 kwen2501 commented Dec 7, 2024

Stack from ghstack (oldest at bottom):

Locally shards a full tensor based on indicated sharding arrangement, and returns a DTensor containing the local shard.

warning: This is a private API purposed to skip the communication otherwise required by distribute_tensor. It is only applicable to a case where all ranks have the same full_tensor.

cc @H-Huang @awgu @wanchaol @fegin @fduwjj @wz337 @wconstab @d4l3k @c-p-i-o @tianyu-l @XilunWu

Copy link

pytorch-bot bot commented Dec 7, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/142288

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit fb3b2a1 with merge base 61dc5e9 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot pytorch-bot bot added the oncall: distributed Add this issue/PR to distributed oncall triage queue label Dec 7, 2024
@kwen2501 kwen2501 requested a review from wz337 December 7, 2024 01:38
@kwen2501 kwen2501 added the release notes: distributed (dtensor) release notes category label Dec 7, 2024
Copy link
Contributor

@wz337 wz337 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stamped to unblock.

@wz337 wz337 added topic: not user facing topic category module: dtensor distributed tensor tag and removed release notes: distributed (dtensor) release notes category labels Dec 7, 2024
Locally shards a full tensor based on indicated sharding arrangement, and
returns a DTensor containing the local shard.
.. warning:: This is a private API purposed to skip the communication
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we say This is a private API that is subject to change. It is ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, added now.

for cur_shape, cur_offset in zip(shape, offset)
]
local_tensor = full_tensor[slices]
return DTensor.from_local(local_tensor, device_mesh, placements)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will need to pass the shape and stride for uneven tensor for from_local. Otherwise, the shape and stride would be inferred from the local tensor as it is uniformly distributed. See example: https://github.com/pytorch/pytorch/blob/main/torch/distributed/_state_dict_utils.py#L566-L572

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the heads-up. I don't have the shape or stride info, and this function assumes things are the same across ranks, so the infer would be fine.

Locally shards a full tensor based on indicated sharding arrangement, and returns a DTensor containing the local shard.

warning: This is a private API purposed to skip the communication otherwise required by `distribute_tensor`. It is only applicable to a case where all ranks have the same `full_tensor`. 

cc H-Huang awgu wanchaol fegin fduwjj wz337 wconstab d4l3k c-p-i-o tianyu-l XilunWu

[ghstack-poisoned]
kwen2501 added a commit that referenced this pull request Dec 7, 2024
ghstack-source-id: fa35b0e
Pull Request resolved: #142288
@kwen2501
Copy link
Contributor Author

kwen2501 commented Dec 7, 2024

@pytorchbot merge -f "CI was green; minor edits to comments"

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use -f as last resort and instead consider -i/--ignore-current to continue the merge ignoring current failures. This will allow currently pending tests to finish and report signal before the merge.

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

AmdSampsa pushed a commit to AmdSampsa/pytorch that referenced this pull request Dec 9, 2024
Locally shards a full tensor based on indicated sharding arrangement, and returns a DTensor containing the local shard.

warning: This is a private API purposed to skip the communication otherwise required by `distribute_tensor`. It is only applicable to a case where all ranks have the same `full_tensor`.

Pull Request resolved: pytorch#142288
Approved by: https://github.com/wz337
@github-actions github-actions bot deleted the gh/kwen2501/112/head branch January 7, 2025 02:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Merged module: dtensor distributed tensor tag oncall: distributed Add this issue/PR to distributed oncall triage queue topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants