Skip to content

Add native BoundedLevenbergMarquardt solver - #1257

Closed
ChrisRackauckas-Claude wants to merge 10 commits into
SciML:masterfrom
ChrisRackauckas-Claude:feature/bounded-lm
Closed

ChrisRackauckas-Claude wants to merge 10 commits into
SciML:masterfrom
ChrisRackauckas-Claude:feature/bounded-lm

Conversation

@ChrisRackauckas-Claude

@ChrisRackauckas-Claude ChrisRackauckas-Claude commented Sep 12, 2026 •

Copy link
Copy Markdown
Member

Adds BoundedLevenbergMarquardt for #1254. An active-set solve minimizes the regularized Gauss–Newton model within the box, followed by a feasible Armijo search and projected-gradient fallback. Damping adapts to model agreement.

The subproblem uses the shared Jacobian and linear-solver caches introduced by the reflective prerequisite. Active variables are constrained through scaling and diagonal augmentation, preserving sparse and operator representations throughout the solve. linsolve, concrete_jac, JVP/VJP backends and callbacks, preconditioning, and reinitialization remain available. The method is opt-in, with its public documentation and minor-version bumps included.

Depends on #1256. The draft targets master and includes its prerequisites; the focused comparison below isolates this method.

Verification

The results below are from the final stacked checkout in #1259, which includes all four methods and the identical shared source used by the prerequisites.

The official NativeBounds group covers all six constructor/globalization choices, sparse analytic and AD Jacobians, operator-only JVP/VJP callbacks, normal-equation and rectangular Krylov solves, preconditioning, scalar/static/mixed shapes, bound-aware differences, and parameter-changing cache reinitialization.

Julia 1.10.11 with the CI minimum dependency set (29 pinned packages), including ADTypes 1.13.0, SciMLBase 3.46.0, SciMLOperators 1.30.0, and the corrected LinearSolve minimum 5.6.0:

GROUP=NativeBounds julia +1.10 --project=scratch/full-min -e 'using Pkg; Pkg.test("NonlinearSolveFirstOrder"; julia_args=["--load=" * abspath("scratch/preload-enzyme.jl")])'
Native bounded methods | 5810   5810  8m26.6s
Testing NonlinearSolveFirstOrder tests passed

Julia 1.13.0 with LinearSolve 5.17.2 and normal precompilation, matching current release CI. Both runs preload Enzyme (preload-enzyme.jl contains only using Enzyme) to cover the reverse-AD backend available in Core:

GROUP=NativeBounds julia +1.13.0 --project=bounded-gn/lib/NonlinearSolveFirstOrder -e 'using Pkg; Pkg.test(; julia_args=["--load=" * abspath("scratch/preload-enzyme.jl")])'
Native bounded methods | 5810   5810  11m09.3s
Testing NonlinearSolveFirstOrder tests passed

Final GROUP=QA runs with Julia 1.12.7 and Pkg.test(; julia_args=["--compiled-modules=existing"]):

--project=lib/NonlinearSolveFirstOrder: QA | 20  20  4m00.5s
--project                           : QA | 28  28  2m53.4s

The full FirstOrder Core group passed on the final source with Julia 1.10.12 and the same minimum-dependency environment. Its 42 top-level test summaries contain 9,144 passing assertions, including all 5,810 NativeBounds assertions:

TMPDIR="$PWD/scratch/tmp" JULIA_NUM_THREADS=1 JULIA_NUM_PRECOMPILE_TASKS=8 JULIA_PKG_PRECOMPILE_AUTO=0 GROUP=Core julia +1.10.12 --project=scratch/full-min -e 'using Pkg; Pkg.test("NonlinearSolveFirstOrder")'
Native bounded methods | 5810   5810  7m43.1s
SciMLOperator Jacobians |   14     14  13.6s
Testing NonlinearSolveFirstOrder tests passed

Runic, typos on changed files, and git diff --check passed.

The full documentation build passed on Julia 1.13.0 with the final source:

env -u GITHUB_PERSONAL_ACCESS_TOKEN JULIA_CONDAPKG_BACKEND=Null JULIA_PYTHONCALL_EXE=/usr/bin/python3 julia +1.13.0 --compiled-modules=existing --project=docs docs/make.jl
[ Info: CheckDocument: running document checks.
[ Info: HTMLWriter: rendering HTML pages.
[ Info: Automatic `version="4.34.0"` for inventory from ../Project.toml

Discriminating regressions

With the original implementation and the new sparse/operator tests, the official group produced 1899 passed, 18 errors:

TrustRegionReflective(...) got unsupported keyword argument "linsolve"

The same representation cases pass in the expanded group above. A later user-supplied FunctionOperator regression exposed use of transpose(J) where an adjoint product is required:

MethodError: no method matching *(::SciMLOperators.TransposedOperator{...}, ::Vector{Float64})
User-supplied Jacobian operators | 4 passed, 1 error

After changing Jacobian products to adjoint(J), that focused test passed 32/32 checks across the four methods, and all six globalization choices are covered in the official group.

The full Core environment loads Enzyme before these tests. Its first run exposed a backend-selection defect and incompatible test instrumentation (2833 passed, 12 errors in the bounded group). The VJP selector now inherits AutoFiniteDiff() unless the user supplies a product backend. The assertion-instrumented ForwardDiff feasibility test explicitly requests finite-difference VJPs; its assertions remain enabled. Automatic reverse-AD with pure residuals remains covered (48/48 operator/reinit checks passed with Enzyme even in the failing run).

A convertible sparse MatrixOperator regression initially failed its storage assertion and then threw MethodError: no method matching copyto!(::FunctionOperator, ...) under a direct solve. Converting through the operator's public matrix interface when a concrete system is requested preserves sparse storage. The focused regression passed 144/144 checks across all six choices, covering default, LU, LSMR, forced concrete LSMR, and reinitialization.

Preconditioner initialization initially received zeros instead of the nonlinear initial state:

Expression: p.u == u0
Evaluated: [0.0, 0.0, 0.0, 0.0] == [0.5, 0.5, 0.5, 0.5]
Initial nonlinear state for preconditioning | 2 passed, 1 failed

Passing the current state into the shared linear-cache constructor made the same focused test pass 3/3 checks; the official suite also asserts the initial callback's state and problem parameters.

GPU paths, downstream packages, and Julia prerelease were not tested locally. No tests were skipped or relaxed for this change. P2 derivative-free and quasi-Newton additions remain deferred pending benchmark demand, following the roadmap.

Julia 1.13 exposed a Dogbox reinitialization regression when cancellation left a coordinate one ulp inside its bound. The focused sparse/LSMR/GMRES reproducer failed 6/9 assertions before the fix and passed 9/9 afterward (all returned Success, maximum solution error at most 6.94e-18). The same cases remain in the unchanged official representation/reinit tests. Dogbox now recognizes coordinate roundoff as well as simultaneous hit-time roundoff when snapping an endpoint.

The downgrade CI failure was separately traced to LinearSolve 5.4's missing rank-deficient QR fallback. LinearSolve 5.6 is now required through the standalone compatibility prerequisite #1261; its existing upstream fallback supplies the fix. Minimum-version testing uses normal precompilation. An independently reported upstream world-age defect affects older LinearSolve versions with precompilation disabled and is fixed in 5.17: SciML/LinearSolve.jl#1282.

Links

Ignore this draft until reviewed by @ChrisRackauckas.

🤖 Generated with Codex CLI 0.154.0 (model: gpt-6-astra). Session: local transcript /home/crackauc/.codex/sessions/2026/09/12/rollout-2026-09-12T04-30-15-01a094bd-179a-7972-97ec-36badb9448cd.jsonl.

Use independent local checkouts and the public AirspeedVelocity API so
Julia LTS can resolve unregistered monorepo sublibrary versions. Publish
comparison tables in the job summary and preserve the result artifacts.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Codex <[email protected]>
Agent-Harness: Codex CLI 0.154.0
Agent-Model: gpt-6-astra
Agent-Session: local transcript /home/crackauc/.codex/sessions/2026/09/12/rollout-2026-09-12T04-30-15-01a094bd-179a-7972-97ec-36badb9448cd.jsonl
ChrisRackauckas and others added 9 commits September 12, 2026 11:05
Add a default Newton regression for a rank-deficient tall Jacobian and
require the first LinearSolve release with the pivoted-QR fallback.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Codex <[email protected]>
Agent-Harness: Codex CLI 0.154.0
Agent-Model: gpt-6-astra
Agent-Session: local transcript /home/crackauc/.codex/sessions/2026/09/12/rollout-2026-09-12T04-30-15-01a094bd-179a-7972-97ec-36badb9448cd.jsonl
Implement scaled and corrected trust-region subproblems with reflected and
Cauchy candidates, feasible differencing, and separate root/KKT termination.
Document dense storage limits and cover native bounds and cache contracts.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Codex <[email protected]>
Agent-Harness: Codex CLI 0.154.0
Agent-Model: gpt-6-astra
Agent-Session: local transcript /home/crackauc/.codex/sessions/2026/09/12/rollout-2026-09-12T04-30-15-01a094bd-179a-7972-97ec-36badb9448cd.jsonl
…thods

Adapt mixed residual/state shapes internally without changing user callbacks.
Cover autodiff, analytic Jacobians, and parameter-changing cache reuse.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Codex <[email protected]>
Agent-Harness: Codex CLI 0.154.0
Agent-Model: gpt-6-astra
Agent-Session: local transcript /home/crackauc/.codex/sessions/2026/09/12/rollout-2026-09-12T04-30-15-01a094bd-179a-7972-97ec-36badb9448cd.jsonl
Reuse the shared Jacobian and LinearSolve caches, including solver options,
preconditioning, and reinitialization. Restrict dense trust-region work to
the projected one- or two-dimensional model.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Codex <[email protected]>
Agent-Harness: Codex CLI 0.154.0
Agent-Model: gpt-6-astra
Agent-Session: local transcript /home/crackauc/.codex/sessions/2026/09/12/rollout-2026-09-12T04-30-15-01a094bd-179a-7972-97ec-36badb9448cd.jsonl
Use a finite-difference Jacobian backend for JVPs and VJPs unless their
backends are explicitly selected. Keep the feasibility assertions outside
reverse AD and verify selection when Enzyme is loaded.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Codex <[email protected]>
Agent-Harness: Codex CLI 0.154.0
Agent-Model: gpt-6-astra
Agent-Session: local transcript /home/crackauc/.codex/sessions/2026/09/12/rollout-2026-09-12T04-30-15-01a094bd-179a-7972-97ec-36badb9448cd.jsonl
Convert operator prototypes through their matrix interface when a concrete
linear system is requested, preserving sparse storage. Exercise default,
LU, and Krylov solves and parameter-changing reinitialization.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Codex <[email protected]>
Agent-Harness: Codex CLI 0.154.0
Agent-Model: gpt-6-astra
Agent-Session: local transcript /home/crackauc/.codex/sessions/2026/09/12/rollout-2026-09-12T04-30-15-01a094bd-179a-7972-97ec-36badb9448cd.jsonl
Pass the current iterate to the shared linear-solver constructor so
preconditioner setup receives the same state and parameters as other
first-order methods. Assert the initial callback values.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Codex <[email protected]>
Agent-Harness: Codex CLI 0.154.0
Agent-Model: gpt-6-astra
Agent-Session: local transcript /home/crackauc/.codex/sessions/2026/09/12/rollout-2026-09-12T04-30-15-01a094bd-179a-7972-97ec-36badb9448cd.jsonl
Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Codex <[email protected]>
Agent-Harness: Codex CLI 0.154.0
Agent-Model: gpt-6-astra
Agent-Session: local transcript /home/crackauc/.codex/sessions/2026/09/12/rollout-2026-09-12T04-30-15-01a094bd-179a-7972-97ec-36badb9448cd.jsonl
Solve the damped box subproblem with an active set and globalize with
a feasible Armijo search and projected-gradient fallback.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Codex <[email protected]>
Agent-Harness: Codex CLI 0.154.0
Agent-Model: gpt-6-astra
Agent-Session: local transcript /home/crackauc/.codex/sessions/2026/09/12/rollout-2026-09-12T04-30-15-01a094bd-179a-7972-97ec-36badb9448cd.jsonl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants