Repository navigation
Add scaling = :auto to MoreTrustRegionDescent - #1300
Merged
ChrisRackauckas merged 3 commits intoSep 22, 2026
Merged
Conversation
Comment on lines
+77
to
+87
| # `scaling = :none`/`:jacobian` shipped as symbols in NonlinearSolveBase v2.52; | ||
| # keep accepting them so that spelling keeps working. | ||
| _more_scaling(s::TrustRegionScaling.T) = s | ||
| function _more_scaling(s::Symbol) | ||
| s === :none && return TrustRegionScaling.None | ||
| s === :jacobian && return TrustRegionScaling.Jacobian | ||
| s === :auto && return TrustRegionScaling.Auto | ||
| return throw( | ||
| ArgumentError("`scaling` must be a `TrustRegionScaling` (`None`, `Jacobian`, \ | ||
| or `Auto`), got `$(s)`.") | ||
| ) |
Member
There was a problem hiding this comment.
Get rid of all symbol use
Member
Author
There was a problem hiding this comment.
Done in a87fb15b2 — _more_scaling(::Symbol) is gone; scaling takes TrustRegionScaling and nothing else (:auto/:jacobian/:none now throw ArgumentError, covered by tests). This intentionally breaks the scaling = :jacobian spelling that shipped in NonlinearSolveBase v2.52.
ChrisRackauckas-Claude
pushed a commit
to ChrisRackauckas-Claude/NonlinearSolve.jl
that referenced
this pull request
Sep 18, 2026
Per review on SciML#1300: `scaling` now takes `TrustRegionScaling` and nothing else — `:none`/`:jacobian`/`:auto` throw `ArgumentError` like any other non-enum value. This knowingly breaks the `scaling = :jacobian` spelling released in NonlinearSolveBase v2.52. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Agent-Harness: Devin CLI 3000.10.21 Agent-Model: SWE-2 Max Agent-Session: /home/crackauc/.local/share/devin/cli/summaries/history_7b3b1ba7a18f464e.md (local transcript)
ChrisRackauckas-Claude
pushed a commit
to ChrisRackauckas-Claude/NonlinearSolve.jl
that referenced
this pull request
Sep 18, 2026
Per review on SciML#1300: `scaling` now takes `TrustRegionScaling` and nothing else — `:none`/`:jacobian`/`:auto` throw `ArgumentError` like any other non-enum value. This knowingly breaks the `scaling = :jacobian` spelling released in NonlinearSolveBase v2.52. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Agent-Harness: Devin CLI 3000.10.21 Agent-Model: SWE-2 Max Agent-Session: /home/crackauc/.local/share/devin/cli/summaries/history_7b3b1ba7a18f464e.md (local transcript)
ChrisRackauckas-Claude
force-pushed
the
auto-jacobian-scaling
branch
from
September 18, 2026 01:59
a87fb15 to
b658609
Compare
Moré's column-norm Jacobian scaling is a large win on badly scaled
least-squares problems but can hurt well-conditioned ones, so a blanket
default is unsafe. `scaling = :auto` makes it adaptive instead: the first
Jacobian's nonzero column norms are gated on a ratio
`maxⱼ‖J[:, j]‖ / minⱼ‖J[:, j]‖ > 20` — above it the solve proceeds exactly
as `:jacobian`, below it exactly as `:none`. The decision latches for the
solve and is re-decided after `reinit!`. Matrix-free Jacobians expose no
column norms, so `:auto` degrades to scaling off there (while `:jacobian`
continues to throw).
The gate is inference-safe: `:auto` sets `has_scaling = Val(true)` and
always allocates a concrete `dtd` diagonal; an inactive gate is `dtd == 1`,
which multiplies through as the identity, so there is no runtime
`Union{Nothing,Vector}` and no new allocations on the `:none`/`:jacobian`
paths. Three Bool fields (`auto_scaling`, `scaling_decided`,
`scaling_active`) carry the gate state, and all `dtd === nothing` /
`has_scaling` branches are audited.
Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Agent-Harness: Devin CLI 3000.10.21
Agent-Model: SWE-2 Max
Agent-Session: /home/crackauc/.local/share/devin/cli/summaries/history_7603fae7ce93404f.md (local transcript)
Match the TrustRegionSubproblem convention: scaling is now a `EnumX.@enumx TrustRegionScaling` with `None`, `Jacobian`, and `Auto` values, stored concretely as `TrustRegionScaling.T` on the algorithm. The `:none`/`:jacobian` symbol spellings shipped in NonlinearSolveBase v2.52, so the constructor still converts them; other values raise ArgumentError. Tests cover the enum API, the legacy spellings, and invalid inputs. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Agent-Harness: Devin CLI 3000.10.21 Agent-Model: SWE-2 Max Agent-Session: /home/crackauc/.local/share/devin/cli/summaries/history_7603fae7ce93404f.md (local transcript)
Per review on SciML#1300: `scaling` now takes `TrustRegionScaling` and nothing else — `:none`/`:jacobian`/`:auto` throw `ArgumentError` like any other non-enum value. This knowingly breaks the `scaling = :jacobian` spelling released in NonlinearSolveBase v2.52. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Agent-Harness: Devin CLI 3000.10.21 Agent-Model: SWE-2 Max Agent-Session: /home/crackauc/.local/share/devin/cli/summaries/history_7b3b1ba7a18f464e.md (local transcript)
ChrisRackauckas-Claude
force-pushed
the
auto-jacobian-scaling
branch
from
September 19, 2026 23:06
b658609 to
64474ba
Compare
ChrisRackauckas
added a commit
that referenced
this pull request
Sep 23, 2026
Ships scaling = :auto for MoreTrustRegionDescent (#1300) and the new TrustRegionRobust kappa-preserving sparse subproblem solves (#1305). Minor because both add API that NonlinearSolveFirstOrder 2.10.0 consumes. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude <[email protected]> Agent-Harness: Claude Code 2.1.273 Agent-Model: claude-opus-5[1m] Agent-Session: 6a01e420-3436-4518-83cc-6cd853283cfb (local transcript; this harness publishes no conversation URL)
ChrisRackauckas
added a commit
that referenced
this pull request
Sep 23, 2026
Ships scaling = :auto for MoreTrustRegionDescent (#1300) and the new TrustRegionRobust kappa-preserving sparse subproblem solves (#1305). Minor because both add API that NonlinearSolveFirstOrder 2.10.0 consumes. Agent-Harness: Claude Code 2.1.273 Agent-Model: claude-opus-5[1m] Agent-Session: 6a01e420-3436-4518-83cc-6cd853283cfb (local transcript; this harness publishes no conversation URL) Co-authored-by: Claude <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
scaling = :jacobian(Moré column-norm scaling) is a large win on badly scaled least-squares problems — on the MGH/HS benchmark tail it cut tp293 223→134 and tp292 135→41 steps — but it hurts well-conditioned ones (tp299 126→197), so it cannot be a blanket default.scaling = TrustRegionScaling.Automakes it adaptive instead:maxⱼ‖J[:,j]‖ / minⱼ‖J[:,j]‖ > 20(implemented on stored squared norms ashi/lo > 20²). Above the threshold the solve proceeds exactly asJacobian; below it exactly asNone.reinit!. Fewer than 2 nonzero columns or an all-zero Jacobian → off.Autodegrades to scaling off (Jacobianstill throws for them).Autosetshas_scaling = Val(true)and always allocates a concretedtd; an inactive gate isdtd == 1, which multiplies through as the identity — no runtimeUnion{Nothing,Vector}and no new allocations on theNone/Jacobianpaths.elseifinsolve!.The
scalingargument is a newEnumX.@enumx TrustRegionScaling(None/Jacobian/Auto), matching theTrustRegionSubproblemconvention. The:none/:jacobiansymbol spellings shipped in NonlinearSolveBase v2.52 are still accepted — the constructor converts them; other values raiseArgumentError.TrustRegionScaling.Noneremains the default —Autois opt-in, so no existing trajectory changes.Test plan
"More subproblem: Auto scaling"testset inleast_squares_tests__item6.jl: directlmparand LU/normal-form paths, bitwise-equal trajectory vsNoneon a well-conditioned problem, gate engagement on a badly scaled one (14 → 3 steps),reinit!re-gating, Krylov LSMR/GMRES matrix-free fallback, scalar and StaticArray cases,@inferredinit/solve!.:none/:jacobian/:autosymbols convert,:bogus/"auto"throwArgumentError.MoreTrustRegionDescent(scaling = TrustRegionScaling.Auto)throwsArgumentErroron unfixed master.least_squares_tests__item6.jl: 117/117 pass.inference_tests__item1.jlclean;operator_jacobian.jl14/14;conditioning_tests__item1/2.jl38/38; umbrellacore_tests__item3.jl16/16.--checkclean;typosclean.Coregroup (long) and GPU/Julia-pre CI lanes.misc_tests__item9.jlhas 4 pre-existing master failures at lines 253–258 (reproduced on unmodified master; unrelated to this diff — fixed in Update tests authored against the Dogleg trust-region default #1302).🤖 Generated with Devin — Agent-Harness: Devin CLI 3000.10.21, Agent-Model: SWE-2 Max. Session transcript (local):
/home/crackauc/.local/share/devin/cli/summaries/history_75aaeac8e79744c6.mdCo-Authored-By: Chris Rackauckas [email protected]