Skip to content

Use the active member's autodiff in out-of-place calc_tderivative - #4957

Open
singhharsh1708 wants to merge 4 commits into
SciML:masterfrom
singhharsh1708:fix-4951
Open

singhharsh1708 wants to merge 4 commits into
SciML:masterfrom
singhharsh1708:fix-4951

Conversation

@singhharsh1708

@singhharsh1708 singhharsh1708 commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Out-of-place calc_tderivative read alg from the integrator, so inside a CompositeAlgorithm it took the autodiff of the last member. It now uses unwrap_alg(integrator, true), as the in-place calc_tderivative! does.

The repro in #4951 (CompositeAlgorithm((Rosenbrock23(), Tsit5()), _ -> 1), out of place) threw on the first step and now returns Success with the same final state as Rosenbrock23() alone. The new test in composite_algorithm_test.jl fails on master.

Fixes #4951

Risk assessment

  • Risk: medium (M3: out-of-place calc_tderivative is shared by every out-of-place Rosenbrock-type step, including the default solver's stiff branches).
  • Blast radius: One line in OrdinaryDiffEqDifferentiation: alg now comes from unwrap_alg(integrator, true), as the in-place calc_tderivative! already does. For a non-composite algorithm this returns the same alg, so standalone solves are unchanged; inside a CompositeAlgorithm the autodiff setting now comes from the active member instead of the last one. In-place solves are not touched.
  • Evidence: The repro in Out-of-place Rosenbrock time derivative uses the autodiff of the last CompositeAlgorithm member #4951 (CompositeAlgorithm((Rosenbrock23(), Tsit5()), _ -> 1), out of place) threw on the first step on master and now returns Success with the same final state as Rosenbrock23() alone. The new test in composite_algorithm_test.jl fails on master. The remaining red checks (SciMLSensitivity Core2, ProbNumDiffEq, AD lts, DiffEqDevTools downgrade, both GPU lanes, NonlinearSolve Core Julia 1) also fail on master.

AI Disclosure: Claude assisted with this change.

@ChrisRackauckas

Copy link
Copy Markdown
Member

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

PR: #4957

Reviewed head: 7092400
Raw SHA-256: e0266d469876f7e090f51333631bc49105f2a144b858d250da1852fe6c76ddab
Source SHA-256: dee5e21fe763e1ee40a350aa59bb94b46ac94d0709e3168920fa35e82056a4c3
Source: standard-review-v1 (harness-log)
Reviewer session: 01a1d257-49f5-79a2-b069-10e0fa24c4d0
Slot: 1
Confidence: unknown
Own risk fixed before author rating/discussion: yes

Risk assessment

  • Risk: medium (M2)
  • Verdict: CHANGES
  • Reviewed head: 7092400

Review report

VERDICT: CHANGES
Round: 1
Head: 7092400
Slot: 1
CI: CI is not green (regress:SciMLSensitivity.jl/Core4/1 / Downstream Tests - Core4)
Session: 01a1d257-49f5-79a2-b069-10e0fa24c4d0

Risk

medium (M2: previously working mixed-AD composite solves change sampled results by up to 1.55e-10; independent analytic probes pass).

Blocking findings

  • [P1] Uncleared downstream regression. The supplied CI status reports a SciMLSensitivity/Core4 regression. Local affected suites and adversarial probes passed, but I did not reproduce or establish a baseline explanation for that failure. The owning head must resolve it or demonstrate baseline-equivalent failure in the same environment before merging. This is a verification gate; no new source-code defect was confirmed locally.

  • Verdict: CHANGES

  • Round: 1

  • Blocking priorities: P1

Non-blocking findings

  • test/InterfaceI/composite_algorithm_test.jl:153 and :156: source inspection shows an autonomous RHS with zero time derivative and an endpoint comparison against the same Rosenbrock implementation. Add a non-autonomous analytic case with different AD backends on the constituent stiff solvers to retain coverage of backend selection. Reviewer probes exercised this case successfully, including a finite-difference-only time argument with zero dual-time calls.

What I ran

AI reviewer: Codex CLI 0.164.0, model gpt-6.1-sol. Review remained blind to PR bodies, comments, reviews, and author risk ratings.

  • git diff origin/master...HEAD, surrounding implementation/test inspection, and git diff --check origin/master...HEAD: no whitespace errors. Final HEAD matched the required SHA; git status --porcelain was empty. Neither root instruction file was present. Newest-commit Agent-Harness/Agent-Model trailers were absent.
  • julia --version: 1.13.2. Resolved a scratch environment from the root and Differentiation projects with local sources pointing to this checkout. Preserved the runtime's layered JULIA_DEPOT_PATH and used the requested job TMPDIR. Tests used two Julia threads, bounds checking, and an 8 GiB memory scope.
  • julia --startup-file=no --check-bounds=yes --project=../scratch/testenv ../scratch/run.jl "$PWD": exit 0. Full composite-algorithm file: 20/20. Official Differentiation test/runtests.jl, GROUP=Core: 226/226 across 17 testsets. Targeted probes: 94/94.
  • Probes covered first/last/middle members, switching, automatic pairs, ForwardDiff/FiniteDiff, scalar/static states, backward solves, and analytic time gradients. Across 32 analytic cases, maximum observed error was 4.61795379713692e-10 against sin(t).
  • Loaded only the merge-base calc_tderivative method as a runtime negative control. The original example threw “This algorithm does not have an autodifferentiation option defined.” Thirteen previously working sampled-solution comparisons remained bitwise equal. Mixed-backend cases changed by at most 1.552633577261986e-10.
  • julia --startup-file=no --check-bounds=yes --project=../scratch/testenv ../scratch/default_stiff_probe.jl: exit 0, 7/7. Checked the analytic solution sin(t) + exp(-1000t) and forced default-family member 4. Maximum error was 1.114027758930547e-10; sampled values, member choices, accepted-step counts, and rejection counts matched the base method exactly.
  • uv run --locked python --version: Python 3.15.0. uv warned that --locked has no effect outside a project; the checkout contains no Python project or uv.lock, so this does not establish a locked project Python environment.

What I did not verify

  • The reported SciMLSensitivity/Core4 failure, its CI logs, or a clean-default-branch reproduction. Inspected cached Core4 test dispatch only.
  • Full CI, QA, other Julia versions, or GPU execution. The negative control replaced one method in the head environment rather than running a complete base checkout.

AUTHOR_GRADE: {"task":"bugfix","score":4,"difficulty":2,"rounds":1,"author_harness":"unknown","author_model":"unknown","note":"347 local assertions passed; the base method reproduces the original AD-option exception. The supplied downstream Core4 regression remains unverified and uncleared."}

Head link: 7092400


🤖 Posted by an AI agent — harness: codex-cli 0.164.0 · model: gpt-6.1-sol
Conversation: local session 01a1d257-49f5-79a2-b069-10e0fa24c4d0 (no session URL)

@singhharsh1708

Copy link
Copy Markdown
Member Author

Made the RHS depend on t so calc_tderivative's value matters, checked against the exact solution, and added a finite-diff-first composite case. Both cases fail with the src change reverted. The resize paths that also read alg_autodiff(integrator.alg) are fixed in #4958.

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.

Out-of-place Rosenbrock time derivative uses the autodiff of the last CompositeAlgorithm member

2 participants