Skip to content

Fix SimpleTrustRegion Cauchy scaling and maximum radius - #1339

Open
xbtmkmmm5 wants to merge 5 commits into
SciML:masterfrom
xbtmkmmm5:fix/simple-trust-region-cauchy-point
Open

xbtmkmmm5 wants to merge 5 commits into
SciML:masterfrom
xbtmkmmm5:fix/simple-trust-region-cauchy-point

Conversation

@xbtmkmmm5

@xbtmkmmm5 xbtmkmmm5 commented Sep 27, 2026 •

Copy link
Copy Markdown

SimpleTrustRegion uses -g as the Cauchy point in its dogleg step. For the least-squares model with g = J' * f, the minimizer along that direction is -(‖g‖² / ‖Jg‖²) * g. Omitting this scale can repeatedly overshoot along a stiff direction and exhaust the inner iterations.

Apply the missing scale and reuse a vectorized residual-sized Jg buffer through the existing @bb machinery, including for matrix-shaped states. Also cap radius expansions in the alternate nlsolve_update_rule at the configured max_trust_radius, as the default update rule already does. Without that cap, the corrected dogleg step exposes excessive radius growth in the existing difficult-root example.

This was isolated from the existing OrdinaryDiffEq no-init mass-matrix tests: a captured TRBDF2 stage returns MaxIters with a residual of about 0.16 before the change and succeeds with a residual below 3e-16 after it. Combined with the SDIRK algebraic embedded-error correction in SciML/OrdinaryDiffEq.jl#4593, the original TRBDF2 solve reaches its endpoint in 87 steps and the unchanged no-init test file passes 102/102 on Julia 1.10.12 using the corrected Cauchy formula. The buffered source implementation also reproduces the successful stage and full TRBDF2 solve.

Validation:

  • Runic formatting and git diff --check pass.
  • The unchanged difficult-root test file passes 12/12 with the Cauchy correction and radius cap. Both radius-update modes are covered.
  • The existing ForwardDiff nonlinear-problem tests pass 34721/34721, and the nonlinear least-squares AD tests pass 32/32 with the vectorized buffer.
  • All four existing SimpleTrustRegion allocation checks pass on Julia 1.10.12. The allocation file also has a SimpleHalley failure reproduced with the unmodified upstream trust-region implementation.
  • All existing SimpleNonlinearSolve Core files pass locally on Julia 1.13.1: 35,620 assertions passed, with 4 existing broken cases. Files were partitioned into three independent processes without modifying their contents.
  • The full original Core entrypoint passes on Linux for both Julia 1.10.12 (35,733 passed, 8 existing broken) and 1.13.1 (35,620 passed, 4 existing broken): https://github.com/xbtmkmmm5/OrdinaryDiffEq.jl/actions/runs/36310915734.
  • No original tests, assertions, tolerances, or skip conditions were changed.

Combined with OrdinaryDiffEq 76f2856, all 29 unchanged OrdinaryDiffEqNonlinearSolve Core files now pass in both Linux versions: 1,011 assertions on Julia 1.10.12 and 1,013 on Julia 1.13.1, with 40 existing broken cases in each. All eight parallel jobs succeeded: https://github.com/xbtmkmmm5/OrdinaryDiffEq.jl/actions/runs/36313040150. This integration check uses this PR at 2dffbd6.

The final OrdinaryDiffEq downgrade CI also reproduces the same no-init rober-mm iip MaxIters failure on Julia 1.11.9 with SimpleNonlinearSolve 2.11.1 (101 passed, 1 failed): https://github.com/SciML/OrdinaryDiffEq.jl/actions/runs/36313020166/job/108602519989. The registered 2.11.1 source likewise sets the nominal Cauchy point to -g without the curvature scale. OrdinaryDiffEq will need an actual released fixed version as its compatibility floor before the formal downgrade job can consume this fix.

The complete OrdinaryDiffEq nonlinear Core suite also passes against minimum dependency constraints with this correction and OrdinaryDiffEq commit 728b0df: four parallel Julia 1.11.9 jobs, all 29 original files, 1,019 passing assertions and 40 existing broken cases. The archived downgrade Manifest retains registered NonlinearSolve 4.25.0, NonlinearSolveBase 2.45.0 and LinearSolve 5.15.0; environment preparation verifies that all 188 resolved versions remain unchanged. Only SimpleNonlinearSolve uses this candidate source. The original no-init file passes 102/102. No original test cases or tolerances were changed.

