You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The custom enzyme rule for solve_up fails when doing sensitivity analysis for a delay differential equation problem.
I expected the same rule that works for ODEProblem to work for DDEProblem
Minimal Reproducible Example 👇
using OrdinaryDiffEq
using DelayDiffEq
using SciMLSensitivity
using Enzyme
using Zygote
using Test
## Zygote matches Enzyme for ODEProblem f(du, u, p, t) = du .= u .* p
u0p = [2.0, 3.0]
functionf(u0p)
prob =ODEProblem{true}(f, u0p[1:1], (0.0, 1.0), u0p[2:2])
sum(solve(prob, Rodas4(), abstol =1e-9, reltol =1e-9, saveat =0.1))
endf(u0p)
du0p_zygote = Zygote.gradient(f, u0p)[1]
du0p =zeros(2)
Enzyme.autodiff(Reverse, f, Active, Duplicated(u0p, du0p))
@test du0p_zygote == du0p
## Enzyme fails for DDEProblemfunctionf_delay(du, u, h, p, t)
du .= u .* p .*h(p, t -0.01)[1]
endh(p, t) =ones(eltype(p), 2)
u0p = [2.0, 3.0]
functionf(u0p)
prob =DDEProblem{true}(f_delay, u0p[1:1], h, (0.0, 0.2), u0p[2:2], constant_lags = [0.1])
sum(solve(prob, MethodOfSteps(Rodas4()), abstol =1e-9, reltol =1e-9, saveat =0.1))
endf(u0p)
du0p_zygote = Zygote.gradient(f, u0p)[1]
du0p =zeros(2)
Enzyme.autodiff(Reverse, f, Active, Duplicated(u0p, du0p)) #Fails @test du0p_zygote == du0p
Error & Stacktrace ⚠️
ERROR: MethodError: no method matching MixedDuplicated(::ODESolution{…}, ::ODESolution{…})
Closest candidates are:MixedDuplicated(::T1, ::Base.RefValue{T1}) where T1
@ EnzymeCore C:\Users\Matt Bossart\.julia\packages\EnzymeCore\a2poZ\src\EnzymeCore.jl:163MixedDuplicated(::T1, ::Base.RefValue{T1}, ::Bool) where T1
@ EnzymeCore C:\Users\Matt Bossart\.julia\packages\EnzymeCore\a2poZ\src\EnzymeCore.jl:163
Stacktrace:
[1] runtime_generic_augfwd(activity::Type{…}, width::Val{…}, ModifiedBetween::Val{…}, RT::Val{…}, f::typeof(SciMLBase.wrap_sol), df::Nothing, primal_1::ODESolution{…}, shadow_1_1::ODESolution{…})
@ Enzyme.Compiler C:\Users\Matt Bossart\.julia\packages\Enzyme\aioBJ\src\rules\jitrules.jl:147
Some type information was truncated. Use `show(err)` to see complete types.
Environment (please complete the following information):
The custom enzyme rule for
solve_up
fails when doing sensitivity analysis for a delay differential equation problem.I expected the same rule that works for
ODEProblem
to work forDDEProblem
Minimal Reproducible Example 👇
Error & Stacktrace⚠️
Environment (please complete the following information):
using Pkg; Pkg.status()
versioninfo()
The text was updated successfully, but these errors were encountered: