# Reverse-Mode AD VJP choices all failed

**URL:** <https://discourse.julialang.org/t/reverse-mode-ad-vjp-choices-all-failed/94929>\
**Category:** Performance\
**Created:** [February 20, 2023, 6:55pm UTC](https://discourse.julialang.org/t/reverse-mode-ad-vjp-choices-all-failed/94929 "2023-02-20T18:55:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)\
**Post date:** [February 20, 2023, 6:55pm UTC](https://discourse.julialang.org/t/reverse-mode-ad-vjp-choices-all-failed/94929/1 "2023-02-20T18:55:26Z")

</div>

Hi,

I am running a neural network with Flux, Zygote, and Optimization libraries. The code is rather long and I have not created a MWE yet (which could take quite a while). The code ran about 800 iterations without trouble, and then all of a sudden generates the error:

```julia
 Warning: Reverse-Mode AD VJP choices all failed. Falling back to numerical VJPs
└ @ SciMLSensitivity ~/.julia/packages/SciMLSensitivity/6YVpi/src/concrete_solve.jl:115
┌ Warning: dt(9.536743e-7) <= dtmin(9.536743e-7) at t=0.16458714. Aborting. There is either an error in your model specification or the true solution is unstable.
└ @ SciMLBase ~/.julia/packages/SciMLBase/hLrpl/src/integrator_interface.jl:529
┌ Warning: Endpoints do not match. Return code: DtLessThanMin. Likely your time range is not a multiple of `saveat`. sol.t[end]: 0.16458714, ts[end]: 12.0
└ @ SciMLSensitivity ~/.julia/packages/SciMLSensitivity/6YVpi/src/concrete_solve.jl:1401
ERROR: DimensionMismatch: dimensions must match: a has dims (Base.OneTo(62),), b has dims (Base.OneTo(61),), mismatch at 1

```

What might make this happen? It is hard to believe that if auto-differentiation suddenly stops working, that a numerical VJP will.

Could this issue be the result of a stiff system of equations, in which case, I should change the numerical integrator? Anybody come across this error? Thanks.

```
Gordon

```

---

<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:** [February 20, 2023, 6:59pm UTC](https://discourse.julialang.org/t/reverse-mode-ad-vjp-choices-all-failed/94929/2 "2023-02-20T18:59:58Z")

</div>

> [@erlebach](#):
>
> ```julia
> ERROR: DimensionMismatch: dimensions must match: a has dims (Base.OneTo(62),), b has dims (Base.OneTo(61),), mismatch at 1
> 
> ```

Looks like your function just fails because there’s a dimension mismatch error?

---

<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:** [February 20, 2023, 7:00pm UTC](https://discourse.julialang.org/t/reverse-mode-ad-vjp-choices-all-failed/94929/3 "2023-02-20T19:00:31Z")

</div>

> [@erlebach](#):
>
> ```julia
> ┌ Warning: dt(9.536743e-7) <= dtmin(9.536743e-7) at t=0.16458714. Aborting. There is either an error in your model specification or the true solution is unstable.
> └ @ SciMLBase ~/.julia/packages/SciMLBase/hLrpl/src/integrator_interface.jl:529
> 
> ```

Because the integration aborted early. If you solve it at those parameters I assume you will see the same thing.

---

<div class="post-metadata">

**Author:** ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)\
**Post date:** [February 20, 2023, 7:03pm UTC](https://discourse.julialang.org/t/reverse-mode-ad-vjp-choices-all-failed/94929/4 "2023-02-20T19:03:58Z")

</div>

Thank you, Chris,

[quote=“erlebach, post:1, topic:94929”]  
`ERROR: DimensionMismatch: dimensions must match: a has dims (Base.OneTo(62),), b has dims (Base.OneTo(61),), m`

My time step is not 1.e-7. That would imply the formation of a singularity with a commensurate decrease of the timestep, which eventually went below some prescribed threshold.

I will delve further. What is frustrating is that it takes time for this error to occur, which makes debugging rather painful.