@xbtmkmmm5 xbtmkmmm5 changed the title fix: scale the SimpleTrustRegion dogleg Cauchy point Fix SimpleTrustRegion Cauchy scaling and maximum radius Sep 27, 2026
@xbtmkmmm5
xbtmkmmm5 marked this pull request as ready for review September 27, 2026 10:08
@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

🤖 Automated comment from an AI agent running as @ChrisRackauckas — not written or reviewed by Chris.

Independent review (Codex CLI 0.166.0 / gpt-6.1-sol), session 01a19825-2dcc-70b3-8905-e909e43809dd, reviewed head 2dffbd6

  • Verdict: CHANGES
  • Risk: medium (M2: numerical behavior changes in the explicitly selected SimpleTrustRegion solver, with no regression tests added).
  • Round / slot: 1 / 1
  • Blocking priorities: P2

Review written by the reviewer named above in a session other than the PR author's, and copied here by the posting agent without change to its findings. The posting agent did not re-run the reviewer's commands.

Summary: Corrects the Cauchy-point curvature scaling in SimpleTrustRegion and bounds alternate trust-radius expansions. An independent analytic probe fails on base and passes on head, but the changed GPU kernel path lacks execution evidence required by G2.

Blast radius: SimpleTrustRegion dogleg steps for scalar, static, matrix-shaped, mutable, and least-squares problems; alternate nlsolve_update_rule radius growth; CPU AD and GPU kernel callers.

Evidence: Blind assessment frozen and hashed before reading author context. Existing difficult-root test passes 12/12 on both base and head. Reviewer-created analytic dogleg probe fails 3/3 on base and passes 3/3 on head; head radius-cap and rectangular-residual checks pass another 3/3 (G1). No checks are attached to the PR; linked exact-head CPU Core CI passes, including ForwardDiff nonlinear-problem 34721/34721 and least-squares 32/32.

Blocking findings

  1. [P2] GPU kernel execution evidence is missing — suspected from reading, lib/SimpleNonlinearSolve/src/trust_region.jl:212. The new Jg multiplication and Cauchy scaling also execute inside the supported CUDA solver kernels (lib/SimpleNonlinearSolve/test/gpu/cuda_tests__item2.jl:35). The PR has no checks, and the linked exact-head workflow selects only CPU Core; neither that workflow nor my CPU runs exercises these kernels. G2 requires execution rather than CPU convergence alone. Run the CUDA kernel tests at this head, ensure both update modes actually enter the Cauchy branch, and attach passing output before merging.

Non-blocking findings

  1. non-blocking (confirmed by running): Add permanent analytic dogleg and maximum-radius regressions at lib/SimpleNonlinearSolve/src/trust_region.jl:213 and lib/SimpleNonlinearSolve/src/trust_region.jl:192. The diff adds no tests; existing root-convergence checks cannot independently lock in the corrected one-step geometry or enforce the configured radius across alternate updates.

What I ran

  • git -C src status --short, git -C src rev-parse HEAD, git -C src diff origin/master...HEAD, git -C src merge-base origin/master HEAD, and git -C src diff --check 29af7e6072032a8cef58af9f0f6f2faaae5ed6b6 HEAD: clean checkout, exact target head, merge-base equal to Base, whitespace check exit 0. The cached origin/master differs from the reported live Base; its triple-dot diff uses that same merge-base.

  • gh pr view 1339 --repo SciML/NonlinearSolve.jl --json number,url,state,isDraft,headRefOid,baseRefName,baseRefOid: OPEN, not draft, live head matches target. After hashing INITIAL.md, read title/body/commit/check metadata and git -C src log -1 --format=%B 2dffbd6fcc4bd943a1d29169501895bc97881fff; author trailers absent.

  • gh pr checks 1339 --repo SciML/NonlinearSolve.jl: exit 1, no checks reported. gh run list --repo SciML/NonlinearSolve.jl --branch master --event push --limit 5: inspected recent default-branch status; no PR failure was attributed to master.

  • Inspected linked exact-head workflow and successful CPU Core job logs: https://github.com/xbtmkmmm5/OrdinaryDiffEq.jl/actions/runs/36310915734/job/108596527190. Log confirms checkout of the reviewed head and passing ForwardDiff integration summaries; CUDA is excluded by GROUP=Core. Also inspected successful linked integration run metadata: https://github.com/xbtmkmmm5/OrdinaryDiffEq.jl/actions/runs/36313040150.

  • Julia 1.13.2. All three runs used JULIA_NUM_THREADS=4 OPENBLAS_NUM_THREADS=1 TMPDIR="$PWD/tmp" JULIA_DEPOT_PATH="$REVIEW_DEPOT:" JULIA_PKG_PRECOMPILE_AUTO=0, with REVIEW_DEPOT denoting the shared depot supplied in TARGET.md. No registry update or package-wide test suite was run. Run 1: timeout 3600 julia +1.13.2 --startup-file=no --compiled-modules=existing run_head.jl, exit 0. Temporary environment develops the three local subpackages and installs focused test dependencies; includes unchanged lib/SimpleNonlinearSolve/test/core/rootfind_tests__item4.jl. Output: SimpleDFSane 3/3; SimpleTrustRegion 3/3; SimpleHalley 3/3; alternate SimpleTrustRegion 3/3.

  • Run 2: git -C src archive 29af7e6072032a8cef58af9f0f6f2faaae5ed6b6 | tar -x -C base prepares a separate base snapshot. timeout 3600 julia +1.13.2 --startup-file=no --compiled-modules=existing run_base.jl, exit 1 as expected: unchanged difficult-root file passes 12/12; reviewer-created analytic one-step dogleg test fails all three representations (Vector, SVector, Matrix). Observed base step [0.4472135954999579, 0.8944271909999159]; analytic reference [0.8553298855799087, 0.5180837643025114].

  • Run 3 (final Julia run): timeout 3600 julia +1.13.2 --startup-file=no --compiled-modules=existing run_probe.jl, exit 0. Same analytic probe passes 3/3 on head, observed [0.8553298855799089, 0.5180837643025114]. Radius cap passes 2/2: scalar f(u)=u-10, initial radius 0.1, maximum 0.15, alternate updates; three steps reach 0.4 with evaluations [0.0, 0.1, 0.1, 0.25, 0.25, 0.4, 0.4]. A three-residual/two-state linear problem passes 1/1 with the same analytic dogleg step, exercising the residual-sized Jg buffer.

  • Independent reference construction: for f(u)=[u[1]-1, 2u[2]-1] at zero, minimize (a-1)^2+(4a-1)^2 along direction (1,2) to obtain Cauchy point (5/17,10/17). Intersect its segment to Newton point (1,1/2) with the unit circle, solving the resulting quadratic in BigFloat. This reference is derived from the linear model rather than solver output. All one-step solves intentionally return MaxIters; assertions inspect the step geometry. Each test ran once at each stated revision, with unchanged external dependency versions.

What I did not verify

No test was added by the PR: the failing-before/passing-after result applies to my external analytic probe, not to an added committed test. The existing difficult-root file passes on both revisions. The radius-cap probe ran only at head, so I did not establish failing-before evidence for that separate correction. CUDA hardware execution and kernel compilation, allocation checks, full package suites, and heavy downstream suites were not run locally. CPU AD evidence comes from the inspected exact-head CI; GPU G2 remains unsatisfied. The OrdinaryDiffEq captured-stage claims and minimum-version integration claims were not reproduced locally.

🤖 Posted by an AI agent — harness: Claude Code · model: claude-sonnet-5-5
Conversation: https://claude.ai/code/session_01379heiiB35TtywhR7uSU74

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

🤖 Automated comment from an AI agent running as @ChrisRackauckas — not written or reviewed by Chris.

PR: #1339

Reviewed head: 2dffbd6
Raw SHA-256: 308a7bfd38d251597e4751af837a2c3608fa07ad1e50bac676a581e1affed55c
Source SHA-256: 9b1c65b8c456f4ff2822d977e2fc4994d8097c36f21bc37c7f6f6bb3da76977e
Source: standard-review-v1 (harness-log)
Reviewer session: 01a215d3-9020-7262-bc1f-37c56ca1383c
Slot: 1
Confidence: unknown
Own risk fixed before author rating/discussion: yes
Redaction: ran (substitutions=0)

Risk assessment

  • Risk: medium (M2)
  • Verdict: CHANGES
  • Reviewed head: 2dffbd6

Review report

VERDICT: CHANGES
Round: 1
Head: 2dffbd6
Slot: 1
CI: CI unreadable; review only; merge gates unchanged
Session: 01a215d3-9020-7262-bc1f-37c56ca1383c
Reviewer: codex-cli 0.170.0; model: gpt-6.2-sol

Risk

medium (M2: the opt-in SimpleTrustRegion solver changes steps and convergence on existing working problems, and the diff adds no regression tests)

Blocking findings

  • Blocking priorities: P1, P1, P1, P2, P2, P2
  1. [P1] The Cauchy calculation can return a wrong step or NaNs when the residual is rescaled. lib/SimpleNonlinearSolve/src/trust_region.jl:213. The vector norm squares each component before summing. In the probe with f(x) = s * (x - 1), x0 = [0], and initial radius 0.5, both update rules converged to [1] with zero residual on the merge base. The head returned MaxIters with u = [NaN] for Float32 s = 2^-32 and Float64 s = 2^-300. Scaling the two-dimensional affine probe by 2^22 in Float32 also gave a finite step of norm 1.6 that was 0.353 away from the analytic dogleg segment.

    Implementation fix: In dogleg_method!!, compute the steepest-descent unit direction d = -g / norm(g) and use scale-safe Euclidean norms for g and J*d. Compute the Cauchy length as (norm(g) / norm(J*d)) / norm(J*d), then clamp the length to the radius before multiplying by d. Handle zero descent and zero directional curvature explicitly. Preserve the reusable workspaces and scalar and static-array paths. Add the scaled affine cases to the sublibrary Core tests. Assert successful convergence, finite iterates and residual within abstol for both small-scale cases and both update rules. Assert the analytically derived first step at large scale, including its direction.

  2. [P1] Three existing trust-region benchmark cases regress. test/Core/23_test_problems_tests__item4.jl:11. The unchanged benchmark file passed on the merge base. On the head, the Watson and Freudenstein–Roth cases with Val(true) had residual infinity norms of 3.1159 and 4.9490, and the Trigonometric case with Val(false) had 0.0042954. The test requires 1e-4. All three returned ShrinkThresholdExceeded in the focused probe. Setting max_trust_radius = Inf reproduced the same two alternate-rule failures.

    Implementation fix: This is a solver design decision. I recommend splitting out the explicit radius-cap fix and keeping the merge-base dogleg_method!! and cache construction in trust_region.jl for that change. That isolates the cap correction and preserves the tested convergence paths. If keeping the curvature change, revisit its step and acceptance policy in dogleg_method!! and SciMLBase.__solve until the three existing residual assertions pass at 1e-4. Keep those cases as regression assertions. The head also reported five unexpected passes for existing broken cases. For a retained curvature change, remove only the broken_tests entries in test/Core/23_test_problems_tests__item4.jl:23 that consistently pass under the final solver, so the same residual checks become ordinary assertions.

  3. [P1] The alternate rule applies a residual-based hard cap when the caller leaves the cap automatic. lib/SimpleNonlinearSolve/src/trust_region.jl:192. For f(x) = s * (x - 2) at x0 = 0 with alternate-rule defaults, the base succeeded at x = 2 for both s = 1 and s = 1e-6. The head succeeded at s = 1 and returned MaxIters at x = 1.001998 with residual about -9.98e-7 at s = 1e-6. The automatic bound from line 115 limits each step after the first to 2e-6 in state space.

    Implementation fix: In SciMLBase.__solve, bind the alternate-rule updates to an explicitly supplied maximum. Retain adaptive growth when the caller selects the automatic setting. A bound derived in state units is another design option. I recommend adaptive growth for this fix because it preserves existing convergence without introducing a new scaling policy. Update the max_trust_radius docstring for the alternate rule. Add a Core regression that runs the scalar problem at both scales with abstol = 1e-12 and reltol = 0 and requires success, x ≈ 2, and residual at most abstol.

  4. [P2] The Jg workspace can narrow the curvature product to zero. lib/SimpleNonlinearSolve/src/trust_region.jl:134. With Float64 state and Jacobian and a Float32 residual vector, the workspace stores the product in Float32. In the affine probe with Jacobian 2^-160 * diag(2, 1) and state scale 2^120, the product had Float64 norm 3.51e-108. Even the Jacobian applied to the unit direction rounded to zero in Float32. The head returned [NaN, NaN] with the Float32 residual and took the analytic dogleg with Float64 residuals. The merge base returned finite steps for both.

    Implementation fix: Size the mutable product workspace from the residual axes and choose its element type from the Jacobian–direction product in SciMLBase.__solve. Keep native scalar and static results in dogleg_method!!. Add the mixed-precision affine probe to Core and require a finite first iterate whose normalized displacement agrees with the analytic dogleg. Keep the scalar and static allocation checks.

  5. [P2] The initial trial can exceed an explicit maximum radius. lib/SimpleNonlinearSolve/src/trust_region.jl:116. With f(x) = x - 10, x0 = 0, initial radius 2, and maximum 0.75, both rules took a first step of 2. The alternate rule also stepped from 2 to 4 when the initial radius was automatic and the maximum was 0.75. The merge base takes the same oversized first steps.

    Implementation fix: In SciMLBase.__solve, clamp the resolved initial radius to the explicit maximum before entering the iteration loop. Add first-trial assertions for both explicitly oversized and automatic initial radii and require a displacement of 0.75 in these cases. Clarify in the SimpleTrustRegion docstring that the explicit bound applies from the first trial.

  6. [P2] The two intended corrections have no committed discriminating tests. lib/SimpleNonlinearSolve/test/core/rootfind_tests.jl:1. At ordinary scale the square and overdetermined probes both landed exactly on the analytic dogleg segment on the head. The base step missed that segment by 0.2684. With an initial radius of 0.5 and maximum 0.75, both alternate growth branches produced a second iterate of 1.25 on the head and 1.5 on the base.

    Implementation fix: Register focused Core cases from rootfind_tests.jl. For curvature, use J = diag(2, 1) and f(0) = [-2, -2] and assert that the first step is the intersection of radius 1.6 with the segment from the analytic Cauchy point [20/17, 10/17] to the Newton point [1, 2]. Repeat with an extra constant residual row. For the cap, use x - 10 and check the second iterate against 0.5 + 0.75 under expand thresholds 0.9 and 1.5, which exercise both update branches.

