tinydiffeq
tinydiffeq is an unsupported research repo of vibe-coded ports of well-established ODE, DAE, and SDE algorithms to JAX. Heavily AI-generated — but the algorithms are well established, with SciML, scipy, and diffrax as the reference implementations — so correctness and performance are often reasonable. The method set is intentionally minimal, though the package is no longer especially tiny.
Fixed-step Euler/RK4, adaptive Tsit5, and linearly implicit Rodas5P for
stiff ODEs and index-1 DAEs; Euler–Maruyama, Milstein, and SRA1 for Itô SDEs
and SDAEs; a port of scipy's collocation solver for two-point BVPs with
unknown parameters; finite-state Markov chains and dense or Krylov linear
exponential actions. Every solve runs in bounded lax loops with static
shapes and composes with jit, vmap, forward mode, reverse mode, and
reverse-over-forward; iterative solves (BVP, DAE roots) differentiate
implicitly at the solution, never through the iterations.
Use diffrax or SciML if you need general mass matrices, fully implicit or higher-index DAEs, adaptive SDE stepping, events, continuous solution objects, or specialized adjoints.
Install
uv add tinydiffeq
For GPU use, add the JAX accelerator build matching your hardware, for
example uv add tinydiffeq "jax[cuda13]".
Example
The vector field may take (x), (x, t), (x, t, args), or
(x, t, args, p) — always in that order. args is pass-through data (not
an AD target by convention); p holds differentiable parameters, and the
state may be any pytree of same-dtype real floating arrays.
import jax
import jax.numpy as jnp
from tinydiffeq import solve_ode, Tsit5, IController, SaveAt
jax.config.update("jax_enable_x64", True) # your call — the library never sets it
def f(x, t, args, p):
return -p * x
sol = solve_ode(
f, Tsit5(), 0.0, 2.0, jnp.asarray(1.0),
p=jnp.asarray(1.3),
dt_0=0.1,
controller=IController(rtol=1e-8, atol=1e-10),
max_steps=512,
save_at=SaveAt(ts=jnp.linspace(0.0, 2.0, 21)),
)
sol.xs # states on the grid, however many internal steps were taken
sol.ok # False if integration or a requested output failed
max_steps bounds attempted internal steps (accepted plus rejected);
SaveAt fixes the output shape regardless of how many steps the controller
takes. Gradients go straight through the solve:
def endpoint(p):
return solve_ode(
f, Tsit5(), 0.0, 2.0, jnp.asarray(1.0), p=p,
dt_0=0.1, controller=IController(rtol=1e-10, atol=1e-12),
max_steps=512,
).xs
jax.grad(endpoint)(jnp.asarray(1.3)) # reverse mode
jax.jvp(endpoint, (jnp.asarray(1.3),), (jnp.asarray(1.0),)) # forward mode
An SDE ensemble — per-key noise, vmap over trajectories:
from tinydiffeq import solve_sde, SRA1
def ou_drift(x):
return -x
def ou_diffusion(x):
return 0.5 * jnp.ones_like(x)
def ou_path(key):
return solve_sde(
ou_drift, ou_diffusion, SRA1(), 0.0, 1.0, jnp.asarray(1.0),
key=key, n_steps=256, save_at=SaveAt(steps=True),
).xs
paths = jax.vmap(ou_path)(jax.random.split(jax.random.key(0), 1000)) # (1000, 257)
SDEs with first-class differentiable noise, semi-explicit DAEs and SDAEs,
two-point BVPs, Markov chains, linear exponential solves, and the design
contracts (static shapes and SaveAt, AD through adaptive stepping,
failure-as-data) are in the
docs.
License
MIT
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tinydiffeq-2.6.1.tar.gz.
File metadata
- Download URL: tinydiffeq-2.6.1.tar.gz
- Upload date:
- Size: 713.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be459432178a8363a050b93a1360a8fe2c569e1f5294249838090e34ba1b4128
|
|
| MD5 |
fc60c8bc3d14a465aef55d9d91f25b96
|
|
| BLAKE2b-256 |
7ff6eb2ffade16153f543db1df8df60865bc17ccfe7a46d3dcd960d43d4ef448
|
Provenance
The following attestation bundles were made for tinydiffeq-2.6.1.tar.gz:
Publisher:
publish.yml on HighDimensionalEconLab/tinydiffeq
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tinydiffeq-2.6.1.tar.gz -
Subject digest:
be459432178a8363a050b93a1360a8fe2c569e1f5294249838090e34ba1b4128 - Sigstore transparency entry: 2539319381
- Sigstore integration time:
-
Permalink:
HighDimensionalEconLab/tinydiffeq@21c8b0d09af14a8a3478db8709d1e39b963c835e -
Branch / Tag:
refs/tags/v2.6.1 - Owner: https://github.com/HighDimensionalEconLab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@21c8b0d09af14a8a3478db8709d1e39b963c835e -
Trigger Event:
release
-
Statement type:
File details
Details for the file tinydiffeq-2.6.1-py3-none-any.whl.
File metadata
- Download URL: tinydiffeq-2.6.1-py3-none-any.whl
- Upload date:
- Size: 81.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa518e478e4c92b2b5b564d910e0c9da607234d501f55ae8e042033d700d7b2a
|
|
| MD5 |
66e82bb49e0fba9b949b8c7647efb91e
|
|
| BLAKE2b-256 |
c74a040d07664d4fc1a2da54ee59ad4d7b6fb28d6a5f841995d6bafecfe47855
|
Provenance
The following attestation bundles were made for tinydiffeq-2.6.1-py3-none-any.whl:
Publisher:
publish.yml on HighDimensionalEconLab/tinydiffeq
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tinydiffeq-2.6.1-py3-none-any.whl -
Subject digest:
fa518e478e4c92b2b5b564d910e0c9da607234d501f55ae8e042033d700d7b2a - Sigstore transparency entry: 2539319568
- Sigstore integration time:
-
Permalink:
HighDimensionalEconLab/tinydiffeq@21c8b0d09af14a8a3478db8709d1e39b963c835e -
Branch / Tag:
refs/tags/v2.6.1 - Owner: https://github.com/HighDimensionalEconLab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@21c8b0d09af14a8a3478db8709d1e39b963c835e -
Trigger Event:
release
-
Statement type: