Skip to content

Commit e7aed06

Browse files
ChrisRackauckas-ClaudeChrisRackauckasclaude
authored
Add sensitivity_vjp_choice toggle to NonlinearVerbosity (#755)
Add a new verbosity toggle for controlling sensitivity VJP choice warnings in SciMLSensitivity.jl. This provides fine-grained control over these specific warnings instead of requiring users to silence all verbosity. Changes: - Add sensitivity_vjp_choice toggle to NonlinearVerbosity - Add sensitivity group containing the toggle - Update all presets to include sensitivity_vjp_choice: - None/Minimal: Silent() - Standard/Detailed/All: WarnLevel() - Add AbstractMessageLevel to imports (required by macro) - Add tests for the new toggle and group 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: ChrisRackauckas <[email protected]> Co-authored-by: Claude Opus 4.5 <[email protected]>
1 parent 55e1acc commit e7aed06

File tree

4 files changed

+38
-26
lines changed

4 files changed

+38
-26
lines changed

Project.toml

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ NonlinearSolveQuasiNewton = "9a2c21bd-3a47-402d-9113-8faf9a0ee114"
2222
NonlinearSolveSpectralMethods = "26075421-4e9a-44e1-8bd1-420ed7ad02b2"
2323
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
2424
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
25+
ReTestItems = "817f1d60-ba6b-4fd5-9520-3cf149f6a823"
2526
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
2627
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
2728
SimpleNonlinearSolve = "727e6d20-b764-4bd8-a329-72de5adea6c7"
@@ -43,23 +44,13 @@ SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
4344
SpeedMapping = "f1835b91-879b-4a3f-a438-e4baacf14412"
4445
Sundials = "c3572dad-4567-51f8-b174-8c6c989267f4"
4546

46-
[sources.BracketingNonlinearSolve]
47-
path = "lib/BracketingNonlinearSolve"
48-
49-
[sources.NonlinearSolveBase]
50-
path = "lib/NonlinearSolveBase"
51-
52-
[sources.NonlinearSolveFirstOrder]
53-
path = "lib/NonlinearSolveFirstOrder"
54-
55-
[sources.NonlinearSolveQuasiNewton]
56-
path = "lib/NonlinearSolveQuasiNewton"
57-
58-
[sources.NonlinearSolveSpectralMethods]
59-
path = "lib/NonlinearSolveSpectralMethods"
60-
61-
[sources.SimpleNonlinearSolve]
62-
path = "lib/SimpleNonlinearSolve"
47+
[sources]
48+
BracketingNonlinearSolve = {path = "lib/BracketingNonlinearSolve"}
49+
NonlinearSolveBase = {path = "lib/NonlinearSolveBase"}
50+
NonlinearSolveFirstOrder = {path = "lib/NonlinearSolveFirstOrder"}
51+
NonlinearSolveQuasiNewton = {path = "lib/NonlinearSolveQuasiNewton"}
52+
NonlinearSolveSpectralMethods = {path = "lib/NonlinearSolveSpectralMethods"}
53+
SimpleNonlinearSolve = {path = "lib/SimpleNonlinearSolve"}
6354

6455
[extensions]
6556
NonlinearSolveFastLevenbergMarquardtExt = "FastLevenbergMarquardt"

lib/NonlinearSolveBase/src/NonlinearSolveBase.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import SciMLBase: solve, init, __init, __solve, wrap_sol, get_root_indp, isinpla
2929
using SciMLJacobianOperators: JacobianOperator, StatefulJacobianOperator
3030
using SciMLOperators: AbstractSciMLOperator, IdentityOperator
3131
using SciMLLogging: SciMLLogging, @SciMLMessage, @verbosity_specifier,
32-
AbstractVerbositySpecifier, AbstractVerbosityPreset,
32+
AbstractVerbositySpecifier, AbstractVerbosityPreset, AbstractMessageLevel,
3333
None, Minimal, Standard, Detailed, All, Silent, InfoLevel, WarnLevel
3434

3535
using SymbolicIndexingInterface: SymbolicIndexingInterface

lib/NonlinearSolveBase/src/verbosity.jl

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ diagnostic messages, warnings, and errors during nonlinear system solution.
1515
## Numerical Group
1616
- `threshold_state`: Messages about threshold state in low-rank methods
1717
18+
## Sensitivity Group
19+
- `sensitivity_vjp_choice`: Messages about VJP choice in sensitivity analysis (used by SciMLSensitivity.jl)
20+
1821
## Linear Solver Group
1922
- `linear_verbosity`: Verbosity configuration for linear solvers
2023
@@ -29,7 +32,7 @@ Create a `NonlinearVerbosity` using a preset configuration:
2932
- `SciMLLogging.Detailed()`: Comprehensive debugging information
3033
- `SciMLLogging.All()`: Maximum verbosity
3134
32-
NonlinearVerbosity(; error_control=nothing, numerical=nothing, linear_verbosity=nothing, kwargs...)
35+
NonlinearVerbosity(; error_control=nothing, numerical=nothing, sensitivity=nothing, linear_verbosity=nothing, kwargs...)
3336
3437
Create a `NonlinearVerbosity` with group-level or individual field control.
3538
@@ -62,7 +65,8 @@ NonlinearVerbosity
6265

6366
@verbosity_specifier NonlinearVerbosity begin
6467
toggles = (:linear_verbosity, :non_enclosing_interval, :alias_u0_immutable,
65-
:linsolve_failed_noncurrent, :termination_condition, :threshold_state)
68+
:linsolve_failed_noncurrent, :termination_condition, :threshold_state,
69+
:sensitivity_vjp_choice)
6670

