Skip to content

[BE] replace the extra DeviceMesh _flatten with mesh access - #667

Merged
XilunWu merged 2 commits into
mainfrom
gh/XilunWu/9/base
Oct 31, 2024
Merged

XilunWu merged 2 commits into
mainfrom
gh/XilunWu/9/base

Conversation

@XilunWu

@XilunWu XilunWu commented Oct 31, 2024 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Note: This PR is a reland of #666 where the PR was mistakenly merged into a wrong branch.

Summary
pytorch/pytorch#138945 fixes DeviceMesh access on flattened mesh which are constructed from more than 2 meshes. Refer to the fix PR for details if interested.

In #592 we avoided this issue by calling _flatten instead of direct accessing the flattened mesh. We want to turn back to mesh access which is more straightforward since the fix has been merged in PyTorch.

… with mesh access"


**Summary**
pytorch/pytorch#138945 fixes DeviceMesh access on flattened mesh which are constructed from more than 2 meshes. Refer to the fix PR for details if interested.

In #592 we avoided this issue by calling `_flatten` instead of direct accessing the flattened mesh. We want to turn back to mesh access which is more straightforward since the fix has been merged in PyTorch.


[ghstack-poisoned]
Stack from [ghstack](https://github.com/ezyang/ghstack) (oldest at
bottom):
* __->__ #666

**Summary**
pytorch/pytorch#138945 fixes DeviceMesh access
on flattened mesh which are constructed from more than 2 meshes. Refer
to the fix PR for details if interested.

In #592 we avoided this issue by calling `_flatten` instead of direct
accessing the flattened mesh. We want to turn back to mesh access which
is more straightforward since the fix has been merged in PyTorch.
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 31, 2024
@XilunWu XilunWu changed the title Gh/xilun wu/9/base [BE] replace the extra DeviceMesh _flatten with mesh access Oct 31, 2024
@XilunWu
XilunWu requested a review from tianyu-l October 31, 2024 05:39

@fegin fegin left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

stamped as it was approved in another PR.

# note: this is a workaround of the above logic for old pytorch version
# where https://github.com/pytorch/pytorch/pull/138945 is not included
# throw a warning to encourage users to upgrade to a newer pytorch version
check_if_feature_in_pytorch(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@fegin
Since we are already suggesting user to use latest PyTorch nightly, I wonder how necessary it is to include such messages, as multiple features would depend on non-stable release. E.g. for PP, we constantly see new features, without such try-catches.

Not saying this is not good, but there seems to be a trade-off / sacrifice for dev velocity and simplicity.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm okay to remove it. Or we can periodically cleanup (like weekly). In general, this is not just for the end users but also for developers like us who may not up the local PyTorch reguarly.

@XilunWu
XilunWu merged commit d7cabfb into main Oct 31, 2024
mori360 pushed a commit to mori360/torchtitan that referenced this pull request Nov 26, 2024
)

Stack from [ghstack](https://github.com/ezyang/ghstack) (oldest at
bottom):
* __->__ pytorch#667

Note: This PR is a reland of pytorch#666 where the PR was mistakenly merged
into a wrong branch.

**Summary**
pytorch/pytorch#138945 fixes DeviceMesh access
on flattened mesh which are constructed from more than 2 meshes. Refer
to the fix PR for details if interested.

In pytorch#592 we avoided this issue by calling `_flatten` instead of direct
accessing the flattened mesh. We want to turn back to mesh access which
is more straightforward since the fix has been merged in PyTorch.
xrsrke pushed a commit to NousResearch/torchtitan that referenced this pull request Feb 13, 2026
)

Stack from [ghstack](https://github.com/ezyang/ghstack) (oldest at
bottom):
* __->__ pytorch#667

Note: This PR is a reland of pytorch#666 where the PR was mistakenly merged
into a wrong branch.

**Summary**
pytorch/pytorch#138945 fixes DeviceMesh access
on flattened mesh which are constructed from more than 2 meshes. Refer
to the fix PR for details if interested.

In pytorch#592 we avoided this issue by calling `_flatten` instead of direct
accessing the flattened mesh. We want to turn back to mesh access which
is more straightforward since the fix has been merged in PyTorch.
xrsrke pushed a commit to NousResearch/torchtitan that referenced this pull request Feb 25, 2026
)

Stack from [ghstack](https://github.com/ezyang/ghstack) (oldest at
bottom):
* __->__ pytorch#667

Note: This PR is a reland of pytorch#666 where the PR was mistakenly merged
into a wrong branch.

**Summary**
pytorch/pytorch#138945 fixes DeviceMesh access
on flattened mesh which are constructed from more than 2 meshes. Refer
to the fix PR for details if interested.

In pytorch#592 we avoided this issue by calling `_flatten` instead of direct
accessing the flattened mesh. We want to turn back to mesh access which
is more straightforward since the fix has been merged in PyTorch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants