Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0439d18
add SciMLLogging
jClugstor Aug 14, 2025
d14a60a
add verbosity types
jClugstor Aug 14, 2025
25a43a0
replace verbose::Bool with verbose::LinearVerbosity
jClugstor Aug 14, 2025
0cf22f0
export symbols, include verbosity.jl
jClugstor Aug 14, 2025
084b7fb
add verbosity documentation
jClugstor Aug 14, 2025
fbb61c2
add verbosity to IterativeSolversExt
jClugstor Aug 14, 2025
a34b7f9
add verbosity to KrylovKitExt
jClugstor Aug 14, 2025
4acfd78
add verbose to PardisoExt
jClugstor Aug 14, 2025
1dec693
add verbose to HYPREExt
jClugstor Aug 14, 2025
fec9ba4
add verbose for iterative solvers
jClugstor Aug 14, 2025
513b8b6
bring in LinearVerbosity
jClugstor Aug 14, 2025
a285e2d
imports
jClugstor Aug 14, 2025
d5d3709
fix default
jClugstor Aug 14, 2025
609a921
add tests
jClugstor Aug 14, 2025
725ae58
make verbose = Bool also valid for backwards compat
jClugstor Aug 14, 2025
0738e25
allow bool verbose
jClugstor Aug 14, 2025
a7c1acb
fix _init_cacheval
jClugstor Aug 14, 2025
d1ed0c0
fix verbose for HYPRE
jClugstor Aug 14, 2025
8d9e217
add compat for SciMLLogging
jClugstor Aug 14, 2025
1c0def4
get rid of stale import
jClugstor Aug 14, 2025
6841f7d
Update runtests.jl
ChrisRackauckas Aug 18, 2025
2e1c4d4
change bool to LinearVerbosity
jClugstor Aug 18, 2025
c994993
add messages for fallbacks
jClugstor Aug 18, 2025
0cf1266
make constructor for logging disabled better
jClugstor Aug 22, 2025
f4e3e0d
fix up verbosity for extensions
jClugstor Aug 22, 2025
4927363
from Bool to LinearVerbosity
jClugstor Aug 22, 2025
d5690d6
import LinearVerbosity for extensions
jClugstor Aug 22, 2025
1c77a95
fix the imports for CliqueTrees
jClugstor Aug 22, 2025
0484d56
fix krylov verbosity
jClugstor Aug 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Preferences = "21216c6a-2e73-6563-6e65-726566657250"
RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
SciMLLogging = "a6db7da4-7206-11f0-1eab-35f2a5dbe1d1"
SciMLOperators = "c0aeaf25-5076-4817-a8d5-81caf7dfa961"
Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46"
StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
Expand Down Expand Up @@ -124,6 +125,7 @@ Reexport = "1.2.2"
SafeTestsets = "0.1"
SciMLBase = "2.70"
SciMLOperators = "1"
SciMLLogging = "1"
Setfield = "1.1.1"
SparseArrays = "1.10"
Sparspak = "0.3.9"
Expand Down
2 changes: 1 addition & 1 deletion docs/src/advanced/developing.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct MyLUFactorization{P} <: LinearSolve.SciMLLinearSolveAlgorithm end

function LinearSolve.init_cacheval(
alg::MyLUFactorization, A, b, u, Pl, Pr, maxiters::Int, abstol, reltol,
verbose::Bool, assump::LinearSolve.OperatorAssumptions)
verbose::LinearVerbosity, assump::LinearSolve.OperatorAssumptions)
lu!(convert(AbstractMatrix, A))
end

Expand Down
89 changes: 89 additions & 0 deletions docs/src/basics/common_solver_opts.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,92 @@ solve completely. Error controls only apply to iterative solvers.
- `maxiters`: The number of iterations allowed. Defaults to `length(prob.b)`
- `Pl,Pr`: The left and right preconditioners, respectively. For more information,
see [the Preconditioners page](@ref prec).

## Verbosity Controls

The verbosity system in LinearSolve.jl provides fine-grained control over the diagnostic messages, warnings, and errors that are displayed during the solution of linear systems.

The verbosity system is organized hierarchically into three main categories:

1. Error Control - Messages related to fallbacks and error handling
2. Performance - Messages related to performance considerations
3. Numerical - Messages related to numerical solvers and iterations

Each category can be configured independently, and individual settings can be adjusted to suit your needs.

### Verbosity Levels
The following verbosity levels are available:

#### Individual Settings
These settings are meant for individual settings within a category. These can also be used to set all of the individual settings in a group to the same value.
- Verbosity.None() - Suppress all messages
- Verbosity.Info() - Show message as log message at info level
- Verbosity.Warn() - Show warnings (default for most settings)
- Verbosity.Error() - Throw errors instead of warnings
- Verbosity.Level(n) - Show messages with a log level setting of n

#### Group Settings
These settings are meant for controlling a group of settings.
- Verbosity.Default() - Use the default settings
- Verbosity.All() - Show all possible messages

### Basic Usage

#### Global Verbosity Control

```julia
using LinearSolve

# Suppress all messages
verbose = LinearVerbosity(Verbosity.None())
prob = LinearProblem(A, b)
sol = solve(prob; verbose=verbose)

# Show all messages
verbose = LinearVerbosity(Verbosity.All())
sol = solve(prob; verbose=verbose)

# Use default settings
verbose = LinearVerbosity(Verbosity.Default())
sol = solve(prob; verbose=verbose)
```

#### Group Level Control

```julia
# Customize by category
verbose = LinearVerbosity(
error_control = Verbosity.Warn(), # Show warnings for error control related issues
performance = Verbosity.None(), # Suppress performance messages
numerical = Verbosity.Info() # Show all numerical related log messages at info level
)

sol = solve(prob; verbose=verbose)
```

#### Fine-grained Control
The constructor for `LinearVerbosity` allows you to set verbosity for each specific message toggle, giving you fine-grained control.
The verbosity settings for the toggles are automatically passed to the group objects.
```julia
# Set specific message types
verbose = LinearVerbosity(
default_lu_fallback = Verbosity.Info(), # Show info when LU fallback is used
KrylovJL_verbosity = Verbosity.Warn(), # Show warnings from KrylovJL
no_right_preconditioning = Verbosity.None(), # Suppress right preconditioning messages
KrylovKit_verbosity = Verbosity.Level(KrylovKit.WARN_LEVEL) # Set KrylovKit verbosity level using KrylovKit's own verbosity levels
)

sol = solve(prob; verbose=verbose)

```

#### Verbosity Levels
##### Error Control Settings
- default_lu_fallback: Controls messages when falling back to LU factorization (default: Warn)
##### Performance Settings
- no_right_preconditioning: Controls messages when right preconditioning is not used (default: Warn)
##### Numerical Settings
- using_IterativeSolvers: Controls messages when using the IterativeSolvers.jl package (default: Warn)
- IterativeSolvers_iterations: Controls messages about iteration counts from IterativeSolvers.jl (default: Warn)
- KrylovKit_verbosity: Controls messages from the KrylovKit.jl package (default: Warn)
- KrylovJL_verbosity: Controls verbosity of the KrylovJL.jl package (default: None)
6 changes: 3 additions & 3 deletions ext/LinearSolveAMDGPUExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module LinearSolveAMDGPUExt

using AMDGPU
using LinearSolve: LinearSolve, LinearCache, AMDGPUOffloadLUFactorization,
AMDGPUOffloadQRFactorization, init_cacheval, OperatorAssumptions
AMDGPUOffloadQRFactorization, init_cacheval, OperatorAssumptions, LinearVerbosity
using LinearSolve.LinearAlgebra, LinearSolve.SciMLBase

