Skip to content

Add Rosenbrock ReverseDiffAdjoint regression coverage - #4255

Closed
ChrisRackauckas-Claude wants to merge 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:fix-4248-rosenbrock-tracked-k-cache
Closed

ChrisRackauckas-Claude wants to merge 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:fix-4248-rosenbrock-tracked-k-cache

Conversation

@ChrisRackauckas-Claude

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

Copy link
Copy Markdown
Member

Ignore this PR until it has been reviewed by @ChrisRackauckas.

What changed and why

Add a regression test for an out-of-place Rosenbrock23(autodiff = AutoFiniteDiff()) solve differentiated with ReverseDiffAdjoint(). The test covers the failure reported in #4248 without adding a container-conversion workaround to OrdinaryDiffEq.

The underlying bug belongs to ArrayInterface.restructure: a ReverseDiff.TrackedArray template combined with an Array{TrackedReal} source fell through to the generic implementation and lost the tracked-array wrapper. The owner-package fix is already merged in JuliaArrays/ArrayInterface.jl#498, but is not yet in a tagged ArrayInterface release. Do not merge this PR until an ArrayInterface release containing that fix is available.

Failing before

Using released ArrayInterface v7.28.1 with the OrdinaryDiffEq regression test:

Out-of-place Rosenbrock23 with ReverseDiffAdjoint: Error During Test
Cannot convert Vector{ReverseDiff.TrackedReal{...}} to
ReverseDiff.TrackedArray{...}
...
rosenbrock_perform_step.jl:328
Test Summary:                                     | Error  Total
Out-of-place Rosenbrock23 with ReverseDiffAdjoint |     1      1

A direct ArrayInterface reproducer on v7.28.1 showed:

tracked template => Vector{ReverseDiff.TrackedReal{...}}
Array{TrackedReal} template => Vector{ReverseDiff.TrackedReal{...}}
Test Failed: restructure(tracked_template, tracked_values) isa ReverseDiff.TrackedArray

This also confirms why an unconditional downstream aos_to_soa is incorrect: the Array{TrackedReal} template must remain an Array.

Passing after the owner fix

With ArrayInterface commit 58f1c4f9ab203ff6e8c0628575b09b2e1e7edab2 from the merged owner fix:

tracked template => ReverseDiff.TrackedArray{...}
Array{TrackedReal} template => Vector{ReverseDiff.TrackedReal{...}}
2/2 passed

The same OrdinaryDiffEq command then passed:

julia +1.12 --project=test/AD --startup-file=no test/AD/autodiff_events.jl

Out-of-place Rosenbrock23 with ReverseDiffAdjoint | Pass 1 Total 1
Mooncake gradient tests                           | Pass 2 Total 2
process exit: 0

Additional validation performed:

GROUP=Core julia +1.10 --project=. -e 'using Pkg; Pkg.test()'  # ArrayInterface master
BandedMatrices 21/21
BlockBandedMatrices 8/8
Core 221/221
AD Integration 28/28
StaticArrays 39/39
ChainRules 20/20
FillArrays 7/7
Testing ArrayInterface tests passed

GROUP=QA julia +1.12 --project=. -e 'using Pkg; Pkg.test()'  # rebased OrdinaryDiffEq, registered deps
Quality Assurance Tests 90/90
Testing OrdinaryDiffEq tests passed

Runic, typos, and git diff --check pass on the final diff.

Not verified

  • GPU and downstream jobs were not run locally.
  • GROUP=Everything was not run.
  • Documentation was not built because this adds no public API, docstring, or documentation page.

ReverseDiff is MIT licensed: https://github.com/JuliaDiff/ReverseDiff.jl/blob/master/LICENSE.md

Closes #4248

ChrisRackauckas-Claude commented Aug 14, 2026 •

Copy link
Copy Markdown
Member Author

Superseded CI note for the previous head: the branch has now been rebased onto current master, which includes the DiffEqBase/SciMLBase blocker fix from #4253.

The over-broad OrdinaryDiffEq aos_to_soa workaround has also been removed. Current head 33b4558eac78767db1b33fbac6ea4030fac88436 is test-only and depends on the merged, unreleased owner-package fix JuliaArrays/ArrayInterface.jl#498. Current-head CI should be evaluated separately from the old jobs linked here.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
@ChrisRackauckas-Claude
ChrisRackauckas-Claude force-pushed the fix-4248-rosenbrock-tracked-k-cache branch from d93c4c4 to 33b4558 Compare August 14, 2026 10:44
@ChrisRackauckas-Claude ChrisRackauckas-Claude changed the title Fix Rosenbrock23 out-of-place ReverseDiffAdjoint state restructuring Add Rosenbrock ReverseDiffAdjoint regression coverage Aug 14, 2026
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.

Rosenbrock23 fails with out-of-place ReverseDiffAdjoint due to k cache type

2 participants