Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 0 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ 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,7 +123,6 @@ RecursiveFactorization = "0.2.23"
Reexport = "1.2.2"
SafeTestsets = "0.1"
SciMLBase = "2.70"
SciMLLogging = "1"
SciMLOperators = "1"
Setfield = "1.1.1"
SparseArrays = "1.10"
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::LinearVerbosity, assump::LinearSolve.OperatorAssumptions)
verbose::Bool, assump::LinearSolve.OperatorAssumptions)
lu!(convert(AbstractMatrix, A))
end

Expand Down
89 changes: 0 additions & 89 deletions docs/src/basics/common_solver_opts.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,92 +26,3 @@ 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)
7 changes: 3 additions & 4 deletions ext/LinearSolveAMDGPUExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ module LinearSolveAMDGPUExt

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

# LU Factorization
Expand All @@ -26,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::LinearVerbosity,
maxiters::Int, abstol, reltol, verbose::Bool,
assumptions::OperatorAssumptions)
AMDGPU.rocSOLVER.getrf!(AMDGPU.ROCArray(A))
end
Expand Down Expand Up @@ -58,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::LinearVerbosity,
maxiters::Int, abstol, reltol, verbose::Bool,
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, LinearVerbosity
using LinearSolve: ArrayInterface, BLISLUFactorization, @get_cacheval, LinearCache, SciMLBase
Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
using LinearSolve: ArrayInterface, BLISLUFactorization, @get_cacheval, LinearCache, SciMLBase
using LinearSolve: ArrayInterface, BLISLUFactorization, @get_cacheval, LinearCache,
SciMLBase

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::LinearVerbosity,
maxiters::Int, abstol, reltol, verbose::Bool,
assumptions::OperatorAssumptions)
Comment on lines +207 to 208
Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
maxiters::Int, abstol, reltol, verbose::Bool,
assumptions::OperatorAssumptions)
maxiters::Int, abstol, reltol, verbose::Bool,
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::LinearVerbosity,
maxiters::Int, abstol, reltol, verbose::Bool,
assumptions::OperatorAssumptions)
Comment on lines 212 to 214
Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
function LinearSolve.init_cacheval(alg::BLISLUFactorization, A::AbstractMatrix{<:Union{Float32,ComplexF32,ComplexF64}}, b, u, Pl, Pr,
maxiters::Int, abstol, reltol, verbose::LinearVerbosity,
maxiters::Int, abstol, reltol, verbose::Bool,
assumptions::OperatorAssumptions)
function LinearSolve.init_cacheval(alg::BLISLUFactorization,
A::AbstractMatrix{<:Union{Float32, ComplexF32, ComplexF64}}, b, u, Pl, Pr,
maxiters::Int, abstol, reltol, verbose::Bool,
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, LinearVerbosity
DefaultAlgorithmChoice

# 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::LinearVerbosity, assumptions::OperatorAssumptions)
abstol, reltol, verbose::Bool, assumptions::OperatorAssumptions)
return nothing
end
end
end

function init_cacheval(::LUFactorization, A::BandedMatrix{T}, b, u, Pl, Pr, maxiters::Int,
abstol, reltol, verbose::LinearVerbosity, assumptions::OperatorAssumptions) where {T}
abstol, reltol, verbose::Bool, 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::LinearVerbosity,
Pr, maxiters::Int, abstol, reltol, verbose::Bool,
assumptions::OperatorAssumptions)
return nothing
end
Expand Down
19 changes: 8 additions & 11 deletions ext/LinearSolveCUDAExt.jl
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
module LinearSolveCUDAExt

using CUDA
using CUDA: CuVector, CuMatrix
using LinearSolve: LinearSolve, is_cusparse, defaultalg, cudss_loaded, DefaultLinearSolver,
DefaultAlgorithmChoice, ALREADY_WARNED_CUDSS, LinearCache,
needs_concrete_A,
error_no_cudss_lu, init_cacheval, OperatorAssumptions,
CudaOffloadFactorization, CudaOffloadLUFactorization, CudaOffloadQRFactorization,
CUDAOffload32MixedLUFactorization,
SparspakFactorization, KLUFactorization, UMFPACKFactorization,
LinearVerbosity
SparspakFactorization, KLUFactorization, UMFPACKFactorization
using LinearSolve.LinearAlgebra, LinearSolve.SciMLBase, LinearSolve.ArrayInterface
using LinearAlgebra: LU
using SciMLBase: AbstractSciMLOperator

