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

[Feature Request] Support dtype arg in torch._foreach_norm #125040

Open
awgu opened this issue Apr 26, 2024 · 2 comments · May be fixed by #125665
Open

[Feature Request] Support dtype arg in torch._foreach_norm #125040

awgu opened this issue Apr 26, 2024 · 2 comments · May be fixed by #125665
Labels
module: mta Issues related to multi-tensor apply kernels and foreach functions triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Comments

@awgu
Copy link
Contributor

awgu commented Apr 26, 2024

torch.linalg.vector_norm() and torch.norm support the dtype argument. Can we get support for it in torch._foreach_norm?

cc @crcrpar @mcarilli @janeyx99

@awgu awgu added the module: mta Issues related to multi-tensor apply kernels and foreach functions label Apr 26, 2024
@crcrpar
Copy link
Collaborator

crcrpar commented Apr 26, 2024

it should be doable.
just to confirm, with dtype we specify the dtype of output tensors, right?

ref: https://pytorch.org/docs/stable/generated/torch.norm.html

@awgu
Copy link
Contributor Author

awgu commented Apr 26, 2024

I think semantically, it should equivalent to casting inputs to dtype first:
Screenshot 2024-04-26 at 12 45 37 PM
https://pytorch.org/docs/stable/generated/torch.linalg.vector_norm.html

I am mostly interested in this behavior. It is not a high priority though because in most cases, the tensors are already fp32 (e.g. gradients for gradient norm clipping).

@mikaylagawarecki mikaylagawarecki added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Apr 26, 2024
@crcrpar crcrpar linked a pull request May 7, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: mta Issues related to multi-tensor apply kernels and foreach functions triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants