Repository navigation
Add ModABNewton: ModAB's bisection phase, then NewtonBisection's steps - #1377
ChrisRackauckas wants to merge 10 commits into
Conversation
ModABNewton bisects without derivatives until f looks linear on the bracket by ModAB's test, then continues with NewtonBisection's Newton steps from the end with the smaller |f|. The derivative is the `jac` of the IntervalNonlinearFunction, or comes from the `autodiff` backend. Derivatives are only used near the root, so it needs fewer derivative evaluations than NewtonBisection, and at multiple roots, where ModAB's linearity test does not pass, it stays with bisection. The Newton loop of NewtonBisection is split out as `newton_bisection_steps` so that both use it. The ForwardDiff extension handles it like the other methods. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude <noreply@anthropic.com> Agent-Harness: Claude Code cloud Agent-Model: withheld (the harness forbids model identifiers in commits) Agent-Session: https://claude.ai/code/session_01HJLdhiuK5ih88KyZciWTEH
|
(AI-generated, Claude Code cloud session: https://claude.ai/code/session_01HJLdhiuK5ih88KyZciWTEH) The red Tests - Core (Julia lts) check fails on Generated by Claude Code |
Core LTS classification at 8121a006: pre-existing on master, fixed on current master. Both Linux and macOS fail Links:
🤖 Posted by an AI agent — harness: Codex CLI · model: gpt-6.1-sol |
Integrate the Julia LTS inference corrections while preserving author commits. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Codex <noreply@openai.com> Agent-Harness: Codex CLI 0.163.0 Agent-Model: gpt-6.1-sol Agent-Session: local session 01a1556d-e323-7f00-82fb-6d484033f65a (no session URL)
Use the existing safe midpoint when adding the endpoints overflows. Select midpoint arithmetic by algorithm in the shared Newton safeguard so ModABNewton uses the same fallback in both phases and NewtonBisection retains its arithmetic. Test analytic roots and bracket containment across signs, scales, interval orderings, and derivative modes. Runtime: codex-cli 0.163.0. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Codex <noreply@openai.com> Agent-Harness: Codex CLI 0.163.0 Agent-Model: gpt-6.1-sol Agent-Session: local session 01a1556d-e323-7f00-82fb-6d484033f65a (no session URL)
d92b280 to
66a3702
Compare
Share the overflow-guarded midpoint between the Newton methods and reject undefined residuals before updating the enclosing interval. Keep derivative-free Dual wrapping efficient, give derivative callbacks an explicit out-of-place trait, and validate unavailable AD backends on the Dual path. Add analytic containment, failure, allocation, and inference regressions to the official Bracketing runner. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Codex <noreply@openai.com> Agent-Harness: Codex CLI 0.163.0 Agent-Model: gpt-6.1-sol Agent-Session: local session 01a1556d-e323-7f00-82fb-6d484033f65a (no session URL)
Taking this — Codex CLI 0.163.0, model gpt-6.1-sol (job 1377-codex). 🤖 Posted by an AI agent — harness: Codex CLI 0.163.0 · model: gpt-6.1-sol |
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Codex <noreply@openai.com> Agent-Harness: Codex CLI 0.163.0 Agent-Model: gpt-6.1-sol Agent-Session: local job 1377-codex (no session URL)
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Codex <noreply@openai.com> Agent-Harness: Codex CLI 0.163.0 Agent-Model: gpt-6.1-sol Agent-Session: local job 1377-codex (no session URL)
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Codex <noreply@openai.com> Agent-Harness: Codex CLI 0.163.0 Agent-Model: gpt-6.1-sol Agent-Session: local job 1377-codex (no session URL)
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Codex <noreply@openai.com> Agent-Harness: Codex CLI 0.163.0 Agent-Model: gpt-6.1-sol Agent-Session: local job 1377-codex (no session URL)
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Codex <noreply@openai.com> Agent-Harness: Codex CLI 0.163.0 Agent-Model: gpt-6.1-sol Agent-Session: local job 1377-codex (no session URL)
Describe derivative savings as dependent on the function and bracket rather than a guarantee. The atan counterexample uses 12 derivative calls versus 8 for NewtonBisection while both methods find the same root. 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__1377 (no session URL)
Adds ModABNewton, which bisects until ModAB's linearity test passes, then uses safeguarded Newton steps. Its prerequisite branches own the Newton safeguards and the Dual-wrapper fixes, so this layer contains the algorithm, documentation and its own tests. The study reports marginal function-evaluation gains and fewer derivative calls; whether this public method is worth merging remains Chris's decision.
Please ignore until reviewed by @ChrisRackauckas. Part of #1377 (#1377).
Failing before / passing after
Integer inputs use positive, negative and reversed brackets, default and zero absolute tolerance, analytic and ForwardDiff derivatives. The unchanged fixture has 32 errors before normalization, and 128 passing assertions after it. Signed
sqrt(big(2))supplies an independent root reference.The cached-Jacobian fixture stores
2xin the residual callback and asserts that every Jacobian call uses that same point. The unchanged test fails 12 ordering assertions before the handoff refresh and passes afterward. The number of derivative calls changes because the cached derivative becomes correct; no assertions or tolerances were weakened.Verification
NONLINEARSOLVE_TEST_GROUP=Core julia +1.12 --project=lib/BracketingNonlinearSolve -e 'using Pkg; Pkg.test()'NONLINEARSOLVE_TEST_GROUP=QA julia +1.12 --project=lib/BracketingNonlinearSolve -e 'using Pkg; Pkg.test()'Root QA,
GROUP=QA julia +1.10 --project="$ROOT_VALIDATION_ENV" -e 'using Pkg; Pkg.test("NonlinearSolve")':Validation environments were separate local environments. For Julia 1.10, SciMLBase 3.58 was added first, then the local sublibraries and root were developed. Formatting and spelling were checked with Runic,
git diff --check, andtypos --config .typos.tomlon the staged diff.Stack and coverage
The owned prerequisite branches contain the numerical and wrapper fixes, with failing-before/passing-after evidence in #1375 and #1376. This PR reuses their scale, NaN and allocation fixtures by adding ModABNewton to constructor loops. Both final Core runs retain all 24,719 assertions, including 1,413 method-specific assertions.
The ModABNewton follow-up normalizes integer brackets before derivative preparation and refreshes a user residual cache before requesting a derivative at an older endpoint. The shared floating-bracket helper belongs to the Newton prerequisite. The docstrings explicitly import
ADTypes: AutoForwardDiff; source history is preserved with normal merge commits.Documentation
julia +1.12 --project="$DOCS_ENV" docs/make.jlThe build on
377e506dexited zero. It reports HTML/search-size warnings and SVG fallbacks for large examples with unchanged build settings. The separate docs environment develops this checkout and its local sublibraries.Root Core LTS
The run on
377e506dpassed 1,572 assertions with 91 existing broken assertions across 82 testsets. No broken or skipped markers were added.Not verified
GPU, downstream, prerelease, other platforms, and a complete downgrade matrix were not rerun locally. The stack raises the SciMLBase minimum to 3.57, which exposes the SCC downgrade incompatibility; the base selection at 3.46 passes. This remains blocked on the open compatible SCC prerequisite; no tests were weakened or silenced. Full study wall-time benchmarks were not rerun.
Reviewer decisions
Chris retains the public API decision, acceptance of the two MIT dependencies in the AD layer, the value of adding ModABNewton, and how the original NewtonBisection branch should integrate master. No changes are pushed to that original author's branch. The cache-safe handoff adds one residual evaluation when it selects an older endpoint; a reviewer should assess that cost against the shared-computation callback benefit. The study benchmarks were not rerun after this change.
Independent review
Fresh Codex CLI 0.163.0 / gpt-6.1-sol review of 377e506d against the actual AD base returned CHANGES, medium-low ML7. Session: local session 01a15d0f-d831-7621-b61b-d7bcf6569b5b (no session URL). Its sole blocker is the inherited SCC compatibility prerequisite: an independent exact-minimum probe fails the solution-original concreteness invariant with SciMLBase 3.57, passes on the archived base at 3.46, and agrees with the retrieved SCC downgrade log. The prerequisite remains open.
The reviewer independently reproduced Core 24,719 on each Julia version, sub QA 20/root QA 26, root Core LTS 1,572 passes with 91 existing broken assertions, and docs exit zero. Its head probes pass 128 integer, 104 cache-ordering and 48 additional analytic root/derivative assertions. In-memory negative controls independently reproduce the 32 integer errors and 12 cache-ordering failures. No additional numerical blocker was found; placement, retained coverage, normal merges, Runic, spelling and whitespace were checked.
Its non-blocking request concerns the older body captured when the review began: it still listed 24,487 tests and runtime equality with
930625dd. The current body reports 24,719 and describes the integer/cache changes explicitly; it makes no runtime-equality claim. The fresh AD review also independently tests this final head and confirms both fixes. AD review summary.Earlier reviewers confirmed two inherited shared follow-ups: sensitivity secant sampling outside tiny brackets with captured Dual state, and Float32 Dual reconstruction with a Float64-promoting residual. Neither is claimed fixed here. No clean stack verdict is claimed while SCC is unresolved.
Downstream CI classification
All three current heads fail ModelingToolkit InterfaceI at the same causal-connection equation orientation assertion,
lib/ModelingToolkitBase/test/components.jl:446: multiplicity, AD, ModABNewton. Each actual log selects 207f39e2, the merge of SciML/ModelingToolkit.jl#5295. ModelingToolkit's own master CI fails the identical assertion without this stack. The older passing NonlinearSolve base integration uses an earlier downstream revision and Symbolics/SymbolicUtils versions. All comparison logs were read.CI rechecked 2026-10-21 22:40 UTC: ModABNewton and its actual AD base each have 56 successful checks and the same single ModelingToolkit failure; multiplicity has 80 successes, the ModelingToolkit and SCC failures, and three skips. No checks remain pending. The latest ModelingToolkit master InterfaceI run at fe189a7e still fails the identical assertion (1,590 passed, one failed, three broken); its actual log was read. The routed CHANGES verdict remains blocked on the separate, unmerged SCC prerequisite. No new source commit or push is claimed for this audit. AD Ubuntu LTS Core reports success on the current AD head. No causal-connection test is changed. This upstream failure is separate from the SCC downgrade compatibility regression exposed by the raised SciMLBase minimum; neither is claimed fixed.
Links
Original NewtonBisection: Add NewtonBisection, a bracketing Newton method that uses the derivative #1330
Multiplicity and safeguards: NewtonBisection: correct the Newton step at multiple roots #1375
Opt-in AD: NewtonBisection: opt-in automatic differentiation #1376
ModABNewton: Add ModABNewton: ModAB's bisection phase, then NewtonBisection's steps #1377
Current head: 377e506d
SCC prerequisite: Keep spelled NonlinearSolution element type concrete across SciMLBase layouts #1332
Study: https://github.com/SciML/NonlinearSolve.jl/blob/interval-derivative-study/study/REPORT.md
Original author discussion: https://claude.ai/code/session_01HJLdhiuK5ih88KyZciWTEH
Upstream connector change: Change comparison to 0 instead of to nothing ModelingToolkit.jl#5295
Matching upstream master failure: https://github.com/SciML/ModelingToolkit.jl/actions/runs/39509027344/job/118925364789
Earlier passing base integration: https://github.com/SciML/NonlinearSolve.jl/actions/runs/39047077630/job/117444557421
Risk assessment
🤖 Posted by an AI agent — harness: Codex CLI 0.163.0 · model: gpt-6.1-sol
Conversation: local job 1377-codex (no session URL)
Risk assessment (independent review, Codex CLI (gpt-6.1-sol), local job oss-reviews-2026-10-22-SciML-NonlinearSolve-jl-1377-377e506 (no session URL), head 377e506)
Executed review notes (head 377e506):
Findings
lib/SCCNonlinearSolve/src/SCCNonlinearSolve.jl:139 — blocking (inherited merge prerequisite). The vector SCC path constructs
STby supplying tenNonlinearSolutiontype parameters. With SciMLBase 3.57, the supported minimum already required by the bracketing prerequisite, that leaves a type parameter free:isconcretetype(eltype(Vector{ST}(undef, 2)))is false. The existing assertion atlib/SCCNonlinearSolve/test/core_tests__item4.jl:100requires it to be true, and the vector is retained asoriginalwhen requested. The same construction is concrete on SciMLBase 3.46. I reproduced this type invariant at both exact versions and at 3.58; I did not run the full SCC solver suite. This code and the raised bracketing minimum are unchanged relative to this PR's actual merge-base, so this is not a regression introduced by ModABNewton. It corroborates the body’s explicitly unresolved SCC prerequisite (Keep spelled NonlinearSolution element type concrete across SciMLBase layouts #1332). Resolve that prerequisite and demonstrate the existing SCC test passing before merging the stack; do not weaken the assertion. The risk policy's merge gates apply independently of the additive diff's ML7 rating.lib/BracketingNonlinearSolve/src/modab_newton.jl:12 — should-fix. “The method needs fewer evaluations of
f'thanNewtonBisection” is not generally true. Forf(x) = atan(x) - atan(1.3),jac(x) = 1/(1+x^2), bounds(-100.0, 100.0), andabstol=0.0, I measured 12 derivative calls and 16 residual calls for ModABNewton versus 8 and 9 for NewtonBisection. Both succeed at the same root. Even bounds(-10.0, 10.0)give 9 versus 8 derivative calls. The three-point linearity heuristic also does not establish that derivatives are used “only near the root.” Describe these as tendencies or motivations, with problem-dependent cost, rather than guarantees. This does not invalidate the three specific derivative-count tests, which pass.Evidence
Risk was assessed from the diff before opening the PR body, recorded in
tmp/risk-before-body.txt. Matched criteria: L1 (documentation), L2 (new tests and expanded constructor loops without weakening assertions), L7 (small internal extraction of the existing Newton iteration), and ML7 (documented/tested exportedModABNewton). Highest: medium-low (ML7). The change reaches an opt-in scalar bracketing solver and its ForwardDiff wrappers; the defaultModABselection and the main NonlinearSolve polyalgorithm are unchanged.The supplied diff exactly matches the local merge-base comparison:
All execution used scratch copies/environments, Julia 1.12.7,
JULIA_NUM_THREADS=4, andtimeout 2400. Head was copied withcp -a repo tmp/head; base was extracted withgit archive 695446ab… | tar -x -C tmp/base.tmp/setup.jldevelops the scratch BracketingNonlinearSolve and NonlinearSolveBase packages and installs the test tools. The environments resolve SciMLBase 3.58.0. The Core drivers include the package's unchanged Muller and root-finding test entry points, wrapped in a single testset.Real output (both exit 0):
Thus I independently reproduced the body's head total. The suite includes analytic square-root references, parameter sensitivities, reversed/integer/Float32/Float64/BigFloat brackets, undefined residuals, scale safeguards, cache ordering, inference and zero-allocation assertions. Existing assertions remain intact; no deleted tests, loosened tolerances, or new broken/skipped markers were found. G1 has independent reference evidence, the changed ForwardDiff paths are exercised, and the cache test satisfies G3.
tmp/equality.jlcompares existing NewtonBisection (analytic and ForwardDiff derivatives) and ModAB calls for nine quadratic parameters and both bracket directions. It records the bits ofu,resid,left, andright, plus the return code.Independent probes (
tmp/probes.jl,tmp/count_probe.jl) check shifted exponential roots against their analytic values and count actual callbacks:The exponential probe initially demanded strict analytic enclosure even when the computed residual rounded to exactly zero (48 pass/24 fail). That was an invalid reviewer assertion for
exp(x-r)-1; the final probe checks reference accuracy within eight epsilons and exact-zero/opposite-sign residuals instead. It passes all 108 assertions.Scratch-only negative controls preserve the PR's assertions. Disabling the residual refresh before the Jacobian handoff produces the body's 12 ordering failures. Replacing the shared floating-bracket normalization with the pre-normalization expression produces 32 integer errors. These are controlled mutations, not failures of the actual merge-base, which does not contain ModABNewton.
The corresponding unchanged head fixtures pass in Core (104 cache and 128 integer assertions). The negative controls demonstrate that these tests discriminate the defects described in the body.
For finding 1,
tmp/setup_scc_types.jlinstalls exact SciMLBase versions in separate scratch environments.tmp/scc_types.jlreproduces the type expression at SCC source lines 139–143 and the existing test's concreteness predicate:Public API/SemVer: the export, constructor, docs entry and solve methods are additive; no existing signatures or defaults change. This addition is suitable for a minor release. No Project.toml, dependency, compatibility, or licence changes occur in this diff; ADTypes/DifferentiationInterface already belong to the base. The inherited dependency additions need their prerequisite review, rather than being counted as new dependencies here.
The supplied
pr.jsonCI snapshot contains 56 SUCCESS / 1 FAILURE. The failure is ModelingToolkit InterfaceI, job119066901153; the body attributes it to an upstream connector assertion. I did not independently retrieve that job log or confirm the attribution. The body correctly avoids claiming an entirely green matrix and discloses the SCC prerequisite and missing final wall-time benchmarks. Its local Core and sublibrary QA counts were independently reproduced here. Finalgit -C repo status --porcelain=v1produced no output; no repo edits, commits, pushes or GitHub posts were made.Not verified
🤖 Posted by an AI agent — harness: Codex CLI · model: gpt-6.1-sol (independent reviewer; appended by Antigravity CLI · model: gemini-4-argon-high)
Conversation: local job oss-reviews-2026-10-22-SciML-NonlinearSolve-jl-1377-377e506 (no session URL)
Fix by Codex CLI 0.164.0 gpt-6.1-sol (head 340c16d)
The assigned ModelingToolkit InterfaceI failure is pre-existing / obsolete upstream evidence. I read the PR's failed run and ModelingToolkit's historical master failure: both fail the same causal-equation assertion at
components.jl:446, with actualinput ~ outputand expectedoutput ~ input(1,590 passes, one failure, three existing broken assertions). ModelingToolkit repaired that expectation in9c1625d9. The latest NonlinearSolve default-branch IntegrationTest is apushrun atd254af93; its actual InterfaceI log passes 1,704 assertions with three existing broken assertions using ModelingToolkita62e8516, which contains that repair. This does not establish a regression caused by this PR. No NonlinearSolve runtime change is made for that failure.The appended review's docstring finding is corrected: derivative savings are described as dependent on the function and initial bracket. I reproduced its counterexample,
atan(x) - atan(1.3)with analytic derivative, bounds(-100, 100)andabstol=0: ModABNewton uses 16 residual / 12 derivative calls versus NewtonBisection's 9 / 8; both return1.3000000000000003. A scratch assertion of the unconditional derivative-saving claim fails as12 < 8(four root/success assertions pass). This is a documentation correction; no runtime fix or changed test expectation is claimed.Local verification
Julia 1.12.7,
JULIA_NUM_THREADS=4,JULIA_NUM_PRECOMPILE_TASKS=1,JULIA_PKG_PRECOMPILE_AUTO=0, writable job-specificTMPDIR.JULIAbelow selects the installed juliaup launcher;DIFFdenotes the captured patch.All three exit 0 with no output. The commit adds two docstring lines and deletes three; it changes no runtime code, dependencies, or official tests.
The full group passed both before and after the documentation edit, 24,719 assertions per run. Tail of the final run:
Instantiation exits 0. The docs command exits 1 before Documenter runs, while importing TaylorDiff through NonlinearSolveHomotopyContinuation. I also ran the same build in a clean checkout of current default
d254af933dd48eeb9b21b4a55f643e92a0840ff6, using the same resolved Manifest with relative local-package paths. That checkout has no tracked modifications and fails identically. Its command, withBASE_DOCSdenoting that clean checkout's docs directory:Error excerpt from both runs:
The trace enters
ChainRules.derivatives_given_outputfortanh, then TaylorDiff'sget_term_raiser. Resolved versions are ChainRules 1.74.11, TaylorDiff 0.3.5, Symbolics 7.48.0. No docs settings, examples, tests, or dependency bounds were changed to bypass it. A successful local docs build is not claimed.A separate dependency-only reproduction imports no SciML package:
In clean scratch environments, this unchanged script exits 0 with ChainRules 1.74.10 and prints
(tanh(z), 1 - (tanh(z)^2)); it exits 1 with ChainRules 1.74.11 and the same non-BooleanNumerror. Both use Julia 1.12.7, ChainRulesCore 1.26.8, Symbolics 7.48.0 and SymbolicUtils 4.55.0; comparing the manifests finds only the ChainRules version/tree differs. Source history identifies the introducing commit asa6107e9b, which adds a Boolean branch to thetanhderivative. This dependency regression is separate from the historical ModelingToolkit failure. No upstream issue was filed from this fixer job.Remaining review state
The SCC compatibility prerequisite remains open and untouched. Its inherited merge blocker is not claimed fixed. Current-head ModelingToolkit InterfaceI was not rerun locally; the default comparison above is executed CI-log evidence. GPU, prerelease, other platforms, SCC solver/downgrade suites, inherited AD edge-case follow-ups and benchmarks were not rerun. CI started on
340c16db; it was checked once and is not being awaited here.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__1377 (no session URL)