Skip to content

NewtonBisection: opt-in automatic differentiation - #1376

Draft
ChrisRackauckas wants to merge 10 commits into
newton-bisection-multiplicityfrom
newton-bisection-autodiff
Draft

ChrisRackauckas wants to merge 10 commits into
newton-bisection-multiplicityfrom
newton-bisection-autodiff

Conversation

@ChrisRackauckas

@ChrisRackauckas ChrisRackauckas commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

🚧 UNREVIEWED — awaiting review by @ChrisRackauckas. Filed by an AI agent running as @ChrisRackauckas; Chris has not seen this.
Harness: Codex CLI 0.163.0 · Model: gpt-6.1-sol
Conversation: local job 1377-codex (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.jl and interval_wrapper_tests.jl within one outer testset; the full official Core group then runs the committed files.

julia +1.12 --project="$VALIDATION_ENV" "$AD_REGRESSION_RUNNER" "$REGRESSION_TESTS"
ERROR: LoadError: Some tests did not pass: 225 passed, 7 failed, 0 errored, 0 broken.

Test Summary:                      | Pass  Total   Time
AD wrapper and backend regressions |  232    232  17.9s

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.

julia +1.12 --project="$VALIDATION_ENV" -e 'using Test, SciMLBase; include(ARGS[1])' "$INTEGER_TESTS"
Before: Integer brackets | 16 errored
After:  Integer brackets | 64 64

Verification

GROUP=Core julia +1.10 --project="$VALIDATION_ENV" -e 'using Pkg; Pkg.test("BracketingNonlinearSolve")'
Test Summary:                              | Pass  Total  Time
Interval wrapper inference and allocations |   54     54  3.6s
Test Summary:                            | Pass  Total  Time
Derivative methods with integer brackets |   64     64  0.7s
     Testing BracketingNonlinearSolve tests passed 
GROUP=Core julia +1.12 --project=lib/BracketingNonlinearSolve -e 'using Pkg; Pkg.test()'
Test Summary:                              | Pass  Total  Time
Interval wrapper inference and allocations |   54     54  3.4s
Test Summary:                            | Pass  Total  Time
Derivative methods with integer brackets |   64     64  0.6s
     Testing BracketingNonlinearSolve tests passed 
GROUP=QA julia +1.12 --project=lib/BracketingNonlinearSolve -e 'using Pkg; Pkg.test()'
  [3f19e933] + p7zip_jll v17.7.0+0
        Info Packages marked with ⌅ have new versions available but compatibility constraints restrict them from upgrading. To see why use `status --outdated -m`
Test Summary: | Pass  Total   Time
QA            |   20     20  34.5s
     Testing BracketingNonlinearSolve tests passed 

Root QA, GROUP=QA julia +1.10 --project="$ROOT_VALIDATION_ENV" -e 'using Pkg; Pkg.test("NonlinearSolve")':

  [3f19e933] + p7zip_jll v17.6.1+0
        Info Packages marked with ⌅ have new versions available but compatibility constraints restrict them from upgrading. To see why use `status --outdated -m`
Test Summary: | Pass  Total     Time
QA            |   26     26  3m28.0s
     Testing NonlinearSolve tests passed 

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, and typos --config .typos.toml on 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.jl
[ Info: Doctest: running doctests.
[ Info: CheckDocument: running document checks.
[ Info: HTMLWriter: rendering HTML pages.
┌ Warning: Documenter could not auto-detect the building environment. Skipping deployment.

HTML/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 built 695446ab successfully. Core and QA output above is from 695446ab (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

Risk assessment

  • Risk: medium
  • Blast radius: new derivative-using scalar bracketing methods and interval Dual handling; public API requires Chris's decision.
  • Evidence: executed negative controls and local test output above.
  • Independent review: Codex CLI 0.163.0 / gpt-6.1-sol rated this AD delta medium-low (ML9), confidence not separately stated, CHANGES solely for inherited SCC compatibility; no new AD-delta defect. Review summary. The author retains medium risk for the broader public API decision.
  • Merge: blocked by the stack SCC compatibility prerequisite and pending Chris’s dependency/public API decisions.

🤖 Posted by an AI agent — harness: Codex CLI 0.163.0 · model: gpt-6.1-sol
Conversation: local job 1377-codex (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.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_ENV denotes an isolated Julia environment developing this checkout's BracketingNonlinearSolve and NonlinearSolveBase, with Test, SciMLBase, ForwardDiff and ADTypes available.

julia --project="$VALIDATION_ENV" -e 'using Test, SciMLBase; @testset "Safeguards" begin include("lib/BracketingNonlinearSolve/test/newton_safeguard_tests.jl") end'

Before (exit 1):

Safeguards | 194  24  218  6.9s
ERROR: Some tests did not pass: 194 passed, 24 failed, 0 errored, 0 broken.

After (exit 0):

Test Summary: | Pass  Total  Time
Safeguards    |  218    218  9.2s

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:

Test Summary:                              | Pass  Total  Time
Interval wrapper inference and allocations |   54     54  2.7s
Test Summary:                            | Pass  Total  Time
Derivative methods with integer brackets |   64     64  0.5s
     Testing BracketingNonlinearSolve tests passed
GROUP=QA julia --project=lib/BracketingNonlinearSolve -e 'using Pkg; Pkg.test()'
Test Summary: | Pass  Total   Time
QA            |   20     20  24.7s
     Testing BracketingNonlinearSolve tests passed
GROUP=QA julia --project -e 'using Pkg; Pkg.test()'
Test Summary: | Pass  Total     Time
QA            |   28     28  4m56.8s
     Testing NonlinearSolve tests passed
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 --check

All 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-failed returned 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-failed reported log 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)

`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

Copy link
Copy Markdown
Member Author

(AI-generated, Claude Code cloud session: https://claude.ai/code/session_01HJLdhiuK5ih88KyZciWTEH)

The red Tests - Core (Julia lts) check fails on solve!() inference: Error During Test at test/Core/core_tests__item3.jl:27. This is the root package's PolyAlgorithm inference test on Julia 1.10. It fails the same way on master (dd8a550b), and this PR only changes BracketingNonlinearSolve. The fix is #1347; details in #1375 (comment).


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
@ChrisRackauckas-Claude

ChrisRackauckas-Claude commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

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

Core LTS classification at be86fe4c: pre-existing on master, fixed on current master. Both Linux and macOS fail PolyAlgorithm Type Inference → solve!() inference (test/Core/core_tests__item3.jl:27), matching the earlier master failure. The head lacks the merged retcode type assertion in #1347. The first completed master Core LTS jobs after that fix pass on both platforms.

Links:


🤖 Posted by an AI agent — harness: Codex CLI · model: gpt-6.1-sol
Conversation: local headless job codex-nls-core-lts-20261017 (no session URL)

ChrisRackauckas and others added 8 commits October 20, 2026 22:54
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)

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