# LU Factorization
Expand All @@ -25,7 +25,7 @@ function SciMLBase.solve!(cache::LinearSolve.LinearCache, alg::AMDGPUOffloadLUFa
end

function LinearSolve.init_cacheval(alg::AMDGPUOffloadLUFactorization, A, b, u, Pl, Pr,
maxiters::Int, abstol, reltol, verbose::Bool,
maxiters::Int, abstol, reltol, verbose::LinearVerbosity,
assumptions::OperatorAssumptions)
AMDGPU.rocSOLVER.getrf!(AMDGPU.ROCArray(A))
end
Expand Down Expand Up @@ -57,7 +57,7 @@ function SciMLBase.solve!(cache::LinearSolve.LinearCache, alg::AMDGPUOffloadQRFa
end

function LinearSolve.init_cacheval(alg::AMDGPUOffloadQRFactorization, A, b, u, Pl, Pr,
maxiters::Int, abstol, reltol, verbose::Bool,
maxiters::Int, abstol, reltol, verbose::LinearVerbosity,
assumptions::OperatorAssumptions)
A_gpu = AMDGPU.ROCArray(A)
tau = AMDGPU.ROCVector{eltype(A_gpu)}(undef, min(size(A_gpu)...))
Expand Down
6 changes: 3 additions & 3 deletions ext/LinearSolveBLISExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ using LinearSolve
using LinearAlgebra: BlasInt, LU
using LinearAlgebra.LAPACK: require_one_based_indexing, chkfinite, chkstride1,
@blasfunc, chkargsok
using LinearSolve: ArrayInterface, BLISLUFactorization, @get_cacheval, LinearCache, SciMLBase
using LinearSolve: ArrayInterface, BLISLUFactorization, @get_cacheval, LinearCache, SciMLBase, LinearVerbosity
using SciMLBase: ReturnCode

const global libblis = blis_jll.blis
Expand Down Expand Up @@ -204,13 +204,13 @@ const PREALLOCATED_BLIS_LU = begin
end

function LinearSolve.init_cacheval(alg::BLISLUFactorization, A, b, u, Pl, Pr,
maxiters::Int, abstol, reltol, verbose::Bool,
maxiters::Int, abstol, reltol, verbose::LinearVerbosity,
assumptions::OperatorAssumptions)
PREALLOCATED_BLIS_LU
end

function LinearSolve.init_cacheval(alg::BLISLUFactorization, A::AbstractMatrix{<:Union{Float32,ComplexF32,ComplexF64}}, b, u, Pl, Pr,
maxiters::Int, abstol, reltol, verbose::Bool,
maxiters::Int, abstol, reltol, verbose::LinearVerbosity,
assumptions::OperatorAssumptions)
A = rand(eltype(A), 0, 0)
ArrayInterface.lu_instance(A), Ref{BlasInt}()
Expand Down
8 changes: 4 additions & 4 deletions ext/LinearSolveBandedMatricesExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module LinearSolveBandedMatricesExt
using BandedMatrices, LinearAlgebra, LinearSolve
import LinearSolve: defaultalg,
do_factorization, init_cacheval, DefaultLinearSolver,
DefaultAlgorithmChoice
DefaultAlgorithmChoice, LinearVerbosity

# Defaults for BandedMatrices
function defaultalg(A::BandedMatrix, b, oa::OperatorAssumptions{Bool})
Expand Down Expand Up @@ -41,14 +41,14 @@ for alg in (:SVDFactorization, :MKLLUFactorization, :DiagonalFactorization,
:AppleAccelerateLUFactorization, :CholeskyFactorization)
@eval begin
function init_cacheval(::$(alg), ::BandedMatrix, b, u, Pl, Pr, maxiters::Int,
abstol, reltol, verbose::Bool, assumptions::OperatorAssumptions)
abstol, reltol, verbose::LinearVerbosity, assumptions::OperatorAssumptions)
return nothing
end
end
end

function init_cacheval(::LUFactorization, A::BandedMatrix{T}, b, u, Pl, Pr, maxiters::Int,
abstol, reltol, verbose::Bool, assumptions::OperatorAssumptions) where {T}
abstol, reltol, verbose::LinearVerbosity, assumptions::OperatorAssumptions) where {T}
(T <: BigFloat) && return qr(similar(A, 0, 0))
return lu(similar(A, 0, 0))
end
Expand All @@ -61,7 +61,7 @@ for alg in (:SVDFactorization, :MKLLUFactorization, :DiagonalFactorization,
:AppleAccelerateLUFactorization, :QRFactorization, :LUFactorization)
@eval begin
function init_cacheval(::$(alg), ::Symmetric{<:Number, <:BandedMatrix}, b, u, Pl,
Pr, maxiters::Int, abstol, reltol, verbose::Bool,
Pr, maxiters::Int, abstol, reltol, verbose::LinearVerbosity,
assumptions::OperatorAssumptions)
return nothing
end
Expand Down
16 changes: 8 additions & 8 deletions ext/LinearSolveCUDAExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using LinearSolve: LinearSolve, is_cusparse, defaultalg, cudss_loaded, DefaultLi
error_no_cudss_lu, init_cacheval, OperatorAssumptions,
CudaOffloadFactorization, CudaOffloadLUFactorization, CudaOffloadQRFactorization,
CUDAOffload32MixedLUFactorization,
SparspakFactorization, KLUFactorization, UMFPACKFactorization
SparspakFactorization, KLUFactorization, UMFPACKFactorization, LinearVerbosity
using LinearSolve.LinearAlgebra, LinearSolve.SciMLBase, LinearSolve.ArrayInterface
using SciMLBase: AbstractSciMLOperator

Expand Down Expand Up @@ -51,7 +51,7 @@ function SciMLBase.solve!(cache::LinearSolve.LinearCache, alg::CudaOffloadLUFact
end

function LinearSolve.init_cacheval(alg::CudaOffloadLUFactorization, A::AbstractArray, b, u, Pl, Pr,
maxiters::Int, abstol, reltol, verbose::Bool,
maxiters::Int, abstol, reltol, verbose::LinearVerbosity,
assumptions::OperatorAssumptions)
T = eltype(A)
noUnitT = typeof(zero(T))
Expand All @@ -74,7 +74,7 @@ function SciMLBase.solve!(cache::LinearSolve.LinearCache, alg::CudaOffloadQRFact
end

function LinearSolve.init_cacheval(alg::CudaOffloadQRFactorization, A, b, u, Pl, Pr,
maxiters::Int, abstol, reltol, verbose::Bool,
maxiters::Int, abstol, reltol, verbose::LinearVerbosity,
assumptions::OperatorAssumptions)
qr(CUDA.CuArray(A))
end
Expand All @@ -93,26 +93,26 @@ function SciMLBase.solve!(cache::LinearSolve.LinearCache, alg::CudaOffloadFactor
end

function LinearSolve.init_cacheval(alg::CudaOffloadFactorization, A::AbstractArray, b, u, Pl, Pr,
maxiters::Int, abstol, reltol, verbose::Bool,
maxiters::Int, abstol, reltol, verbose::LinearVerbosity,
assumptions::OperatorAssumptions)
qr(CUDA.CuArray(A))
end

function LinearSolve.init_cacheval(
::SparspakFactorization, A::CUDA.CUSPARSE.CuSparseMatrixCSR, b, u,
Pl, Pr, maxiters::Int, abstol, reltol, verbose::Bool, assumptions::OperatorAssumptions)
Pl, Pr, maxiters::Int, abstol, reltol, verbose::LinearVerbosity, assumptions::OperatorAssumptions)
nothing
end

function LinearSolve.init_cacheval(
::KLUFactorization, A::CUDA.CUSPARSE.CuSparseMatrixCSR, b, u,
Pl, Pr, maxiters::Int, abstol, reltol, verbose::Bool, assumptions::OperatorAssumptions)
Pl, Pr, maxiters::Int, abstol, reltol, verbose::LinearVerbosity, assumptions::OperatorAssumptions)
nothing
end

function LinearSolve.init_cacheval(
::UMFPACKFactorization, A::CUDA.CUSPARSE.CuSparseMatrixCSR, b, u,
Pl, Pr, maxiters::Int, abstol, reltol, verbose::Bool, assumptions::OperatorAssumptions)
Pl, Pr, maxiters::Int, abstol, reltol, verbose::LinearVerbosity, assumptions::OperatorAssumptions)
nothing
end

Expand Down Expand Up @@ -140,7 +140,7 @@ function SciMLBase.solve!(cache::LinearSolve.LinearCache, alg::CUDAOffload32Mixe
end

function LinearSolve.init_cacheval(alg::CUDAOffload32MixedLUFactorization, A, b, u, Pl, Pr,
maxiters::Int, abstol, reltol, verbose::Bool,
maxiters::Int, abstol, reltol, verbose::LinearVerbosity,
assumptions::OperatorAssumptions)
# Pre-allocate with Float32 arrays
A_f32 = Float32.(A)
Expand Down
4 changes: 2 additions & 2 deletions ext/LinearSolveCUSOLVERRFExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ using SciMLBase: SciMLBase, LinearProblem, ReturnCode
function LinearSolve.init_cacheval(alg::LinearSolve.CUSOLVERRFFactorization,
A, b, u, Pl, Pr,
maxiters::Int, abstol, reltol,
verbose::Bool, assumptions::OperatorAssumptions)
verbose::LinearVerbosity, assumptions::OperatorAssumptions)
nothing
end

function LinearSolve.init_cacheval(alg::LinearSolve.CUSOLVERRFFactorization,
A::Union{CuSparseMatrixCSR{Float64, Int32}, SparseMatrixCSC{Float64, <:Integer}},
b, u, Pl, Pr,
maxiters::Int, abstol, reltol,
verbose::Bool, assumptions::OperatorAssumptions)
verbose::LinearVerbosity, assumptions::OperatorAssumptions)
# Create initial factorization with appropriate options
nrhs = b isa AbstractMatrix ? size(b, 2) : 1
symbolic = alg.symbolic
Expand Down
2 changes: 1 addition & 1 deletion ext/LinearSolveCliqueTreesExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ end

function LinearSolve.init_cacheval(
alg::CliqueTreesFactorization, A::AbstractMatrix, b, u, Pl, Pr, maxiters::Int, abstol,
reltol, verbose::Bool, assumptions::OperatorAssumptions)
reltol, verbose::LinearVerbosity, assumptions::OperatorAssumptions)
symbfact = _symbolic(A, alg)
cholfact, cholwork = cholinit(A, symbfact)
linwork = lininit(1, cholfact)
Expand Down
4 changes: 2 additions & 2 deletions ext/LinearSolveFastAlmostBandedMatricesExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module LinearSolveFastAlmostBandedMatricesExt
using FastAlmostBandedMatrices, LinearAlgebra, LinearSolve
import LinearSolve: defaultalg,
do_factorization, init_cacheval, DefaultLinearSolver,
DefaultAlgorithmChoice
DefaultAlgorithmChoice, LinearVerbosity

