Skip to main content
QUICK REVIEW

[Paper Review] torchode: A Parallel ODE Solver for PyTorch

Marten Lienen, Stephan Günnemann|arXiv (Cornell University)|Oct 22, 2022
Parallel Computing and Optimization TechniquesComputer Science6 citations
TL;DR

torchode is a high-performance, parallel ODE solver for PyTorch that independently integrates multiple ODEs in a batch with separate solver states, enabling up to 4.3x faster execution per step and robustness against batch-induced step inflation. It supports JIT compilation, extensible step size control (including PID), and detailed solver statistics collection for research extensibility and introspection.

ABSTRACT

We introduce an ODE solver for the PyTorch ecosystem that can solve multiple ODEs in parallel independently from each other while achieving significant performance gains. Our implementation tracks each ODE's progress separately and is carefully optimized for GPUs and compatibility with PyTorch's JIT compiler. Its design lets researchers easily augment any aspect of the solver and collect and analyze internal solver statistics. In our experiments, our implementation is up to 4.3 times faster per step than other ODE solvers and it is robust against within-batch interactions that lead other solvers to take up to 4 times as many steps. Code available at https://github.com/martenlienen/torchode

Motivation & Objective

  • To address the performance gap in PyTorch ODE solvers compared to other frameworks like JAX and Julia.
  • To eliminate unintended interactions between batched ODEs that can inflate solver steps and degrade training efficiency.
  • To enable researchers to easily extend solver behavior and collect internal statistics for model analysis.
  • To optimize GPU performance through batch-parallel, state-isolated integration with support for advanced step size controllers.
  • To provide a production-ready, extensible ODE solver that supports both independent and joint adjoint backpropagation for CNF and other models.

Proposed method

  • torchode treats each ODE in a batch as an independent problem with separate initial conditions, integration ranges, step size, and acceptance status.
  • It maintains individual solver states per ODE instance, including step size, error estimates, and accept/reject decisions, avoiding cross-batch interference.
  • The solver uses a PID controller for adaptive step size selection based on control theory, improving responsiveness to rapid changes in stiffness.
  • It supports JIT compilation via PyTorch’s JIT compiler for performance-critical inference and training.
  • The implementation allows plug-in replacement of components such as the step size controller and integrator, enabling extensibility for custom learning or analysis.
  • A separate joint adjoint pass is provided for CNF models, leveraging Horner’s rule and combined kernels to reduce backward pass computation.

Experimental results

Research questions

  • RQ1Can parallel, independent ODE solving in PyTorch eliminate batch-induced step inflation and improve training efficiency?
  • RQ2How does a PID-based step size controller compare to integral controllers in reducing solver steps for stiff ODEs?
  • RQ3To what extent does independent ODE solving affect model performance in continuous normalizing flows and time series modeling?
  • RQ4Can a PyTorch-native ODE solver achieve performance comparable to JAX-based solvers like diffrax?
  • RQ5What is the impact of solver introspection and statistics collection on model debugging and hyperparameter tuning?

Key findings

  • torchode achieves up to 4.3 times faster execution per step compared to existing PyTorch ODE solvers, particularly on stiff problems.
  • The solver avoids the 4x step inflation seen in other solvers due to batch interactions, maintaining consistent performance across diverse integration intervals.
  • PID control reduces solver steps by 3–5% on highly stiff problems (e.g., μ=25 in Van der Pol oscillator), but offers no benefit on smooth problems.
  • The joint adjoint pass in torchode is significantly faster than torchdiffeq and TorchDyn due to optimized kernel fusion and Horner’s rule application.
  • Independent ODE solving does not degrade model performance—bits/dim and MAE remain comparable to joint solvers, indicating no negative impact on learning.
  • The inclusion of detailed solver statistics and extensibility enables researchers to monitor and analyze solver behavior without global state or code injection.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.