6771
presets = (
6872
None = (
@@ -71,45 +75,51 @@ NonlinearVerbosity
7175
alias_u0_immutable = Silent(),
7276
linsolve_failed_noncurrent = Silent(),
7377
termination_condition = Silent(),
74-
threshold_state = Silent()
78+
threshold_state = Silent(),
79+
sensitivity_vjp_choice = Silent()
7580
),
7681
Minimal = (
7782
linear_verbosity = None(),
7883
non_enclosing_interval = WarnLevel(),
7984
alias_u0_immutable = Silent(),
8085
linsolve_failed_noncurrent = WarnLevel(),
8186
termination_condition = Silent(),
82-
threshold_state = Silent()
87+
threshold_state = Silent(),
88+
sensitivity_vjp_choice = Silent()
8389
),
8490
Standard = (
8591
linear_verbosity = None(),
8692
non_enclosing_interval = WarnLevel(),
8793
alias_u0_immutable = WarnLevel(),
8894
linsolve_failed_noncurrent = WarnLevel(),
8995
termination_condition = WarnLevel(),
90-
threshold_state = WarnLevel()
96+
threshold_state = WarnLevel(),
97+
sensitivity_vjp_choice = WarnLevel()
9198
),
9299
Detailed = (
93100
linear_verbosity = Detailed(),
94101
non_enclosing_interval = WarnLevel(),
95102
alias_u0_immutable = WarnLevel(),
96103
linsolve_failed_noncurrent = WarnLevel(),
97104
termination_condition = WarnLevel(),
98-
threshold_state = WarnLevel()
105+
threshold_state = WarnLevel(),
106+
sensitivity_vjp_choice = WarnLevel()
99107
),
100108
All = (
101109
linear_verbosity = Detailed(),
102110
non_enclosing_interval = WarnLevel(),
103111
alias_u0_immutable = WarnLevel(),
104112
linsolve_failed_noncurrent = WarnLevel(),
105113
termination_condition = WarnLevel(),
106-
threshold_state = InfoLevel()
114+
threshold_state = InfoLevel(),
115+
sensitivity_vjp_choice = WarnLevel()
107116
)
108117
)
109118

110119
groups = (
111120
error_control = (:non_enclosing_interval, :alias_u0_immutable,
112121
:linsolve_failed_noncurrent, :termination_condition),
113-
numerical = (:threshold_state,)
122+
numerical = (:threshold_state,),
123+
sensitivity = (:sensitivity_vjp_choice,)
114124
)
115125
end

test/verbosity_tests.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,24 @@
1616
@test v_none.non_enclosing_interval isa SciMLLogging.Silent
1717
@test v_none.threshold_state isa SciMLLogging.Silent
1818
@test v_none.alias_u0_immutable isa SciMLLogging.Silent
19+
@test v_none.sensitivity_vjp_choice isa SciMLLogging.Silent
1920

2021
@test v_minimal.non_enclosing_interval isa SciMLLogging.WarnLevel
2122
@test v_minimal.alias_u0_immutable isa SciMLLogging.Silent
2223
@test v_minimal.termination_condition isa SciMLLogging.Silent
24+
@test v_minimal.sensitivity_vjp_choice isa SciMLLogging.Silent
2325

2426
@test v_standard.non_enclosing_interval isa SciMLLogging.WarnLevel
2527
@test v_standard.threshold_state isa SciMLLogging.WarnLevel
28+
@test v_standard.sensitivity_vjp_choice isa SciMLLogging.WarnLevel
2629

2730
@test v_detailed.alias_u0_immutable isa SciMLLogging.WarnLevel
2831
@test v_detailed.termination_condition isa SciMLLogging.WarnLevel
32+
@test v_detailed.sensitivity_vjp_choice isa SciMLLogging.WarnLevel
2933

3034
@test v_all.linsolve_failed_noncurrent isa SciMLLogging.WarnLevel
3135
@test v_all.threshold_state isa SciMLLogging.InfoLevel
36+
@test v_all.sensitivity_vjp_choice isa SciMLLogging.WarnLevel
3237
end
3338

3439
@testset "Group-level keyword constructors" begin
@@ -40,6 +45,12 @@
4045

4146
v_numerical = NonlinearVerbosity(numerical = SciMLLogging.Silent())
4247
@test v_numerical.threshold_state isa SciMLLogging.Silent
48+
49+
v_sensitivity = NonlinearVerbosity(sensitivity = SciMLLogging.Silent())
50+
@test v_sensitivity.sensitivity_vjp_choice isa SciMLLogging.Silent
51+
52+
v_sensitivity2 = NonlinearVerbosity(sensitivity = SciMLLogging.InfoLevel())
53+
@test v_sensitivity2.sensitivity_vjp_choice isa SciMLLogging.InfoLevel
4354
end
4455

4556
@testset "Mixed group and individual settings" begin

0 commit comments

Comments
 (0)