Skip to main content

Cubie

CUDA Batch Integration Engine

Docs CUDA tests Python tests codecov PyPI version PyPI Downloads

Cubie solves large batches of ODEs and DAEs on your computer's NVIDIA GPU. It's as easy to use as SciPy or MATLAB - you write your problem in Python and call solve_ivp on it. For a guide on converting your MATLAB or SciPy problem to Cubie, check out Coming from MATLAB and Coming from SciPy.

Cubie compiles your system of equations into a GPU kernel that integrates every trajectory in a batch of initial values or parameter sets in parallel. Because GPUs are so good at parallel workloads, a batch of ten thousand or so trajectories takes about as long as a batch of one.

How long a batch of integrations feels in MATLAB or SciPy and in CuBIE

Cubie runs much faster than SciPy's solve_ivp or MATLAB's ode45/ode23s, even when you run them in parallel on the CPU. Cubie's advantage grows as you increase batch size, up to a plateau somewhere around 10,000x faster.

CuBIE's speedup over SciPy and MATLAB against the number of trajectories

These numbers were obtained running the same batch of parameters on the same ODE systems (Lorenz, POLLU air-pollution, and the Linder et al. (2025) version of the Fabbri-Severi sino-atrial cell model). MATLAB ran its solves in a parfor loop, using ode45 for the Lorenz system and ode23s for the two stiff systems. SciPy ran in a multiprocessing parallel setup, using the Fortran dopri5 on Lorenz and Radau on the two stiff systems. Both MATLAB and SciPy were given a helping hand by using analytic Jacobians for the stiff systems, and SciPy's RHS was JIT compiled through numba, to give them a fighting chance.

Under the hood, cubie uses numba-cuda-mlir to compile the integration algorithms and your provided ODE/DAE systems into GPU code and ferry your data in between your computer and GPU. It goes fast because it strips as much data from the GPUs memory as it can, instead compiling it into the code that the GPU runs.

Cubie against other GPU integrators: figures coming soon

It's the fastest parallel integrator I've found. Similar work has been done in parallel, for JAX on Linux, by gradsolve and modax, in Julia by DiffEqGPU.jl, in CUDA C++ by MPGOS, and in higher-level systems Diffrax and torchdiffeq. Cubie held its own, at the time of measurement. For large systems and implicit algorithms, it really shines.

Capabilities

Solve huge batches

  • Give Cubie the ranges you want to explore, and it will build and run every combination of them. Cubie is most comfortable in the hundreds of thousands, or millions, of trajectories.
  • Calculate summary metrics during integration (averages, statistics, derivatives, etc) and discard the trajectories, so you keep only what you need and fit more runs into each solve.
  • Save only the variables you need at the times you want them.
  • If the results you want are still bigger than your computer's RAM or GPU's VRAM, Cubie chops it up into batches and gets it done without complaining.
  • Rerun solvers cheaply - compiled kernels are cached for future use.
  • Get results as NumPy arrays or pandas DataFrames.

Bring your model

  • Define ODE and DAE systems as equation strings, Python functions, SymPy expressions, or CellML 1.0/1.1 models.
  • Force your system with functions of time in its equations, or with arbitrary sampled (measured) signals which Cubie interpolates on the GPU.
  • Structurally simplify DAEs with alias elimination, index reduction and tearing before Cubie generates solver code.

Choose your solver

  • Cubie has a large range of Runge-Kutta methods available to pick from:
    • Explicit: tsit5 (the default), euler, heun-21, ralston-33, rk23, rk4, rk45, cash-karp-54, fehlberg-45, vern7 and dop853.
    • Diagonally-Implicit: backwards_euler, crank_nicolson, implicit_midpoint, trapezoidal_dirk, sdirk_2_2, kvaerno3, kvaerno5, l_stable_dirk_3, l_stable_sdirk_4 and three eldirk32 variants.
    • Fully Implicit: radau_iia_3, radau_iia_5, radau_iia_9, firk_gauss_legendre_2 and firk_gauss_legendre_4.
    • Rosenbrock and Rosenbrock-W: choose from 37 methods, including rosenbrock23, ros3p, rodas4, rodas4p, rodas5p, rodas6p and the ros34pw family.
  • Pass MATLAB and SciPy names such as ode45, ode23s or Radau and Cubie picks the matching method. Read the algorithm guide for help choosing one.