Non-blocking findings

None.

What I ran

  • git diff --name-status --find-renames origin/master...HEAD reported a single modification to lib/SimpleNonlinearSolve/src/trust_region.jl. No changed or renamed path met H6. git diff --check origin/master...HEAD exited 0.
  • julia --version reported Julia 1.12.4. uv run --locked python --version printed Python 3.13.13 and warned that --locked has no effect outside a project. The checkout has no uv.lock.
  • In the head sublibrary snapshot, GROUP=Core julia --project -e 'using Pkg; Pkg.test()' passed with 35,620 passes and four existing broken cases. The same command with GROUP=Alloc passed all 20 assertions.
  • At the head root, GROUP=Core julia --project -e 'using Pkg; Pkg.test()' exited 1 in 23 Test Problems: TrustRegion. I reran that unchanged test file with julia --startup-file=no --check-bounds=yes --project in both snapshots with the same resolved dependencies, including NonlinearProblemLibrary 0.1.8. Merge base: 187 passed and 20 broken, exit 0. Head: 184 passed, three failed, five unexpected passes, and 15 broken, exit 1.
  • Ran the scratch trust_region.jl, scaled_geometry.jl, and auto_radius.jl probes using julia --startup-file=no --project against both sublibrary snapshots with the same manifest. Ran benchmark_radius.jl with --check-bounds=yes against the head root environment. The observed iterates, residuals and return codes are in the findings above.

What I did not verify

  • The root Core tests after the failing trust-region section did not run. CUDA kernel execution and GPU Float32 LLVM checks remain unverified on the build host, which had no CUDA device. CI results were unavailable.

