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
See the spin-out Equinox library for neural networks etc.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file diffrax-0.1.2.tar.gz
.
File metadata
- Download URL: diffrax-0.1.2.tar.gz
- Upload date:
- Size: 104.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 693855e2b587b08d4fe4ab7bd6ca3a6c861c6e373bc260a0608017cf1faf4f43 |
|
MD5 | b863a704b79a7028f184358b53cde0a3 |
|
BLAKE2b-256 | c6d0f4ad520eb8e6b3514221c6b71a381361dc9ce5a546d34fd8a17ae0eaae20 |
File details
Details for the file diffrax-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: diffrax-0.1.2-py3-none-any.whl
- Upload date:
- Size: 108.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d4d94057683d024a6fe3d8e31308d6add43969c71ef4de501e5f09a54b20ff9 |
|
MD5 | ef80fa38703a70d9b3df6f2c544ed645 |
|
BLAKE2b-256 | 40fccffe2a98b7bf6994ddcb8814eedf06f3285f377a30e546d8f4cded037f4e |