Skip to content

Fix safe-mode stagnation to honor mode.internalnorm (#1310) - #1333

Draft
ChrisRackauckas-Claude wants to merge 6 commits into
SciML:masterfrom
ChrisRackauckas-Claude:fix-1310-stagnation-internalnorm
Draft

ChrisRackauckas-Claude wants to merge 6 commits into
SciML:masterfrom
ChrisRackauckas-Claude:fix-1310-stagnation-internalnorm

Conversation

@ChrisRackauckas-Claude

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

Copy link
Copy Markdown
Member

Summary

Safe termination modes evaluated residual norms via mode.internalnorm but hard-coded L2_NORM for the stagnation step-norm (and RelNorm u0_norm), so custom norms (e.g. MPI reductions) were silently bypassed during stall detection. This patch routes those checks through Utils.apply_norm(mode.internalnorm, …) and adds counting-norm regressions for AbsNorm step norms and RelNorm u0_norm, plus an explicit-L2_NORM stall sanity check.

Behaviour change

Default NonlinearProblem solves use AbsNormSafeBestTerminationMode(Base.Fix1(maximum, abs)) (L∞), not L2. Stagnation previously compared step sizes with hard-coded L2_NORM, so default solves effectively mixed L∞ residuals with L2 stall checks. After this PR, stagnation uses the mode's L∞ norm as well.

Demo (n=100, 40 constant steps of 2e-7 per entry, abstol=1e-6): on master the solve reaches step 40 without stopping; with this PR it returns Stalled at step 33. NonlinearProblemLibrary: 236 solves identical.

Failing before / passing after

AbsNorm step-norm (src fix stashed; regression asserts calls[] == 5):

stagnation uses mode.internalnorm (#1310): Test Failed
  Expression: calls[] == 5
   Evaluated: 3 == 5
Test Summary:                             | Fail  Total
stagnation uses mode.internalnorm (#1310) |    1      1
ERROR: Some tests did not pass: 0 passed, 1 failed, 0 errored, 0 broken.

After (fix restored):

Test Summary:                             | Pass  Total
stagnation uses mode.internalnorm (#1310) |    3      3

RelNorm u0_norm (u0_norm lines temporarily reverted to L2_NORM; expects 3 calls on init and reinit):

init calls = 2
RelNorm u0_norm uses mode.internalnorm (#1310): Test Failed
  Expression: calls[] == 3
   Evaluated: 2 == 3
reinit calls = 2
  Expression: calls[] == 3
   Evaluated: 2 == 3
Test Summary:                                  | Fail  Total
RelNorm u0_norm uses mode.internalnorm (#1310) |    2      2
ERROR: Some tests did not pass: 0 passed, 2 failed, 0 errored, 0 broken.

After (fix restored):

Test Summary:                                  | Pass  Total
RelNorm u0_norm uses mode.internalnorm (#1310) |    2      2

Test group

NONLINEARSOLVE_TEST_GROUP=Core via Pkg.test in lib/NonlinearSolveBase — passed (rerun after review follow-ups).

Tail:

Test Summary:          | Pass  Total  Time
Termination Conditions |   49     49  5.7s
…
     Testing NonlinearSolveBase tests passed

CI notes

Current CI reds on this PR (Adjoint, FirstOrder Core — see #1325 — and two sublibrary QA public-API findings on names this PR does not touch) are pre-existing / unrelated; they are not caused by this change.

Not verified

  • Full root NonlinearSolve.jl Core / All groups
  • Real MPI multi-rank runs with a distributed norm
  • The n=100 Linf-vs-L2 stall demo above was from the independent review, not re-run here

Reviewer pushback

  • Whether RelNorm u0_norm should stay L2 for historical tolerance scaling (this PR uses internalnorm for consistency)
  • Whether default Linf stagnation (Behaviour change) needs a docs note beyond this PR description

Fixes #1310

Please ignore this draft until reviewed by @ChrisRackauckas.

Risk assessment

  • Risk: low (code), with a default-behaviour change to note
  • Blast radius: safe termination modes in NonlinearSolveBase. The stagnation step norm and the RelNorm u0_norm now use mode.internalnorm, so every norm in termination_conditions.jl goes through it. Behaviour change: the default mode's norm is L∞, so default solves now test stagnation in L∞ instead of L2. In the reviewer's demo (n=100, 40 constant steps of 2e-7, abstol 1e-6) the solve returns Stalled at step 33 where master runs on. NonlinearProblemLibrary gave identical results across 236 solves. No public API change, no allocation or inference regression.
  • Evidence: the counting-norm tests fail on master (3 and 2 calls) and pass here (5 and 3). NonlinearSolveBase Core passes. The red CI jobs are unrelated: Adjoint also fails on master, FirstOrder Core is master red on lib/NonlinearSolveFirstOrder GROUP=Core: Enzyme.Compiler.ThunkCallError, bisects to Enzyme v0.13.203 (good) -> v0.13.204 (bad) #1325, and the two sublibrary QA public-API findings are on names this PR doesn't touch.
  • Independent review: Claude Code (Opus 5.5; the author is Cursor Auto), two rounds. Round 1: medium, CHANGES (the behaviour change was undisclosed and a test was missing). Round 2 on bcd2c0e: low, high confidence, MERGE, with one stale-comment nit sent back to the author.
  • Merge: needs human review, only because of the default L∞ stagnation change. The code itself is low-risk.

🤖 Generated with Cursor Agent CLI 2026.09.26-dd393fe (model: auto), transcript /log.txt

Risk assessment and review coordination by 🤖 Claude Code (model: claude-opus-5-5[1m]), https://claude.ai/code/session_01NdFVhANTF4nepTbqYxjfRP

Risk assessment

  • Risk: medium
  • Blast radius: Anyone using a safe termination mode in NonlinearSolveBase, which includes every default NonlinearProblem solve. The default mode is AbsNormSafeBestTerminationMode(Base.Fix1(maximum, abs); max_stalled_steps = 32) (termination_conditions.jl:390). Its stall check used the L2 norm of the step and now uses the L∞ norm. For a vector, L∞ ≤ L2, so large or slow-converging systems can now return Stalled earlier where master kept iterating. Default NonlinearLeastSquaresProblem solves are not affected because their mode's norm is already L2. For RelNorm safe modes with a custom norm, the stall scale u0_norm also changes. MPI and other custom-norm users get the intended fix for Stagnation checks ignore custom norms (problematic for MPI) #1310. Downstream jobs pass on the head commit: MTK Initialization/InterfaceI/InterfaceII, OrdinaryDiffEq InterfaceI/InterfaceII/Regression_I, BoundaryValueDiffEq, DiffEqCallbacks.
  • Evidence: No regressions: every one of the 8 failing checks on head 9aa3c84 also fails on master or on other PRs from the same period.
    • tests / Adjoint, all 4 jobs (julia 1 and lts, ubuntu and macos): pre-existing. All 4 fail on the last three master CI runs (29af7e60, 54e9eea8, 192b11f5).
    • downgrade-sublibraries / test (lib/NonlinearSolveFirstOrder): pre-existing. Master 29af7e60 fails with the same output: 1512 passed, 28 errored, all ThunkCallError at rootfind_tests__item8.jl:30 (SVector OOP). The PR description does not mention this failure.
    • sublibraries / lib/NonlinearSolveFirstOrder Core (Julia 1): pre-existing. Same ThunkCallError errors, tracked in master red on lib/NonlinearSolveFirstOrder GROUP=Core: Enzyme.Compiler.ThunkCallError, bisects to Enzyme v0.13.203 (good) -> v0.13.204 (bad) #1325 (Enzyme 0.13.204). It also fails on master 708f2c7d and 4b5a6162, and on PRs polyalg-fallthrough-stale-subcache, smc/unwrapped-problem-specialization and fix-1288-bounded-lm-enzyme.
    • sublibraries / lib/NonlinearSolveFirstOrder [QA]: pre-existing. The finding is that RobustTrustRegionLinsolve is imported from NonlinearSolveBase but is not public there. It fails on master 708f2c7d/4b5a6162 and on the same three PRs.
    • sublibraries / lib/NonlinearSolveBase [QA]: pre-existing. Two findings: a non-public import of implicit_sensitivity_solve in NonlinearSolveBaseForwardDiffExt, and nlls_solve_adjoint_dp/solve_call are not rendered in the docs. It fails on master 708f2c7d and on the same three PRs. This PR touches none of those names.
    • Master's latest Sublibrary CI run shows green only because path filtering skipped the Base and FirstOrder jobs.
    • NonlinearSolveBase Core passes on Julia lts, 1 and pre. Root Core, Downstream, PolyAlgorithms, Wrappers and QA all pass.
  • Independent review: Devin CLI / fusion-claude-opus-5-5-high-sidekick-swe-2-medium rated it medium, high confidence: the fix is small and correct, CI shows no regression, and the new tests fail before the fix and pass after it, but it silently tightens stall detection for every default NonlinearProblem solve.
    • Code: three lines change, from L2_NORM(...) to Utils.apply_norm(mode.internalnorm, ...). apply_norm is internal to NonlinearSolveBase itself, so no dependency internals are used.
    • Tests and API: 65 test lines are added and none are removed or weakened. No public API signature changes.
    • Disclosure: the PR description does disclose the L2 → L∞ change.
    • Not verified: the n=100 stall demo and the "236 NonlinearProblemLibrary solves identical" result were not reproduced by the author.
    • Not done: there is no NEWS entry, docs note or version bump for the behavior change.
  • Merge: needs human review for these findings:
    1. The default stall check changes from L2 to L∞ for all NonlinearProblem solves (max_stalled_steps = 32), so some solves may now return Stalled earlier. That is user-visible, and a maintainer should decide whether it counts as a bug fix or a behavior change that needs a docs or NEWS note and a minor version bump.
    2. RelNorm safe modes with a custom norm now compute u0_norm with that norm instead of L2, which changes their tolerance scaling. The author also flagged this as an open question.
    3. The PR is still a draft, marked "ignore until reviewed by @ChrisRackauckas", and has no human reviews.
    4. The CI notes in the description leave out the red downgrade-sublibraries FirstOrder job. It is also red on master, so it is not a regression.

🤖 Risk assessment posted by an AI agent (fleet master) — harness: Devin CLI / fusion-claude-opus-5-5-high-sidekick-swe-2-medium; dispatched by Claude Code head, model claude-opus-5-5[1m]
Conversation: local Claude Code session 3cd6500a-1f81-46b5-ac0b-c466e15b6a53 (session ID, no URL)

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

Risk assessment (independent review, Codex gpt-6.1-sol, head a14fb3e)

  • Verdict: CHANGES
  • Rating: Codex gpt-6.1-sol rated it high (H2) at head a14fb3e
  • Risk: high (H2: the default NonlinearProblem safe-best mode changes its stagnation step norm from L2 to L∞, changing termination iterations and returned states on the default path of core NonlinearSolve). Other matched criteria: L2 (added assertions), ML1 (configured-norm contract fix), and M2 (working-path results change); H2 sets the rating.
  • Blast radius: Every regular default root-finding solve, including Newton/trust-region and default polyalgorithm users; explicit safe modes with custom norms; relative safe modes' initial-state scaling and reinitialization. Default least-squares modes already use L2 and retain that norm. No new dependency, dependency-license change, exported name, signature change, or removed/weakened assertion appears in the full diff. No newly public name needs documentation. The configured-norm fix follows the existing contract; I did not establish an H1 documented-API break requiring a major bump. The H2 default-policy change still requires Chris's decision.
  • Evidence: Read the linked issue and full git diff origin/HEAD...HEAD; checked exact-head check-run metadata and failing logs. git diff origin/HEAD...HEAD --check passed; checkout remained clean. Local targeted commands and results, using Julia 1.12.4, JULIA_NUM_THREADS=4, the requested JULIA_DEPOT_PATH, and scratch-local temporary files:
    • Set SCRATCH=<local path>. Archived HEAD and origin/HEAD (8d5e163e724ddfc1232055175dd8fb592915809f) into scratch and used identical resolved dependency versions. Ran timeout 3600 julia --project="$SCRATCH/env" "$SCRATCH/new_tests.jl": 5 passed. Ran the same extracted PR testsets with --project="$SCRATCH/env-base": 2 passed, 3 failed; observed 3 == 5, 2 == 3, and 2 == 3 failures. Logs: scratch/head-tests.log, scratch/base-tests.log.
    • Ran timeout 3600 julia --project="$SCRATCH/env" "$SCRATCH/numerical_probe.jl" and the same command with env-base. For the supplied sequence u_k = fill(k*2e-7,100) and analytic residual f(u)=1e6*(u-8e-6), head's default termination cache stops at 33, Stalled, residual L∞ 1.4; base stops at 40, Success, residual 0. This exercises the default cache with prescribed iterates, not a solver-generated trajectory. Logs: scratch/head-numerical.log, scratch/base-numerical.log.
    • In a scratch-only copy, changed only reinitialization to evaluate the custom norm without assigning it to cache.u0_norm. timeout 3600 julia --project="$SCRATCH/env-mutant" "$SCRATCH/new_tests.jl" still reports 5 passed. This deliberately faulty copy is evidence about test sensitivity, not a defect in the submitted assignment. Log: scratch/mutant-tests.log.
    • G1 FAIL: No added convergence/accuracy regression against an independent reference exercises the changed default/custom-norm stopping decisions. Callback counts and the unchanged explicit-L2 check do not supply that evidence. The prescribed-iterate probe establishes changed behavior, not end-to-end numerical accuracy.
    • G2 FAIL: Exact-head CUDA and Adjoint checks are green, but no multi-rank MPI regression exercises the collective norm/stagnation path that motivates this fix. The PR explicitly lists real MPI runs as unverified. Reactant tracing and MPI-specific code are not added; MPI callback behavior is nevertheless the claimed fix and remains unexercised.
    • G3 FAIL: The relative-mode reinit test counts calls to a constant function; it cannot detect a stale cached norm value. The scratch mutation above demonstrates that gap.
    • Current red CI compared with default-branch evidence: Both root LTS Core errors match master 5476c468 at core_tests__item3.jl:27 (solve!() inference; 8 passed, 1 errored), including identical type-mismatch text. SCC Core matches that same master's isconcretetype(eltype(scc_sol_debug.original)) failure (12 passed, 1 failed). The LTS benchmark log fails resolving SciMLJacobianOperators while explicitly benchmarking its own base revision 8a86577a, before a head comparison. These four reds are not evidence of regressions introduced here. Detailed read-only comparison: scratch/baseline-ci-report.md.
  • Merge: needs changes (G1 numerical-reference regression, G2 multi-rank verification, G3 value-sensitive reinit coverage); after verification, H2 still requires a maintainer decision.

🤖 Posted by an AI agent — harness: Codex CLI 0.162.1 · model: gpt-6.1-sol
Conversation: local headless review run (no public session URL); transcript kept by the fleet master.

🤖 Automated review section from an AI agent running as Chris Rackauckas's account — not written or reviewed by Chris.

Risk assessment (independent review, Codex desktop (runtime 0.164.0-alpha.11.1) gpt-6.1-sol, slot 1, head a14fb3e)

  • Risk: high (H2: Changes default safe-mode stagnation from hard-coded L2 to the configured Linf norm, affecting default numerical stopping.)
  • Verdict: CHANGES
  • Session: 01a18db7-b604-7560-9e84-00a7b7860161
  • Blocking priorities: P2

Review round 1, written by the reviewer named above (Codex desktop (runtime 0.164.0-alpha.11.1) / gpt-6.1-sol) 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: Routes stagnation step norms and relative initial-iterate norms through internalnorm. The implementation passes targeted checks, but committed tests do not detect stale norm state and do not establish changed-default numerical accuracy or the claimed MPI behavior.

Blast radius: Safe/SafeBest termination displacement checks and RelNorm initialization/reinitialization, including the default Linf mode and user-supplied distributed norms.

Evidence: Julia 1.13.0: all five added assertions pass. Restoring exact base init/reinit/safe-call methods fails the AbsNorm route assertion (3 calls instead of 5). An independent 100-component constant-step check has Linf(step)=2e-7, L2(step)=2e-6, abstol=1e-6, and correctly stops at step 33 under the head default. A deliberate stale-value reinit mutant also passes all five committed assertions, then fails an independent cached-value assertion (10 versus 30); this exposes a G3 coverage gap rather than an incorrect submitted assignment.

Blocking findings

  1. [P2] lib/NonlinearSolveBase/test/runtests.jl:188 — Assert the reinitialized cached norm value, not only callback counts (confirmed by running; G3). In a runtime-only mutant, reinit! calls the configured norm but discards its result, leaving u0_norm stale. All five committed assertions still pass. A norm 10*maximum(abs,x), initialized at [1] then reinitialized at [3], leaves 10 rather than the required 30 in the mutant. The submitted assignment itself is correct; the missing value-sensitive regression fails the explicit shared-cache gate. Add differing initialization/reinitialization values and a behavior or cache-value assertion.
  2. [P2] lib/NonlinearSolveBase/test/runtests.jl:140 — Add an end-to-end independent convergence/accuracy regression for the default/custom-norm stopping change (suspected from reading; G1 needs-verification). Counting calls and checking the unchanged explicit-L2 flat-iterate case do not show the accuracy of the changed Linf default. The reviewer's prescribed-iterate Linf/L2 comparison establishes which threshold fires, not end-to-end solver accuracy. Exercise a representative solve against an analytic root or independent reference, with an error bound that catches premature stagnation.
  3. [P2] lib/NonlinearSolveBase/test/runtests.jl:140 — Exercise the distributed norm use case behind issue Stagnation checks ignore custom norms (problematic for MPI) #1310 (suspected from reading; G2 needs-verification). The new tests use a serial constant counting function and no MPI job is demonstrated. Although no MPI implementation is added here, the claimed correction is that a collective norm controls stagnation consistently across ranks. Add or provide a multi-rank test demonstrating consistent termination and no collective mismatch, or explicitly narrow and verify the supported claim with the maintainer.

Non-blocking findings

None.

What I ran

Read the issue #58 review contract, exact-head diff, relevant surrounding code and repository AGENTS.md/CLAUDE.md where present. Initial independent risks/code notes were frozen before fetching author descriptions and discussion. Only review scratch environments were added; tracked source files remain unchanged. Base records the fetched current target branch. The PR metadata reported 8a86577, which equals the verified merge base; the three-dot diff is therefore unchanged. Negative-control methods were compared with the fetched base: they are identical except the SimpleTrustRegion control, which was refreshed and rerun successfully.

git rev-parse HEAD
# a14fb3e5166f67a55bccce370f38c438a154ef79
git diff 8e0acfe279dc30d82bc8eef781d1579064312c07...HEAD
git diff --check 8e0acfe279dc30d82bc8eef781d1579064312c07...HEAD
# exit 0
git merge-tree --write-tree 8e0acfe279dc30d82bc8eef781d1579064312c07 a14fb3e5166f67a55bccce370f38c438a154ef79
# exit 0 (clean merge tree)
git log -1 --no-merges --format=%B
gh pr checks 1333 --repo SciML/NonlinearSolve.jl
gh run list --repo SciML/NonlinearSolve.jl --branch master --event push --limit 5 --json databaseId,headSha,conclusion,url,name,status

Executed both added testsets unchanged: 3/3 stagnation plus 2/2 relative init/reinit assertions, exit 0. Base-method control exits 1 at the first discriminating call-count failure, so its second testset does not run; no passing base claim is made. The analytic default check asserts Stalled at step 33, exit 0. Inspected successful Base Core job 115562242009, failed benchmark/SCC logs, issue #1310 and current base CI. In a separate process, replaced only the reinit assignment with a call that discards the result: both committed testsets still report 3/3 and 2/2, then a value-sensitive check fails (exit 1). No tracked source was edited.

Local Julia commands used Julia 1.13.0, JULIA_NUM_THREADS=4, OPENBLAS_NUM_THREADS=1, a dedicated TMPDIR, an isolated writable depot with existing packages available read-only, and one top-level Julia process at a time. Dependencies were developed into separate scratch projects, never a sublibrary's own project. No full-suite result is inferred from a targeted run. G1: changed-default end-to-end accuracy remains unverified. G2: real MPI callback execution remains unverified. G3: the stale-value mutant demonstrates missing reinit coverage.

Live-head check snapshot: 4 FAILURE, 3 SKIPPED, 93 SUCCESS.

What I did not verify

No real MPI multi-rank run or independent end-to-end convergence/accuracy test for the changed default stopping rule. G1/G2 remain needs-verification, and G3 is not satisfied by call-count-only reinit coverage. Full local Core/QA/downstream suites were not run. The complete initial review was saved before reading the detailed prior same-head assessment, but author summaries were already visible, so the reviewer comparison is not fully blinded.

Targeted harnesses were invoked as julia --startup-file=no --project="$REVIEW_ENV" "$REVIEW_SCRIPT" [base-source-control]; those variables designate the isolated project and source-specific harness described above. These are portable command spellings; the actual invocation used the corresponding concrete scratch paths, which this issue's output format prohibits publishing.

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

🤖 Automated review section from an AI agent running as Chris Rackauckas's account — not written or reviewed by Chris.

Fix by Codex CLI 0.164.0 gpt-6.1-sol (head a09be83)

Merged current master normally, preserving both parents and the existing stagnation changes. The two reported LTS Core failures are the solve!() return-type inference error addressed upstream by #1347. Master’s latest push run passes both affected jobs. This update incorporates that fix without a second implementation or changes to assertions.

Verification

Julia 1.10.12, four threads, one-hour command timeouts. The archived pre-merge source and merged source used the same resolved dependency versions, including SciMLBase 3.58.0.

  • Before: ran the existing test/Core/core_tests__item3.jl from the pre-merge archive, both with normal compilation and with --compiled-modules=no. Both executions exited 1. Eight solve() assertions passed, followed by the same solve!() inference error seen in CI: the concrete solution includes ReturnCode.T while the inferred solution omits that type parameter.
Test Summary:     | Pass  Total   Time
solve() inference |    8      8  25.0s
Test Summary:      | Error  Total  Time
solve!() inference |     1      1  5.5s
  • After: timeout 3600 julia +lts --compiled-modules=no --project -e 'using Test; include("test/Core/core_tests__item3.jl")' exited 0:
Test Summary:     | Pass  Total   Time
solve() inference |    8      8  28.2s
Test Summary:      | Pass  Total   Time
solve!() inference |    8      8  15.4s
  • Full relevant group: GROUP=Core timeout 3600 julia +lts --project -e 'using Pkg; Pkg.test()' exited 0; top-level summaries total 1,587 passing assertions, including all 16 inference assertions. Tail:
Test Summary:                                             | Pass  Total   Time
FastShortcutHomotopyPolyalg + homotopy initialization_alg |   12     12  15.3s
 15.344001 seconds (17.91 M allocations: 1.276 GiB, 2.14% gc time, 99.77% compilation time)
     Testing NonlinearSolve tests passed
  • QA: GROUP=QA timeout 3600 julia +lts --project -e 'using Pkg; Pkg.test()' exited 0:
Test Summary: | Pass  Total     Time
QA            |   26     26  1m36.1s
     Testing NonlinearSolve tests passed
  • Formatting: timeout 3600 julia +1.12 --project=@runic -m Runic --inplace lib/NonlinearSolveBase/src/termination_conditions.jl lib/NonlinearSolveBase/test/runtests.jl exited 0 with no output or changes. Also ran Runic via xargs on all 33 Julia files incorporated by the merge; exit 0, no output or changes.
  • Spelling: git diff --cached --unified=0 | python3 -c 'import sys; print("".join(l[1:] for l in sys.stdin if l.startswith("+") and not l.startswith("+++")), end="")' | typos - --format brief exited 0 with no output before committing. Diff metadata was excluded from spelling input.
  • git diff --cached --check exited 0 before committing.

Not verified locally: macOS, MPI, GPU, downstream suites, docs build, or completion of the new CI run. Existing review findings G1 (independent numerical accuracy), G2 (multi-rank MPI), and G3 (value-sensitive reinitialization coverage) remain outstanding; this update addresses the assigned LTS Core failures only.

Risk assessment

  • Risk: high remains the existing independent rating for the PR’s default stopping-policy change.
  • Blast radius: master merge plus the existing safe-mode norm changes; no additional authored behavior change.
  • Evidence: failing-before/passing-after inference test, full LTS Core and QA passes, formatting and spelling checks.
  • Independent review: pending on this head; prior CHANGES findings remain outstanding.
  • Merge: needs human review; this session does not authorize merging.

Next counted review must come from a smart model in a fresh session, not this fix session (risk.md § Independent reviews).

Links


🤖 Posted by an AI agent — harness: Codex CLI 0.164.0 · model: gpt-6.1-sol
Conversation: local fixer job SciML__NonlinearSolve.jl__1333 (no session URL)

🤖 Automated review section from an AI agent running as Chris Rackauckas's account — not written or reviewed by Chris.

Fix by Codex CLI 0.170.0 gpt-6.2-sol (head b1f9e6e)

Added an end-to-end Newton accuracy regression against a known root for the default and weighted maximum norms. The longer weighted-norm solve distinguishes the stagnation rules. The relative safe-best reinit test now checks the cached norm at both initial states. The two-rank MPI reproduction exercises both absolute safe modes.

Homotopy Continuation CI

Both assigned Julia 1 jobs failed while importing TaylorDiff 0.3.5. Its derivative generator passed a symbolic value into the ChainRules tanh rule, which threw TypeError: non-boolean (Symbolics.Num) used in boolean context. An isolated using TaylorDiff reproduced the failure with TaylorDiff 0.3.5, ChainRules 1.74.13, and Symbolics 7.48.0. Updating only the requested TaylorDiff version to 0.3.6 made that import exit 0 with TaylorDiff loaded.

Master’s Julia 1 Core and QA jobs pass with TaylorDiff 0.3.6 and ChainRules 1.74.13. The original PR checkout also passes both groups with a fresh resolution to TaylorDiff 0.3.6. The fix is in TaylorDiff. Upstream fix · PR failures · Master Core · Master QA

Regression controls

Julia 1.13.3, four threads or fewer and one-hour timeouts. SCRATCH denotes the directory containing the archived master source and isolated local environments.

  • Newton accuracy. timeout 3600 julia +1 --startup-file=no --project="$SCRATCH/master" test/Core/stagnation_tests__item1.jl exited 1. The default solve passed both assertions. The weighted-norm solve returned Stalled and its error was 1.7501326545824839e-6 against the analytic bound 3.0e-13. The same command with --project=. exited 0 with Default | 2 2 and Weighted maximum norm | 2 2.
  • Reinit. timeout 3600 julia +1 --startup-file=no --project="$SCRATCH/reinit-stale" "$SCRATCH/reinit-norm.jl" exited 1 with 3 passed, 1 failed and 10.0 == 30.0. That environment evaluates the norm during reinit and discards its result. The same extracted test with --project="$SCRATCH/mpi-head" exited 0 with RelNorm u0_norm uses mode.internalnorm | 4 4.
  • MPI 0.20.29. timeout 3600 julia +1 --startup-file=no --project="$SCRATCH/mpi-master" "$SCRATCH/run-mpi.jl" "$SCRATCH/mpi-stagnation.jl" exited 1. Each rank reported 6 passed, 2 failed and the gathered stop decisions were [1, 0] while one rank was moving. The same command with --project="$SCRATCH/mpi-head" exited 0, with Collective stagnation norms | 8 8 on each rank. Both ranks continued while either rank moved and both returned Stalled once stationary, in both absolute safe modes.

Full groups and checks

  • Root Core ran GROUP=Core timeout 3600 julia +1 --project -e 'using Pkg; Pkg.test()'. Output included Newton stagnation and accuracy | 4 4 and ended with Testing NonlinearSolve tests passed.
  • Root QA ran GROUP=QA timeout 3600 julia +1 --project -e 'using Pkg; Pkg.test()'. Tail showed QA | 28 28 and Testing NonlinearSolve tests passed.
  • The same Core and QA commands ran from lib/NonlinearSolveBase. Core reported Termination Conditions | 51 51, with Dense LU refactorization allocations | 14 14 in the tail. QA reported QA | 20 20. Both ended with Testing NonlinearSolveBase tests passed.
  • The same Core and QA commands ran from lib/NonlinearSolveHomotopyContinuation at the original PR head. Core reported AllRoots | 116 116, Single Root | 35 35 and Taylor Polynomialize | 40 40. QA reported QA | 19 1 20, with the existing broken persistent-task check. Both ended with Testing NonlinearSolveHomotopyContinuation tests passed.
  • Formatting ran timeout 3600 julia --project=@runic -m Runic --inplace lib/NonlinearSolveBase/test/runtests.jl test/runtests.jl test/Core/stagnation_tests__item1.jl with Julia 1.12.4. Exit 0 with no output.
  • Spelling ran git diff --cached --unified=0 | python3 -c 'import sys; print("".join(line[1:] for line in sys.stdin if line.startswith("+") and not line.startswith("+++")), end="")' | typos - --format brief. It and git diff --cached --check exited 0 with no output.

The separate SCC Core failure also occurs on master with the same abstract NonlinearSolution element type. The local validation covers the assigned Julia 1 jobs and the new regressions. The default L∞ stopping policy still awaits a maintainer decision. Master SCC failure

Two-rank reproducer

Run in an environment with MPI, SciMLBase and the local NonlinearSolveBase source. Save the launcher and test as run-mpi.jl and mpi-stagnation.jl.

using MPI
run(`$(MPI.mpiexec()) -n 2 $(Base.julia_cmd()) --threads=1 --project=$(dirname(Base.active_project())) $(only(ARGS))`)
using MPI
using NonlinearSolveBase: AbsNormSafeTerminationMode, AbsNormSafeBestTerminationMode
using SciMLBase: NonlinearProblem, ReturnCode, init
using Test

MPI.Init()
comm = MPI.COMM_WORLD
rank = MPI.Comm_rank(comm)
@test MPI.Comm_size(comm) == 2
global_norm(x) = MPI.Allreduce(maximum(abs, x), MPI.MAX, comm)

@testset "Collective stagnation norms" begin
    for Mode in (AbsNormSafeTerminationMode, AbsNormSafeBestTerminationMode)
        residual = [4.0]
        u = [1.0]
        step = [2.0 * rank]
        prob = NonlinearProblem((u, p) -> residual, u)
        mode = Mode(global_norm; max_stalled_steps = 1)
        cache = init(prob, mode, residual, u; abstol = 1.0, reltol = 0.0)

        first = cache(residual, u .+ step, u)
        next_u = u .+ 2 .* step
        moving = MPI.Allgather(Int(cache(residual, next_u, u .+ step)), comm)
        stationary = MPI.Allgather(Int(cache(residual, next_u, next_u)), comm)

        @test !first
        @test moving == [0, 0]
        @test stationary == [1, 1]
        @test cache.retcode == ReturnCode.Stalled
    end
end

Next counted review must come from a smart model in a fresh session, not this fix session.


🤖 Posted by an AI agent — harness: Codex CLI 0.170.0 · model: gpt-6.2-sol
Conversation: local session 01a20194-837e-7d62-80ec-c8e36423e0fb (no session URL)

ChrisRackauckas and others added 3 commits September 26, 2026 09:42
Stagnation step-norm (and RelNorm u0_norm) checks hard-coded L2_NORM,
so custom norms such as MPI reductions were bypassed during stall detection.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Cursor Agent <noreply@cursor.com>
Agent-Harness: Cursor Agent CLI 2026.09.26-dd393fe
Agent-Model: auto
Agent-Session: local session, transcript at /home/crackauc/sandbox/goals/issue-backlog/jobs/fix-NonlinearSolve.jl-1310/log.txt on amdci2.julia.csail.mit.edu
…ML#1310)

Document that the L2 stall sanity check is for an explicit L2_NORM mode
(package default is Linf), and assert RelNormSafe* init/reinit routes
u0_norm through mode.internalnorm.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Cursor Agent <noreply@cursor.com>
Agent-Harness: Cursor Agent CLI 2026.09.26-dd393fe
Agent-Model: auto
Agent-Session: local session, transcript at /home/crackauc/sandbox/goals/issue-backlog/jobs/fix-NonlinearSolve.jl-1310/log.txt on amdci2.julia.csail.mit.edu
Keep the present-tense note that the package default is Linf, not L2.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Cursor Agent <noreply@cursor.com>
Agent-Harness: Cursor Agent CLI 2026.09.26-dd393fe
Agent-Model: auto
Agent-Session: local session, transcript at /home/crackauc/sandbox/goals/issue-backlog/jobs/fix-NonlinearSolve.jl-1310/log.txt on amdci2.julia.csail.mit.edu
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Devin <noreply@cognition.ai>
Agent-Harness: Devin CLI 3000.11.3 (conflict resolution), Claude Code 2.1.285 (orchestration)
Agent-Model: fusion-claude-opus-5-5-high-sidekick-swe-2-medium
Agent-Session: local Claude session 3c311569-dda6-4687-bc9f-65febb212c33 (fleet master); Devin log /Users/chrisrackauckas/sandbox/master/fusion-fixes/SciML_NonlinearSolve.jl-1333/log.txt
@ChrisRackauckas

Copy link
Copy Markdown
Member

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

Merged the default branch into this PR (clean merge, no conflicts; head a14fb3e) so CI runs on current master.


🤖 Posted by an AI agent — harness: Devin CLI 3000.11.3 (merge), Claude Code 2.1.285 (posting) · model: fusion-claude-opus-5-5-high-sidekick-swe-2-medium
Conversation: local Claude session 3c311569-dda6-4687-bc9f-65febb212c33 (fleet master)

ChrisRackauckas and others added 2 commits November 9, 2026 22:47
Bring in the upstream return-code type assertion and retain the existing
stagnation norm changes. The LTS inference test fails on the pre-merge
checkout and passes with this merge; full LTS Core and QA also pass.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Codex <noreply@openai.com>
Agent-Harness: Codex CLI 0.164.0
Agent-Model: gpt-6.1-sol
Agent-Session: local fixer job SciML__NonlinearSolve.jl__1333 (no session URL)
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Codex <noreply@openai.com>
Agent-Harness: Codex CLI 0.170.0
Agent-Model: gpt-6.2-sol
Agent-Job: SciML__NonlinearSolve.jl__1333--20261122T044713Z-codex-gpt-6.2-sol
Agent-Session: local session 01a20194-837e-7d62-80ec-c8e36423e0fb (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.

Stagnation checks ignore custom norms (problematic for MPI)

2 participants