Skip to content

Preserve AD wrappers in Rosenbrock stages - #4101

Draft
ChrisRackauckas-Claude wants to merge 4 commits into
SciML:masterfrom
ChrisRackauckas-Claude:agent/preserve-tracked-rosenbrock-stages
Draft

ChrisRackauckas-Claude wants to merge 4 commits into
SciML:masterfrom
ChrisRackauckas-Claude:agent/preserve-tracked-rosenbrock-stages

Conversation

@ChrisRackauckas-Claude

@ChrisRackauckas-Claude ChrisRackauckas-Claude commented Aug 2, 2026 •

Copy link
Copy Markdown
Member

Summary

  • restore AD storage wrappers after restructuring flat Rosenbrock linear-solve results
  • preserve existing state containers, including ArrayPartition, unless the struct-of-arrays conversion matches the original container type
  • add a ReverseDiff regression that exercises the public init / solve! path

Root cause

The first commit of #3996 (100fe236) replaced the former reshape helper with ArrayInterface.restructure. For an out-of-place ReverseDiff state, that changes a TrackedArray template into a plain Vector{TrackedReal}, and the Rosenbrock stage update later attempts to convert the tracked scalars back to Float64.

The focused reproducer passes at the parent commit (5e3c607) and fails at 100fe236. Converting the restructured result with the public ArrayInterface.aos_to_soa API restores the tracked wrapper. The type guard avoids changing other state-container representations.

Validation

  • GROUP=Core julia +1.10 --project=lib/OrdinaryDiffEqRosenbrock -e 'using Pkg; Pkg.test()'
    • DAE Rosenbrock AD Tests: 16 / 16
    • Rosenbrock AD Tests: 64 / 64
    • Rosenbrock Convergence Tests: 192 / 192
  • whole-repository Runic check passed

Ignore this PR until reviewed by @ChrisRackauckas.

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

Risk assessment (independent review, Codex CLI 0.164.0-alpha.11.1 gpt-6-astra, slot 1, head a2461bc)

  • Risk: medium-high (MH1: The shared stage-restructuring helper changes AD wrapper types on main-lane Rodas solvers; the supported minimum dependency stack still fails the new regression.)
  • Verdict: CHANGES
  • Session: 01a18da8-0055-70e2-850a-45982d205850
  • Blocking priorities: P2

Review round 1, written by the reviewer named above (Codex CLI 0.164.0-alpha.11.1 / gpt-6-astra) 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: The PR restores structure-of-arrays AD wrappers after Rosenbrock stage solves and adds an analytic ReverseDiff regression. The regression passes current-dependency Core CI but fails the downgrade job, leaving the advertised fix incomplete on supported dependencies.

Blast radius: Out-of-place Rosenbrock/Rodas stage and dense-output reconstruction, including main-lane Rodas algorithms; scalar handling is unchanged.

Evidence: Exact head/diff inspected; Julia 1.12.6 Core CI passes 192/192 Rosenbrock convergence checks. Julia 1.11.9 downgrade CI errors in the newly added tracked-state test (191 passed, 1 error). G1 has the independent gradient [1,1.2,-0.22]; G2 has executed AD coverage, but execution exposes a supported-stack failure. No independent fail-before control was run, so the missing-evidence modifier cannot lower the already MH1 rating.

Blocking findings

  1. [P2] lib/OrdinaryDiffEqRosenbrock/Project.toml:61 and lib/OrdinaryDiffEqRosenbrock/test/ode_rosenbrock_tests.jl:564 — confirmed by running (PR CI; reviewer inspected the log): the downgrade job resolves ReverseDiff 1.16.0 and ArrayInterface 7.28.0, both permitted by this head, then the new regression throws MethodError: Cannot convert Vector{ReverseDiff.TrackedReal{...}} to ReverseDiff.TrackedArray{...}. The failing assignment is jac_reuse.cached_dT = dT in lib/OrdinaryDiffEqDifferentiation/src/derivative_utils.jl:999; the expected contract is a completed solve with gradient [1.0, 1.2, -0.22]. Current-dependency CI passes with ReverseDiff 1.17.0/ArrayInterface 7.28.1, but that does not validate the declared lower bounds. Preserve the required tracked wrapper through this differentiation cache path, or determine and encode the actual required dependency minima, then rerun the exact regression in the minimum-version job. Do not skip the failing test.

Non-blocking findings

None.

