Skip to main content

JAX bindings for the diffsol Rust ODE solver, callable inside jax.jit and differentiable with jax.grad.

Project description

diffsol-jax

JAX wrapper around diffsol, a Rust ODE solver library. Exposes diffsol's ODE solvers via jax.ffi so they can be called from inside jax.jit and differentiated with jax.grad.

The user writes an RHS function in Python, which gets lowered to a diffsl source string and compiled on first call.

Architecture

Python rhs fn  ->  DiffSL string  ->  XLA FFI call
                                          |
                                       C++ shim
                                          |
                                       diffsol

Example usage

import jax
import jax.numpy as jnp
from diffsol_jax import ODEProblem

def lotka_volterra(t, y, p):
    x, yy = y[0], y[1]
    alpha, beta, delta, gamma = p[0], p[1], p[2], p[3]
    return (alpha * x - beta * x * yy, delta * x * yy - gamma * yy)

params = jnp.array([1.5, 1.0, 0.75, 3.0])
y0     = jnp.array([1.0, 0.5])

problem = ODEProblem(lotka_volterra, y0=y0, params=params)

t_span = jnp.array([0.0, 10.0])
ts, ys = jax.jit(lambda p: problem.solve(p, t_span))(params)
# ts: float64[200],  ys: float64[200, 2]

Limitations

  • CPU only, f64 only.
  • No vmap batching rule; vmap_method="sequential" gives correct results via a Python loop.
  • The DiffSL lowerer handles elementwise ops and the common ODE patterns (Lotka-Volterra, Lorenz). Operations like dot_general, reduce_sum, and concatenate are not supported, so neural ODEs are not supported yet.
  • Differentiation uses JAX-level forward sensitivities (no separate adjoint pass). DiffSL modules are JIT-compiled with Cranelift and cached per source string; the first call compiles, subsequent calls reuse the compiled module and update parameters via set_params.
  • Does not work with jax.pmap
  • Higher-order derivatives

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

