_init_originator_gradient: wrap nested Enzyme.gradient with set_runtime_activity#1458
Draft
ChrisRackauckas-Claude wants to merge 1 commit into
Draft
Conversation
…vity The `EnzymeOriginator` overload at concrete_solve.jl:377 called `Enzyme.gradient(Enzyme.Reverse, Const(f), tunables)` without `set_runtime_activity`. The outer user-level call's `set_runtime_activity(Reverse)` flag does not propagate into this nested gradient, so the inner Enzyme call raised `EnzymeRuntimeActivityError` at MTK's init `remake` even when the caller used the documented Enzyme pattern. Wrap with `set_runtime_activity(Reverse)` so the nested gradient respects the same activity relaxation as the outer call. Unblocks the `@test_broken` Enzyme block in `test/parameter_initialization.jl` (SciML#1455). Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
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.
Please ignore this PR until reviewed by @ChrisRackauckas.
Summary
The
EnzymeOriginatoroverload of_init_originator_gradient(src/concrete_solve.jl:377) calledwithout
set_runtime_activity. The outer user-levelEnzyme.autodiff(set_runtime_activity(Reverse), ...)call's runtime-activity relaxation does not propagate into this nested gradient, so the inner Enzyme call raisedEnzymeRuntimeActivityErrorat MTK's initremakeeven when the caller used the documented pattern (see PR #1455).This patch wraps the inner gradient with
set_runtime_activity(Reverse)so the nested gradient inherits the same activity relaxation as the outer call.Diff
Effect on #1455
After this patch the
EnzymeRuntimeActivityErroris gone, but the@test_brokenEnzyme block intest/parameter_initialization.jlstill trips a different downstream error:MethodError: no method matching MixedDuplicated(::ODESolution{...})inside Enzyme's runtime-activity wrapping of theODESolutiontype. That is a separate Enzyme/MTK problem unrelated to the inner-gradient-activity issue this PR fixes. So #1455 stays@test_brokenfor now; this PR is independently useful for anyone hitting the runtime-activity error from a clean Enzyme call path.Test plan
MixedDuplicated/ODESolutionMethodError rather thanEnzymeRuntimeActivityError, confirming this PR moves past the inner-activity wall.