Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
2ce2898
adding verbosity stuff
jClugstor Jul 10, 2025
736b90e
bring back compilation workload
jClugstor Jul 22, 2025
ab22f79
add some toggles
jClugstor Jul 22, 2025
6b18880
use scoped values
jClugstor Jul 22, 2025
02a46d5
imports
jClugstor Jul 22, 2025
4cc5560
use SciMLMessage
jClugstor Jul 22, 2025
a62b908
add more message
jClugstor Jul 23, 2025
f3d8e4b
add defaults
jClugstor Jul 23, 2025
33b8997
use correct names
jClugstor Jul 23, 2025
1b77ca0
fix type of scopedvalue
jClugstor Jul 23, 2025
c123035
these don't need to be mutable
jClugstor Jul 24, 2025
6dcc91f
fix kwargs
jClugstor Jul 24, 2025
48bd8e6
redundant linsolve kwargs
jClugstor Jul 24, 2025
c772d3c
get rid of comments
jClugstor Jul 24, 2025
5d89987
resintate setup workload
jClugstor Jul 24, 2025
e809f9d
get rid of ScopedValues experiment
jClugstor Jul 30, 2025
ff7cea2
add verbose to caches
jClugstor Jul 30, 2025
cdbba29
add verbosity messages, fix constructor
jClugstor Jul 30, 2025
5452f62
imports, other preparations
jClugstor Jul 30, 2025
e312c2c
make sure that LinearVerbosity is passed to linsolve
jClugstor Jul 31, 2025
c7070bf
ensure that LinearVerbosity is passed on in more places
jClugstor Jul 31, 2025
a3703e1
typo, struct should be mutable
jClugstor Jul 31, 2025
89e1a08
turn back messages that don't have access to verbose to warn
jClugstor Jul 31, 2025
edee93c
make sure that verbosity is in polysolve cache
jClugstor Jul 31, 2025
45edae4
add verbosity tests
jClugstor Jul 31, 2025
a549ddf
get rid of stale import, add compat bounds
jClugstor Jul 31, 2025
d293b8a
ensure backwards compatibility
jClugstor Aug 1, 2025
817f3ab
import Verbosity for default verbosity
jClugstor Aug 1, 2025
184c02f
make sure linear kwargs are passed
jClugstor Aug 1, 2025
1bf1d3e
fix kwarg passing
jClugstor Aug 1, 2025
5e5351c
fix numerical verbosity
jClugstor Aug 1, 2025
e8d1449
add backwards compat tests for Bool verbose
jClugstor Aug 1, 2025
cd80d86
change constructors to use kwargs
jClugstor Aug 1, 2025
474d0fa
completely refactor verbosity specifier
jClugstor Oct 20, 2025
df26802
fix @SciMLMessage macro usage
jClugstor Oct 20, 2025
9170758
fix imports, add tests
jClugstor Oct 20, 2025
c4344e3
refactor for new SciMLLogging
jClugstor Oct 20, 2025
0ae7c11
linear should be minimal
jClugstor Oct 21, 2025
3713686
fix imports and exports
jClugstor Oct 21, 2025
75c2155
add SciMLLogging to test target
jClugstor Oct 21, 2025
ba250b0
fix verbosity tests
jClugstor Oct 21, 2025
58840ad
remove bad getproperty
jClugstor Oct 21, 2025
d6ee5c5
bump SciMLLogging
jClugstor Oct 21, 2025
5be94e0
remove unused toggles
jClugstor Oct 21, 2025
643f667
Update Project.toml
ChrisRackauckas Oct 29, 2025
cc41979
Update Project.toml
ChrisRackauckas Oct 29, 2025
eb9bd6a
remove stale imports
jClugstor Oct 29, 2025
14e2e3f
bump versions
jClugstor Oct 29, 2025
78288cd
bump nonlinearsolvebase for downgrade
jClugstor Oct 30, 2025
3991f12
add some docs
jClugstor Nov 3, 2025
bba8e72
add some tests
jClugstor Nov 3, 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
10 changes: 6 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "NonlinearSolve"
uuid = "8913a72c-1f9b-4ce2-8d82-65094dcecaec"
authors = ["SciML"]
version = "4.12.0"
version = "4.13.0"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down Expand Up @@ -85,14 +85,14 @@ LeastSquaresOptim = "0.8.5"
LineSearch = "0.1.4"
LineSearches = "7.3"
LinearAlgebra = "1.10"
LinearSolve = "2.36.1, 3"
LinearSolve = "3.46"
MINPACK = "1.2"
MPI = "0.20.22"
NLSolvers = "0.5"
NLsolve = "4.5"
NaNMath = "1"
NonlinearProblemLibrary = "0.1.2"
NonlinearSolveBase = "2"
NonlinearSolveBase = "2.1"
NonlinearSolveFirstOrder = "1.2"
NonlinearSolveQuasiNewton = "1.8"
NonlinearSolveSpectralMethods = "1.1"
Expand All @@ -106,6 +106,7 @@ Random = "1.10"
ReTestItems = "1.24"
Reexport = "1.2.2"
ReverseDiff = "1.15"
SciMLLogging = "1.3"
SIAMFANLEquations = "1.0.1"
SciMLBase = "2.116"
SimpleNonlinearSolve = "2.1"
Expand Down Expand Up @@ -145,6 +146,7 @@ PolyesterForwardDiff = "98d1487c-24ca-40b6-b7ab-df2af84e126b"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
ReTestItems = "817f1d60-ba6b-4fd5-9520-3cf149f6a823"
ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267"
SciMLLogging = "a6db7da4-7206-11f0-1eab-35f2a5dbe1d1"
SIAMFANLEquations = "084e46ad-d928-497d-ad5e-07fa361a48c4"
SparseConnectivityTracer = "9f842d2f-2579-4b1d-911e-f412cf18a3f5"
SparseMatrixColorings = "0a514795-09f3-496d-8182-132a7b665d35"
Expand All @@ -157,4 +159,4 @@ Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"

