From d75fefa400316945b06c660c7618a6da81d6d411 Mon Sep 17 00:00:00 2001 From: Avik Pal Date: Thu, 28 Mar 2024 10:26:30 -0400 Subject: [PATCH 1/2] Fix SteadyState Adjoint for OOP jacobian --- src/steadystate_adjoint.jl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/steadystate_adjoint.jl b/src/steadystate_adjoint.jl index 5b7b88c4a..4daeb7eba 100644 --- a/src/steadystate_adjoint.jl +++ b/src/steadystate_adjoint.jl @@ -55,7 +55,11 @@ end if needs_jac if DiffEqBase.has_jac(f) - f.jac(diffcache.J, y, p, nothing) + if DiffEqBase.isinplace(sol.prob) + f.jac(diffcache.J, y, p, nothing) + else + copyto!(diffcache.J, f.jac(y, p, nothing)) + end else if DiffEqBase.isinplace(sol.prob) jacobian!(diffcache.J, diffcache.uf, y, diffcache.f_cache, From 3eaf6f0faf069cf412f1d282039706dea4544e31 Mon Sep 17 00:00:00 2001 From: Avik Pal Date: Thu, 16 May 2024 14:45:23 -0400 Subject: [PATCH 2/2] untrack tracker grad --- src/concrete_solve.jl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/concrete_solve.jl b/src/concrete_solve.jl index 707c7f95d..20b0d0e88 100644 --- a/src/concrete_solve.jl +++ b/src/concrete_solve.jl @@ -1519,6 +1519,9 @@ function DiffEqBase._concrete_solve_adjoint( end function steadystatebackpass(Δ) + if originator isa SciMLBase.TrackerOriginator + Δ = Tracker.data(Δ) + end # Δ = dg/dx or diffcache.dg_val # del g/del p = 0 function df(_out, u, p, t, i)