Repository navigation
Fix reverse AD through despecialized parameters - #1228
ChrisRackauckas merged 1 commit into
Conversation
Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: OpenAI Codex <[email protected]> Agent-Harness: Codex (version unknown) Agent-Model: unknown Agent-Session: local thread 01a06c1d-564b-7ef0-ada6-d83a233b55e2
|
CI is fully resolved: 29 checks passed, 3 skipped, and 64 failed. An exhaustive audit of all 64 failed-job logs found The same failure reproduces on clean NonlinearSolve master. It is tracked at SciML/SparseColumnPivotedQR.jl#72 and fixed by the green draft SciML/SparseColumnPivotedQR.jl#71. Developing that fix while retaining AMD 0.5.4 made the local NonlinearSolveBase suite pass 366/366 and root QA pass 28/28, as recorded in this PR body. |
|
CI follow-up after the refreshed run:
Release ordering: this PR needs to own NonlinearSolveBase 2.49.3 because SciML/ModelingToolkit.jl#5062 now requires its reverse-mode AD fixes. #1226 currently also claims 2.49.3; after this PR is reviewed, merged, and released, that PR should rebase and bump to 2.49.4. |
|
Retriggering the unchanged draft now that the transient SciPy link is reachable again and the exact Julia 1.10.12 Broyden reproducer passes locally. |
- NonlinearSolveBase: rebuild a pre-wrapped function when its signatures do not match u0/p (#1226) - Fix reverse AD through despecialized parameters (#1228) - Preserve Jacobian cache parameter representation (#1227) - Preserve TrustRegion cache parameter representation on reinit (#1229) Agent-Harness: Claude Code Agent-Model: claude-opus-5[1m] Claude-Session: https://claude.ai/code/session_014FEzNTLFutCmTEAZ3zBg5R Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
- NonlinearSolveBase: rebuild a pre-wrapped function when its signatures do not match u0/p (#1226) - Fix reverse AD through despecialized parameters (#1228) - Preserve Jacobian cache parameter representation (#1227) - Preserve TrustRegion cache parameter representation on reinit (#1229) - Run runic on docstrings and markdown files (#1231) - Release NonlinearSolveFirstOrder 2.5.1 (#1232) - NonlinearSolveBase: report the wrapped arity for despecialization wrappers (#1230) Agent-Harness: Claude Code Agent-Model: claude-opus-5[1m] Claude-Session: https://claude.ai/code/session_014FEzNTLFutCmTEAZ3zBg5R Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
- Drop stale [compat] majors older than one year (#1198) - Drop @fastmath from L2_NORM/Linf_NORM so isfinite guards survive (#1182) - Release 4.28.1 (#1202) - Release 2.48.1 (#1206) - Align QA NLsolve compat with root project (#1205) - Widen NonlinearSolveBase LogExpFunctions compat to 0.3.28–1 (#1203) - Continue polyalgorithm after stalled least-squares solves (#1204) - Align Wrappers NLsolve compat with root project (#1208) - Release 2.48.2 (#1210) - Preserve despecialized parameters during reinit (#1199) Agent-Harness: Claude Code Agent-Model: claude-opus-5[1m] Claude-Session: https://claude.ai/code/session_014FEzNTLFutCmTEAZ3zBg5R Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
- Require all components to stall before resetting Broyden (#1184) - Add adaptive Jacobian reuse to first-order solvers (#1072) - Release 4.29.1 (#1220) - Release 2.49.1 (#1221) - Release 1.15.3 (#1222) - Fix @static_timeit for TimerOutputs ≥ 0.5.27 (#1224) (#1225) - NonlinearSolveBase: rebuild a pre-wrapped function when its signatures do not match u0/p (#1226) - Fix reverse AD through despecialized parameters (#1228) - Preserve Jacobian cache parameter representation (#1227) - Preserve TrustRegion cache parameter representation on reinit (#1229) Agent-Harness: Claude Code Agent-Model: claude-opus-5[1m] Claude-Session: https://claude.ai/code/session_014FEzNTLFutCmTEAZ3zBg5R Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
- Remove name duplicates in keyword arguments/named tuples (#1238) - Add 32-bit Core CI lane via test_groups.toml (#1239) - Add a native bounded trust-region solver (#1219) Agent-Harness: Claude Code Agent-Model: claude-opus-5[1m] Claude-Session: https://claude.ai/code/session_014FEzNTLFutCmTEAZ3zBg5R Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
What changed
Reverse-mode sensitivity calculations now unwrap
DespecializedParametersbefore the inner adjoint solve and restore the wrapper-shaped cotangent at the outer AD boundary. Enzyme accumulation now follows structured non-tunable fields through that wrapper, while the Mooncake bridge converts the resulting nestedNamedTuplecotangents into Mooncake forward/reverse data.This is the NonlinearSolveBase companion needed by SciML/ModelingToolkit.jl#5062: that PR intentionally despecializes MTK initialization problems, which exposed the existing reverse-AD assumptions about concrete parameter layout. The separate #1226 addresses a prewrapped-function signature mismatch and does not handle these structured cotangents.
Regression evidence
Before this fix,
SciMLSensitivity/test/Core8/desauty_dae_mwe.jlreported13 pass, 4 errors, 5 broken: Enzyme and Mooncake could not propagate through the newly despecialized SCC initialization problems. After the initial exception paths were repaired, the same run reported17 pass, 4 fail, 5 brokenbecause all four SCC parameter gradients were zero. The new structured Mooncake regression test also failed before the final converter with:With this change, the same downstream SCC test reports:
The five
brokenassertions predate this change and were not altered.Verification
GROUP=Adjoint julia +1.12 --project=. -e 'using Pkg; Pkg.test()'— all three safe testsets passed: 6/6 Adjoint, 3/3maybe_wrap_nonlinear_f, and 1/1 Enzyme reverse-mode.julia +1.12 --project=test/Adjoint -e 'using Test; include("test/Adjoint/adjoint_tests__item1.jl")'— exit 0, including vector and nested structuredAutoDespecializegradients through Zygote and Mooncake.julia +1.10 --project=test/Adjoint -e 'using Test; include("test/Adjoint/adjoint_tests__item1.jl")'— exit 0.julia +1.12 --project=lib/NonlinearSolveBase -e 'using Pkg; Pkg.test()'— 366/366 assertions passed after developing the already-open SparseColumnPivotedQR fix described below; the new Enzyme accumulation test was 10/10.GROUP=QA julia +1.12 --project=. -e 'using Pkg; Pkg.test()'— 28/28 passed with the same dependency fix developed.julia +1.12 --project=. -e 'include("test/Core8/desauty_dae_mwe.jl")'in SciMLSensitivity with local ModelingToolkit and NonlinearSolveBase — 21 passed, 5 pre-existing broken.SnoopCompileCore.@snoop_invalidationswhile loading NonlinearSolveBase, ChainRulesCore, and Mooncake — upstream and this branch are exactly equal atlogedges=397,logmeths=8543.julia +1.12 -m Runic --check <changed Julia files>— clean.typos <changed files>— clean.git diff --check— clean.The unmodified dependency resolve currently fails before tests because AMD 0.5.4 removed the private
AMD.SS_Intbinding used by SparseColumnPivotedQR 2.1.7. This reproduces on clean NonlinearSolve master. The existing fix SciML/SparseColumnPivotedQR.jl#71 replaces that private access with publiccolamd; its CI is green, and developing it while retaining AMD 0.5.4 makes clean-master and this branch pass. The regression is tracked at SciML/SparseColumnPivotedQR.jl#72.Review notes
The Mooncake method is deliberately restricted to
ChainRulesCore.Tangent{SciMLBase.DespecializedParameters}. Mooncake documentsincrement_and_get_rdata!as the extension point when@from_chainrulescannot convert a tangent combination; a broadNamedTuplemethod here would be type piracy beyond this package's wrapper.I did not run
GROUP=Everything, GPU jobs, downstream packages beyond the targeted SciMLSensitivity regression, or the docs build. No public API or documentation changed.🤖 Generated with Codex (version unknown; model: unknown; session: local thread 01a06c1d-564b-7ef0-ada6-d83a233b55e2)