Fix HVP through ode_determine_initdt - #4372
Merged
ChrisRackauckas merged 1 commit intoAug 25, 2026
Merged
Conversation
@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.
ode_determine_initdt
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.
ode_determine_initdt's Mooncake rule is registered with@zero_adjoint, which only marks it primitive underReverseMode. That's fine for a plain gradient, but HVP forward-differentiates whatever reverse rule got built, so the outer forward pass still recurses intoode_determine_initdt's body and hits_ode_initdt_iip's try/catch (an UpsilonNode IR verification error).Switching to
@zero_derivativeregisters 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.