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

Fix gmres errors in CI triggered by new Scipy version #81

Merged
merged 3 commits into from
Feb 28, 2024

Conversation

btalamini
Copy link
Collaborator

@btalamini btalamini commented Feb 27, 2024

We were passing JAX arrays to Scipy GMRES and duck typing was making it work. However, Scipy's GMRES has been refactored, and now it tries to modify some arrays in place. This is perfectly reasonable, but now the immutability of JAX arrays is causing a problem. I fixed this by making deep copies of the data to plain numpy arrays (including output of the matvec and preconditioner operators).

I also did some small maintenance in the nearby code. Please take a look at the change in the relative tolerance specification. I think it fixes a conceptual error, but it's going to cause a change in behavior. This modification also has the benefit of eliminating a deprecated parameter (Scipy is phasing out tol in favor of explicit rtol in the iterative solvers.)

Fixes #78

Scipy GMRES now modifies the preconditioned residual in place. This
is perfectly reasonable, but we were passing in jax numpy arrays,
which do not allow this. This was unsafe, but we got away with it.

This commit makes deep copies of jax arrays to plain numpy arrays
in the operators and initial data that the scipy gmres sees.
The relative tolerance for convergence was being set to a fraction
of the rhs norm, but the `tol` option is already a relative
tolerance.

This commit also fies a depracation warning, since the `tol`
parameter is deprecated in facor of `rtol`.
@btalamini btalamini merged commit be8a2fe into sandialabs:main Feb 28, 2024
2 of 3 checks passed
@btalamini btalamini deleted the fix_gmres_errors branch February 28, 2024 00:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scipy 1.12.0 breaks GMRES usage
2 participants