Skip to content

Conversation

@awgu
Copy link
Collaborator

@awgu awgu commented Dec 1, 2022

Stack from ghstack (oldest at bottom):

For PyTorch FSDP, the only way that gradients are in low precision is if keep_low_precision_grads=True or if the user turns on AMP. This PR adds tests for the former and improves the documentation for clip_grad_norm_(), especially around these non-full-precision cases.

@pytorch-bot
Copy link

pytorch-bot bot commented Dec 1, 2022

🔗 Helpful Links

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

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

✅ No Failures

As of commit d9fd5d8:
💚 Looks good so far! There are no failures yet. 💚

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

awgu pushed a commit that referenced this pull request Dec 1, 2022
ghstack-source-id: e936299
Pull Request resolved: #90028
@awgu awgu added the topic: improvements topic category label Dec 1, 2022
For PyTorch FSDP, the only way that gradients are in low precision is if `keep_low_precision_grads=True` or if the user turns on AMP. This PR adds tests for the former and improves the documentation for `clip_grad_norm_()`, especially around these non-full-precision cases.

[ghstack-poisoned]
Copy link
Contributor

@rohan-varma rohan-varma left a comment

Choose a reason for hiding this comment

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

Great catch! Do we know why this was not picked up by unittests earlier?

applied per subset of model parameters.
.. note:: If every FSDP instance uses ``NO_SHARD``, meaning that no
gradients are sharded across ranks, then you may directly use
:func:`torch.nn.utils.clip_grad_norm_`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we warn explicitly about this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have it so that if all instances use NO_SHARD, then this method returns torch.nn.utils.clip_grad_norm_(), so it is equivalent.

For PyTorch FSDP, the only way that gradients are in low precision is if `keep_low_precision_grads=True` or if the user turns on AMP. This PR adds tests for the former and improves the documentation for `clip_grad_norm_()`, especially around these non-full-precision cases.

[ghstack-poisoned]
@awgu
Copy link
Collaborator Author

awgu commented Dec 2, 2022

Great catch! Do we know why this was not picked up by unittests earlier?

We did not not test keep_low_precision_grads=True previously :/

For PyTorch FSDP, the only way that gradients are in low precision is if `keep_low_precision_grads=True` or if the user turns on AMP. This PR adds tests for the former and improves the documentation for `clip_grad_norm_()`, especially around these non-full-precision cases.

[ghstack-poisoned]
awgu pushed a commit to awgu/pytorch that referenced this pull request Dec 2, 2022
ghstack-source-id: 5ae7c09
Pull Request resolved: pytorch#90028
For PyTorch FSDP, the only way that gradients are in low precision is if `keep_low_precision_grads=True` or if the user turns on AMP. This PR adds tests for the former and improves the documentation for `clip_grad_norm_()`, especially around these non-full-precision cases.

[ghstack-poisoned]
awgu pushed a commit that referenced this pull request Dec 2, 2022
ghstack-source-id: e8c7026
Pull Request resolved: #90028
@awgu awgu added the ciflow/trunk Trigger trunk jobs on your pull request label Dec 2, 2022
@awgu
Copy link
Collaborator Author

awgu commented Dec 2, 2022

@pytorchbot rebase -s

@pytorchmergebot
Copy link
Collaborator

@pytorchbot successfully started a rebase job. Check the current status here

For PyTorch FSDP, the only way that gradients are in low precision is if `keep_low_precision_grads=True` or if the user turns on AMP. This PR adds tests for the former and improves the documentation for `clip_grad_norm_()`, especially around these non-full-precision cases.

[ghstack-poisoned]
@pytorchmergebot
Copy link
Collaborator

Successfully rebased gh/awgu/225/orig onto refs/remotes/origin/viable/strict, please pull locally before adding more changes (for example, via ghstack checkout https://github.com/pytorch/pytorch/pull/90028)

pytorchmergebot pushed a commit that referenced this pull request Dec 2, 2022
ghstack-source-id: db8e898
Pull Request resolved: #90028
@awgu
Copy link
Collaborator Author

awgu commented Dec 2, 2022

@pytorchbot merge

@pytorchmergebot
Copy link
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

kulinseth pushed a commit to kulinseth/pytorch that referenced this pull request Dec 10, 2022
For PyTorch FSDP, the only way that gradients are in low precision is if `keep_low_precision_grads=True` or if the user turns on AMP. This PR adds tests for the former and improves the documentation for `clip_grad_norm_()`, especially around these non-full-precision cases.
Pull Request resolved: pytorch#90028
Approved by: https://github.com/rohan-varma
@facebook-github-bot facebook-github-bot deleted the gh/awgu/225/head branch June 8, 2023 15:29
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.

4 participants