Skip to main content

Make OSDI device models (Verilog-A compiled to .osdi) differentiable via JAX

Project description

bosdi — Batched OSDI

CI License: MIT Python 3.13 Platform: Linux | macOS Status: Experimental

Experimental — bosdi is under active development. The OSDI binary evaluation path is stable and well-tested, but the Verilog-A to JAX lowering compiler (bosdi.va) is in alpha and its API may change without notice. The VA lowering depends on a custom fork of OpenVAF that exposes the compiler's intermediate representation; this fork is not yet merged upstream.

Evaluate OSDI device models (Verilog-A compiled to .osdi binaries) in batched parallel via JAX.

Two evaluation paths

bosdi provides two ways to evaluate Verilog-A compact models inside JAX:

OSDI binary path (stable)

Loads a pre-compiled .osdi binary and evaluates N device instances in parallel via Rayon inside a JAX XLA custom call. The OSDI ABI provides analytical Jacobians with respect to node voltages only (conductances dI/dV, capacitances dQ/dV). A @custom_jvp rule makes jax.grad() work through node voltages — but not through model parameters or state.

from osdi_loader import load_osdi_model
from osdi_jax import osdi_eval

model = load_osdi_model("path/to/device.osdi")
N = 1024
voltages = jnp.zeros((N, model.num_nodes), dtype=jnp.float64)
params = jnp.full((N, model.num_params), jnp.nan, dtype=jnp.float64)
old_state = jnp.zeros((N, model.num_states), dtype=jnp.float64)

cur, cond, chg, cap, new_state = osdi_eval(model.id, voltages, params, old_state)

# jax.grad works through node voltages
grad_fn = jax.grad(lambda v: osdi_eval(model.id, v, params, old_state)[0].sum())

VA to JAX lowering (alpha)

Compiles Verilog-A source directly into pure JAX/Python, producing a function that is fully differentiable through all inputs — voltages, parameters, and temperature. This enables parameter optimization, sensitivity analysis, and end-to-end gradient-based design flows that the OSDI path cannot support.

Requires openvaf-r (a custom OpenVAF fork).

python -m bosdi.va device.va

When to use which

OSDI binary VA to JAX
Use case Circuit simulation (Newton solve) Parameter fitting, sensitivity analysis, inverse design
Differentiable w.r.t. Node voltages only Voltages, parameters, and temperature
Performance Fast — Rayon-parallel C/Rust, batched XLA FFI Pure Python/JAX — slower per-eval, but composable with jax.jit/jax.vmap
Maturity Stable Alpha
Dependencies None beyond bosdi openvaf-r fork

The OSDI path treats the compiled model as a black box and extracts only what the ABI exposes: currents, charges, and their Jacobians w.r.t. node voltages. This is exactly what a Newton solver needs, but the parameter axis is opaque to JAX — you cannot backpropagate through it.

The VA to JAX path exists to remove that limitation. By lowering the Verilog-A source into native JAX operations, every computation becomes visible to JAX's autodiff, making the model fully differentiable. This is what enables gradient-based parameter extraction, design-space exploration, and end-to-end optimization of circuits where device parameters are the degrees of freedom.

Architecture

OSDI path:
  Python: osdi_eval()  →  JAX XLA custom call
    →  C++ (nanobind/XLA FFI): unpack buffers
      →  Rust (Rayon): evaluate N devices in parallel
        →  OSDI binary: currents, conductances, charges, capacitances

VA path:
  Verilog-A source  →  openvaf-r (MIR dump)
    →  bosdi.va lowering + SCCP optimization
      →  Pure JAX/Python function (fully differentiable)

Installation

Using Pixi (recommended)

git clone https://github.com/gdsfactory/bosdi && cd bosdi
pixi run build

Using pip

pip install bosdi

Build & test

pixi run build   # compile Rust static lib + C++ extension
pixi run test    # run pytest suite

# single test
pixi run pytest tests/test_osdi.py::test_resistor_dc_evaluation -v

OSDI outputs

The OSDI path returns per-device arrays shaped by model.num_nodes (terminals + internal nodes + branch-current auxiliaries):

Output Shape Description
cur [N, num_nodes] Resistive current residual at each unknown
cond [N, num_nodes²] G = ∂cur/∂V Jacobian (flattened row-major)
chg [N, num_nodes] Charge residual at each unknown
cap [N, num_nodes²] C = ∂chg/∂V Jacobian (flattened row-major)

Pass jnp.nan for any parameter to use its Verilog-A default. Parameters can be addressed by name via model.param_names. See tests/test_bsim4_model_card.py for a full example.

Further reading

  • OSDI technical reference — parameter handling, model introspection, output layout, host-simulator integration (companion method vs MNA/DAE), and debug utilities

Limitations

  • Platform: Linux and macOS; Python 3.11+; OSDI 0.4 ABI only. .osdi binaries are platform-specific — compile from .va sources via openvaf-r on each target
  • OSDI differentiability: jax.grad() works through node voltages only, not model parameters — use the VA path for parameter gradients
  • Stateful models (num_states > 0): evaluation is skipped and outputs are zeroed
  • VA lowering (alpha): user-defined analog function calls and noise contributions are not yet supported

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

