-
-
Notifications
You must be signed in to change notification settings - Fork 121
Fix Enzyme solve_up rule signature to support DuplicatedNoNeed #1218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Enzyme solve_up rule signature to support DuplicatedNoNeed #1218
Conversation
Fixes SciML/SciMLSensitivity.jl#1225 The Enzyme rules for solve_up were failing when sensealg was passed via the ODEProblem constructor instead of solve(). The issue was that the return type annotation was restricted to Duplicated{RT}, but Enzyme can also use DuplicatedNoNeed{RT}. Changes: - Updated augmented_primal signature to accept both Duplicated and DuplicatedNoNeed - Updated reverse signature to accept both Duplicated and DuplicatedNoNeed - Fixed type handling to extract the inner result type instead of using the annotation type - Removed incorrect type assertion in reverse function 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
UpdateI've corrected the fix. The key changes: Previous (incorrect) approach: ::Type{RT} where {RT <: Union{Duplicated, DuplicatedNoNeed}}This made Corrected approach: ::Type{<:Union{Duplicated{RT}, DuplicatedNoNeed{RT}}} where {RT}This correctly extracts Current Status✅ MethodError fixed - The function signature now properly matches both The signature fix is correct and necessary - it resolves the immediate MethodError reported in issue #1225. The segfault is a separate Enzyme issue that would need to be reported upstream. |
|
Closing to create a cleaner PR with the corrected fix. |
|
@ChrisRackauckas this PR is itself broken and causes issues for downstream users of the current code.... |
|
also beyond the type loss, this is also incorrect as you're returning a primal in a case the primal was not requested. we should probably move this to easyrules |
Summary
Fixes SciML/SciMLSensitivity.jl#1225
The Enzyme rules for
solve_upwere failing whensensealgwas passed via theODEProblemconstructor instead ofsolve(). The issue was that the return type annotation was restricted toDuplicated{RT}, but Enzyme can also useDuplicatedNoNeed{RT}.Changes
augmented_primalsignature to accept bothDuplicatedandDuplicatedNoNeedreversesignature to accept bothDuplicatedandDuplicatedNoNeeddres::RTin reverse functionDetails
The error was:
The closest candidate was:
The fix makes the signature accept both types:
Test plan
🤖 Generated with Claude Code