[targets]
test = ["Aqua", "BandedMatrices", "BenchmarkTools", "ExplicitImports", "FastLevenbergMarquardt", "FixedPointAcceleration", "Hwloc", "InteractiveUtils", "LeastSquaresOptim", "LineSearches", "MINPACK", "NLSolvers", "NLsolve", "NaNMath", "NonlinearProblemLibrary", "OrdinaryDiffEqTsit5", "PETSc", "Pkg", "PolyesterForwardDiff", "Random", "ReTestItems", "SIAMFANLEquations", "SparseConnectivityTracer", "SparseMatrixColorings", "SpeedMapping", "StableRNGs", "StaticArrays", "Sundials", "Test", "Zygote", "ReverseDiff", "Tracker"]
test = ["Aqua", "BandedMatrices", "BenchmarkTools", "ExplicitImports", "FastLevenbergMarquardt", "FixedPointAcceleration", "Hwloc", "InteractiveUtils", "LeastSquaresOptim", "LineSearches", "MINPACK", "NLSolvers", "NLsolve", "NaNMath", "NonlinearProblemLibrary", "OrdinaryDiffEqTsit5", "PETSc", "Pkg", "PolyesterForwardDiff", "Random", "ReTestItems", "SIAMFANLEquations", "SparseConnectivityTracer", "SparseMatrixColorings", "SpeedMapping", "StableRNGs", "StaticArrays", "Sundials", "Test", "Zygote", "ReverseDiff", "Tracker", "SciMLLogging"]
29 changes: 29 additions & 0 deletions docs/src/basics/solve.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,32 @@ These are exclusively available for native `NonlinearSolve.jl` solvers.
level of detail of the trace. (Defaults to `TraceMinimal()`)
- `store_trace`: Must be `Val(true)` or `Val(false)`. This controls whether the trace is
stored in the solution object. (Defaults to `Val(false)`)

## Verbosity Controls

