--- id: torchdiffeq version: "0.2.5" license: unclear license_treatment: permissive maintenance: aging --- # torchdiffeq — ODE solvers and adjoint sensitivity analysis in PyTorch. License: permissive · Maintenance: aging · Downloads: 1.1M/mo ## What it is and what it does torchdiffeq is a PyTorch library for solving ordinary differential equations (ODEs) with full support for automatic differentiation. It implements the main interface `odeint` which solves initial value problems of the form dy/dt = f(t, y) with y(t_0) = y_0, supporting multiple solver algorithms (Runge-Kutta variants, Adams methods, and others) and GPU execution. The key capability is backpropagation through ODE solutions: you can compute gradients with respect to the initial condition, parameters, and time points. For deep learning applications, it provides an adjoint method that trades computation for memory, using O(1) memory during backprop by solving an adjoint ODE in the backward pass. The library also supports event-based termination (stopping when a condition is met) with differentiable event times and states, useful for physics-informed neural networks and other scientific computing tasks. Use it for: - Training neural ODEs where the model is defined as a differential equation and gradients flow through the solver. - Physics-informed neural networks that need to differentiate through ODE solutions with memory efficiency. - Simulating and learning dynamics in continuous-time systems (e.g., bouncing ball, learned physics models). - Sensitivity analysis where you need gradients of ODE solutions with respect to parameters or initial conditions. - GPU-accelerated scientific computing requiring both forward ODE integration and backpropagation. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Provides PyTorch-based ODE solvers with backpropagation support through the adjoint method, enabling differentiable solutions to ordinary differential equations with constant memory cost. Yes, if you need differentiable ODE solving in PyTorch. The library is well-established (6472 stars, top 5000 PyPI), has low install friction, permissive licensing, and no known vulnerabilities. The aging maintenance status (631 days since release) is a minor concern but the repo remains active. Install it when you're building neural ODEs, physics-informed models, or any system requiring gradients through ODE solutions. ## Install pip install torchdiffeq uv add torchdiffeq poetry add torchdiffeq ## Installing torchdiffeq Before you install: Low friction install with only torch and scipy as runtime dependencies. Package is aging (631 days since last release) but repository remains active and unarchived with strong community adoption (6472 stars). License in practice: MIT license (permissive) means you can use this freely in commercial and private projects with minimal restrictions. Quickstart: pip install torchdiffeq from torchdiffeq import odeint # Solve dy/dt = f(t, y) with initial condition y0 at times t result = odeint(func, y0, t) # For memory-efficient backprop through adjoint method: from torchdiffeq import odeint_adjoint as odeint result = odeint(func, y0, t) # func must be nn.Module When using odeint_adjoint, func must be a torch.nn.Module to collect parameters; direct function callables will not work with the adjoint method. Verify before relying: - Whether the adjoint method's O(1) memory claim holds for all problem sizes and solver configurations in practice. - Performance characteristics on GPU versus CPU for typical problem scales. - Numerical stability guarantees for backpropagation through different solver methods beyond dopri5. ## Package facts - License: not declared (permissive) - Python support: supports_current - Install friction: low - Maintenance: aging - Downloads: 1.1M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags pytorch ode solver, differentiable ode solver, neural ode, adjoint sensitivity analysis, backprop through ode, odeint pytorch, gpu ode solver, neural-ode, adjoint-method, differentiable-computing [View on SkillFed](https://skillfed.io/packages/torchdiffeq) · [View on PyPI](https://pypi.org/project/torchdiffeq/)