Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FSDP] Re-support model dtype change after FSDP init #91192

Closed
wants to merge 5 commits into from

Conversation

awgu
Copy link
Contributor

@awgu awgu commented Dec 20, 2022

Stack from ghstack:

Closes #90838.

To make mixed precision precise internally, #90660 changed the implementation to save _orig_param_dtype, _low_prec_param_dtype, and _reduce_dtype explicitly. However, these are computed at FSDP construction time, so it does not allow the user to change the model dtype after FSDP construction time but before lazy initialization. This PR recomputes those dtype attributes as needed if the model dtype changes in that window.

Note that any mixed precision settings specified by the user take precedence over the model dtype.

@pytorch-bot
Copy link

pytorch-bot bot commented Dec 20, 2022

🔗 Helpful Links

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

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

✅ No Failures

As of commit f2ea4a2:
💚 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 release notes: distributed (fsdp) release notes category label Dec 20, 2022
@awgu awgu added the topic: improvements topic category label Dec 20, 2022
awgu added a commit to awgu/pytorch that referenced this pull request Dec 20, 2022
ghstack-source-id: 3815e5ae8eac082490112724bbc3e847161b4397
Pull Request resolved: pytorch#91192
To make mixed precision precise internally, #90660 changed the implementation to save `_orig_param_dtype`, `_low_prec_param_dtype`, and `_reduce_dtype` explicitly. However, these are computed at FSDP construction time, so it does not allow the user to change the model dtype after FSDP construction time but before lazy initialization. This PR recomputes those dtype attributes as needed if the model dtype changes in that window.

Note that any mixed precision settings specified by the user take precedence over the model dtype.

[ghstack-poisoned]
awgu added a commit to awgu/pytorch that referenced this pull request Dec 20, 2022
ghstack-source-id: c4fb1436b9925f203bbd8fcf84891e2e7d2048c0
Pull Request resolved: pytorch#91192
awgu added a commit to awgu/pytorch that referenced this pull request Dec 20, 2022
ghstack-source-id: c4fb1436b9925f203bbd8fcf84891e2e7d2048c0
Pull Request resolved: pytorch#91192
To make mixed precision precise internally, #90660 changed the implementation to save `_orig_param_dtype`, `_low_prec_param_dtype`, and `_reduce_dtype` explicitly. However, these are computed at FSDP construction time, so it does not allow the user to change the model dtype after FSDP construction time but before lazy initialization. This PR recomputes those dtype attributes as needed if the model dtype changes in that window.

Note that any mixed precision settings specified by the user take precedence over the model dtype.

[ghstack-poisoned]
awgu added a commit to awgu/pytorch that referenced this pull request Dec 21, 2022
ghstack-source-id: 177caa7b10d34939c3979d6f212db5fceb283e44
Pull Request resolved: pytorch#91192
@awgu awgu added the ciflow/trunk Trigger trunk jobs on your pull request label Dec 21, 2022
awgu added a commit to awgu/pytorch that referenced this pull request Jan 10, 2023
ghstack-source-id: 177caa7b10d34939c3979d6f212db5fceb283e44
Pull Request resolved: pytorch#91192
awgu added a commit to awgu/pytorch that referenced this pull request Jan 10, 2023
ghstack-source-id: 177caa7b10d34939c3979d6f212db5fceb283e44
Pull Request resolved: pytorch#91192
Closes #90838.

To make mixed precision precise internally, #90660 changed the implementation to save `_orig_param_dtype`, `_low_prec_param_dtype`, and `_reduce_dtype` explicitly. However, these are computed at FSDP construction time, so it does not allow the user to change the model dtype after FSDP construction time but before lazy initialization. This PR recomputes those dtype attributes as needed if the model dtype changes in that window.

Note that any mixed precision settings specified by the user take precedence over the model dtype.

[ghstack-poisoned]
awgu added a commit to awgu/pytorch that referenced this pull request Jan 10, 2023
ghstack-source-id: cdc64afe5bbb7f6c441958dfaff6afcb70bc308c
Pull Request resolved: pytorch#91192
Closes #90838.

To make mixed precision precise internally, #90660 changed the implementation to save `_orig_param_dtype`, `_low_prec_param_dtype`, and `_reduce_dtype` explicitly. However, these are computed at FSDP construction time, so it does not allow the user to change the model dtype after FSDP construction time but before lazy initialization. This PR recomputes those dtype attributes as needed if the model dtype changes in that window.

Note that any mixed precision settings specified by the user take precedence over the model dtype.

[ghstack-poisoned]
awgu added a commit to awgu/pytorch that referenced this pull request Jan 11, 2023
ghstack-source-id: cd846eca268ff9277ef68c15424e78de76e233f6
Pull Request resolved: pytorch#91192
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 release notes: distributed (fsdp) release notes category topic: improvements topic category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants