Repository navigation
NewtonBisection: opt-in automatic differentiation - #1376
ChrisRackauckas wants to merge 10 commits into
Conversation
`NewtonBisection(; autodiff)` takes an ADTypes backend, used when the IntervalNonlinearFunction has no `jac`: one pass through DifferentiationInterface gives f and its derivative together. With a `jac`, the method is unchanged. Without `jac` and without `autodiff` it throws the ArgumentError as before, now suggesting `autodiff = AutoForwardDiff()`. AD is not the default: measured over the nine standard functions at abstol = 0, with each function's cost of a ForwardDiff Dual evaluation relative to f, AD-backed NewtonBisection costs 124-129 f-evaluations against 108 for ModAB, and on events of an ODE interpolant it is 3.7 to 8 times slower per event than ModAB. A default would silently make the method slower than the default solver. The preparation is not strict, because the Newton points take the type of `x - f(x)/f'(x)`, which differs from the bracket's type when f promotes (a Float32 bracket with a Float64 f). ADTypes and DifferentiationInterface become direct dependencies; both are already dependencies of NonlinearSolveBase, so nothing new is loaded. In the ForwardDiff extension, a problem with Duals in the time span and no `jac` gets, for an AD NewtonBisection, a `jac` from the derivative of the original f, stripped afterwards; differentiating the stripped f would nest the new tag inside the Duals that f closes over. 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 |
Cancel superseded PR CI runs Add a cancel-in-progress concurrency group, active only for pull_request events, to the PR workflows that lack one. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Agent-Harness: Claude Code 2.1.302 Agent-Model: claude-sonnet-5-5 Agent-Session: local subagent of the fleet-master session
Core LTS classification at be86fe4c: 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 |
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)
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)
Promote endpoints with each trial point before interior clamping, and check termination after the last permitted step. Cover promoted residuals with analytic and automatic derivatives, reversed brackets, and final-step exits. 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-astra Agent-Session: local fixer job SciML__NonlinearSolve.jl__1376 (no session URL)
Adds opt-in differentiation through DifferentiationInterface when an interval problem has no supplied jacobian. Concrete derivative wrappers preserve inference and zero allocations for Dual endpoints, and unavailable backends produce ArgumentError. ADTypes and DifferentiationInterface are MIT licensed; accepting these direct dependencies remains Chris's decision.
Please ignore until reviewed by @ChrisRackauckas. Part of #1377 (#1377).
Failing before / passing after
The same regression files were run against the AD branch before and after the wrapper fix. The runner includes
newton_safeguard_tests.jlandinterval_wrapper_tests.jlwithin one outer testset; the full official Core group then runs the committed files.Integer brackets are normalized before preparing the derivative backend. The committed input fixture covers analytic and ForwardDiff derivatives, positive/negative/reversed brackets, default and zero absolute tolerance; signed
sqrt(big(2))supplies the reference. The same fixture has 16 initialization errors without normalization and 64 passing assertions with it.Verification
GROUP=Core julia +1.12 --project=lib/BracketingNonlinearSolve -e 'using Pkg; Pkg.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.Documentation
A separate environment copies the docs project, resolves its sources to this checkout, and develops the local sublibraries and root. The build completed with exit zero:
julia +1.12 --project="$DOCS_ENV" docs/make.jlHTML/search-size warnings and SVG fallbacks for large examples were reported. Build settings were unchanged. The normal merge of the prerequisite wrapper guard leaves the full tracked source tree byte-identical to the tree validated by these tests and docs.
The author documentation build above ran on
b91696f3; the fresh independent review also built695446absuccessfully. Core and QA output above is from695446ab(22,343 Core assertions on each version).Not verified
GPU, downstream, prerelease, other platforms, and a complete downgrade matrix were not rerun locally. The SCC downgrade issue remains dependent on the open prerequisite fix; 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.
Independent review
Fresh Codex CLI 0.163.0 / gpt-6.1-sol review of 695446ab against 9e93e479 returned CHANGES, medium-low ML9. Session: local session 01a15cff-6a03-7f72-9310-e4c5d111fe0f (no session URL). The only blocker is the inherited SCC compatibility prerequisite: the exact SciMLBase 3.57 configuration fails the original-concreteness assertion, 11 passes/1 failure. That is a stack merge gate, not a new defect in the AD delta.
The reviewer independently ran Core 22,343 on each version, QA 20/root QA 26, root Core LTS 1,572 passes with 91 existing broken assertions, the matched 225 pass/7 fail to 232 pass wrapper control, 88 additional backend/sensitivity assertions including FiniteDiff, and the docs build at this head (exit zero). It found no additional implementation defect against the actual parent.
It also fetched final ModABNewton 377e506d: Core 24,719 on both versions, unchanged new fixtures failing on the old head and passing on the final head, plus independent integer 128/128 and cache-handoff 24/24 probes. The integer and stale-cache findings on the older stack are confirmed resolved. Placement and normal merge history were checked; no numerical assertions were weakened or removed.
Earlier review confirmed inherited shared sensitivity limitations: a secant can sample outside a tiny original bracket, and Float32 Dual reconstruction can fail when the residual promotes to Float64. Both are tracked in the handoff and are not claimed fixed. Chris still decides whether to accept the two MIT dependencies and the public option.
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
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)
Fix by Codex CLI 0.164.0 gpt-6-astra (head b34eeb1)
NewtonBisection promotes the bracket endpoints and trial point to a common precision before clamping to the interior. Float32 endpoints with Float64 residuals therefore retain an enclosing bracket instead of evaluating outside it or cycling to MaxIters. The convergence check also runs after the final permitted step, returning Success or FloatingPointLimit when appropriate.
The regressions cover analytic and automatic derivatives, both root signs, reversed brackets, final-step tolerance and floating-point termination, derivative-call counts, and an exhausted iteration budget. No tests or tolerances were weakened.
Failing before / passing after
The same committed safeguard test file was run against the unfixed source at 695446a and the fixed source.
VALIDATION_ENVdenotes an isolated Julia environment developing this checkout's BracketingNonlinearSolve and NonlinearSolveBase, with Test, SciMLBase, ForwardDiff and ADTypes available.Before (exit 1):
After (exit 0):
Local validation
Julia 1.12.4, JULIA_NUM_THREADS=4, JULIA_NUM_PRECOMPILE_TASKS=1.
GROUP=Core julia --project=lib/BracketingNonlinearSolve -e 'using Pkg; Pkg.test()'22,383 passing assertions across 18 testsets; output tail:
GROUP=QA julia --project=lib/BracketingNonlinearSolve -e 'using Pkg; Pkg.test()'GROUP=QA julia --project -e 'using Pkg; Pkg.test()'julia --project=@runic -m Runic --inplace lib/BracketingNonlinearSolve/src/newton_bisection.jl lib/BracketingNonlinearSolve/test/newton_safeguard_tests.jl git diff HEAD^ HEAD | typos --config .typos.toml - git diff --checkAll exited zero with no output.
CI and verification limits
Before editing, all 57 reported checks were successful;
gh run view 39551491532 -R SciML/NonlinearSolve.jl --log-failedreturned no failed logs. There was no active failing test to classify against the default branch. After pushing, a single inspection confirmed workflows started on b34eeb1. Dependabot Auto-merge immediately reported startup_failure with zero jobs;--log-failedreportedlog not found. Its workflow is identical to upstream master, which has no branch runs for that workflow; the startup failure's cause is unverified. No workflow was changed.CI completion, Julia LTS, GPU, downstream suites, and documentation were not rerun in this fix session. This correction changes no docstrings or public API. The earlier dependency and broader PR design decisions remain outside this fix.
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-astra
Conversation: local fixer job SciML__NonlinearSolve.jl__1376 (no session URL)