google-research / torchsde

Differentiable SDE solvers with GPU support and efficient sensitivity analysis.
Apache License 2.0
1.52k stars 195 forks source link

Binterval recursion fix #42

Closed patrick-kidger closed 3 years ago

patrick-kidger commented 3 years ago

Rather than trampolining everything, I've taken the more straightforward approach of inlining a lot of the function indirections that were previously present. This should reduce the size of the call stack that's built up by a factor of something like six.

The code is largely cleaner for this change, as well, which is nice.

It does introduce one additional dependency: boltons, which is a popular stdlib-like library for "things that are missing from the stdlib"; in this case a better LRU cache implementation. Obviously additional dependencies are to be avoided, but I think this one is reasonable.