Skip to content

[FSDP2] Added mesh arg to fsdp_pre_all_gather - #123953

Closed
awgu wants to merge 2 commits into
gh/awgu/560/basefrom
gh/awgu/560/head
Closed

awgu wants to merge 2 commits into
gh/awgu/560/basefrom
gh/awgu/560/head

Conversation

@awgu

@awgu awgu commented Apr 12, 2024 •

Copy link
Copy Markdown
Collaborator

Stack from ghstack (oldest at bottom):

This PR adds a mesh: DeviceMesh argument to fsdp_pre_all_gather() so that the extension can know over which mesh the all-gather is happening. This can be useful in recovering the post-all-gather tensor size in the fsdp_post_all_gather() (e.g. for NF4Tensor).

cc @mrshenli @pritamdamania87 @zhaojuanmao @satgera @rohan-varma @gqchen @aazzolini @osalpekar @jiayisuse @H-Huang @kwen2501 @penguinwu @fegin @XilunWu @wanchaol @fduwjj @wz337 @tianyu-l @wconstab @yf225 @chauhang

@pytorch-bot

pytorch-bot Bot commented Apr 12, 2024 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ No Failures

As of commit 39efd62 with merge base 7cd7a7a (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 oncall: distributed Add this issue/PR to distributed oncall triage queue release notes: distributed (fsdp) release notes category labels Apr 12, 2024
awgu pushed a commit that referenced this pull request Apr 12, 2024
ghstack-source-id: 0276191
Pull Request resolved: #123953
@awgu

awgu commented Apr 12, 2024

Copy link
Copy Markdown
Collaborator Author

@weifengpy I was thinking that it would be better to include the mesh as an arg to the fsdp_pre_all_gather and then subclasses can save the mesh.size() if needed in the metadata.

The reason is that the call-site for the fsdp_pre_all_gather knows which mesh it would be calling all-gather over, whereas the call-site for fsdp_post_all_gather does not.

This would matter only for the case of reshard_after_forward: int, where we could be all-gathering over a different mesh in backward. We do not support reshard_after_forward: int with the extensions yet (and doing so correctly for the user might be kind of tricky), so this is not a big deal either way.

@awgu awgu added release notes: distributed (fsdp2) release notes category and removed release notes: distributed (fsdp) release notes category labels Apr 12, 2024
@awgu
awgu requested a review from weifengpy April 12, 2024 18:05
@weifengpy

Copy link
Copy Markdown
Contributor

@weifengpy I was thinking that it would be better to include the mesh as an arg to the fsdp_pre_all_gather and then subclasses can save the mesh.size() if needed in the metadata.

The reason is that the call-site for the fsdp_pre_all_gather knows which mesh it would be calling all-gather over, whereas the call-site for fsdp_post_all_gather does not.

This would matter only for the case of reshard_after_forward: int, where we could be all-gathering over a different mesh in backward. We do not support reshard_after_forward: int with the extensions yet (and doing so correctly for the user might be kind of tricky), so this is not a big deal either way.

nice. I am good with passing mesh during fsdp_pre_all_gather. will give it a try on NF4Tensor.
BTW: I see this in draft mode. are you planning more changes?

@awgu

awgu commented Apr 13, 2024

Copy link
Copy Markdown
Collaborator Author

@weifengpy sorry, no more planned changes -- I just wanted to check with you first 😅

@weifengpy

Copy link
Copy Markdown
Contributor

@weifengpy sorry, no more planned changes -- I just wanted to check with you first 😅

all good. all good

@awgu
awgu marked this pull request as ready for review April 13, 2024 00:36
cc mrshenli pritamdamania87 zhaojuanmao satgera rohan-varma gqchen aazzolini osalpekar jiayisuse H-Huang kwen2501 penguinwu fegin XilunWu wanchaol fduwjj wz337 tianyu-l wconstab yf225 chauhang

[ghstack-poisoned]
@awgu awgu added the ciflow/trunk Trigger trunk jobs on your pull request label Apr 15, 2024
@awgu

awgu commented Apr 15, 2024

Copy link
Copy Markdown
Collaborator Author

@pytorchbot merge

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

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

sanketpurandare pushed a commit to sanketpurandare/pytorch that referenced this pull request Apr 22, 2024
This PR adds a `mesh: DeviceMesh` argument to `fsdp_pre_all_gather()` so that the extension can know over which mesh the all-gather is happening. This can be useful in recovering the post-all-gather tensor size in the `fsdp_post_all_gather()` (e.g. for `NF4Tensor`).

Pull Request resolved: pytorch#123953
Approved by: https://github.com/Skylion007, https://github.com/wanchaol
ghstack dependencies: pytorch#119302, pytorch#122908
petrex pushed a commit to petrex/pytorch that referenced this pull request May 3, 2024
This PR adds a `mesh: DeviceMesh` argument to `fsdp_pre_all_gather()` so that the extension can know over which mesh the all-gather is happening. This can be useful in recovering the post-all-gather tensor size in the `fsdp_post_all_gather()` (e.g. for `NF4Tensor`).

Pull Request resolved: pytorch#123953
Approved by: https://github.com/Skylion007, https://github.com/wanchaol
ghstack dependencies: pytorch#119302, pytorch#122908
@github-actions
github-actions Bot deleted the gh/awgu/560/head branch May 16, 2024 01:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request Merged oncall: distributed Add this issue/PR to distributed oncall triage queue release notes: distributed (fsdp2) release notes category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants