Skip to content

Conversation

@ricardoV94
Copy link
Member

@ricardoV94 ricardoV94 commented Jan 8, 2026

Closes #1078

Instead of adding on_error to every Op, this PR choses the simpler approach, just catch and return nan by default.

This also allows us to simplify the numba implementations quite a lot and get rid of a couple of low-level dispatch for condition number and the like. Perhaps it even speeds up uncached compilation.

Only one Op had this special behavior: Cholesky. For helping with transitioning, on_error="raise" is now implemented symbolically with a FutureWarning. The default switched to on_error="nan", which is the "default" in all lingalg Ops (at least the ones I covered).

This is analogous to us returning 1/0->nan without any error/warning. If it's undefined/can't be computed we return nan, and let the users deal with it. Most of the times the error makes it hader to work with, not easier, as there is no symbolic try/except, while there is symbolic isnan(x).any().


I also removed the check_finite argument internally. Users can define it without it having any effect for API compat. The stated reason for this in Scipy is that some implementation of BLAS/Lapack can hang / crash the system with non-finite values. I'm taking a chance here, as those issues may never show up in the versions our users install / modern implementations. We can revisit this later if it proves to be still needed.

I'm marking this as a major breaking change.


Finally, I've removed some lapack overloads that were never used anywhere, and inlined others that were used only in one place. I believe it makes code more readable and perhaps uncached numba compilation faster


cache_key = 1
return numba_pivot_to_permutation, cache_key
cache_version = 2
Copy link
Member Author

Choose a reason for hiding this comment

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

renamed to cache_version, because it's not a cache_key, but an extra field that will be incorporated into the cache_key by the decorator

@ricardoV94 ricardoV94 force-pushed the linalg_do_not_raise branch 3 times, most recently from 994795c to 64b1ee6 Compare January 8, 2026 16:08
Inline when only used in one place, or remove if altogether unused
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add on_error argument to linalg functions

1 participant