Skip to content

Conversation

@ChrisRackauckas-Claude
Copy link
Contributor

Summary

  • Normalizes CallbackAffectPWrapper signature from (dp, p, u, t) to (dp, u, p, t) to match the standard (du, u, p, t) convention
  • Uses the dgrad output path (p-derivative) in vecjacobian! instead of hijacking the path (u-derivative) via swapped arguments
  • Adds _get_wp_paramjac_config helper for correct param-sized output buffers in Enzyme and ReverseDiff VJP paths

This unblocks PRs #1335, #1292, #1260, #1223 that need SciMLStructures support, where canonicalize(Tunable(), _p) was running on state y instead of actual parameters (because integrator.p was passed in the y position), and Enzyme code assumed position 2 is a state-like object.

Files changed

  • src/callback_tracking.jl — Signature change, normalized vecjacobian! calls, added _get_wp_paramjac_config helper, replaced get_paramjac_config with param-aware version
  • src/derivative_wrappers.jl — ReverseDiff on-the-fly tape: CallbackSensitivityFunctionPSwap dispatch for param-sized output buffer
  • src/quadrature_adjoint.jl — QuadratureAdjoint callback path: normalized wp call order, vecjacobian! args, and paramjac config

Test plan

  • Callbacks1 test group passes all 360 tests locally (Julia 1.12.4)
  • Verified unmodified code also passes 360 tests (baseline comparison)
  • Critical test cases exercised: "parameter changing callback", "Dosing example", all sensealg variants (BacksolveAdjoint, InterpolatingAdjoint, QuadratureAdjoint, GaussAdjoint, ReverseDiffAdjoint)

🤖 Generated with Claude Code

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]>
@ChrisRackauckas ChrisRackauckas merged commit 3172d7f into SciML:master Feb 13, 2026
45 of 48 checks passed
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.

2 participants