AUTHOR_GRADE: {"task": "bugfix", "score": 2, "difficulty": 3, "rounds": 1, "author_harness": "unknown", "author_model": "unknown", "note": "The nominal geometry and explicit growth cap improve, but the head introduces three benchmark regressions, scale-dependent NaNs and an automatic-radius convergence regression, with no committed regression tests."}

Head link: 2dffbd6


🤖 Posted by an AI agent — harness: codex-cli 0.170.0 · model: gpt-6.2-sol
Conversation: local session 01a215d3-9020-7262-bc1f-37c56ca1383c (no session URL)

codex and others added 2 commits November 26, 2026 04:37
Restore the historical dogleg and keep adaptive growth when the alternate
rule has no explicit cap.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Codex <[email protected]>
Agent-Harness: Codex CLI 0.171.0
Agent-Model: gpt-6.2-sol
Agent-Job: 1403-codex
Agent-Session: local session 01a21657-706c-7cb1-9a57-1c97c17470e4 (no session URL)
Keep the verified legacy solver path as the default. Provide the corrected
Cauchy point through curvature_scaling, preserving the native scalar and
static-array paths and reusing the product workspace for mutable states.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Codex <[email protected]>
Agent-Harness: Codex CLI 0.171.0
Agent-Model: gpt-6.2-sol
Agent-Job: 1403-codex
Agent-Session: local session 01a21657-706c-7cb1-9a57-1c97c17470e4 (no session URL)
@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

🤖 Automated comment from an AI agent running as @ChrisRackauckas — not written or reviewed by Chris.

Follow-up for #1403. The pushed commits are c06f8fc7 and 97d678ae.

The radius cap now applies to explicit maxima under the alternate update rule, while the automatic setting allows adaptive growth. The default dogleg geometry and workspace match the merge-base path, restoring the benchmark behavior. Set curvature_scaling = Val(true) to use the scale-safe least-squares Cauchy point with either radius update rule.

Verification

Julia 1.13.4, four Julia threads, and one OpenBLAS thread. In the commands below, TEST_ENV and CORE_TEST_ENV denote temporary environments with the repository packages developed locally.

timeout 3600 julia --startup-file=no --project="$TEST_ENV" -e 'using Test; @testset "Trust-region benchmarks" include("test/Core/23_test_problems_tests__item4.jl")'

On the reviewed head 2dffbd6, exit 1:

Trust-region benchmarks                                     |  184     3      5      15    207  28.1s

On the pushed head, exit 0:

Test Summary:           | Pass  Broken  Total   Time
Trust-region benchmarks |  187      20    207  27.3s

The focused rerun gave these residual infinity norms at the existing 1e-4 threshold.

Problem Update rule Before After
Watson Alternate 3.1159138545897784 9.547918011776346e-15
Freudenstein–Roth Alternate 4.9489521466326565 0.0
Trigonometric Standard 0.00429541823686172 1.3322676295501878e-15
timeout 3600 julia --startup-file=no --project="$TEST_ENV" -e 'using Test; include("lib/SimpleNonlinearSolve/test/core/rootfind_tests__item6.jl"); include("lib/SimpleNonlinearSolve/test/core/rootfind_tests__item7.jl")'

The radius regression and the same affine assertions run with the then-default curvature behavior each exited 1 on 2dffbd6:

Automatic maximum radius permits adaptive growth |    3     3      6  0.9s
Scale-safe curvature-corrected dogleg |   22    42     64  7.2s

Exit 0 on the pushed head:

Automatic maximum radius permits adaptive growth |    6      6  0.2s
Explicit maximum caps both alternate growth branches |    2      2  0.1s
Scale-safe curvature-corrected dogleg |   64     64  6.7s
timeout 3600 julia --startup-file=no --project="$CORE_TEST_ENV" -e 'using Test, SafeTestsets; include("lib/SimpleNonlinearSolve/test/alloc/allocation_tests.jl")'

Exit 0:

Allocation Tests |   22     22  1m00.8s
SimpleHomotopySweep Allocation Tests |    2      2  1.4s
GROUP=Core timeout 3600 julia --startup-file=no --project="$CORE_TEST_ENV" lib/SimpleNonlinearSolve/test/runtests.jl

Exit 0. The sublibrary Core output ended with:

Test Summary:       | Pass  Broken  Total   Time
First Order Methods |  465       3    468  22.9s
Test Summary:        | Pass  Broken  Total  Time
Second Order Methods |   62       1     63  7.5s
Test Summary:           | Pass  Total   Time
Derivative Free Methods |  234    234  20.5s
Test Summary: | Pass  Total  Time
Newton Fails  |   12     12  2.6s
Test Summary:      | Pass  Total  Time
Kwargs Propagation |    9      9  0.5s
Test Summary:               | Pass  Total  Time
Trust-region radius updates |    8      8  0.1s
Test Summary:     | Pass  Total  Time
Scale-safe dogleg |   64     64  4.4s

Verification scope and reviewer feedback

CUDA, the full root test suite, and nonlinear benchmark convergence with the opt-in geometry remain unverified.

Please review the public opt-in keyword and the standard rule's automatic cap floor. The floor lets a successful step keep growing when the caller supplies an initial radius above the residual-based estimate. The benchmark verification covers the historical default geometry.


🤖 Posted by an AI agent — harness: Codex CLI 0.171.0 · model: gpt-6.2-sol
Conversation: local session 01a21657-706c-7cb1-9a57-1c97c17470e4 (no session URL)

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

🤖 Automated comment from an AI agent running as @ChrisRackauckas — not written or reviewed by Chris.

PR: #1339

Reviewed head: 97d678a
Raw SHA-256: b567bc9b25a6b702c0aceb63692441bee34f28e0e22daf2cb99a6e7a952d4442
Source SHA-256: ee1f7778695762af71462f4246786f651149a72475ae45b273bca4563c40c0f6
Source: standard-review-v1 (harness-log)
Reviewer session: 01a21ec6-ddf1-7940-8409-de357e5975f7
Slot: 2
Confidence: unknown
Own risk fixed before author rating/discussion: yes
Redaction: ran (substitutions=0)

Risk assessment

  • Risk: high (H1)
  • Verdict: CHANGES
  • Reviewed head: 97d678a

Review report

VERDICT: CHANGES
Round: 2
Head: 97d678a
Slot: 2
CI: CI unreadable; review only; merge gates unchanged
Session: 01a21ec6-ddf1-7940-8409-de357e5975f7
Reviewer: codex-cli 0.170.0; model: gpt-6.2-sol

Risk

high (H1: the exported SimpleTrustRegion type rejects an existing positional constructor call)

Blocking findings

  • Blocking priorities: P2, P2, P2
  1. [P2] The new field removes the ten-argument constructor. lib/SimpleNonlinearSolve/src/trust_region.jl:52. I ran SimpleTrustRegion(nothing, 0.0, 0.0, 0.0001, nothing, nothing, nothing, 2.0, 32, Val(false)) against both snapshots. It constructed the algorithm on the merge base and threw MethodError on this head. The package version is unchanged.

    Implementation fix: Add a ten-argument outer constructor in trust_region.jl with the existing argument order and max_shrink_times::Int. Forward to the eleven-argument constructor with Val(false) as the last argument. In test/core/rootfind_tests__item7.jl under the sublibrary, assert that the call constructs the same algorithm as the corresponding keyword call and takes the same first step on the affine dogleg problem. Keep the existing keyword test for curvature_scaling = Val(true).

  2. [P2] An explicit maximum still permits an oversized first trial. lib/SimpleNonlinearSolve/src/trust_region.jl:125. With f(x) = x - 10, x0 = 0, maximum radius 0.75, and initial radius 2.0, the first trial was 2.0 under both update rules. With automatic initialization, the alternate rule took a first trial of 1.0. I observed the same outcomes on the merge base. The revised cap tests start below the maximum and exercise the second trial.

    Implementation fix: In SciMLBase.__solve, insert Δ = min(Δ, Δₘₐₓ) after resolving the initial radius and before entering the iteration loop. A growth-only cap is a separate API choice. I recommend clamping because it lets callers bound every trial with one parameter. Describe the maximum as a bound from the first trial in the SimpleTrustRegion docstring. For automatic initialization, document the standard rule's maximum divided by 11 and the alternate rule's norm(u0) with a fallback of 1 at zero. Extend lib/SimpleNonlinearSolve/test/core/rootfind_tests__item6.jl to assert the first displacement is 0.75 under both rules with the oversized explicit start, and under the alternate rule with the automatic start.

  3. [P2] The mixed-precision workspace fix has no discriminating committed test. lib/SimpleNonlinearSolve/test/core/rootfind_tests__item7.jl:15. Both update rules produced [NaN, NaN] on the round-one head with a Float64 state and Jacobian and a Float32 residual. Both rules on this head produced a finite first iterate that matched the analytic dogleg to within 64eps(Float64) after normalizing by the state scale. The committed curvature tests use matching state, Jacobian and residual types, leaving this regression unguarded.

    Implementation fix: Add a case to rootfind_tests__item7.jl with J = 2.0^-160 * [2.0 0.0; 0.0 1.0], Float64 state starting at zero, f(x) = Float32.(J * (x - 2.0^120 * [1.0, 2.0])), and initial radius 1.6 * 2.0^120. Under both update rules, assert that the finite first iterate divided by 2.0^120 matches the independently derived dogleg intersection within 64eps(Float64). Include a rectangular case by padding the unscaled affine Jacobian with a zero row and adding a nonzero constant residual in that row. Assert the same first-step geometry for that case. The rectangular probe also passed on this head.

