Skip to main content

tinydiffeq

CI Docs PyPI Python versions License: MIT Ruff

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]" on Linux CUDA or uv add tinydiffeq metaljax on Apple Silicon macOS (run with JAX_PLATFORMS=metal in float32).

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

Metadata

Release files for tinydiffeq 2.6.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tinydiffeq 2.6.2
File Size Uploaded Provenance Actions
tinydiffeq-2.6.2.tar.gz 715.3 kB With provenance Details for tinydiffeq-2.6.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tinydiffeq 2.6.2
File Interpreter ABI Platform Actions
tinydiffeq-2.6.2-py3-none-any.whl Python 3 none any Details for tinydiffeq-2.6.2-py3-none-any.whl

Total release size: 796.4 kB

Release files / tinydiffeq-2.6.2.tar.gz

Download URL tinydiffeq-2.6.2.tar.gz
Size 715.3 kB
Tags Source
SHA-256 checksum
How to use checksums
c0f0bec8f0cb50e8644c989168699f25accd8705f47333e40de459abfdbe83b9
BLAKE2b-256 checksum
How to use checksums
cdeae8f633c3e15839c3d574fd9edffb0dd869224864ccd963ff7e916f5956b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.

Transparency log

Release files / tinydiffeq-2.6.2-py3-none-any.whl

Download URL tinydiffeq-2.6.2-py3-none-any.whl
Size 81.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
54953ab26f64eda366a03729e7f3e0765cde63f52d01809f3abb2d9ce46da681
BLAKE2b-256 checksum
How to use checksums
a0661fce244794e17971a767f0930925a0c6cb44fdfc4e738118155fd4e23172
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.

Transparency log

Security for tinydiffeq 2.6.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for tinydiffeq-2.6.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page