Skip to main content

GPU+autodiff-capable ODE/SDE/CDE solvers written in JAX.

Project description

Diffrax

Numerical differential equation solvers in JAX. Autodifferentiable and GPU-capable.

Diffrax is a JAX-based library providing numerical differential equation solvers.

Features include:

  • ODE/SDE/CDE (ordinary/stochastic/controlled) solvers;
  • lots of different solvers (including Tsit5, Dopri8, symplectic solvers, implicit solvers);
  • vmappable everything (including the region of integration);
  • using a PyTree as the state;
  • dense solutions;
  • multiple adjoint methods for backpropagation;
  • support for neural differential equations.

From a technical point of view, the internal structure of the library is pretty cool -- all kinds of equations (ODEs, SDEs, CDEs) are solved in a unified way (rather than being treated separately), producing a small tightly-written library.

Installation

pip install diffrax

Requires Python >=3.7 and JAX >=0.3.4.

Documentation

Available at https://docs.kidger.site/diffrax.

Quick example

from diffrax import diffeqsolve, ODETerm, Dopri5
import jax.numpy as jnp

def f(t, y, args):
    return -y

term = ODETerm(f)
solver = Dopri5()
y0 = jnp.array([2., 3.])
solution = diffeqsolve(term, solver, t0=0, t1=1, dt0=0.1, y0=y0)

Here, Dopri5 refers to the Dormand--Prince 5(4) numerical differential equation solver, which is a standard choice for many problems.

Citation

If you found this library useful in academic research, please cite: (arXiv link)

@phdthesis{kidger2021on,
    title={{O}n {N}eural {D}ifferential {E}quations},
    author={Patrick Kidger},
    year={2021},
    school={University of Oxford},
}

(Also consider starring the project on GitHub.)

See also

Neural networks: Equinox.

Type annotations and runtime checking for PyTrees and shape/dtype of JAX arrays: jaxtyping.

SymPy<->JAX conversion; train symbolic expressions via gradient descent: sympy2jax.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

diffrax-0.2.2.tar.gz (109.7 kB view details)

Uploaded Source

Built Distribution

diffrax-0.2.2-py3-none-any.whl (138.1 kB view details)

Uploaded Python 3

File details

Details for the file diffrax-0.2.2.tar.gz.

File metadata

  • Download URL: diffrax-0.2.2.tar.gz
  • Upload date:
  • Size: 109.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for diffrax-0.2.2.tar.gz
Algorithm Hash digest
SHA256 f2147d78aa9ccae613a67df6f52b4473aabdb64d0566275c2dc4c3dbca30f181
MD5 e4d46582b5926f76625b3ab0d2f4d86f
BLAKE2b-256 f72800d8c842928d2160869662fe1b8ff40501e2c81b8f2bd1286491bddf590e

See more details on using hashes here.

File details

Details for the file diffrax-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: diffrax-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 138.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for diffrax-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e58debc827293b37784452ea2dc7b788a72efa705ecd91fdb1f521cded463f99
MD5 73daf6946e2afd4ffec0e4b78e0d4359
BLAKE2b-256 c410ff2db91d16a5adef1673d520d98b9c31e90071979e287d0281b7875fe029

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page