Make OSDI device models (Verilog-A compiled to .osdi) differentiable via JAX
Project description
bosdi — Batched OSDI
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.
.osdibinaries are platform-specific — compile from.vasources 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 functioncalls 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
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bosdi-0.1.1.tar.gz.
File metadata
- Download URL: bosdi-0.1.1.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc0ce55a5d6908abb857090b154c741fe33b5420d8e9af4b24c7dfbfa9730dcd
|
|
| MD5 |
8810abdfce1e1730118f0892baa9abe8
|
|
| BLAKE2b-256 |
9bf09b4a20eec9c3c31a809692b4e30bc8bff37ae5e22cb64cdd1fa4e3aaf9b2
|
Provenance
The following attestation bundles were made for bosdi-0.1.1.tar.gz:
Publisher:
release.yml on gdsfactory/bosdi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bosdi-0.1.1.tar.gz -
Subject digest:
dc0ce55a5d6908abb857090b154c741fe33b5420d8e9af4b24c7dfbfa9730dcd - Sigstore transparency entry: 1804778063
- Sigstore integration time:
-
Permalink:
gdsfactory/bosdi@7422342f98e3838f2ef62498be75ad99b7b8d873 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/gdsfactory
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7422342f98e3838f2ef62498be75ad99b7b8d873 -
Trigger Event:
push
-
Statement type:
File details
Details for the file bosdi-0.1.1-cp313-cp313-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: bosdi-0.1.1-cp313-cp313-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 1.8 MB
- Tags: CPython 3.13, manylinux: glibc 2.39+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e76c43c688a0be99ab00062a63d668d80b7226bffc34cb9aea077131a7a62331
|
|
| MD5 |
77b7adec15bdae46372ef0f4192b8b73
|
|
| BLAKE2b-256 |
93862a792529e401eeba58963d378553e6c6921acad5cc13adbbde374cae633a
|
Provenance
The following attestation bundles were made for bosdi-0.1.1-cp313-cp313-manylinux_2_39_x86_64.whl:
Publisher:
release.yml on gdsfactory/bosdi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bosdi-0.1.1-cp313-cp313-manylinux_2_39_x86_64.whl -
Subject digest:
e76c43c688a0be99ab00062a63d668d80b7226bffc34cb9aea077131a7a62331 - Sigstore transparency entry: 1804778143
- Sigstore integration time:
-
Permalink:
gdsfactory/bosdi@7422342f98e3838f2ef62498be75ad99b7b8d873 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/gdsfactory
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7422342f98e3838f2ef62498be75ad99b7b8d873 -
Trigger Event:
push
-
Statement type:
File details
Details for the file bosdi-0.1.1-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: bosdi-0.1.1-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 838.7 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
880106b8333034d2e4b940f2f569069e2d7f395936bd7652c650a4064fcba4b6
|
|
| MD5 |
1521582f330341d9fb99fb0868854b12
|
|
| BLAKE2b-256 |
d262f424c6396e5d44f2c5eac479363d8061e74d18740ce612c971f1f99d2e56
|
Provenance
The following attestation bundles were made for bosdi-0.1.1-cp313-cp313-macosx_11_0_arm64.whl:
Publisher:
release.yml on gdsfactory/bosdi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bosdi-0.1.1-cp313-cp313-macosx_11_0_arm64.whl -
Subject digest:
880106b8333034d2e4b940f2f569069e2d7f395936bd7652c650a4064fcba4b6 - Sigstore transparency entry: 1804778214
- Sigstore integration time:
-
Permalink:
gdsfactory/bosdi@7422342f98e3838f2ef62498be75ad99b7b8d873 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/gdsfactory
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7422342f98e3838f2ef62498be75ad99b7b8d873 -
Trigger Event:
push
-
Statement type:
File details
Details for the file bosdi-0.1.1-cp312-cp312-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: bosdi-0.1.1-cp312-cp312-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 1.8 MB
- Tags: CPython 3.12, manylinux: glibc 2.39+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
281d732b490b01eed677efe96dcf786e58ec38acdbd1b19435493c4683a8cd11
|
|
| MD5 |
c1ea581eb93366ae219f94eb9be0e161
|
|
| BLAKE2b-256 |
9e20cbd0eae4918b1528c098dc3c7c799a55066b7aefef97eef19153436173bd
|
Provenance
The following attestation bundles were made for bosdi-0.1.1-cp312-cp312-manylinux_2_39_x86_64.whl:
Publisher:
release.yml on gdsfactory/bosdi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bosdi-0.1.1-cp312-cp312-manylinux_2_39_x86_64.whl -
Subject digest:
281d732b490b01eed677efe96dcf786e58ec38acdbd1b19435493c4683a8cd11 - Sigstore transparency entry: 1804778177
- Sigstore integration time:
-
Permalink:
gdsfactory/bosdi@7422342f98e3838f2ef62498be75ad99b7b8d873 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/gdsfactory
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7422342f98e3838f2ef62498be75ad99b7b8d873 -
Trigger Event:
push
-
Statement type:
File details
Details for the file bosdi-0.1.1-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: bosdi-0.1.1-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 850.1 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1bb24976d7fb3a35449f74f5516e89a8e6abcaa0342e92f9c7aaf56e1f9ee5c4
|
|
| MD5 |
f0890fb59001bb750f7b59f8081be7d3
|
|
| BLAKE2b-256 |
68a5ab43c4438a8886bf3b553e3e9df81dcb82ddb14a0ae3481dd6a9a63236fd
|
Provenance
The following attestation bundles were made for bosdi-0.1.1-cp312-cp312-macosx_11_0_arm64.whl:
Publisher:
release.yml on gdsfactory/bosdi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bosdi-0.1.1-cp312-cp312-macosx_11_0_arm64.whl -
Subject digest:
1bb24976d7fb3a35449f74f5516e89a8e6abcaa0342e92f9c7aaf56e1f9ee5c4 - Sigstore transparency entry: 1804778095
- Sigstore integration time:
-
Permalink:
gdsfactory/bosdi@7422342f98e3838f2ef62498be75ad99b7b8d873 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/gdsfactory
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7422342f98e3838f2ef62498be75ad99b7b8d873 -
Trigger Event:
push
-
Statement type: