rtqichen / torchdiffeq

Differentiable ODE solvers with full GPU support and O(1)-memory backpropagation.
MIT License
5.5k stars 912 forks source link

Scipy LSODA for stiff ODE #249

Open janrohleff opened 6 months ago

janrohleff commented 6 months ago

Hey,

thank you for this great package. I have a problem using the scipy LSODA solver together with odeint_adjoint for a nonlinear stiff ODE. The problem is the following:

  1. The forward solve with the scipy solver works well.
  2. When I try to compute the backward pass the solver always get stuck at some specific time-point depending on the tolerance. I don‘t get an error and the file is still running, but it doesn‘t make any progress, i.e. stuck at this t. I think the problem is that you solve in the „backward call“ the state-equation backward in time, which is numericaly not a good idea for stiff ODEs.

But do you have any idea how this could be fixed? Or do you thinking of implementing a Torch version of LSODA, so that one just can use automatic-differentiation and use odeint.

Thank you!

HoangMinhPhan commented 3 weeks ago

I also got the same problem for stiff ODE. I hope that the author can introduce new solvers to solve stiff problems, or adapt scipy solvers to be compatible with backward in pytorch.