sax
Autograd and XLA for S-parameters
What it is and what it does
SAX wraps JAX to provide a functional, dictionary-based framework for simulating and optimizing circuits described by S-parameters (scattering matrices). It was built for photonic integrated circuits but works with any frequency-domain circuit model. Rather than defining custom data structures, SAX stays close to JAX's functional paradigm: you write component models as functions returning S-dictionaries, compose them into circuits via netlists, and optimize them using JAX's autodiff and XLA compilation.
The package handles the boilerplate of circuit composition and parameter passing, allowing you to define a directional coupler, waveguide, or other component once and then combine them into larger systems like Mach-Zehnder interferometers. You can then sweep parameters (wavelength, coupling strength, length) across ranges and plot transmission spectra or use JAX's optimization tools to tune component parameters for a target response.
Use it for:
- Design and simulate photonic integrated circuits by composing waveguides, couplers, and other optical components into larger systems.
- Optimize photonic circuit parameters (coupling ratios, waveguide lengths, phase shifts) to achieve target transmission or reflection spectra.
- Perform frequency-domain S-parameter analysis on arbitrary circuits without writing custom matrix algebra.
- Leverage JAX autodiff to compute gradients for circuit optimization or sensitivity analysis across wavelength ranges.
- Combine circuit simulation with machine learning workflows via JAX's ecosystem (Optax, Flax, etc.).
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
SAX is a JAX-based simulator and optimizer for S-parameter circuits, primarily designed for photonic integrated circuits but applicable to any frequency-domain circuit simulation using scattering parameters.
Yes, if you work with S-parameter circuit simulation or photonic design. SAX is actively maintained, has no known vulnerabilities, and offers a clean functional interface built on JAX's autodiff and XLA compilation. The dependency footprint is large but manageable. Install with caution if your environment has strict dependency constraints; otherwise, it is a solid choice for frequency-domain circuit work.
Install
sax on PyPI
pip
pip install saxuv
uv add saxpoetry
poetry add saxInstalling sax
Before you install
Low install friction with a pure-wheel distribution. Active maintenance (66 days since last release) and support for current Python versions (3.11–3.14). Requires 19 runtime dependencies including JAX, NumPy, and scientific libraries; installation is straightforward but the dependency stack is substantial.
License in practice
Apache-2.0 permissive license allows commercial and private use with minimal restrictions; you must include a copy of the license and state significant changes, but there are no copyleft obligations.
Quickstart
pip install sax
import sax
import jax.numpy as jnp
def coupler(coupling=0.5):
kappa = coupling**0.5
tau = (1-coupling)**0.5
return sax.reciprocal({
("in0", "out0"): tau,
("in0", "out1"): 1j*kappa,
("in1", "out0"): 1j*kappa,
("in1", "out1"): tau,
})
result = coupler(coupling=0.3)
Requires Python >=3.11.0; JAX installation may require additional system dependencies depending on your platform (CPU vs. GPU/TPU support).
Verify before relying
- Whether the package's 19 dependencies can be installed together without version conflicts in typical environments.
- Performance characteristics and scalability limits for large circuit topologies or high-dimensional parameter sweeps.
Package facts
| License | Apache Software License (permissive) |
| Python support | supports the current Python release (>=3.11.0) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 19 — jax, jaxellip, jaxtyping, klujax, lark, matplotlib, natsort, networkx, numpy, optax, orjson, pandas, pydantic, pyyaml, scikit-rf, sympy, tqdm, typing-extensions, xarray |
| Maintenance | actively maintained — 66 days since the last release |
| First released | |
| Downloads | 136,305/month — #11,400 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: sax-0.18.2-py3-none-any.whl
Keywords: simulation, optimization, autograd, simulation-framework, circuit, physics-simulation, photonics, s-parameters, jax, xla, photonic-circuit, photonic-optimization
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
gpluginsGplugins provides a plugin system for…
unclear · top 15,000 on PyPI
kfactoryKFactory is a Python framework for designing…
unclear · top 15,000 on PyPI
jaxJAX is a Python library for automatic…
permissive · top 1,000 on PyPI
gdsfactoryGDSFactory generates CAD files (GDS, OASIS,…
unclear · top 15,000 on PyPI
scikit-rfscikit-rf is an object-oriented Python library…
permissive · top 15,000 on PyPI
jax-cuda12-pjrtProvides NVIDIA GPU acceleration for JAX…
permissive · top 15,000 on PyPI
jax-cuda13-pjrtProvides NVIDIA GPU acceleration for JAX…
permissive · top 15,000 on PyPI
jaxlibjaxlib is the compiled XLA backend that enables…
permissive · top 5,000 on PyPI
PySpicePySpice provides a Python interface to Ngspice…
copyleft · top 15,000 on PyPI
gdsfactoryplusGDSFactory+ extends the GDSFactory library with…
unclear · top 15,000 on PyPI