diffsol_jax-0.0.1.tar.gz (106.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

diffsol_jax-0.0.1-cp313-cp313-win_amd64.whl (3.7 MB view details)

Uploaded CPython 3.13Windows x86-64

diffsol_jax-0.0.1-cp313-cp313-manylinux_2_28_x86_64.whl (7.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

diffsol_jax-0.0.1-cp313-cp313-macosx_14_0_arm64.whl (5.3 MB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

diffsol_jax-0.0.1-cp312-cp312-win_amd64.whl (3.7 MB view details)

Uploaded CPython 3.12Windows x86-64

diffsol_jax-0.0.1-cp312-cp312-manylinux_2_28_x86_64.whl (7.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

diffsol_jax-0.0.1-cp312-cp312-macosx_14_0_arm64.whl (5.3 MB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

diffsol_jax-0.0.1-cp311-cp311-win_amd64.whl (3.7 MB view details)

Uploaded CPython 3.11Windows x86-64

diffsol_jax-0.0.1-cp311-cp311-manylinux_2_28_x86_64.whl (7.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

diffsol_jax-0.0.1-cp311-cp311-macosx_14_0_arm64.whl (5.3 MB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

File details

Details for the file diffsol_jax-0.0.1.tar.gz.

File metadata

  • Download URL: diffsol_jax-0.0.1.tar.gz
  • Upload date:
  • Size: 106.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for diffsol_jax-0.0.1.tar.gz
Algorithm Hash digest
SHA256 0676430ce7f6a2cd921feb2de0fcd5748532c3c02845d9942a33df6ec6d8ed25
MD5 4724ded3b8e08c0ec4cbd49b3f8d47d0
BLAKE2b-256 3aa70917ad68387d9eec93c59c140e953ddbb01f08c0f74fcea77e8dd109c25f

See more details on using hashes here.

Provenance

The following attestation bundles were made for diffsol_jax-0.0.1.tar.gz:

Publisher: ci.yml on jackbmontgomery/diffsol-jax

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file diffsol_jax-0.0.1-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for diffsol_jax-0.0.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 10f801c404910aa133eda9e63b81aadb2e7623623e698c5422101939fb844154
MD5 df2e0c39b9d6437899483c1056b3fcfe
BLAKE2b-256 d50ac92ee3048e4f0b13ea82ca1363d5d2ee986a02a6943886adb8e402b61f6e

See more details on using hashes here.

Provenance

The following attestation bundles were made for diffsol_jax-0.0.1-cp313-cp313-win_amd64.whl:

Publisher: ci.yml on jackbmontgomery/diffsol-jax

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file diffsol_jax-0.0.1-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for diffsol_jax-0.0.1-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 76b956ac61a083a783e186f8e4463ece6b3926bdbffb825f42fa538ad831ff18
MD5 27b2cd87f3f33fe84a9185532715f140
BLAKE2b-256 46a68baed6fe65e5f08cd4c19e1dbbf78b03fab4903c69db9cd1be44121d25bb

See more details on using hashes here.

Provenance

The following attestation bundles were made for diffsol_jax-0.0.1-cp313-cp313-manylinux_2_28_x86_64.whl:

Publisher: ci.yml on jackbmontgomery/diffsol-jax

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file diffsol_jax-0.0.1-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for diffsol_jax-0.0.1-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 a8a8a67fa8e581eeb6df795ee9bda98dc7a35136b5058c9b3645704bad52824e
MD5 42212e675ea776094178e393b3644ab3
BLAKE2b-256 efb91b9ff84f68fcffa13306205a0c5ff417eedce62d2c9b4dcb49c498b6efc6

See more details on using hashes here.

Provenance

The following attestation bundles were made for diffsol_jax-0.0.1-cp313-cp313-macosx_14_0_arm64.whl:

Publisher: ci.yml on jackbmontgomery/diffsol-jax

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file diffsol_jax-0.0.1-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for diffsol_jax-0.0.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 f3140abd0c9152abbd948fc15cd27f1141ae6c7237f2e74122b1377d19e00bb7
MD5 7805e6dcb2bf8cf57b429d4d18164ec5
BLAKE2b-256 9705c6e442bf0c2f51174130ecac576457a8f15f9715ab4f13c3840696ed9885

See more details on using hashes here.

Provenance

The following attestation bundles were made for diffsol_jax-0.0.1-cp312-cp312-win_amd64.whl:

Publisher: ci.yml on jackbmontgomery/diffsol-jax

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file diffsol_jax-0.0.1-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for diffsol_jax-0.0.1-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e37fb90d9eecad42757a51eb18640e31d3a4000509c5c84ca5628e0f15cb50aa
MD5 c5cbbac55016bd1e75677ac031218fed
BLAKE2b-256 ad9347057e7151dd45a18c83f5c7227eb80ba3fbbbd58569c569342eef332abd

See more details on using hashes here.

Provenance

The following attestation bundles were made for diffsol_jax-0.0.1-cp312-cp312-manylinux_2_28_x86_64.whl:

Publisher: ci.yml on jackbmontgomery/diffsol-jax

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file diffsol_jax-0.0.1-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for diffsol_jax-0.0.1-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 edd5d58017b85aaa912bc9e69bacbca4d65fb7f3e884db627a074d11e29277e2
MD5 2fb81c577614c092bbb9e0f8119dfbbf
BLAKE2b-256 7821812f1c4a0adcd13888d84f1f7ace25f57b09eb1481f912fcbda7a3d53f6b

See more details on using hashes here.

Provenance

The following attestation bundles were made for diffsol_jax-0.0.1-cp312-cp312-macosx_14_0_arm64.whl:

Publisher: ci.yml on jackbmontgomery/diffsol-jax

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file diffsol_jax-0.0.1-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for diffsol_jax-0.0.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d8a636c5edc4acad01080006f7dbf25c846b498f7740c9dfea78f5e8a473d85a
MD5 624ce725f508fdef6b0f958aafd5e8de
BLAKE2b-256 2fa5021fbb62f622534caecb89e7b4a55c7482dcb77ae9cf2d9334c6bd93902b

See more details on using hashes here.

Provenance

The following attestation bundles were made for diffsol_jax-0.0.1-cp311-cp311-win_amd64.whl:

Publisher: ci.yml on jackbmontgomery/diffsol-jax

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file diffsol_jax-0.0.1-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for diffsol_jax-0.0.1-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e82e14bb622948e316066724c0fbfc6299aa40769abd2235e56846064dba625a
MD5 1f97cc6b820232eb4c41a72563ccc710
BLAKE2b-256 c11182b877c69f4abbb3e25775481b028cf2c85ce527f17efa5bc5f586db6ac1

See more details on using hashes here.

Provenance

The following attestation bundles were made for diffsol_jax-0.0.1-cp311-cp311-manylinux_2_28_x86_64.whl:

Publisher: ci.yml on jackbmontgomery/diffsol-jax

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file diffsol_jax-0.0.1-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for diffsol_jax-0.0.1-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 e0eda77f47f5bb124a63416dd6e040ba0b48651375623db05ceda28d02c00d9a
MD5 c80cbd2d0bc28bce29e1dc166c269fce
BLAKE2b-256 de60731ddd8e125690c662f114318aad94f1e2be94ad5cf930b36a5fcab3a33c

See more details on using hashes here.

Provenance

The following attestation bundles were made for diffsol_jax-0.0.1-cp311-cp311-macosx_14_0_arm64.whl:

Publisher: ci.yml on jackbmontgomery/diffsol-jax

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page