# DiffEqSensitivity.jl: Issues with ReverseDiffAdjoint sensealg

Hi all, I am starting out in `DiffEqSensitivity`, and I ran into the following issue.

When computing gradients as per the following example I get StackOverFlow

``````using ReverseDiff
using OrdinaryDiffEq
using DiffEqSensitivity

function ode!(derivative, state, parameters, t)
derivative .= parameters
end

function ode(state, parameters, t)
return ode!(similar(state), state, parameters, t)
end

function solve_euler(state, times, parameters)
problem = ODEProblem{true}(ode!, state, times[[1, end]], parameters; saveat=times, sensealg=ReverseDiffAdjoint())
return solve(problem, Euler(); dt=1e-1)
end

const initial_state = ones(2)
const solution_times = [1.0, 2.0]
ReverseDiff.gradient(p -> sum(sum(solve_euler(initial_state, solution_times, p))), zeros(2))
``````

Passing a non-mutating ode (i.e. `ODEProblem{false}(ode,..)` instead of `ODEProblem{true}(ode!,...)`) results in no StackOverflow, but then the execution never finishes.

Any ideas whatâ€™s happening? Thanks!

I am on intel-based MacOS 12.6, Julia 1.7.3 (2022-05-06) and:

``````
[41bf760c] DiffEqSensitivity v6.79.0
[0c46a032] DifferentialEquations v7.2.0
[37e2e3b7] ReverseDiff v1.14.1
``````
1 Like

Is there any reason you canâ€™t update this to `SciMLSensitivity`? All of the tutorials and such have deprecated DiffEqSensitivity long ago IIRC, and the upgrade path is just a name change for most things.

Thanks, I was not aware of SciMLSensitivity! Unfortunately, even after using it, instead of DiffEqSensitivity, I still end up with the above issues.

For what its worth I started using DiffEqSensitivity due to this that currently mentions:

Installation

This functionality does not come standard with DifferentialEquations.jl. To use this functionality, you must install DiffEqSensitivity.jl:

``````]add DiffEqSensitivity
using DiffEqSensitivity
``````

The above link was the first google result that came up on the search â€śdifferentialequations.jl sensitivityâ€ť

aha, it looks like that page never updated to its dev version: Local Sensitivity Analysis (Automatic Differentiation) Â· DifferentialEquations.jl . Iâ€™ll fix that.

Oh jeez, Actions Â· SciML/DiffEqDocs.jl Â· GitHub the docs got over some size limit so they werenâ€™t deploying for months (but they were passing all doc build tests!). So sorry about that: that explains the uptick in questions! Thanks for helping to point this out.

1 Like

Your issue here is fixed in Filter sensealg to stop infinite recursion of ReverseDiff -> RD by ChrisRackauckas Â· Pull Request #742 Â· SciML/SciMLSensitivity.jl Â· GitHub . A patch with this fix should be out tonight.

Thanks so much for the instant fix!