Improve eig tests in preparation for new eig backends#166322
Closed
johannesz-codes wants to merge 2 commits intopytorch:mainfrom
Closed
Improve eig tests in preparation for new eig backends#166322johannesz-codes wants to merge 2 commits intopytorch:mainfrom
johannesz-codes wants to merge 2 commits intopytorch:mainfrom
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/166322
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 1e3010e with merge base 6ecd6b2 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Contributor
Author
|
https://dev-discuss.pytorch.org/t/cusolver-dnxgeev-faster-cuda-eigenvalue-calculations/3248/6 Since I forgot to add the link in the original PR |
- Verify validity of eigenvectors using the eigen decomposition identity for improved robustness, as eigenvectors are not unique. - Increases test reliability across backends (cuSOLVER, MAGMA, CPU). - Tolerances derived from numerical comparisons between cuSOLVER and NumPy. See discussion: https://dev-discuss.pytorch.org/t/cusolver-dnxgeev-faster-cuda-eigenvalue-calculations/3248/6
e089d4e to
fd3ef67
Compare
lezcano
reviewed
Oct 28, 2025
lezcano
reviewed
Oct 28, 2025
lezcano
reviewed
Oct 28, 2025
Collaborator
lezcano
left a comment
There was a problem hiding this comment.
A few things:
- Could you inline the function you just wrote?
- Don't move things to CPU unnecessarily. Those computations can be performed on the device.
- Use
assertEqual(a@v, v - w)rather than rolling out your own comparison (let alone printing unconditionally)
lezcano
approved these changes
Oct 28, 2025
Collaborator
lezcano
left a comment
There was a problem hiding this comment.
Great! Thank you for the clean-up!
Collaborator
|
@pytorchbot merge |
Collaborator
Merge startedYour 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Improves validation of
torch.linalg.eigresults by verifying the eigen decomposition identity A v − v λ = 0.Motivation
Eigenvectors are not unique, and numerical differences between backends (cuSOLVER, MAGMA, CPU)
can cause false test failures. This PR replaces direct elementwise comparisons with a mathematical
identity check, improving robustness across devices.
Details
fulfills_eigen_decomposition_identity()intest_eig_compare_backends()to validate the eigen equation.See discussion: dev-discuss.pytorch.org link
Impact