Support AutoEnzyme Jacobians inside Reactant kernels - #1067
Support AutoEnzyme Jacobians inside Reactant kernels#1067ChrisRackauckas-Claude wants to merge 1 commit into
Conversation
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://chatgpt.com/codex/tasks/01a03a07-4f58-7d73-90d2-5e7aa3ba9fd7
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1067 +/- ##
==========================================
- Coverage 97.40% 93.24% -4.17%
==========================================
Files 143 142 -1
Lines 8299 8334 +35
==========================================
- Hits 8084 7771 -313
- Misses 215 563 +348
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Mister bot (and his owner), opening a PR when I reacted to the issue saying it should be fixed upstream is not cool. If you want a tracing-friendly Jacobian function, I think |
|
CI audit (2026-08-26): every executable check is green, including the new
|
Sorry this and the issue were "done at the same time", so your comment came "after" the PR. In timing-wise, yes you did slip the comment in during a 1 hour period while it was doing a local validation of the code, and it should've validated the code before opening the issue, but the issue+PR were done at exactly the same time for reasons I hope are pretty clear.
|
Ignore this PR until it has been reviewed by @ChrisRackauckas.
What changed and why
AutoEnzyme()Jacobian preparation scalar-indexes Reactant traced arrays, so ordinary DifferentiationInterface Jacobian calls fail insideReactant.@jit. This adds a Reactant weak extension that detects compilation and routes forward/defaultAutoEnzymeJacobians through Enzyme's traced-compatible batched forward autodiff path (onehotdirections plus DI pushforwards). Both out-of-place and mutating functions return Reactant arrays and support allocating, mutating, and value-plus-Jacobian APIs.The higher-level
Enzyme.jacobianconvenience function is not used because its forward implementation currently fails intupstackfor traced arrays; the underlying public Enzyme primitives work. The mutating-function route wraps the residual out of place because differentiating a mutated traced output directly produced zero tangents.Closes #1066
This is the DifferentiationInterface prerequisite for removing the custom Jacobian lowering in SciML/NonlinearSolve.jl#1197.
Verification
Failing before the fix, using the exact new test file against unmodified
mainatf0fb136d:Passing with the fix:
Existing Enzyme backend group:
Core formalities, including Aqua, JET, documentation, and ExplicitImports:
Repository pre-commit hooks passed for every changed file: typos, YAML/TOML validation, large-file and conflict checks, whitespace/EOF checks, and Runic formatting.
Not verified
AutoEnzymeis not supported by this change; default and forward mode are the intended Jacobian route.Reviewer notes
0.2.283, the version used for the reproducer and verification.🤖 Generated with Claude Code
https://chatgpt.com/codex/tasks/01a03a07-4f58-7d73-90d2-5e7aa3ba9fd7