What I ran

  • git rev-parse HEAD returned a2461bc60992ba6ef6de4651dcb77e43836131b4; exact detached PR head verified (exit 0).
  • git diff origin/master...HEAD and git diff --check origin/master...HEAD completed (exit 0); changed files, tests, callers, and repository instructions inspected. Root AGENTS.md and CLAUDE.md are absent. Risk was frozen before opening the description.
  • git rev-parse origin/master returned 14b964b315e1310b5e3621a1bcfe6b92e9e506aa; GitHub's PR metadata base is a7080c6f6d992edee79fa40450e0bd6eb0b8f735. The review diff uses the three-dot merge base; the header records the fetched base-branch tip.
  • git log -1 --first-parent --no-merges --format=%B inspected (exit 0); author trailers recorded below, or unknown when absent.
  • gh pr view 4101 --repo SciML/OrdinaryDiffEq.jl --json number,url,state,isDraft,headRefOid,baseRefName,baseRefOid,title,files,statusCheckRollup and the subsequent PR body read succeeded. Live state was OPEN.
  • Inspected gh pr checks 4101 --repo SciML/OrdinaryDiffEq.jl data: 123 success, 13 failure, 1 skipped.
  • gh run view 30757654870 --repo SciML/OrdinaryDiffEq.jl --job 91522550568 --log (retrieval exit 0): Julia 1.12.6, ReverseDiff 1.17.0, ArrayInterface 7.28.1; Rosenbrock Convergence Tests | 192 192, then Testing OrdinaryDiffEqRosenbrock tests passed. The test entry point includes the new analytic gradient check. Passing Core job.
  • gh run view 30757654811 --repo SciML/OrdinaryDiffEq.jl --log-failed (retrieval exit 0): Julia 1.11.9, ReverseDiff 1.16.0, ArrayInterface 7.28.0; the new OOP Rosenbrock preserves ReverseDiff tracked states test errors, Rosenbrock Convergence Tests | 191 1 192 (Pass/Error/Total), and the test process exits 1. Failing downgrade job.
  • Failed logs were also inspected for 30757654870 (QA), 30757654928 (AD/GPU), 30757654833 (docs), and 30757654638 (integration), using gh run view <run> --repo SciML/OrdinaryDiffEq.jl --log-failed (retrieval exit 0). They include public-API QA, AD callback, GPU DAE, docs cross-reference, and downstream compatibility/AD failures. These are not used to infer the cause of the concrete new-regression failure above. Sublibrary CI, CI, docs, integration.
  • Recent master push runs were inspected with gh run list --repo SciML/OrdinaryDiffEq.jl --branch master --event push --limit 5. Default CI run 41058796553 fails AutoZygote callback and GPU warning tests, whereas the historical PR CI has different failures. Default downgrade run 41058798190 reports success. No identical master failure of this PR's new ReverseDiff regression was independently established. Default CI log, default downgrade.

What I did not verify

No reviewer Julia process was run for this PR. The author-reported failing-before baseline and the minimal dependency version responsible for the downgrade difference were not independently reproduced. Inspected CI, not a local rerun, provides the passing and failing head evidence. Full GPU/AD/downstream equivalence to the current default branch remains unverified.

🤖 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 9b01e0c)

Require ArrayInterface 7.29, which includes its tracked-array restructure fix, and retain the analytic ReverseDiff regression. Rosenbrock stage reconstruction now uses the same implementation as current default. A normal merge of current default preserves the original branch history and incorporates its differentiation and CI fixes, including the required FiniteDiff 2.33 / DifferentiationInterface 0.7.21 floors.

Regression evidence

The original PR with ArrayInterface 7.28.0, ReverseDiff 1.16.0, FiniteDiff 2.27.0 and DifferentiationInterface 0.7.18 errors assigning a vector of tracked scalars to cached_dT::TrackedArray. Raising only ArrayInterface on that old base still fails. Clean current default with ArrayInterface 7.28.0 also fails the tracked stage assignment.

Before, on the original PR minimum stack:

Test Summary:                                       | Error  Total   Time
OOP Rosenbrock preserves ReverseDiff tracked states |     1      1  12.6s

After, on this branch with ArrayInterface 7.29.0, ReverseDiff 1.16.0 and current default's differentiation floors:

gradient = [1.0, 1.2000000000076803, -0.21999999998600772]
Test Summary:                                       | Pass  Total   Time
OOP Rosenbrock preserves ReverseDiff tracked states |    1      1  22.5s

Local validation

GROUP=Core julia +1.11 --project=lib/OrdinaryDiffEqRosenbrock -e 'using Pkg; Pkg.test(; julia_args=["--compiled-modules=existing"])'
Test Summary:           | Pass  Total      Time
DAE Rosenbrock AD Tests |   16     16  16m30.6s
Test Summary:                    | Pass  Total     Time
Callback-truncated interpolation | 2628   2628  5m34.8s
Test Summary:       | Pass  Total      Time
Rosenbrock AD Tests |   65     65  10m44.0s
Test Summary:                | Pass  Total      Time
Rosenbrock Convergence Tests |  228    228  14m15.6s
     Testing OrdinaryDiffEqRosenbrock tests passed 
GROUP=QA timeout 7200 julia +1.13.3 --project=lib/OrdinaryDiffEqRosenbrock -e 'using Pkg; Pkg.resolve(); Pkg.test(; julia_args=["--compiled-modules=existing"])'
Test Summary:    | Pass  Broken  Total     Time
Allocation Tests |   20      20     40  5m54.0s
Test Summary:   | Pass  Total     Time
Inference Tests |   40     40  3m02.2s
Test Summary: | Pass  Total  Time
JET Tests     |    1      1  1.2s
Test Summary: | Pass  Total     Time
Aqua          |   21     21  1m51.6s
     Testing OrdinaryDiffEqRosenbrock tests passed 
GROUP=AD timeout 7200 julia +1.13.3 --project -e 'using Pkg; Pkg.test(; julia_args=["--compiled-modules=existing"])'
Test Summary:         | Pass  Broken  Total     Time
Autodiff Events Tests |    5       1      6  3m56.6s
Test Summary:          | Pass  Total     Time
Discrete Adjoint Tests |   12     12  9m53.6s
     Testing OrdinaryDiffEq tests passed 
GROUP=Interface timeout 7200 julia +1.13.3 --project=lib/DelayDiffEq -e 'using Pkg; Pkg.test(; julia_args=["--compiled-modules=existing"])'
Test Summary:   | Pass  Total     Time
Verbosity Tests |    9      9  1m11.7s
Test Summary:         | Pass  Total     Time
Multi-Algorithm Tests |   28     28  1m35.5s
     Testing DelayDiffEq tests passed 
julia +1.13 --project=@runic -m Runic --inplace lib/OrdinaryDiffEqRosenbrock/test/ode_rosenbrock_tests.jl
typos lib/OrdinaryDiffEqRosenbrock/Project.toml lib/OrdinaryDiffEqRosenbrock/test/ode_rosenbrock_tests.jl

Both exit 0; spelling produces no output. The tracked worktree matches the validated index and the diff against default passes whitespace checks.

Pre-existing docs dependency failure

Fresh resolution on both this branch and a clean default checkout fails before makedocs, loading TaylorDiff, with TypeError(func=:if, expected=Bool, got::Symbolics.Num). The original August failed-log downloads now return HTTP 410, so current executions and the review's preserved error were used instead.

An unchanged standalone probe importing only ChainRules, ChainRulesCore, Symbolics and InteractiveUtils isolates the transition on Julia 1.13.3: ChainRules 1.74.11 errors in frule((NoTangent(), true), tanh, z) for symbolic z; 1.74.10 passes an analytic derivative check, returning 0.7864477329659274 at z=0.5. The introducing commit is in the linked ChainRules change. No dependency pin or workaround is committed.

The full docs build passes with the ChainRules version from the last passing default CI, using only an ignored local manifest setting. Commands:

