Skip to content

Mark CallbackCache as non-differentiable for Mooncake - #4688

Merged
ChrisRackauckas merged 4 commits into
SciML:masterfrom
AstitvaAggarwal:mooncake-callbackcache-notangent
Oct 9, 2026
Merged

ChrisRackauckas merged 4 commits into
SciML:masterfrom
AstitvaAggarwal:mooncake-callbackcache-notangent

Conversation

@AstitvaAggarwal

@AstitvaAggarwal AstitvaAggarwal commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Fixes SciML/SciMLSensitivity.jl#1680.

Since #4376, ODEIntegrator.callback_cache is Union{Nothing, CallbackCache} when callbacks are erased. Mooncake can't build a tangent for that field, so MooncakeAdjoint HVPs fail with no constructors have been defined for Any.

This gives the Union field no tangent. A concretely typed cache keeps its tangent, so event-time gradients are unaffected, and nothing changes at runtime.

Tests: the #1680 HVP, and an event-time gradient through a VectorContinuousCallback.

cc: @ChrisRackauckas , @ChrisRackauckas-Claude

@AstitvaAggarwal

AstitvaAggarwal commented Sep 30, 2026 •

Copy link
Copy Markdown
Member Author

Unlike #4689, this doesn't change the solver, so there are no extra allocations and none of the failures there from building a CallbackCache for every erased solve (units, custom arrays, null u0, enum states). Only the erased field Union{Nothing, CallbackCache} loses its tangent, so event-time gradients still work (the bouncing-ball test gives [-1.0, 285.6]).

Neither PR handles callbacks on default problems on Julia 1.12 under MooncakeAdjoint; both still fail at invokelatest.

@AstitvaAggarwal

AstitvaAggarwal commented Oct 2, 2026 •

Copy link
Copy Markdown
Member Author

This PR is likely a quicker and smaller focused fix (within the Mooncake ext) for the current AD issue without changes in the core solver.

@ChrisRackauckas
ChrisRackauckas merged commit 0559b2b into SciML:master Oct 9, 2026
134 of 139 checks passed
ChrisRackauckas referenced this pull request Oct 13, 2026
…inaryDiffEqBDF, OrdinaryDiffEqExplicitRK, OrdinaryDiffEqFIRK, OrdinaryDiffEqFeagin, OrdinaryDiffEqHighOrderRK, OrdinaryDiffEqPDIRK, OrdinaryDiffEqRKN, OrdinaryDiffEqSDIRK, StochasticDiffEqHighOrder, StochasticDiffEqLowOrder, and StochasticDiffEqMilstein for release (#4871)

Agent-Harness: Devin CLI 3000.11.3
Agent-Model: Fusion (Claude Opus 5.5 Medium + SWE-2 Medium)
Agent-Session: local transcript ~/.local/share/devin/cli/transcripts/flash-hour.json

Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
ChrisRackauckas added a commit that referenced this pull request Oct 14, 2026
Releases #4688 (CallbackCache non-differentiable for Mooncake), the only
DiffEqBase change since 7.21.3. SciMLSensitivity Core1 "Mooncake with
MooncakeAdjoint" keeps failing until it is registered.



Agent-Harness: Claude Code (subagent of ci-green head)
Agent-Model: claude-opus-5-5[1m]
Agent-Session: https://claude.ai/code/session_011aK5Xvp9NpdkzKuEwtiMGd

Co-authored-by: ChrisRackauckas-Claude <[email protected]>
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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.

MooncakeAdjoint HVP fails on Julia 1.12 since callback types are erased

2 participants