Skip to content

Fix HVP through ode_determine_initdt - #4372

Merged
ChrisRackauckas merged 1 commit into
SciML:masterfrom
AstitvaAggarwal:fix/1277-hvp-initdt-forward-mode
Aug 25, 2026
Merged

Fix HVP through ode_determine_initdt#4372
ChrisRackauckas merged 1 commit into
SciML:masterfrom
AstitvaAggarwal:fix/1277-hvp-initdt-forward-mode

Conversation

@AstitvaAggarwal

Copy link
Copy Markdown
Member

ode_determine_initdt's Mooncake rule is registered with @zero_adjoint, which only marks it primitive under ReverseMode. That's fine for a plain gradient, but HVP forward-differentiates whatever reverse rule got built, so the outer forward pass still recurses into ode_determine_initdt's body and hits _ode_initdt_iip's try/catch (an UpsilonNode IR verification error).

Switching to @zero_derivative registers both modes, so the outer forward pass treats it as a primitive too and never reaches the try/catch.

Verified on Julia 1.10 and 1.11 against SciML/SciMLSensitivity.jl#1427's HVP regression, gradients matching ForwardDiff.

@zero_adjoint only registers the primitive for ReverseMode. HVP forward-
differentiates whatever reverse rule got built, so the outer forward pass
still recurses into ode_determine_initdt's body and hits _ode_initdt_iip's
try/catch (UpsilonNode IR verification error). @zero_derivative covers
both modes, so the outer pass treats it as a primitive too.
@AstitvaAggarwal AstitvaAggarwal changed the title Fix HVP through ode_determine_initdt Fix HVP through ode_determine_initdt Aug 25, 2026
@ChrisRackauckas
ChrisRackauckas merged commit 6b10ec9 into SciML:master Aug 25, 2026
122 of 132 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