Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[FSDP2] respect reshard_after_forward=True for root model#154704

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
weifengpy wants to merge6 commits intogh/weifengpy/26/basefromgh/weifengpy/26/head

Conversation

@weifengpy
Copy link
Contributor

@weifengpyweifengpy commentedMay 30, 2025
edited
Loading

resolve#154655

Stack fromghstack (oldest at bottom):

fully_shard(root, reshard_after_forward=True) didn't really reshard parameters after forward, because we assumed root model will be used in backward immeidately. The assumption becomes invalid in 2 cases

  • we have 3 roots for CLIP, T5, FLUX. we should reshard parameters are CLIP and T5 immeidately after their forward
    for recommendation model, we may have mutiple root for dense part

Change default beahvior to always respectreshard_after_forward=True

cc@H-Huang@awgu@wanchaol@fegin@fduwjj@wz337@wconstab@d4l3k

Differential Revision:D75663200

@pytorch-bot
Copy link

pytorch-botbot commentedMay 30, 2025
edited
Loading

🔗 Helpful Links

🧪 See artifacts and rendered test results athud.pytorch.org/pr/154704

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

✅ No Failures

As of commit2bbef5b with merge base0c6c778 (image):
💚 Looks good so far! There are no failures yet. 💚

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

weifengpy added a commit that referenced this pull requestMay 30, 2025
@pytorch-botpytorch-botbot added ciflow/inductor oncall: distributedAdd this issue/PR to distributed oncall triage queue release notes: distributed (fsdp)release notes category labelsMay 30, 2025
@weifengpyweifengpy requested review fromawgu andmori360May 30, 2025 06:22
@weifengpy
Copy link
ContributorAuthor

@weifengpy has imported this pull request. If you are a Meta employee, you can view this diffon Phabricator.

@pytorch-botpytorch-botbot added the ciflow/trunkTrigger trunk jobs on your pull request labelMay 30, 2025
@weifengpyweifengpy marked this pull request as draftMay 30, 2025 16:55
…model"resolve#154655cc H-Huang awgu wanchaol fegin fduwjj wz337 wconstab d4l3kDifferential Revision: [D75663200](https://our.internmc.facebook.com/intern/diff/D75663200)[ghstack-poisoned]
@weifengpyweifengpy added release notes: distributed (fsdp2)release notes category and removed release notes: distributed (fsdp)release notes category labelsJun 1, 2025
@weifengpyweifengpy changed the title[FSDP2] respect reshard_after_forward=True/False for root model[FSDP2] respect reshard_after_forward=True for root modelJun 1, 2025
resolve#154655`fully_shard(root, reshard_after_forward=True)` didn't really reshard parameters after forward, because we assumed root model will be used in backward immeidately. The assumption becomes invalid in 2 cases* we have 3 roots for CLIP, T5, FLUX. we should reshard parameters are CLIP and T5 immeidately after their forwardfor recommendation model, we may have mutiple root for dense partChange default beahvior to always respect `reshard_after_forward=True`cc H-Huang awgu wanchaol fegin fduwjj wz337 wconstab d4l3kDifferential Revision: [D75663200](https://our.internmc.facebook.com/intern/diff/D75663200)[ghstack-poisoned]
@weifengpy
Copy link
ContributorAuthor

@weifengpy has imported this pull request. If you are a Meta employee, you can view this diffon Phabricator.

resolve#154655`fully_shard(root, reshard_after_forward=True)` didn't really reshard parameters after forward, because we assumed root model will be used in backward immeidately. The assumption becomes invalid in 2 cases* we have 3 roots for CLIP, T5, FLUX. we should reshard parameters are CLIP and T5 immeidately after their forwardfor recommendation model, we may have mutiple root for dense partChange default beahvior to always respect `reshard_after_forward=True`cc H-Huang awgu wanchaol fegin fduwjj wz337 wconstab d4l3kDifferential Revision: [D75663200](https://our.internmc.facebook.com/intern/diff/D75663200)[ghstack-poisoned]
@weifengpy
Copy link
ContributorAuthor

@weifengpy has imported this pull request. If you are a Meta employee, you can view this diffon Phabricator.

resolve#154655`fully_shard(root, reshard_after_forward=True)` didn't really reshard parameters after forward, because we assumed root model will be used in backward immeidately. The assumption becomes invalid in 2 cases* we have 3 roots for CLIP, T5, FLUX. we should reshard parameters are CLIP and T5 immeidately after their forwardfor recommendation model, we may have mutiple root for dense partChange default beahvior to always respect `reshard_after_forward=True`cc H-Huang awgu wanchaol fegin fduwjj wz337 wconstab d4l3kDifferential Revision: [D75663200](https://our.internmc.facebook.com/intern/diff/D75663200)[ghstack-poisoned]
resolve#154655`fully_shard(root, reshard_after_forward=True)` didn't really reshard parameters after forward, because we assumed root model will be used in backward immeidately. The assumption becomes invalid in 2 cases* we have 3 roots for CLIP, T5, FLUX. we should reshard parameters are CLIP and T5 immeidately after their forwardfor recommendation model, we may have mutiple root for dense partChange default beahvior to always respect `reshard_after_forward=True`cc H-Huang awgu wanchaol fegin fduwjj wz337 wconstab d4l3kDifferential Revision: [D75663200](https://our.internmc.facebook.com/intern/diff/D75663200)[ghstack-poisoned]
weifengpy added a commit that referenced this pull requestJun 2, 2025
setattr(module,param_name,param)
fully_shard(model)
# need to fix reshard_after_forward=True
# https://github.com/pytorch/pytorch/issues/154836
Copy link
ContributorAuthor

@weifengpyweifengpyJun 2, 2025
edited
Loading

Choose a reason for hiding this comment

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

this PR unreveals an existing bug in extension. should be following up separately and change it back toreshard_after_forward=True

mori360 reacted with thumbs up emoji
@weifengpy
Copy link
ContributorAuthor

@weifengpy has imported this pull request. If you are a Meta employee, you can view this diffon Phabricator.

@weifengpy
Copy link
ContributorAuthor

@weifengpy has imported this pull request. If you are a Meta employee, you can view this diffon Phabricator.

@weifengpyweifengpy marked this pull request as ready for reviewJune 2, 2025 08:46
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we remove the comments at line118model(inp) # root does not reshard after forward under test_param_registration_after_forward

weifengpy reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

good point. I will update the PR. anything else?

Copy link
Contributor

@mori360mori360 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! LGTM

@weifengpy
Copy link
ContributorAuthor

@pytorchmergebot merge

pytorch-bot[bot] reacted with thumbs up emoji

@pytorchmergebot
Copy link
Collaborator

Merge started

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

Learn more about merging in thewiki.

Questions? Feedback? Please reach out to thePyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

iupaikov-amd pushed a commit to ROCm/pytorch that referenced this pull requestJun 4, 2025
…4704)resolvepytorch#154655`fully_shard(root, reshard_after_forward=True)` didn't really reshard parameters after forward, because we assumed root model will be used in backward immeidately. The assumption becomes invalid in 2 cases* we have 3 roots for CLIP, T5, FLUX. we should reshard parameters are CLIP and T5 immeidately after their forwardfor recommendation model, we may have mutiple root for dense partChange default beahvior to always respect `reshard_after_forward=True`Differential Revision: [D75663200](https://our.internmc.facebook.com/intern/diff/D75663200)Pull Requestresolved:pytorch#154704Approved by:https://github.com/mori360
@github-actionsgithub-actionsbot deleted the gh/weifengpy/26/head branchJuly 4, 2025 02:20
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@mori360mori360mori360 approved these changes

@awguawguAwaiting requested review from awgu

Assignees

No one assigned

Labels

ciflow/inductorciflow/trunkTrigger trunk jobs on your pull requestMergedoncall: distributedAdd this issue/PR to distributed oncall triage queuerelease notes: distributed (fsdp2)release notes category

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@weifengpy@pytorchmergebot@mori360

[8]ページ先頭

©2009-2025 Movatter.jp