{"id":51027321,"url":"https://github.com/gdsfactory/bosdi","last_synced_at":"2026-06-21T20:31:08.757Z","repository":{"id":364276103,"uuid":"1266589210","full_name":"gdsfactory/bosdi","owner":"gdsfactory","description":"Batched execution of OSDI via rayon","archived":false,"fork":false,"pushed_at":"2026-06-12T11:32:13.000Z","size":3433,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-12T12:11:44.555Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gdsfactory.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-11T19:04:20.000Z","updated_at":"2026-06-12T11:32:17.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/gdsfactory/bosdi","commit_stats":null,"previous_names":["gdsfactory/bosdi"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/gdsfactory/bosdi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gdsfactory%2Fbosdi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gdsfactory%2Fbosdi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gdsfactory%2Fbosdi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gdsfactory%2Fbosdi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gdsfactory","download_url":"https://codeload.github.com/gdsfactory/bosdi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gdsfactory%2Fbosdi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34625624,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-21T02:00:05.568Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-21T20:31:07.291Z","updated_at":"2026-06-21T20:31:08.749Z","avatar_url":"https://github.com/gdsfactory.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bosdi — Batched OSDI\n\n![CI](https://github.com/gdsfactory/bosdi/actions/workflows/test.yml/badge.svg)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)\n![Python 3.13](https://img.shields.io/badge/python-3.13-blue.svg)\n![Platform: Linux | macOS](https://img.shields.io/badge/platform-linux%20%7C%20macOS-lightgrey)\n![Status: Experimental](https://img.shields.io/badge/status-experimental-orange)\n\n\u003e **Experimental** — bosdi is under active development. The OSDI binary evaluation path is stable and well-tested, but\n\u003e the Verilog-A to JAX lowering compiler (`bosdi.va`) is in **alpha** and its API may change without notice. The VA\n\u003e lowering depends on a [custom fork of OpenVAF](https://github.com/cdaunt/OpenVAF) that exposes the compiler's\n\u003e intermediate representation; this fork is not yet merged upstream.\n\nEvaluate [OSDI](https://github.com/OpenVAF/OpenVAF) device models (Verilog-A compiled to `.osdi` binaries) in batched\nparallel via JAX.\n\n## Two evaluation paths\n\nbosdi provides two ways to evaluate Verilog-A compact models inside JAX:\n\n### OSDI binary path (stable)\n\nLoads a pre-compiled `.osdi` binary and evaluates N device instances in parallel via Rayon inside a JAX XLA custom call.\nThe OSDI ABI provides analytical Jacobians with respect to **node voltages only** (conductances `dI/dV`, capacitances\n`dQ/dV`). A `@custom_jvp` rule makes `jax.grad()` work through node voltages — but not through model parameters or\nstate.\n\n```python\nfrom osdi_loader import load_osdi_model\nfrom osdi_jax import osdi_eval\n\nmodel = load_osdi_model(\"path/to/device.osdi\")\nN = 1024\nvoltages = jnp.zeros((N, model.num_nodes), dtype=jnp.float64)\nparams = jnp.full((N, model.num_params), jnp.nan, dtype=jnp.float64)\nold_state = jnp.zeros((N, model.num_states), dtype=jnp.float64)\n\ncur, cond, chg, cap, new_state = osdi_eval(model.id, voltages, params, old_state)\n\n# jax.grad works through node voltages\ngrad_fn = jax.grad(lambda v: osdi_eval(model.id, v, params, old_state)[0].sum())\n```\n\n### VA to JAX lowering (alpha)\n\nCompiles Verilog-A source directly into pure JAX/Python, producing a function that is **fully differentiable** through\nall inputs — voltages, parameters, and temperature. This enables parameter optimization, sensitivity analysis, and\nend-to-end gradient-based design flows that the OSDI path cannot support.\n\nRequires [openvaf-r](https://github.com/cdaunt/OpenVAF) (a custom OpenVAF fork).\n\n```bash\npython -m bosdi.va device.va\n```\n\n### When to use which\n\n|                           | OSDI binary                                   | VA to JAX                                                                   |\n| ------------------------- | --------------------------------------------- | --------------------------------------------------------------------------- |\n| **Use case**              | Circuit simulation (Newton solve)             | Parameter fitting, sensitivity analysis, inverse design                     |\n| **Differentiable w.r.t.** | Node voltages only                            | Voltages, parameters, and temperature                                       |\n| **Performance**           | Fast — Rayon-parallel C/Rust, batched XLA FFI | Pure Python/JAX — slower per-eval, but composable with `jax.jit`/`jax.vmap` |\n| **Maturity**              | Stable                                        | Alpha                                                                       |\n| **Dependencies**          | None beyond bosdi                             | [openvaf-r](https://github.com/cdaunt/OpenVAF) fork                         |\n\nThe OSDI path treats the compiled model as a black box and extracts only what the ABI exposes: currents, charges, and\ntheir Jacobians w.r.t. node voltages. This is exactly what a Newton solver needs, but the parameter axis is opaque to\nJAX — you cannot backpropagate through it.\n\nThe VA to JAX path exists to remove that limitation. By lowering the Verilog-A source into native JAX operations, every\ncomputation becomes visible to JAX's autodiff, making the model fully differentiable. This is what enables\ngradient-based parameter extraction, design-space exploration, and end-to-end optimization of circuits where device\nparameters are the degrees of freedom.\n\n## Architecture\n\n```\nOSDI path:\n  Python: osdi_eval()  →  JAX XLA custom call\n    →  C++ (nanobind/XLA FFI): unpack buffers\n      →  Rust (Rayon): evaluate N devices in parallel\n        →  OSDI binary: currents, conductances, charges, capacitances\n\nVA path:\n  Verilog-A source  →  openvaf-r (MIR dump)\n    →  bosdi.va lowering + SCCP optimization\n      →  Pure JAX/Python function (fully differentiable)\n```\n\n## Installation\n\n### Using Pixi (recommended)\n\n```bash\ngit clone https://github.com/gdsfactory/bosdi \u0026\u0026 cd bosdi\npixi run build\n```\n\n### Using pip\n\n```bash\npip install bosdi\n```\n\n## Build \u0026 test\n\n```bash\npixi run build   # compile Rust static lib + C++ extension\npixi run test    # run pytest suite\n\n# single test\npixi run pytest tests/test_osdi.py::test_resistor_dc_evaluation -v\n```\n\n## OSDI outputs\n\nThe OSDI path returns per-device arrays shaped by `model.num_nodes` (terminals + internal nodes + branch-current\nauxiliaries):\n\n| Output | Shape             | Description                                  |\n| ------ | ----------------- | -------------------------------------------- |\n| `cur`  | `[N, num_nodes]`  | Resistive current residual at each unknown   |\n| `cond` | `[N, num_nodes²]` | `G = ∂cur/∂V` Jacobian (flattened row-major) |\n| `chg`  | `[N, num_nodes]`  | Charge residual at each unknown              |\n| `cap`  | `[N, num_nodes²]` | `C = ∂chg/∂V` Jacobian (flattened row-major) |\n\nPass `jnp.nan` for any parameter to use its Verilog-A default. Parameters can be addressed by name via\n`model.param_names`. See `tests/test_bsim4_model_card.py` for a full example.\n\n## Further reading\n\n- [OSDI technical reference](docs/osdi-technical-reference.md) — parameter handling, model introspection, output layout,\n  host-simulator integration (companion method vs MNA/DAE), and debug utilities\n\n## Limitations\n\n- **Platform:** Linux and macOS; Python 3.11+; OSDI 0.4 ABI only. `.osdi` binaries are platform-specific — compile from\n  `.va` sources via [openvaf-r](https://github.com/cdaunt/OpenVAF) on each target\n- **OSDI differentiability:** `jax.grad()` works through node voltages only, not model parameters — use the VA path for\n  parameter gradients\n- **Stateful models** (`num_states \u003e 0`): evaluation is skipped and outputs are zeroed\n- **VA lowering (alpha):** user-defined `analog function` calls and noise contributions are not yet supported\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgdsfactory%2Fbosdi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgdsfactory%2Fbosdi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgdsfactory%2Fbosdi/lists"}