Repository navigation
Handle despecialized parameter cotangents in ODE solution AD - #1567
ChrisRackauckas merged 1 commit into
Conversation
ChainRulesCore returns a Tangent around DespecializedParameters for ODESolution pullbacks. Unwrap that cotangent before remaking the problem, and cover the path in the downstream autodiff test. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Codex <[email protected]> Agent-Harness: Codex CLI Agent-Model: gpt-5-codex Agent-Session: /home/crackauc/sandbox/tmp_20260829_113159_30815
|
Independent native-run check found a missing test dependency in the new regression test. Applying this PR's exact extension/test changes to clean SciMLBase GROUP=DownstreamAD julia --project=. -e 'using Pkg; Pkg.test()'exits 1 before executing assertions: The runner activates I have made that two-line environment change locally and restarted the native group; no passing-after result is claimed yet. This is a composed validation with the fixture correction in #1576 and a local Mooncake NamedTuple-copy fix for chalk-lab/Mooncake.jl#1299. Neither affects this import failure. The original unmodified SciMLBase run reached the known Zygote tangent error (4 pass, 1 error, 1 pre-existing broken), confirming the environment could run the original test file. 🤖 Generated with Codex CLI 0.153.4 (model: gpt-6-astra; session: local session ID 01a0598f-11b9-72d1-91d9-b2fbb186557d). |
|
After adding the missing downstream dependency, the exact new regression test still fails in the native Julia 1.10.11 DownstreamAD group (exit 1): The unconfigured The seven original assertions pass with your production fix. The added regression needs to exercise the intended pullback. I am testing the following repair through the public Zygote interface, keeping the original type assertion: _, pullback = Zygote.pullback(s -> s[o, 1], sol)
cotangent = ChainRulesCore.unthunk(only(pullback(one(sol[o, 1]))))
@test cotangent.prob.p isa SciMLBase.DespecializedParametersThe repaired test's native failing-before run is in progress with the production fix removed. Passing-after verification is still pending; no assertions were skipped or weakened. 🤖 Generated with Codex CLI 0.153.4 (model: gpt-6-astra; session: local session ID 01a0598f-11b9-72d1-91d9-b2fbb186557d). |
|
The corrected regression now discriminates and passes locally. This supersedes the earlier suggested output-wrapper assertion, which was wrong: the primal solution parameters are despecialized, but AD reconstruction may legitimately return concrete parameter cotangents. The test uses the public configured Native validation on Julia 1.10.11: These are not full downstream-group success claims. The focused current-master tree subsequently hits the separate observable fixture failures addressed in #1576. A composed run including that fixture correction passed observable AD (23 pass, one pre-existing broken), then received SIGTERM in ensemble adjoints; an identical-source retry is running. The environment also includes a locally validated, unpublished Mooncake output-copy fix. No checks were skipped or weakened. The test-only follow-up remains local pending full validation; no duplicate production fix is proposed. 🤖 Generated with Codex CLI 0.153.4 (model: gpt-6-astra; local session ID: 01a0598f-11b9-72d1-91d9-b2fbb186557d). |
Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude <[email protected]> Claude-Session: https://chatgpt.com/codex/tasks/01a03a17-ad6f-7131-82fc-d0fd57ea6512 Co-authored-by: ChrisRackauckas-Claude <[email protected]>
`test/downstream/remake_autodiff.jl` has used `ChainRulesCore` since #1567, but it was never added to `test/downstream/Project.toml`. `GROUP=DownstreamAD` fails on master with Autodiff Remake: Error During Test LoadError: ArgumentError: Package ChainRulesCore not found in current path. Autodiff Remake is the group's first testset, so the error aborts the run before the rest of the group executes. Claude-Session: https://claude.ai/code/session_019wKpyZHy9u4QhR4ePiVmam Co-authored-by: ChrisRackauckas-Claude <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
* Add the missing ChainRulesCore test dependency `test/downstream/remake_autodiff.jl` has used `ChainRulesCore` since #1567, but it was never added to `test/downstream/Project.toml`. `GROUP=DownstreamAD` fails on master with Autodiff Remake: Error During Test LoadError: ArgumentError: Package ChainRulesCore not found in current path. Autodiff Remake is the group's first testset, so the error aborts the run before the rest of the group executes. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_019wKpyZHy9u4QhR4ePiVmam * Dispatch the despecialized cotangent test through a RuleConfig `ChainRulesCore.rrule(getindex, sol, x, 1)` has no `RuleConfig` argument, so it never reached the `ODESolution` rule under test and fell through to the generic `ChainRules` `AbstractArray` rule, whose `InplaceableThunk` has no `prob` field. Passing `Zygote.ZygoteRuleConfig()` exposes a second bug: the non-observed branch of the pullback hands `remake` a `Tangent{DespecializedParameters}`, so the `Tangent` unwrapping is hoisted to cover both branches. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_019wKpyZHy9u4QhR4ePiVmam --------- Co-authored-by: ChrisRackauckas-Claude <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
|
The complete native Julia 1.10.11 The first run received SIGTERM after the first two test files; that evidence is preserved. The unchanged-source retry completed the ensemble file in 61m39.6s. This is composed evidence: base 3d95609, the observed tangent fix from the merged #1567, the observable fixture change from #1576, the corrected numerical regression/dependency declaration described above, and a local Mooncake output-copy correction. It is not validation of today's master. Since then, upstream has merged #1582, #1584 and #1587. The root's older test-only proposal will not be published as a duplicate. A clean current-master native audit is running with registry dependencies, including Mooncake 0.5.53's own output-copy correction. 🤖 Generated with Codex CLI 0.153.4 (model: gpt-6-astra; local session ID: 01a0598f-11b9-72d1-91d9-b2fbb186557d). |
What changed
ChainRulesCore returns
Tangent{DespecializedParameters}for the parameter cotangent produced by the symbolic ODESolution pullback. Unwrap this cotangent before callingremake, and add a regression test at the pullback boundary. This is intentionally separate from #1564.Please ignore this draft until reviewed by @ChrisRackauckas.
Failing-before / passing-after
Environment: Julia 1.10.12 (commit d93beab124c), ModelingToolkit 11.40.0, ModelingToolkitBase 1.68.1, isolated
JULIA_DEPOT_PATH.Before the fix, exact command:
env JULIA_DEPOT_PATH=/home/crackauc/sandbox/tmp_20260829_113159_30815/SciMLBase-downstreamad-master/.julia_depot TMPDIR=/home/crackauc/tmp /home/crackauc/.juliaup/bin/julia +1.10.12 --project=downstream -e 'include("downstream/remake_autodiff.jl")'failed (exit 1) with:
After the fix, the same command passed (exit 0):
Other validation
GROUP=QA julia +1.10.12 --project -e 'using Pkg; Pkg.test()':QA | 121 | 121,SciMLBase tests passed.typos ext/SciMLBaseChainRulesCoreExt.jl test/downstream/remake_autodiff.jl: exit 0.GROUP=DownstreamADrun still reports unrelated existing failures inobservables_autodiff.jl(Mooncake type assertion and AutoZygote parameter equality); the focusedremake_autodiff.jltest is green.🤖 Generated with Codex CLI (model: gpt-5-codex). Agent session:
/home/crackauc/sandbox/tmp_20260829_113159_30815(local session path).