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 through the continuous adjoint, so gradients flow through the ODE solve.
fis atorch.nn.Moduleor any callabley -> f(y)on afloat64tensor — no hand-written Jacobian (it is computed automatically withtorch.autograd).y0may 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) |
Features
- Stiff-capable — BDF + Newton, not an explicit RK.
- Automatic Jacobian —
torch.autograd; passjaconly 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=Nis bit-identical to serial. - GPU —
device="cuda"offloads the Newton LU to cuSOLVER; on a GPU with compute capability ≥ 7.5 it also evaluatesfon-device.
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.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| yabi_torch-0.1.1.tar.gz | 357.3 kB | Without provenance | Details for yabi_torch-0.1.1.tar.gz |
Release files / yabi_torch-0.1.1.tar.gz
| Download URL | yabi_torch-0.1.1.tar.gz |
|---|---|
| Size | 357.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0b990d7e44a0ed0424dd8e6c7a0c0354e30cabe75963f2cffa1581baea30a113
|
|
BLAKE2b-256 checksum How to use checksums |
acd57d27120c8a33d84132e5c2923e44fb887438d450b5c3e76b86fbee3d69ec
|
| 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.1
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.