Customise (if you want to)

  • Most inner details of the algorithms, step-size controllers, norms, solvers, etc are exposed as arguments, so if you're coming from an exhaustive differential equation suite like SciML's DifferentialEquations.jl, or you are deeply familiar with numerical integration and want to optimise, you can get your hands dirty.

Installation

pip install "cubie[cuda13]"

The extra in square brackets installs a CUDA toolkit: cuda13 for CUDA 13, cuda12 for CUDA 12. Without it, pip install cubie finds whatever CUDA toolkit you have installed. If this means nothing to you, use cuda13.

Requirements

  • Linux or Windows.
  • Python 3.11-3.14.
  • An NVIDIA GPU with compute capability 6.0 or later.
  • An up-to-date NVIDIA driver.
  • Optionally, Pandas and Matplotlib, which you can install with pip install "cubie[optional]".

Quick start

import numpy as np
from cubie import create_ODE_system, solve_ivp


system = create_ODE_system(
    ["dx = v", "dv = mu * (1 - x*x) * v - x"],
    states={"x": 1.0, "v": 0.0},
    parameters={"mu": 1.5},
)

result = solve_ivp(
    system,
    y0={"x": np.linspace(1.0, 2.0, 1024)},
    parameters={"mu": np.linspace(1.0, 3.0, 1024)},
    duration=20.0,
)

Cubie integrates all 1,048,576 combinations of the 1,024 initial values of x and the 1,024 values of mu, starting v from its default of 0.0. On an RTX 4070 SUPER, Cubie takes about 1s to compile and run it for the first time. Once it's compiled once, every future batch takes 30 to 45 ms, in the same and future sessions.

For repeated solves, you would probably keep a Solver object and call Solver.solve() (see the docs). This cuts repeated solve time to 8ms.

Documentation

The documentation covers system creation, batching, solver configuration, outputs, and performance.

Acknowledgements

  • SciML, DifferentialEquations.jl — SciML's differential equations ecosystem was the main reference for every correctness, step-control, algorithm detail, or default constant question I ran into when building Cubie. Cubie's implementation differs a lot, mostly due to it's GPU-first nature, but almost every piece of math and many default settings values were either drawn from or rigorously checked against a SciML implementation. The DAE initialiser is ported directly from OrdinaryDiffEq.jl under an MIT license, as was some code in the DAE structural simplification pipeline. . Any solving of DAEs through Cubie should cite them directly: See Rackauckas and Nie (2017). If you want to explore numerical integration further, head to their docs, where they have many accessibly-written explanations of which algorithms do what well.
  • ModelingToolkit.jl — Cubie's DAE tearing and structural-simplification implementation is largely a direct port of ModelingToolkit.jl's approach, adapted to Cubie's symbolic IR and CUDA code generation. DAE users should cite them directly as well: See Ma et al. (2021).
  • cellmlmanip and chaste_codegen — Their work is used to import CellML models and detect and repair removable singularities in Goldman-Hodgkin-Katz-style equations. See Hendrix et al. (2022).

License

MIT (LICENSE); third-party notices in THIRD_PARTY_LICENSES.

Contributing

Pull requests are welcome. Please open an issue before starting a major change so that the design can be discussed first.

Metadata

Release files for cubie 0.19.0

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

Source distribution (sdist)

Source distribution for cubie 0.19.0
File Size Uploaded Provenance Actions
cubie-0.19.0.tar.gz 760.6 kB With provenance Details for cubie-0.19.0.tar.gz

Built distribution (wheel)

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

Total release size: 1.6 MB

Release files / cubie-0.19.0.tar.gz

Download URL cubie-0.19.0.tar.gz
Size 760.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a1aa0ba0146f2d6d5d9229f722eca34c1b1d86c30bd53261ae96ba19380574f8
BLAKE2b-256 checksum
How to use checksums
58540b50e30bbea653f73acedd44bca6a78d92afafc2138ee0296a03da551bcb
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 20, 2026.

Transparency log

Release files / cubie-0.19.0-py3-none-any.whl

Download URL cubie-0.19.0-py3-none-any.whl
Size 832.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b11161268fe787c7e21fc037c21e10f361978d2ef17bd149c46b590f9376b48c
BLAKE2b-256 checksum
How to use checksums
9ecee6d7d9e4faf077b71f973e38c5f1e6b98c99db114295ae7ad7680c61eea2
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 20, 2026.

Transparency log

Security for cubie 0.19.0

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 cubie-0.19.0.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 20, 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.

Release history Release notifications | RSS feed

This release

0.19.0 This release

2 release files Full provenance

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