bosdi-0.1.3.tar.gz (229.8 kB view details)

Uploaded Source

Built Distributions

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

bosdi-0.1.3-cp313-cp313-manylinux_2_39_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.39+ x86-64

bosdi-0.1.3-cp313-cp313-manylinux_2_28_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

bosdi-0.1.3-cp313-cp313-macosx_11_0_arm64.whl (850.3 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

bosdi-0.1.3-cp312-cp312-manylinux_2_39_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.39+ x86-64

bosdi-0.1.3-cp312-cp312-manylinux_2_28_x86_64.whl (2.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

bosdi-0.1.3-cp312-cp312-macosx_11_0_arm64.whl (838.7 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

Details for the file bosdi-0.1.3.tar.gz.

File metadata

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

File hashes

Hashes for bosdi-0.1.3.tar.gz
Algorithm Hash digest
SHA256 900c3342a7b8f2ec7a56e4dcfda4d5f8bf671124435a9f19839254d347115605
MD5 be83913ce014721b289739f34f8b6afc
BLAKE2b-256 6439f807e0d57721aef5954bf7dd824226e5d5265fb0a1926a19fe400766d2ba

See more details on using hashes here.

Provenance

The following attestation bundles were made for bosdi-0.1.3.tar.gz:

Publisher: release.yml on gdsfactory/bosdi

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

File details

Details for the file bosdi-0.1.3-cp313-cp313-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for bosdi-0.1.3-cp313-cp313-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 964d761c928f418337b0d5e5b4bf2b7925f59019ffb90564cacddd37b21c6da3
MD5 a66fd174b5b34a134e75400d1f8ee4ee
BLAKE2b-256 f14e302050cc7ea80cd4e6270db74b6938bb1f93110de096b6b208aff92cdab9

See more details on using hashes here.

Provenance

The following attestation bundles were made for bosdi-0.1.3-cp313-cp313-manylinux_2_39_x86_64.whl:

Publisher: release.yml on gdsfactory/bosdi

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

File details

Details for the file bosdi-0.1.3-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for bosdi-0.1.3-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d62717297dc753e0a902cac7b5d1cf23c3ec069330a957101b5d1a97626f30a9
MD5 f1eb03f72be97cac200f9d33b9fd32a2
BLAKE2b-256 e90d7527bc35a4da367951dc5edc1dbc764bfd827c2b8da5173d1f905fbda11e

See more details on using hashes here.

Provenance

The following attestation bundles were made for bosdi-0.1.3-cp313-cp313-manylinux_2_28_x86_64.whl:

Publisher: release.yml on gdsfactory/bosdi

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

File details

Details for the file bosdi-0.1.3-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for bosdi-0.1.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b2e70260b2740869f128eea67e98ac58b898963af1d6e6bb087cb932617a8018
MD5 39aeacb480e8a3bc3146ae9bcf125ca2
BLAKE2b-256 98678fa15bb07bc6cb9db336209ce2aad794310780fbbd0d939c4b1bab455329

See more details on using hashes here.

Provenance

The following attestation bundles were made for bosdi-0.1.3-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: release.yml on gdsfactory/bosdi

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

File details

Details for the file bosdi-0.1.3-cp312-cp312-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for bosdi-0.1.3-cp312-cp312-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 367f7645f6bf61fa96748811a989af6d046debca894fcb9096fed8874913d0e9
MD5 d0c48078fdb0e9155bfc59fa9611511f
BLAKE2b-256 8a3b3b12ed8ac001957a1e333deb88fda1aab68f60f25759daebd00e03f304b3

See more details on using hashes here.

Provenance

The following attestation bundles were made for bosdi-0.1.3-cp312-cp312-manylinux_2_39_x86_64.whl:

Publisher: release.yml on gdsfactory/bosdi

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

File details

Details for the file bosdi-0.1.3-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for bosdi-0.1.3-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 846cfb2900189b8e72e12231393f10fa22902f26e8a5a4568d2f2362ad392ee2
MD5 85d7dde85c12f036e8533cc261a9b60a
BLAKE2b-256 1a69b8f3c0eacc7fe91605885c6215dc208660d6a51255b4f95b494c2f2dea2e

See more details on using hashes here.

Provenance

The following attestation bundles were made for bosdi-0.1.3-cp312-cp312-manylinux_2_28_x86_64.whl:

Publisher: release.yml on gdsfactory/bosdi

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

File details

Details for the file bosdi-0.1.3-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for bosdi-0.1.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cac4d4cf87a31ce22a5aed477621c75f86acb318bcf3e07cabe28f15900e3b28
MD5 ad771474fb95c885a5b044ccbd7b2777
BLAKE2b-256 cdc5fb3783d9e570928ddef4ea05d7801740a001e90850a275460c83bd5ab7e4

See more details on using hashes here.

Provenance

The following attestation bundles were made for bosdi-0.1.3-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: release.yml on gdsfactory/bosdi

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