-
Notifications
You must be signed in to change notification settings - Fork 25.6k
[Draft] Deprecation / Aliases for torch.linalg #57549
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
Conversation
💊 CI failures summary and remediationsAs of commit 5a04311 (more details on the Dr. CI page): ✅ None of the CI failures appear to be your fault 💚
❄️ 1 failure tentatively classified as flakybut reruns have not yet been triggered to confirm:
|
"torch.lstsq is deprecated in favor of torch.linalg.lstsq and will be removed in a future PyTorch release.\n", | ||
"torch.linalg.lstsq has reversed arguments and does not return the QR decomposition in " | ||
"the returned tuple, (it returns other information about the problem).\n", | ||
"X, _ = torch.lstsq(B, A).solution[:A.size(1)]\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a very specific invocation and manipulation of the result of torch.lstsq()
Maybe there's a more generic way to tell users to replace torch.lstsq() with torch.linalg.lstsq(), or maybe we need more time to deprecate torch.lstsq()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also comes from a previous wrong design. torch.lstsq
returns the solution and the residuals packed into the "solution" tensor.
Any user would have to unpack the solution and the residuals. That slicing there does the unpacking. I'll add this point to the warning.
TORCH_WARN_ONCE( | ||
"torch.solve is deprecated in favor of torch.linalg.solve", | ||
"and will be removed in a future PyTorch release.\n", | ||
"torch.linalg.solve has its arguments reversed and does not return the LU factorization.\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What should a user do if they want the LU factorization?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly we do not have a good solution for this yet, as torch.lu
is split into several functions (torch.lu
and torch.lu_unpack
). I would not worry about this too much, as that return was caused by a wrong design: (t's returning some internal part of the implementation that is not linked to the result (torch.solve
could be implemented via QR or SVD as well).
TORCH_WARN_ONCE( | ||
"torch.eig is deprecated in favor of torch.linalg.eig and will be removed in a future ", | ||
"PyTorch release.\n", | ||
"torch.linalg.eig returns complex tensors of dtype cfloat or cdouble rather than real tensors.\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"than real tensors mimicking complex tensors."
cc @anjali411 for a language sanity check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @lezcano! Language overall looks really good; I made a few suggestions inline
We'll have to separate out each deprecation into its own PR, however, and be sure that those PRs eliminate all uses of the deprecated function within the PyTorch code base, too (except for tests), so that when calling torch.linalg.svd, for example, we don't accidentally call into torch.svd and throw an error
Summary: This PR adds a note to the documentation that torch.svd is deprecated together with an upgrade guide on how to use `torch.linalg.svd` and `torch.linalg.svdvals` (Lezcano's instructions from #57549). In addition, all usage of the old svd function is replaced with a new one from torch.linalg module, except for the `at::linalg_pinv` function, that fails the XLA CI build (pytorch/xla#2755, see failure in draft PR #57772). Pull Request resolved: #57981 Reviewed By: ngimel Differential Revision: D28345558 Pulled By: mruberry fbshipit-source-id: 02dd9ae6efe975026e80ca128e9b91dfc65d7213
Summary: This PR adds a note to the documentation that torch.svd is deprecated together with an upgrade guide on how to use `torch.linalg.svd` and `torch.linalg.svdvals` (Lezcano's instructions from pytorch#57549). In addition, all usage of the old svd function is replaced with a new one from torch.linalg module, except for the `at::linalg_pinv` function, that fails the XLA CI build (pytorch/xla#2755, see failure in draft PR pytorch#57772). Pull Request resolved: pytorch#57981 Reviewed By: ngimel Differential Revision: D28345558 Pulled By: mruberry fbshipit-source-id: 02dd9ae6efe975026e80ca128e9b91dfc65d7213
Adds deprecation notes and aliases to the documentation and code of
torch.
methods pointing to their equivalents intorch.linalg
.It also fixes the function
torch.chain_matmul
, which was not using theout=
parameter when passed.Script to check the warnings
Script to check that the suggested replacements are correct