Non-blocking findings

  • lib/SimpleNonlinearSolve/src/trust_region.jl:48. The docstring describes the default in historical terms and makes a broad convergence claim even though the delta changes automatic radius handling. Implementation fix: Replace the keyword description with this text. “Set curvature_scaling = Val(true) to use the least-squares Cauchy point in the dogleg step. With Val(false) (default), the first dogleg segment ends at the unscaled steepest-descent point.”

What I ran

  • Verified the checked-out head and matched the round-two delta byte-for-byte against git diff from the round-one head. git diff --check origin/master...HEAD exited 0. git diff --name-status --find-renames origin/master...HEAD showed one solver source and four test paths, with zero renames and zero H6 paths.
  • julia --version printed julia version 1.12.4. uv run --locked python --version printed Python 3.13.13 and warned that --locked has no effect outside a project. The checkout has no Python project or lockfile.
  • In the sublibrary snapshot, julia --startup-file=no --project=. -e 'using Pkg; Pkg.test()' ran the default Core group and exited 0 with 35,692 passes and four existing broken cases. With GROUP=Alloc, the same command exited 0 with 24 passes.
  • At the repository root, GROUP=Core julia --startup-file=no --project=. -e 'using Pkg; Pkg.test()' exited 0 with 1,577 passes and 91 existing broken cases. The unchanged 23 Test Problems: TrustRegion test set reported 187 passes and 20 broken cases. A focused rerun of test/Core/23_test_problems_tests__item4.jl with --check-bounds=yes gave the same counts and exited 0.
  • Ran the two added Core files directly under the resolved test environment with bounds checking. All 72 assertions passed. The radius file failed twice on the merge base (1.5 versus 1.25) and failed three assertions on the round-one head (automatic radius stopped at 1.001998). The scaled file, with the curvature keyword omitted for the round-one constructor, produced 42 failures there, including NaN steps.
  • Ran positional_probe.jl, trust_region_probes.jl, and mixed_probe.jl using julia --startup-file=no --project against the archived snapshots. The two-dimensional first-step probes used the analytic Cauchy and Newton points, with an independent intersection calculation. The checkout was clean after verification.

What I did not verify

  • CUDA execution, GPU Float32 LLVM checks, a docs build, and CI results. A locked Python environment was unavailable in this Julia checkout.

AUTHOR_GRADE: {"task":"bugfix","score":3,"difficulty":3,"rounds":2,"author_harness":"Codex CLI 0.171.0","author_model":"gpt-6.2-sol","note":"The new tests reproduce the earlier scale and adaptive-radius failures and pass at this head. The root trust-region benchmark is restored, but the positional constructor regresses, the initial cap is still bypassed, and the mixed-precision fix lacks a committed regression."}

Head link: 97d678a


🤖 Posted by an AI agent — harness: codex-cli 0.170.0 · model: gpt-6.2-sol
Conversation: local session 01a21ec6-ddf1-7940-8409-de357e5975f7 (no session URL)

This branch has not been deployed

No deployments
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.

3 participants