julia +1.13.3 --project=docs -e 'using Pkg; Pkg.pin(PackageSpec(name="ChainRules",uuid="082447d4-558c-5d27-93f4-14fc19e9eca2",version="1.74.10"))'
julia +1.13.3 --compiled-modules=existing --project=docs docs/make.jl
[ Info: CheckDocument: running document checks.
[ Info: RenderDocument: rendering document.
[ Info: HTMLWriter: rendering HTML pages.

Exit 0; deployment is skipped outside CI. Latest-resolution docs remains an upstream ChainRules/TaylorDiff interoperability failure. No upstream issue was filed outside this job's repository grant.

Not run locally: GPU, integration/downstream, full Everything, AD LTS, or the complete sublibrary downgrade matrix. Existing default CI passed the two named downgrade jobs and DelayDiffEq Interface; its unrelated AD LTS/GPU failures were audited separately. No assertions, tolerances or validation settings were weakened.

Links

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


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

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

Fix by Muse CLI Code muse-wonder-full-1.0 (head fa8fe2f)

Merged the current default branch (3 commits, including the TaylorDiff 0.3.6 compat floors) into this branch with a normal merge, then fixed the one remaining non-pre-existing failure: the Rosenbrock Core job on Julia LTS (1.10), where this PR's ReverseDiff regression errored. The Documentation and TaylorSeries downgrade jobs are green on the default branch and this branch is now identical to the default branch for those paths.

Root cause on LTS: the broadcasted stage right-hand side of an out-of-place Rosenbrock step widens to TrackedArray{Real, ...} for ReverseDiff tracked states on Julia 1.10, and the generic factorization solve then converts the LU factors to an integer element type (InexactError: Int64(-6.358470930209569e6)). The stage solves now copy the right-hand side into the factorization element type when they differ (_rosenbrock_lsolve, used at all out-of-place stage and dense-output solves); when the element types already match the solve is unchanged.

Regression evidence (Julia 1.10, focused new testset)

Before, on both the previous head and a clean default-branch checkout:

OOP Rosenbrock preserves ReverseDiff tracked states: Error During Test
  InexactError: Int64(-6.358470930209569e6)
Test Summary:                                       | Error  Total   Time
OOP Rosenbrock preserves ReverseDiff tracked states |     1      1  16.4s

After:

gradient = [1.0, 1.2000000000049889, -0.2199999999972647]
Test Summary:                                       | Pass  Total   Time
OOP Rosenbrock preserves ReverseDiff tracked states |    1      1  15.8s

The same focused test also passes on Julia 1.11.

Local validation

GROUP=Core julia +1.10 --project=lib/OrdinaryDiffEqRosenbrock -e 'using Pkg; Pkg.test()'
Test Summary:           | Pass  Total   Time
DAE Rosenbrock AD Tests |   16     16  9m59.0s
Test Summary:                    | Pass  Total   Time
Callback-truncated interpolation | 2628   2628  1m47.9s
Test Summary:       | Pass  Total   Time
Rosenbrock AD Tests |   65     65  5m42.0s
Test Summary:                | Pass  Total   Time
Rosenbrock Convergence Tests |  228    228  5m20.8s
GROUP=QA julia +1.11 --project=lib/OrdinaryDiffEqRosenbrock -e 'using Pkg; Pkg.test()'
Test Summary:    | Pass  Broken  Total     Time
Allocation Tests |   20      20     40  12m01.3s
Test Summary:   | Pass  Total     Time
Inference Tests |   40     40  8m21.7s
Test Summary: | Pass  Total  Time
JET Tests     |    1      1  38.2s
Test Summary: | Pass  Fail  Total     Time
Aqua          |   20     1     21  1m43.7s

The single Aqua failure is the persistent-tasks check: package precompilation did not exit within its 60 s bound while the machine load average was above 50. A fresh using OrdinaryDiffEqRosenbrock loads and exits in 3 s, and every other Aqua check (ambiguities, piracy, stale deps, compat, ExplicitImports, public API) passes.

julia --project=@runic -m Runic --inplace <changed files>
julia --project=@runic -m Runic --check <changed files>
typos <changed files>

All exit 0, no output.

Pre-existing failures on the default branch, unchanged by this head (deterministic CI comparison): both GPU jobs, AD on Julia LTS, SciMLSensitivity Core2 downstream, and ProbNumDiffEq downstream (the TaylorDiff Symbolics.Num precompile error that the merged TaylorDiff 0.3.6 floors address). No assertions, tolerances or test settings were weakened.

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


🤖 Posted by an AI agent — harness: Muse CLI Code · model: muse-wonder-full-1.0
Conversation: local fixer job SciML__OrdinaryDiffEq.jl__4101 (no session URL)

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
@ChrisRackauckas

Copy link
Copy Markdown
Member

Doesn't JuliaArrays/ArrayInterface.jl#498 cover this?

ChrisRackauckas and others added 3 commits November 6, 2026 15:53
…ixes

Require ArrayInterface 7.29 and retain the analytic ReverseDiff regression.
Use the owning package's tracked-array restructuring support directly.
Merge upstream/master to include its differentiation and CI fixes while
preserving the existing branch history.

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__OrdinaryDiffEq.jl__4101 (no session URL)
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Muse <noreply@meta.com>
Agent-Harness: Muse CLI Code
Agent-Model: muse-wonder-full-1.0
Agent-Session: local fixer job SciML__OrdinaryDiffEq.jl__4101 (no session URL)
On Julia 1.10 the broadcasted stage right-hand side of an
out-of-place Rosenbrock step can widen to an abstract element
type for ReverseDiff tracked states, and the generic
factorization solve then converts the factors to an integer
element type. Copy the right-hand side into the factorization
element type when they differ.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Muse <noreply@meta.com>
Agent-Harness: Muse CLI Code
Agent-Model: muse-wonder-full-1.0
Agent-Session: local fixer job SciML__OrdinaryDiffEq.jl__4101 (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.

2 participants