NonlinearSolve.jl provides fine-grained control over diagnostic messages, warnings, and errors
through the `verbose` keyword argument. The verbosity system allows you to control what
information is displayed during the solve process. See [SciMLLogging.jl](https://docs.sciml.ai/SciMLLogging/dev/) for more details.

```@docs
NonlinearVerbosity
Copy link
Member

Choose a reason for hiding this comment

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

This goes in a manual page. Can you make a follow up PR? Just the quick introduction goes here, the docstring with more information on all of the controls needs a manual page.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, will do

Copy link
Member Author

Choose a reason for hiding this comment

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

```

### Quick Start

```julia
# Use a preset
solve(prob, alg; verbose = NonlinearVerbosity(SciMLLogging.Standard()))

# Silence all messages
solve(prob, alg; verbose = NonlinearVerbosity(SciMLLogging.None()))

# Maximum verbosity
solve(prob, alg; verbose = NonlinearVerbosity(SciMLLogging.All()))

# Custom configuration
solve(prob, alg; verbose = NonlinearVerbosity(
alias_u0_immutable = SciMLLogging.WarnLevel(),
threshold_state = SciMLLogging.InfoLevel()
))
```
2 changes: 1 addition & 1 deletion lib/BracketingNonlinearSolve/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ ConcreteStructs = "0.2.3"
ExplicitImports = "1.10.1"
ForwardDiff = "0.10.36, 1"
InteractiveUtils = "<0.0.1, 1"
NonlinearSolveBase = "2"
NonlinearSolveBase = "2.1"
PrecompileTools = "1.2"
Reexport = "1.2.2"
SciMLBase = "2.116"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using PrecompileTools: @compile_workload, @setup_workload
using Reexport: @reexport

using CommonSolve: CommonSolve, solve
using NonlinearSolveBase: NonlinearSolveBase, AbstractNonlinearSolveAlgorithm
using NonlinearSolveBase: NonlinearSolveBase, AbstractNonlinearSolveAlgorithm, NonlinearVerbosity, @SciMLMessage, AbstractVerbosityPreset
using SciMLBase: SciMLBase, IntervalNonlinearProblem, ReturnCode

abstract type AbstractBracketingAlgorithm <: AbstractNonlinearSolveAlgorithm end
Expand Down
8 changes: 4 additions & 4 deletions lib/BracketingNonlinearSolve/src/bisection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ end

function SciMLBase.__solve(
prob::IntervalNonlinearProblem, alg::Bisection, args...;
maxiters = 1000, abstol = nothing, verbose::Bool = true, kwargs...
maxiters = 1000, abstol = nothing, verbose::NonlinearVerbosity = NonlinearVerbosity(), kwargs...
)
@assert !SciMLBase.isinplace(prob) "`Bisection` only supports out-of-place problems."

Expand All @@ -45,9 +45,9 @@ function SciMLBase.__solve(
end

if sign(fl) == sign(fr)
verbose &&
@warn "The interval is not an enclosing interval, opposite signs at the \
boundaries are required."
@SciMLMessage("The interval is not an enclosing interval, opposite signs at the \
boundaries are required.",
verbose, :non_enclosing_interval)
return SciMLBase.build_solution(
prob, alg, left, fl; retcode = ReturnCode.InitialFailure, left, right
)
Expand Down
18 changes: 14 additions & 4 deletions lib/BracketingNonlinearSolve/src/brent.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,20 @@ struct Brent <: AbstractBracketingAlgorithm end

function SciMLBase.__solve(
prob::IntervalNonlinearProblem, alg::Brent, args...;
maxiters = 1000, abstol = nothing, verbose::Bool = true, kwargs...
maxiters = 1000, abstol = nothing, verbose = NonlinearVerbosity(), kwargs...
)
@assert !SciMLBase.isinplace(prob) "`Brent` only supports out-of-place problems."

if verbose isa Bool
if verbose
verbose = NonlinearVerbosity()
else
verbose = NonlinearVerbosity(None())
end
elseif verbose isa AbstractVerbosityPreset
verbose = NonlinearVerbosity(verbose)
end

f = Base.Fix2(prob.f, prob.p)
left, right = prob.tspan
fl, fr = f(left), f(right)
Expand All @@ -33,9 +43,9 @@ function SciMLBase.__solve(
end

if sign(fl) == sign(fr)
verbose &&
@warn "The interval is not an enclosing interval, opposite signs at the \
boundaries are required."
@SciMLMessage("The interval is not an enclosing interval, opposite signs at the \
Copy link
Member

Choose a reason for hiding this comment

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

Does this support Bool? Or do all of the downstream packages need to lower bound to the new NonlinearSolveBase?

Copy link
Member

Choose a reason for hiding this comment

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

Oh I see the lower bounds, perfect.

boundaries are required.",
verbose, :non_enclosing_interval)
return SciMLBase.build_solution(
prob, alg, left, fl; retcode = ReturnCode.InitialFailure, left, right
)
Expand Down
18 changes: 14 additions & 4 deletions lib/BracketingNonlinearSolve/src/falsi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,20 @@ struct Falsi <: AbstractBracketingAlgorithm end

function SciMLBase.__solve(
prob::IntervalNonlinearProblem, alg::Falsi, args...;
maxiters = 1000, abstol = nothing, verbose::Bool = true, kwargs...
maxiters = 1000, abstol = nothing, verbose = NonlinearVerbosity(), kwargs...
)
@assert !SciMLBase.isinplace(prob) "`False` only supports out-of-place problems."

if verbose isa Bool
if verbose
verbose = NonlinearVerbosity()
else
verbose = NonlinearVerbosity(None())
end
elseif verbose isa AbstractVerbosityPreset
verbose = NonlinearVerbosity(verbose)
end

f = Base.Fix2(prob.f, prob.p)
l, r = prob.tspan # don't reuse these variables
left, right = prob.tspan
Expand All @@ -32,9 +42,9 @@ function SciMLBase.__solve(
end

if sign(fl) == sign(fr)
verbose &&
@warn "The interval is not an enclosing interval, opposite signs at the \
boundaries are required."
@SciMLMessage("The interval is not an enclosing interval, opposite signs at the \
boundaries are required.",
verbose, :non_enclosing_interval)
return SciMLBase.build_solution(
prob, alg, left, fl; retcode = ReturnCode.InitialFailure, left, right
)
Expand Down
8 changes: 4 additions & 4 deletions lib/BracketingNonlinearSolve/src/itp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ end

function SciMLBase.__solve(
prob::IntervalNonlinearProblem, alg::ITP, args...;
maxiters = 1000, abstol = nothing, verbose::Bool = true, kwargs...
maxiters = 1000, abstol = nothing, verbose::NonlinearVerbosity = NonlinearVerbosity(), kwargs...
)
@assert !SciMLBase.isinplace(prob) "`ITP` only supports out-of-place problems."

Expand All @@ -83,9 +83,9 @@ function SciMLBase.__solve(
end

if sign(fl) == sign(fr)
verbose &&
@warn "The interval is not an enclosing interval, opposite signs at the \
boundaries are required."
@SciMLMessage("The interval is not an enclosing interval, opposite signs at the \
boundaries are required.",
verbose, :non_enclosing_interval)
return SciMLBase.build_solution(
prob, alg, left, fl; retcode = ReturnCode.InitialFailure, left, right
)
Expand Down
8 changes: 4 additions & 4 deletions lib/BracketingNonlinearSolve/src/ridder.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ struct Ridder <: AbstractBracketingAlgorithm end

function SciMLBase.__solve(
prob::IntervalNonlinearProblem, alg::Ridder, args...;
maxiters = 1000, abstol = nothing, verbose::Bool = true, kwargs...
maxiters = 1000, abstol = nothing, verbose::NonlinearVerbosity = NonlinearVerbosity(), kwargs...
)
@assert !SciMLBase.isinplace(prob) "`Ridder` only supports out-of-place problems."

Expand All @@ -32,9 +32,9 @@ function SciMLBase.__solve(
end

if sign(fl) == sign(fr)
verbose &&
@warn "The interval is not an enclosing interval, opposite signs at the \
boundaries are required."
@SciMLMessage("The interval is not an enclosing interval, opposite signs at the \
boundaries are required.",
verbose, :non_enclosing_interval)
return SciMLBase.build_solution(
prob, alg, left, fl; retcode = ReturnCode.InitialFailure, left, right
)
Expand Down
11 changes: 6 additions & 5 deletions lib/NonlinearSolveBase/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "NonlinearSolveBase"
uuid = "be0214bd-f91f-a760-ac4e-3421ce2b2da0"
authors = ["Avik Pal <avikpal@mit.edu> and contributors"]
version = "2.0"
version = "2.1"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand All @@ -21,6 +21,7 @@ Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd"
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
SciMLJacobianOperators = "19f34311-ddf3-4b8b-af20-060888a46c0e"
SciMLLogging = "a6db7da4-7206-11f0-1eab-35f2a5dbe1d1"
SciMLOperators = "c0aeaf25-5076-4817-a8d5-81caf7dfa961"
SciMLStructures = "53ae85a6-f571-4167-b2af-e1d143709226"
Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46"
Expand Down Expand Up @@ -54,7 +55,6 @@ NonlinearSolveBaseSparseArraysExt = "SparseArrays"
NonlinearSolveBaseSparseMatrixColoringsExt = "SparseMatrixColorings"
NonlinearSolveBaseTrackerExt = "Tracker"


[compat]
ADTypes = "1.9"
Adapt = "4.1.0"
Expand All @@ -66,15 +66,15 @@ CommonSolve = "0.2.4"
Compat = "4.15"
ConcreteStructs = "0.2.3"
DifferentiationInterface = "0.6.16, 0.7"
EnzymeCore = "0.8"
Enzyme = "0.13.12"
EnzymeCore = "0.8"
ExplicitImports = "1.10.1"
FastClosures = "0.3"
ForwardDiff = "0.10.36, 1"
InteractiveUtils = "<0.0.1, 1"
LineSearch = "0.1.4"
LinearAlgebra = "1.10"
LinearSolve = "3.15"
LinearSolve = "3.46"
Markdown = "1.10"
MaybeInplace = "0.1.4"
Mooncake = "0.4"
Expand All @@ -84,6 +84,7 @@ RecursiveArrayTools = "3"
ReverseDiff = "1.15"
SciMLBase = "2.116"
SciMLJacobianOperators = "0.1.1"
SciMLLogging = "1.3.1"
SciMLOperators = "1.7"
SciMLStructures = "1.5"
Setfield = "1.1.2"
Expand All @@ -92,8 +93,8 @@ SparseMatrixColorings = "0.4.5"
StaticArraysCore = "1.4"
SymbolicIndexingInterface = "0.3.43"
Test = "1.10"
Tracker = "0.2.35"
TimerOutputs = "0.5.23"
Tracker = "0.2.35"
julia = "1.10"

[extras]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@ using ArrayInterface: ArrayInterface
using CommonSolve: CommonSolve, init, solve!
using LinearSolve: LinearSolve, QRFactorization, SciMLLinearSolveAlgorithm
using SciMLBase: ReturnCode, LinearProblem, LinearAliasSpecifier
using SciMLLogging: @SciMLMessage

using LinearAlgebra: ColumnNorm

using NonlinearSolveBase: NonlinearSolveBase, LinearSolveJLCache, LinearSolveResult, Utils
using NonlinearSolveBase: NonlinearSolveBase, LinearSolveJLCache, LinearSolveResult, Utils, NonlinearVerbosity
Copy link
Member

Choose a reason for hiding this comment

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

Is this not passing down the linearverbosity? Seems incorrect.


function (cache::LinearSolveJLCache)(;
A = nothing, b = nothing, linu = nothing,
reuse_A_if_factorization = false, verbose = true, kwargs...
reuse_A_if_factorization = false, kwargs...
)
cache.stats.nsolve += 1

update_A!(cache, A, reuse_A_if_factorization)
b !== nothing && setproperty!(cache.lincache, :b, b)
linu !== nothing && NonlinearSolveBase.set_lincache_u!(cache, linu)

linres = solve!(cache.lincache)
if linres.retcode === ReturnCode.Failure
return LinearSolveResult(; linres.u, success = false)
Expand Down
7 changes: 7 additions & 0 deletions lib/NonlinearSolveBase/src/NonlinearSolveBase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ import SciMLBase: solve, init, __init, __solve, wrap_sol, get_root_indp, isinpla

using SciMLJacobianOperators: JacobianOperator, StatefulJacobianOperator
using SciMLOperators: AbstractSciMLOperator, IdentityOperator
using SciMLLogging: @SciMLMessage, AbstractVerbositySpecifier, AbstractVerbosityPreset, AbstractMessageLevel,
None, Minimal, Standard, Detailed, All, Silent, InfoLevel, WarnLevel

using SymbolicIndexingInterface: SymbolicIndexingInterface
import SciMLStructures
using Setfield: @set!
Expand All @@ -41,6 +44,7 @@ const SII = SymbolicIndexingInterface

include("public.jl")
include("utils.jl")
include("verbosity.jl")

include("abstract_types.jl")
include("common_defaults.jl")
Expand All @@ -54,6 +58,7 @@ include("tracing.jl")
include("wrappers.jl")
include("polyalg.jl")


include("descent/common.jl")
include("descent/newton.jl")
include("descent/steepest.jl")
Expand Down Expand Up @@ -92,6 +97,8 @@ export DescentResult, SteepestDescent, NewtonDescent, DampedNewtonDescent, Dogle

export NonlinearSolvePolyAlgorithm

export NonlinearVerbosity

export pickchunksize

end
1 change: 1 addition & 0 deletions lib/NonlinearSolveBase/src/abstract_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ the cache:
- `maxtime`: the maximum time limit for the solver. (Optional)
- `timer`: the timer for the solver. (Optional)
- `total_time`: the total time taken by the solver. (Optional)
- `verbose`: a verbosity object that contains options determining what log messages are emitted.
"""
abstract type AbstractNonlinearSolveCache <: AbstractNonlinearSolveBaseAPI end

Expand Down
Loading
Loading