BUG: check that all elements are finite before calling gesdd to prevent hangs or garbage results - #32593
Open
ikrommyd wants to merge 4 commits into
Open
BUG: check that all elements are finite before calling gesdd to prevent hangs or garbage results#32593ikrommyd wants to merge 4 commits into
ikrommyd wants to merge 4 commits into
Conversation
Signed-off-by: Iason Krommydas <[email protected]>
Signed-off-by: Iason Krommydas <[email protected]>
Member
Author
|
Another way would be to do this in python like |
Signed-off-by: Iason Krommydas <[email protected]>
Member
Author
ikrommyd
marked this pull request as ready for review
September 11, 2026 15:34
seberg
approved these changes
Sep 13, 2026
Member
There was a problem hiding this comment.
Thanks, looks all fine to me, just a link out might be nice. Two small comments I don't actually care about:
- I suspect this bug was just around for-ever. Don't mind a release note, but also don't particularly need it. (I think the the one computer I tried had a strange build with lapack-lite.)
- I trust that this is really unmeasurably faster than anything (because the algorithms below always do multiple iterations).
One curiosity (I suspect it's fine): Can we also get in trouble for almost infinite results here, due to overflows in later calculation?
Signed-off-by: Iason Krommydas <[email protected]>
Member
Author
Things like this work on my machines: rng = np.random.default_rng(1234)
a = rng.random((6, 6))
scale = 2.0 ** 1000
s = np.linalg.svd(a * scale, compute_uv=False)
np.testing.assert_allclose(s, np.linalg.svd(a, compute_uv=False) * scale, rtol=1e-12) |
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.
PR summary
Closes #32591
Adds a check that the input is all finite before the LAPACK
gesddroutines are called insidenumpy.linalg.svd,numpy.linalg.lstsqand the functions built on them. If the input contains infinities, LAPACK often hangs (see the linked issue for more info) or returns garbage results otherwise. That check is very very cheap to make compared to the actual computation.AI Disclosure
An AI model has reviewed the changes.