Feature/custom structs backsolve adjoint#1292
Closed
simenhu wants to merge 6 commits intoSciML:masterfrom
Closed
Conversation
Contributor
|
I've rebased this PR onto the latest master to resolve the merge conflicts. The rebased branch is available at: https://github.com/ChrisRackauckas-Claude/SciMLSensitivity.jl/tree/feature/custom_structs_backsolve_adjoint @simenhu To update your PR with the rebased changes, you can run: git remote add claude https://github.com/ChrisRackauckas-Claude/SciMLSensitivity.jl.git
git fetch claude feature/custom_structs_backsolve_adjoint
git checkout feature/custom_structs_backsolve_adjoint
git reset --hard claude/feature/custom_structs_backsolve_adjoint
git push --force origin feature/custom_structs_backsolve_adjointThe rebase resolved the following conflicts in
Co-Authored-By: Chris Rackauckas [email protected] |
2 tasks
Contributor
|
Opened a rebased version of this PR at #1335. |
Minor optimization: cache the result of isscimlstructure(p) in a local variable to avoid calling it twice in the hot _vecjacobian! path. Co-Authored-By: Chris Rackauckas <[email protected]>
Performance optimization: use the pre-cached wrapped function (pf) from S.diffcache.pf instead of calling repack_ode_function in every _vecjacobian! call. The function wrapping is already done during setup in adjoint_common.jl, so we can reuse it directly. This avoids: - Closure creation in the hot path - Calling repack inside the closure on every ODE evaluation Co-Authored-By: Chris Rackauckas <[email protected]>
…ions The closure was only defined for inplace signature (du, u, p, t), but out-of-place functions need (u, p, t) signature. Added isinplace parameter to generate the correct closure based on the function type. Co-Authored-By: Chris Rackauckas <[email protected]>
For some sensitivity algorithms (QuadratureAdjoint, etc.), pf is set to nothing in adjointdiffcache. Fall back to the original behavior of using SciMLBase.Void(f) for inplace or f for out-of-place when pf is nothing. Co-Authored-By: Chris Rackauckas <[email protected]>
0e9e939 to
d7661ab
Compare
ChrisRackauckas-Claude
pushed a commit
to ChrisRackauckas-Claude/SciMLSensitivity.jl
that referenced
this pull request
Feb 12, 2026
Change CallbackAffectPWrapper signature from (dp, p, u, t) to (dp, u, p, t) and use the dgrad output path for p-derivatives instead of hijacking the dλ (u-derivative) path via swapped vecjacobian! arguments. This unblocks PRs SciML#1335, SciML#1292, SciML#1260, SciML#1223 that need SciMLStructures support, where canonicalize(Tunable(), _p) was running on state y instead of actual parameters, and Enzyme code assumed position 2 is a state-like object. Changes: - CallbackAffectPWrapper: (dp, p, u, t) → (dp, u, p, t) - vecjacobian! calls: use standard arg order with dgrad kwarg - Add _get_wp_paramjac_config helper for param-sized output buffers - ReverseDiff on-the-fly tape: PSwap dispatch for param-sized output - QuadratureAdjoint callback path: normalize wp call and vecjacobian! Co-Authored-By: Chris Rackauckas <[email protected]>
3 tasks
ChrisRackauckas-Claude
pushed a commit
to ChrisRackauckas-Claude/SciMLSensitivity.jl
that referenced
this pull request
Feb 13, 2026
Previously only GaussAdjoint supported SciMLStructures-compatible parameter types. This extends support to BacksolveAdjoint, InterpolatingAdjoint, and QuadratureAdjoint by: - Fixing parameter gates in concrete_solve.jl and sensitivity_interface.jl to allow SciMLStructures types through - Wrapping unwrappedf with repack in ForwardDiff ParamJacobianWrapper and ParamGradientWrapper (adjoint_common.jl) so ForwardDiff sees plain vectors - Adding canonicalization in the Bool _vecjacobian! path (derivative_wrappers.jl) to pass tunables to jacobian! calls - Fixing ZygoteVJP to differentiate w.r.t. tunables with repack wrapper - Fixing EnzymeVJP to extract gradients from shadow struct via canonicalize after autodiff - Overhauling QuadratureAdjoint's AdjointSensitivityIntegrand to use tunables/repack throughout constructor, vec_pjac!, and result init Refs: SciML#1335, SciML#1292, SciML#1260, SciML#1223 Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude Opus 4.6 <[email protected]>
3 tasks
Member
|
Handled in #1349 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
contributor guidelines, in particular the SciML Style Guide and
COLPRAC.
Additional context
BacksolveAdjoint now works with SciMLStructures