Skip to content

fix docs for CSR #1006

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

oscardssmith
Copy link

With

A_gpu = CuSparseMatrixCSR(sprand(T, n, n, 0.05) + I)
b_cpu = CuVector(rand(T, n))
julia> x, stats = bicgstab(A_gpu, b_gpu, M=opM)

we before got

(Float32[1.0198809, 4.0956926, 1.28241, -1.7407427, -2.9416926, -0.32771796, 0.4703165, 5.368891, -3.1246433, -1.7737565  …  0.97625387, 3.7136111, -1.0120717, 2.8906355, -1.1602651, 0.46383825, 2.538051, 1.448916, 2.4476223, -3.592498], SimpleStats
 niter: 54
 solved: false
 inconsistent: false
 indefinite: false
 residuals: []
 Aresiduals: []
 κ₂(A): []
 timer: 48.24ms
 status: breakdown αₖ == 0
)

but with this, get

(Float32[-0.4150291, 2.639933, -1.3929893, -1.1049638, -1.2597414, 0.0031488854, -1.918298, 5.812737, -1.3443595, -1.2016623  …  1.6825913, 3.0281372, -1.4967421, 3.0308955, -1.1063535, 0.2894782, 1.1083188, -0.1900546, 2.3867438, 1.4211323], SimpleStats
 niter: 66
 solved: true
 inconsistent: false
 indefinite: false
 residuals: []
 Aresiduals: []
 κ₂(A): []
 timer: 57.85ms
 status: solution good enough given atol and rtol
)

With
```
A_gpu = CuSparseMatrixCSR(sprand(T, n, n, 0.05) + I)
b_cpu = CuVector(rand(T, n))
julia> x, stats = bicgstab(A_gpu, b_gpu, M=opM)
```
we before got
```
(Float32[1.0198809, 4.0956926, 1.28241, -1.7407427, -2.9416926, -0.32771796, 0.4703165, 5.368891, -3.1246433, -1.7737565  …  0.97625387, 3.7136111, -1.0120717, 2.8906355, -1.1602651, 0.46383825, 2.538051, 1.448916, 2.4476223, -3.592498], SimpleStats
 niter: 54
 solved: false
 inconsistent: false
 indefinite: false
 residuals: []
 Aresiduals: []
 κ₂(A): []
 timer: 48.24ms
 status: breakdown αₖ == 0
)
```
but with this, get
```
(Float32[-0.4150291, 2.639933, -1.3929893, -1.1049638, -1.2597414, 0.0031488854, -1.918298, 5.812737, -1.3443595, -1.2016623  …  1.6825913, 3.0281372, -1.4967421, 3.0308955, -1.1063535, 0.2894782, 1.1083188, -0.1900546, 2.3867438, 1.4211323], SimpleStats
 niter: 66
 solved: true
 inconsistent: false
 indefinite: false
 residuals: []
 Aresiduals: []
 κ₂(A): []
 timer: 57.85ms
 status: solution good enough given atol and rtol
)
```
@amontoison
Copy link
Member

amontoison commented May 9, 2025

@oscardssmith The breakdown is independent of the good / bad preconditioner. What we should check is if we converge in one iteration with an ILU preconditioner of a dense matrix stored in sparse CSR format.

Copy link

codecov bot commented May 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.49%. Comparing base (9536ef7) to head (cedd424).
Report is 80 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1006      +/-   ##
==========================================
+ Coverage   94.68%   97.49%   +2.81%     
==========================================
  Files          45       49       +4     
  Lines        8027     9298    +1271     
==========================================
+ Hits         7600     9065    +1465     
+ Misses        427      233     -194     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@oscardssmith
Copy link
Author

What we should check is if we converge in one iteration with an ILU preconditioner of a dense matrix stored in sparse CSR format.

This is true for the old, but not the new one.

The breakdown is independent of the good / bad preconditioner

What is it dependent on? Randomly failing to solve seems like a fairly large problem.

@amontoison
Copy link
Member

amontoison commented May 9, 2025

What we should check is if we converge in one iteration with an ILU preconditioner of a dense matrix stored in sparse CSR format.

This is true for the old, but not the new one.

Ok, so it means that the old preconditioner is correct.

The breakdown is independent of the good / bad preconditioner

What is it dependent on? Randomly failing to solve seems like a fairly large problem.

Yes, it is why we should never use bicgstab :)
It could randomly breakdown.
Everybody wanted this method implemented in Krylov.jl but it can breakdown at any moment.
It is cheap but not robust.

@oscardssmith
Copy link
Author

In that case, should the docs switch to gmres or some other better algorithm?

@amontoison
Copy link
Member

amontoison commented May 9, 2025

I already suggest better algorithms in the docstring of bicgstab.
bilq and dqgmres are cheaper than gmres and more robust than bicgstab.
https://jso.dev/Krylov.jl/dev/solvers/unsymmetric/#BiCGSTAB

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.

2 participants