torchdiffeq icon indicating copy to clipboard operation
torchdiffeq copied to clipboard

underflow in dt nan

Open huanranchen opened this issue 2 years ago • 1 comments

Hi, when using dopri5 algorithm, it sometimes occurs "underflow in dt nan". Could we set a upper bound and a lower bound for dt to avoid such problems?

huanranchen avatar Nov 21 '23 03:11 huanranchen

There is a min_step argument if you use any RK adaptive-step solver like the default dopri5. https://github.com/rtqichen/torchdiffeq/blob/master/torchdiffeq/_impl/rk_common.py#L146

odeint(..., method="dopri5", options={"min_step": 0.01})

Depending on your application, it might be worth thinking more about how to model a less stiff ODE though (if that is a possibility).

rtqichen avatar Mar 12 '24 03:03 rtqichen

Thanks a lot!

This error occurs since dt is too small. By setting "min_step": 0.01, it works!

There is a min_step argument if you use any RK adaptive-step solver like the default dopri5. https://github.com/rtqichen/torchdiffeq/blob/master/torchdiffeq/_impl/rk_common.py#L146

odeint(..., method="dopri5", options={"min_step": 0.01})

Depending on your application, it might be worth thinking more about how to model a less stiff ODE though (if that is a possibility).

huanranchen avatar May 21 '24 04:05 huanranchen

There is a min_step argument if you use any RK adaptive-step solver like the default dopri5. https://github.com/rtqichen/torchdiffeq/blob/master/torchdiffeq/_impl/rk_common.py#L146

odeint(..., method="dopri5", options={"min_step": 0.01})

Depending on your application, it might be worth thinking more about how to model a less stiff ODE though (if that is a possibility).

But this version (enabling setting min_step) hasn't been updated on pip. If we use pip to install torchdiffeq, we still cannot set min_step.

huanranchen avatar May 21 '24 05:05 huanranchen

Thanks for letting me know. Latest version has been updated on pip.

rtqichen avatar May 29 '24 15:05 rtqichen