# Sensitivity fail on DAEs

**URL:** <https://discourse.julialang.org/t/sensitivity-fail-on-daes/98205>\
**Category:** Modelling & Simulations\
**Tags:** sciml\
**Created:** [May 2, 2023, 2:30pm UTC](https://discourse.julialang.org/t/sensitivity-fail-on-daes/98205 "2023-05-02T14:30:28Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [May 2, 2023, 4:02pm UTC](https://discourse.julialang.org/t/sensitivity-fail-on-daes/98205/4 "2023-05-02T16:02:22Z")

</div>

> [@Guido\_Ballabio](#):
>
> I noticed it would work without autodiff, however I found out it was too slow for my application on NNs.

That shouldn’t effect performance. This is forward-mode autodiff of the Jacobians in the ODE solve, not the adjoint method or the vjp calculation. So `autodiff=false` should be around 2x of the autodiff one.

> [@Guido\_Ballabio](#):
>
> Do you have any other suggestion?

I’m turning this into a test case as we speak. A working version is:

```julia
sensealg = InterpolatingAdjoint(autojacvec=ZygoteVJP())
_, dp = adjoint_sensitivities(sol, Rosenbrock23(); sensealg=sensealg, g=(u, p, t)->sum(u), dgdu_continuous = (du,u,p,t)->du.=1);

```

Basically, it seems to be an interaction between stiff ODE solvers with autodiff on, not supplying the `dg` derivative, and checkpointing. In this piece I turned off checkpointing and supplied `dgdu_continuous` and it works. I have a fix for the checkpointing part and will put a patch in when I figure out why not supplying `dgdu_continuous` is related, but this should be enough for you to test the real impact on your code.

For performance gains, I would suspect you wouldn’t want to use Rosenbrock methods for the adjoint. Things like `TRBDF2` will be a lot faster in the backpass, regardless of the forward pass’s ODE solver choice.

---

_[View the full topic](https://discourse.julialang.org/t/sensitivity-fail-on-daes/98205)._
