Skip to content

TrustRegionRobust: conditioning-preserving sparse subproblem solves - #1305

Merged
ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:tr-robust-sparse
Sep 22, 2026
Merged

ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:tr-robust-sparse

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

Summary

TrustRegionRobust() is a discoverable wrapper around TrustRegion that selects the conditioning-preserving formulation of the Moré subproblem for each Jacobian kind, via a new RobustTrustRegionLinsolve sentinel resolved at init:

  • Sparse-structured Jacobians → LinearSolve.SparseColumnPivotedQRFactorization on the rectangular augmented system [J; √λD] p = [-fu; 0] — a pure-Julia, MIT-licensed, rank-revealing column-pivoted sparse QR (SparseColumnPivotedQR.jl, already a hard dependency of LinearSolve). No JᵀJ is formed, so the κ² conditioning loss of the normal equations never applies, and rank-deficient Jacobians are handled natively by the pivoting.
  • Dense Jacobians → unchanged MINPACK lmpar/qrsolv path (one pivoted QR per Jacobian, then per-λ Givens updates) — already conditioning-preserving.
  • Matrix-free Jacobians → unchanged augmented Krylov operator path.

This is the numerically-robust counterpart to #1299: that PR routes sparse Jacobians to the n×n normal-form path (fast — 102→6 sparse factorizations measured) but forms JᵀJ, squaring the condition number. This PR exposes the κ-preserving formulation as an explicit opt-in for Jacobians ill-conditioned enough that JᵀJ loses digits.

The sentinel requests a concrete Jacobian (needs_concrete_A) so jac_prototype structure can be inspected, and a non-square system (needs_square_A = false) so the augmented path is taken. The solver itself is resolved lazily through NonlinearSolveBaseLinearSolveExt (ext._robust_sparse_qr()), so LinearSolve stays a weak dependency of NonlinearSolveBase and a missing extension only errors when a sparse Jacobian actually needs it.

The augmented sparsity pattern is λ-independent (λ rescales only the D-block values), so SparseColumnPivotedQRFactorization's symbolic analysis is reused across damping trials via the existing lincache/update_A! machinery.

Trade-offs (measured, sparse chained-Rosenbrock fixture)

path outer steps linear solves factorizations
normal-form (default per #1299) 6 6 6
rectangular scpqr (this PR) 11 185 102

Each λ trial refactorizes the (m+n)×n augmented system rather than the n×n normal equations — hence opt-in rather than default. The step-count difference is worth a follow-up look: the rectangular path keeps hitting the trust-region boundary where the normal-form path finds interior GN steps, which may be a benign rank-revealing difference on the λ=0 [J; 0] system.

A further follow-up under investigation: LHLFactorization.jl (already a LinearSolve dep) implements Wilkinson's Hessenberg reduction for shift families (σI + τJ)x = b — (BᵀB + λI) with B = JD⁻¹ is exactly such a family, so one O(n³) reduction could serve all λ trials at O(n²) each, without squaring κ and without per-λ sparse refactorization.

Test plan

  • New TrustRegionRobust testset: sparse J → normal_form === Val{false}, augmented isa SparseMatrixCSC, JᵀJ === nothing, converges; dense J → lmpar path retained (augmented === nothing); invalid subproblem overrides throw ArgumentError
  • Discrimination: TrustRegionRobust is undefined on master (new API); testset passes 89/89 on this branch
  • Full least_squares_tests__item6.jl file: 89/89 pass locally
  • Runic formatting clean; typos clean
  • Full CI groups (Core/GPU/Julia-version lanes) — will run on CI

🤖 Generated with Devin (harness: Devin CLI 3000.10.21, model: SWE-2 Max)
Session: local transcript /home/crackauc/.local/share/devin/cli/summaries/history_7b3b1ba7a18f464e.md

`TrustRegionRobust()` wraps `TrustRegion` with a `MoreTrustRegionDescent`
whose `linsolve` is the new `RobustTrustRegionLinsolve` sentinel, resolved
at `init` once the Jacobian is materialized:

- Sparse-structured Jacobians solve the rectangular augmented system
  `[J; √λD] p = [-fu; 0]` via `LinearSolve.SparseColumnPivotedQRFactorization`
  — a pure-Julia, MIT-licensed, rank-revealing column-pivoted sparse QR.
  The sparsity pattern is λ-independent (λ only rescales values in the
  D-block rows), so the symbolic analysis is reused across damping trials.
  No `JᵀJ` is formed, so the κ² conditioning loss of the normal-equations
  route never applies; rank-deficient Jacobians are handled natively by
  the pivoting.
- Dense Jacobians keep the MINPACK `lmpar`/`qrsolv` path (one pivoted QR
  per Jacobian, Givens updates per λ) — already conditioning-preserving.
- Matrix-free Jacobians keep the augmented Krylov operator path.

The sentinel forces `needs_concrete_A` so a sparse `jac_prototype`
materializes, and `needs_square_A = false` so the rectangular augmented
system is built. Non-square `linsolve` on a genuinely matrix-free problem
errors through the usual path, as before.

Trade-off vs the normal-form route (SciML#1299): each λ trial is a sparse QR
refactorization of the (m+n)×n system instead of a sparse Cholesky of the
n×n normal equations — measured ~9 factorizations/step vs ~1 on the sparse
chained-Rosenbrock fixture — so this is the conditioning-robust option, not
the fast default.

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
ChrisRackauckas merged commit ce7518c into SciML:master Sep 22, 2026
94 of 104 checks passed
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]>
ChrisRackauckas added a commit that referenced this pull request Sep 23, 2026
…Base floor to 2.54

FirstOrder references TrustRegionRobust, which #1305 added to NonlinearSolveBase
2.54.0 and which appears 0 times in the registered 2.53.0. The floor was 2.52.

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
…Base floor to 2.54 (#1313)

FirstOrder references TrustRegionRobust, which #1305 added to NonlinearSolveBase
2.54.0 and which appears 0 times in the registered 2.53.0. The floor was 2.52.



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]>
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