function defaultalg(A::AlmostBandedMatrix, b, oa::OperatorAssumptions{Bool})
if oa.issq
Expand All @@ -21,7 +21,7 @@ for alg in (:SVDFactorization, :MKLLUFactorization, :DiagonalFactorization,
:AppleAccelerateLUFactorization, :CholeskyFactorization, :LUFactorization)
@eval begin
function init_cacheval(::$(alg), ::AlmostBandedMatrix, b, u, Pl, Pr, maxiters::Int,
abstol, reltol, verbose::Bool, assumptions::OperatorAssumptions)
abstol, reltol, verbose::LinearVerbosity, assumptions::OperatorAssumptions)
return nothing
end
end
Expand Down
11 changes: 6 additions & 5 deletions ext/LinearSolveFastLapackInterfaceExt.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module LinearSolveFastLapackInterfaceExt

using LinearSolve, LinearAlgebra
using LinearSolve: LinearVerbosity
using FastLapackInterface

struct WorkspaceAndFactors{W, F}
Expand All @@ -9,7 +10,7 @@ struct WorkspaceAndFactors{W, F}
end

function LinearSolve.init_cacheval(::FastLUFactorization, A, b, u, Pl, Pr,
maxiters::Int, abstol, reltol, verbose::Bool,
maxiters::Int, abstol, reltol, verbose::LinearVerbosity,
assumptions::OperatorAssumptions)
ws = LUWs(A)
return WorkspaceAndFactors(
Expand All @@ -36,26 +37,26 @@ end

function LinearSolve.init_cacheval(
alg::FastQRFactorization{NoPivot}, A::AbstractMatrix, b, u, Pl, Pr,
maxiters::Int, abstol, reltol, verbose::Bool,
maxiters::Int, abstol, reltol, verbose::LinearVerbosity,
assumptions::OperatorAssumptions)
ws = QRWYWs(A; blocksize = alg.blocksize)
return WorkspaceAndFactors(ws,
LinearSolve.ArrayInterface.qr_instance(convert(AbstractMatrix, A)))
end
function LinearSolve.init_cacheval(
::FastQRFactorization{ColumnNorm}, A::AbstractMatrix, b, u, Pl, Pr,
maxiters::Int, abstol, reltol, verbose::Bool,
maxiters::Int, abstol, reltol, verbose::LinearVerbosity,
assumptions::OperatorAssumptions)
ws = QRpWs(A)
return WorkspaceAndFactors(ws,
LinearSolve.ArrayInterface.qr_instance(convert(AbstractMatrix, A)))
end

function LinearSolve.init_cacheval(alg::FastQRFactorization, A, b, u, Pl, Pr,
maxiters::Int, abstol, reltol, verbose::Bool,
maxiters::Int, abstol, reltol, verbose::LinearVerbosity,
assumptions::OperatorAssumptions)
return init_cacheval(alg, convert(AbstractMatrix, A), b, u, Pl, Pr,
maxiters::Int, abstol, reltol, verbose::Bool,
maxiters::Int, abstol, reltol, verbose::LinearVerbosity,
assumptions::OperatorAssumptions)
end

Expand Down
5 changes: 3 additions & 2 deletions ext/LinearSolveForwardDiffExt.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
module LinearSolveForwardDiffExt

using LinearSolve
using LinearSolve: SciMLLinearSolveAlgorithm, __init
using LinearSolve: SciMLLinearSolveAlgorithm, __init, LinearVerbosity
using LinearAlgebra
using ForwardDiff
using ForwardDiff: Dual, Partials
using SciMLBase
using RecursiveArrayTools
using SciMLLogging: Verbosity

const DualLinearProblem = LinearProblem{
<:Union{Number, <:AbstractArray, Nothing}, iip,
Expand Down Expand Up @@ -136,7 +137,7 @@ function __dual_init(
abstol = LinearSolve.default_tol(real(eltype(prob.b))),
reltol = LinearSolve.default_tol(real(eltype(prob.b))),
maxiters::Int = length(prob.b),
verbose::Bool = false,
verbose = LinearVerbosity(Verbosity.None()),
Pl = nothing,
Pr = nothing,
assumptions = OperatorAssumptions(issquare(prob.A)),
Expand Down
Loading
Loading