Skip to main content

yabi-torch

A batched, differentiable ODE solver for PyTorch — YABI's variable-order BDF integrator with the continuous adjoint, wrapped as a torch-native solve_ivp.

pip install yabi-torch
import torch
from yabi_torch import solve_ivp

# Robertson — a classic stiff ODE (mass-conserving chemical kinetics)
def f(y):
    return torch.stack([
        -0.04 * y[0] + 1e4 * y[1] * y[2],
         0.04 * y[0] - 1e4 * y[1] * y[2] - 3e7 * y[1] ** 2,
         3e7 * y[1] ** 2,
    ])

y0 = torch.tensor([1.0, 0.0, 0.0], dtype=torch.float64, requires_grad=True)
yT = solve_ivp(f, y0, t_span=(0.0, 1e5), rtol=1e-6, atol=1e-10)

yT.sum().backward()          # y0.grad = d(sum y(T)) / d y0, via the continuous adjoint
print(yT)                    # [0.0179, 7.3e-8, 0.9821]  (mass conserved)

What it is

yabi_torch.solve_ivp solves the autonomous initial-value problem y' = f(y), y(t0) = y0 with YABI's BDF integrator (orders 1–6, variable step, Newton iteration) — the kind of solver that handles stiff systems where explicit methods like torchdiffeq's RK need impractically small steps. It is differentiable in y0 and in the model parameters θ through the continuous adjoint, so a neural ODE can be trained (loss.backward() fills both y0.grad and the network's .grad).

  • f is a torch.nn.Module or any callable y -> f(y) on a float64 tensor — no hand-written Jacobian (it is computed automatically with torch.autograd).
  • y0 may be a single (n,) or a batch (batch, n); the gradient is the adjoint per trajectory.

API

solve_ivp(f, y0, t_span=(0.0, 1.0), rtol=1e-8, atol=1e-10,
          jac=None, solver="dense", threads=1, device="cpu")
option meaning
f the vector field y -> f(y) (torch.nn.Module or callable)
y0 (n,) or (batch, n) torch.float64 tensor
t_span (t0, t1) — f is autonomous, so only t1 - t0 matters
jac optional analytic Jacobian, numpy (n,) -> (n*n,) column-major (else automatic)
solver "dense" (full Jacobian, dense Newton) or "matrix_free" (J·v via torch.autograd, GMRES)
threads trajectories solved concurrently (default 1 = serial; bit-identical to serial)
device "cpu" (default) or "cuda" (f/Jacobian on GPU + cuSOLVER Newton; needs the CUDA wheel)

Features

  • Stiff-capable — BDF + Newton, not an explicit RK.
  • Automatic Jacobian — torch.autograd; pass jac only if you want the analytic path.
  • Dense and matrix-free — both Jacobian representations behind one API.
  • Batched + differentiable — solve a batch and backprop through it.
  • Parallel batch — threads=N is bit-identical to serial.
  • GPU — device="cuda" offloads the dense Newton LU to cuSOLVER and (on a GPU with compute capability ≥ 7.5) evaluates f on-device. This requires a CUDA-enabled build (YABI_USE_CUDA=ON) — the PyPI wheels are CPU-only, so device="cuda" needs a source build. A CUDA wheel is planned.

Requirements

  • Python ≥ 3.10, NumPy, PyTorch ≥ 2.0.
  • Installing from source (the sdist) needs a C++17 compiler, CMake ≥ 3.16, and BLAS/LAPACK.

License

Apache-2.0. The integrator core is YABI.

Metadata

Release files for yabi-torch 0.1.4

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

Source distribution (sdist)

Source distribution for yabi-torch 0.1.4
File Size Uploaded Provenance Actions
yabi_torch-0.1.4.tar.gz 49.1 MB Without provenance Details for yabi_torch-0.1.4.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for yabi-torch 0.1.4
File Actions
yabi_torch-0.1.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for yabi_torch-0.1.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
yabi_torch-0.1.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for yabi_torch-0.1.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
yabi_torch-0.1.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for yabi_torch-0.1.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
yabi_torch-0.1.4-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for yabi_torch-0.1.4-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Total release size: 98.2 MB

Release files / yabi_torch-0.1.4.tar.gz

Download URL yabi_torch-0.1.4.tar.gz
Size 49.1 MB
Tags Source
SHA-256 checksum
How to use checksums
61515f400ac1f540e2a8b6a021959ad567fd3247078446b23377e4b2f7683636
BLAKE2b-256 checksum
How to use checksums
e52cebc86a796e89b8db642da8221cc18cab8427a5fe03246f9432d24d9680a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / yabi_torch-0.1.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL yabi_torch-0.1.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 12.3 MB
Tags CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
93804ec13df049d541c3417f2b90ba86e4f465b923189a43feeb35c0a4421928
BLAKE2b-256 checksum
How to use checksums
343412df7ace507fcb96971475515e250a13c37a0ba442152d2279d80fffc262
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / yabi_torch-0.1.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL yabi_torch-0.1.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 12.3 MB
Tags CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
e0525f93af076feeb6bbf4f9b6cf8110f2aa9ea31c0627384679d78c1fdd2ff7
BLAKE2b-256 checksum
How to use checksums
67e536bc99173b292fb09d841d5115f0c24c300b30bd805fcc05b45f18794695
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / yabi_torch-0.1.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL yabi_torch-0.1.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 12.3 MB
Tags CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
2a785f89070f2f3dd1d83b73f0decc8804248bbbaba8f69b9e7a821a6640afb4
BLAKE2b-256 checksum
How to use checksums
e04ea684205cb035db525754d4267963fdceaacf9bd7599c0d34d535de025e13
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / yabi_torch-0.1.4-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL yabi_torch-0.1.4-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 12.3 MB
Tags CPython 3.10 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
c1af1eb04b4642b7b341a9108e90b023e4bc47b9dc181543f72332d4655f9d04
BLAKE2b-256 checksum
How to use checksums
d490982cb457889a125f6abbf86eb745d3440414cbaae2b2642fa793f65ba142
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Security for yabi-torch 0.1.4

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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