function LinearSolve.is_cusparse(A::Union{
Expand Down Expand Up @@ -54,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::LinearVerbosity,
maxiters::Int, abstol, reltol, verbose::Bool,
assumptions::OperatorAssumptions)
T = eltype(A)
noUnitT = typeof(zero(T))
Expand All @@ -77,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::LinearVerbosity,
maxiters::Int, abstol, reltol, verbose::Bool,
assumptions::OperatorAssumptions)
qr(CUDA.CuArray(A))
end
Expand All @@ -96,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::LinearVerbosity,
maxiters::Int, abstol, reltol, verbose::Bool,
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::LinearVerbosity, assumptions::OperatorAssumptions)
Pl, Pr, maxiters::Int, abstol, reltol, verbose::Bool, assumptions::OperatorAssumptions)
nothing
end

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

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

Expand Down Expand Up @@ -143,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::LinearVerbosity,
maxiters::Int, abstol, reltol, verbose::Bool,
assumptions::OperatorAssumptions)
# Pre-allocate with Float32 arrays
A_f32 = Float32.(A)
Expand Down
6 changes: 3 additions & 3 deletions ext/LinearSolveCUSOLVERRFExt.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module LinearSolveCUSOLVERRFExt

using LinearSolve: LinearSolve, @get_cacheval, pattern_changed, OperatorAssumptions, LinearVerbosity
using LinearSolve: LinearSolve, @get_cacheval, pattern_changed, OperatorAssumptions
using CUSOLVERRF: CUSOLVERRF, RFLU, CUDA
using SparseArrays: SparseArrays, SparseMatrixCSC, nnz
using CUSOLVERRF.CUDA.CUSPARSE: CuSparseMatrixCSR
Expand All @@ -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::LinearVerbosity, assumptions::OperatorAssumptions)
verbose::Bool, 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::LinearVerbosity, assumptions::OperatorAssumptions)
verbose::Bool, assumptions::OperatorAssumptions)
# Create initial factorization with appropriate options
nrhs = b isa AbstractMatrix ? size(b, 2) : 1
symbolic = alg.symbolic
Expand Down
3 changes: 1 addition & 2 deletions ext/LinearSolveCliqueTreesExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module LinearSolveCliqueTreesExt

using CliqueTrees: symbolic, cholinit, lininit, cholesky!, linsolve!
using LinearSolve
using LinearSolve: LinearVerbosity
using SparseArrays

function _symbolic(A::AbstractMatrix, alg::CliqueTreesFactorization)
Expand All @@ -23,7 +22,7 @@ end

function LinearSolve.init_cacheval(
alg::CliqueTreesFactorization, A::AbstractMatrix, b, u, Pl, Pr, maxiters::Int, abstol,
reltol, verbose::LinearVerbosity, assumptions::OperatorAssumptions)
reltol, verbose::Bool, assumptions::OperatorAssumptions)
Comment on lines 24 to +25
Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
alg::CliqueTreesFactorization, A::AbstractMatrix, b, u, Pl, Pr, maxiters::Int, abstol,
reltol, verbose::LinearVerbosity, assumptions::OperatorAssumptions)
reltol, verbose::Bool, assumptions::OperatorAssumptions)
alg::CliqueTreesFactorization, A::AbstractMatrix, b, u, Pl, Pr, maxiters::Int, abstol,
reltol, verbose::Bool, 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, LinearVerbosity
DefaultAlgorithmChoice

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::LinearVerbosity, assumptions::OperatorAssumptions)
abstol, reltol, verbose::Bool, assumptions::OperatorAssumptions)
return nothing
end
end
Expand Down
11 changes: 5 additions & 6 deletions ext/LinearSolveFastLapackInterfaceExt.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module LinearSolveFastLapackInterfaceExt

using LinearSolve, LinearAlgebra
using LinearSolve: LinearVerbosity
using FastLapackInterface

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

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

function LinearSolve.init_cacheval(
alg::FastQRFactorization{NoPivot}, A::AbstractMatrix, b, u, Pl, Pr,
maxiters::Int, abstol, reltol, verbose::LinearVerbosity,
maxiters::Int, abstol, reltol, verbose::Bool,
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::LinearVerbosity,
maxiters::Int, abstol, reltol, verbose::Bool,
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::LinearVerbosity,
maxiters::Int, abstol, reltol, verbose::Bool,
assumptions::OperatorAssumptions)
return init_cacheval(alg, convert(AbstractMatrix, A), b, u, Pl, Pr,
maxiters::Int, abstol, reltol, verbose::LinearVerbosity,
maxiters::Int, abstol, reltol, verbose::Bool,
assumptions::OperatorAssumptions)
end

Expand Down
Loading
Loading