Skip to content

Change default solver to QR#131

Merged
termi-official merged 4 commits into
masterfrom
do/change-default-coarse-solver
Jun 12, 2026
Merged

Change default solver to QR#131
termi-official merged 4 commits into
masterfrom
do/change-default-coarse-solver

Conversation

@termi-official

@termi-official termi-official commented May 22, 2026

Copy link
Copy Markdown
Collaborator

Supersedes #121

@termi-official termi-official changed the title Change default solver to UMFPACK Change default solver to QR May 22, 2026
@termi-official

Copy link
Copy Markdown
Collaborator Author

@ChrisRackauckas is this good enough? The BackslashSolver from Claude in 121 has some type inference issues.

Comment thread src/coarse_solver.jl
struct QRSolver{F} <: CoarseSolver
factorization::F
function QRSolver(A)
fact = qr(A)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

make this a column-pivoted QR, so it handles singularities?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I am pretty sure SPQR already handles these faithfully:

julia> A = sprand(4,4,0.1)
4×4 SparseMatrixCSC{Float64, Int64} with 3 stored entries:
                               
 0.248639  0.469341              
                               
                   0.0588856    

julia> f = qr(A)
SparseArrays.SPQR.QRSparse{Float64, Int64}
Q factor:
4×4 SparseArrays.SPQR.QRSparseQ{Float64, Int64}
R factor:
4×4 SparseMatrixCSC{Float64, Int64} with 3 stored entries:
 0.248639            0.469341    
          0.0588856             
                               
                               
Row permutation:
4-element Vector{Int64}:
 2
 4
 3
 1
Column permutation:
4-element Vector{Int64}:
 1
 3
 2
 4

Or do you have something else in mind? Note that if we start converting the coarse matrix from sparse to dense (as done in the pinv solver), then we again run into memory issues.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I dug into this topic quite a bit, and yes SPQR does work. There's now also https://github.com/SciML/SparseColumnPivotedQR.jl now, but SPQR is likely better for the matrices that people are using an AMG for.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for taking time here! I tried to benchmark everything to look out for regressions, but ran into some trouble with the new OrdinaryDiffEq release (SciML/SciMLBenchmarks.jl#1601).

FYI if the coarse solver is accessible via LinearSolve, then it can be used via coarse_solver = AMG.LinearSolveWrapper(myalg) already since AMG v1.0 or so.

@termi-official termi-official force-pushed the do/change-default-coarse-solver branch from f8e4644 to fffeabf Compare June 12, 2026 11:48
@termi-official termi-official merged commit c5e2ecd into master Jun 12, 2026
3 of 6 checks passed
@termi-official termi-official deleted the do/change-default-coarse-solver branch June 12, 2026 12:02
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