-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
MAINT:ENH:sparse.linalg: Rewrite iterative solvers in Python #18488
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
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.
I bumped the milestone on this one because there are other solvers that needs attention about deprecations. We can wait another 6 months on top of 15 years I think :) |
32600c9
to
631d0cd
Compare
I spoke to Pauli offline and went over about his preconditioning tolerance machinery. There is no problem as far as we can see. Also a tolerance initialization bug was causing some relaxation in the solution which is now fixed. |
631d0cd
to
d0b23e0
Compare
d0b23e0
to
5ee4391
Compare
If everyone is happy, I'd like to add the Fortran code deletion commit on top and merge soon. Please let me know if you spot any issues in the meantime. |
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.
Minor tweak needed due to bumping the milestone
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.
Minor tweak needed due to bumping the milestone
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.
Cannot re-review in depth, but the test changes look benign, which means that the implementation should be doing what it's supposed to. I trust you on this. 👍
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 looks great @ilayn! I had a look now, and can review in more detail and get this merged - just can't promise it happens this week, because I have a trip starting tomorrow.
One issue I just noticed with the tol
deprecation (which came up in an unrelated PR earlier today): it won't trigger if a user writes something like: bicg(A, b, x0, None, 1000, M)
. To address that, the signature can be changed to use tol=_NoValue
with _NoValue
being a constant defined in the file. And then also emit the deprecation warning if the user passes None
.
The performance is comparable and slightly faster with Python
I didn't see any benchmark results here or on the initial PR - may be worth updating the PR description with whatever results you have?
It's a bit better than that. if somebody was not using tol before, they don't get any warning because now
Yes, I should. I'll generate something . |
That is a good idea in principle, however my point was that you can then not remove the keyword. Use of a positional |
Here are some very funky results :) I have no idea what is going on with cgs or gmres (possibly I'm measuring failure speed, I'll run those again) but in general we are in good shape The difference looks big but the scale is zoomed hence it's not that big. The expensive parts of these solvers are the matvecs and preconditioner ops but they were already being done on the python side anyways hence the performance is pretty much the same if we don't stray away from inplace NumPy ops. I'll check on GMRES one more time to see if I forgot some inplace linalg function but I'd take this PR against that sphagetti even if we lost 20% to be honest. |
Ah you mean you don't want to yank out a keyword from the middle to disturb the positional arguments if I understand correctly. But I think that kind of breakage is justified in this situation. Anyways let's continue when you are back 😃 I'll also need to reset myself from all this FORTRAN radiation I've been exposed lately. . |
Just as a reminder, how should we proceed with the tol keyword here? Don't know a separate PR might be a better strategy to deal with it but I guess @rgommers saying is a better way to go once and for all. |
The deprecation warning from #8400 (in In fact, it's warning as soon as I think this is very unlikely usage, and considering the length of time this has been warning, it'd be defensible IMO to just remove Haven't looked how many other functions are affected by this though, and I can also see the argument that it'd be cleaner to deprecate positional usage completely (and then switch to keyword-only arguments). |
@ @h-vetinari @rgommers @j-bowhay Should we merge this and deal with the |
1fda004
to
99a57bc
Compare
OK, I'll open the PR in a bit. |
Contuniation of #18391
As discussed in #18367 for
linalg.interpolative
,iterative
solvers are also in the same state that it is almost impossible to implement any enhancements such as returning the iteration information and so on. This PR, reimplements all code in pure Python and with a bit of care to inplace operations thanks to NumPy no performance is lost.@mdhaber @tupui Touched optimize tests for handling DperecationWarnings in these solvers and also did some PEP8 cleanup in separate commits. So should be easier to review those parts. When this goes in, I can go into nonlinear optimize code to find where these are triggered.
@h-vetinari The fixtures were generating ~1000 tests and skipping 500ish of them causing lots of
s
, so modified the fixtures such that tests are skipped and collect-time. Please have a look.When ready, I'll remove the Fortran files and the compilation machinery as the last step.
Reference issue
Closes #5022
Closes #6198
Closes #12748
Closes #15533
Closes #15693
Closes #17744
These ones are auxiliary signature issues, that will need addressing once this PR goes in
Related #12624
Related #15657
Related #15738
Related #16123
Memory Lane for past discussions
#1466
#7623
#7624
#8400
#10341
#16050
What does this implement/fix?
_isolve/iterative
Fortran code.tol
/atol
handling is just a mess and is waiting to be overhauled for at least 5 years. This PR will unite both issues for iterative solvers at least