Clean-room, differentiable SPICE circuit simulation and discrete adjoint sensitivity analysis in Rust.
Documentation ·
RustEDA Suite ·
Benchmarks ·
Development Status ·
Apache-2.0
RustSpice compiles SPICE netlists (.op, .dc, .tran) into contiguous Structure-of-Arrays (SoA) device kernels and topology-specialized sparse LU solvers, running 4.1–7.0× faster than ngspice-45 at half the memory while computing exact 1× LᵀUᵀ discrete adjoint gradients (∂V/∂θ) for analog sizing and AI-in-the-loop optimization.
| Benchmark (receipt-backed) | RustSpice | Reference (ngspice-45 / 47) |
RustSpice delta |
|---|---|---|---|
| Extracted Ibex RC decks (10 decks, 173–5,614 unknowns) | 4.1–7.0× faster | Faster ngspice-45 solver | 1.4–2.1× less peak RSS |
| Transient accuracy (same 10 RC decks, nominal grid) | 10 / 10 PASS | Tight reference | Closer than default ngspice in 10/10 (6/10 own grid) |
| Broad ngspice-47 accuracy suite (951 decks) | 857 PASS, 0 FAIL | ngspice-47 | 16 documented gaps, 77 info, 1 unverified |
| Robustness fuzzing | 400 random + 200 hostile | — | Explicit resource caps, zero panics |
Receipts and session notes live in Benchmark Report, GPU Batch Report, and RustEDA Benchmarks.
- Zero-copy strict SPICE parser & SSA device IR: Parses standard
.op/.dc/.trandecks with expressions,.include, and explicit memory/time caps; lowers#[spice_device]models with auto-differentiated analytical Jacobians. - SoA SIMD + Cranelift JIT sparse LU: Conflict-free gather tables (
CscGatherTable), deterministicf64residual verification, adaptive transient integration with breakpoint tracking, and topology-specialized unrolled LU factorization. - Single-pass discrete adjoint sensitivities: Computes exact parameter gradients
∂V/∂θvia oneLᵀUᵀback-solve for circuit sizing, with optional zero-copy DLPack / Python bridge (rustspice-py) kept outside core Rust crates. - Platform-native backends: Deterministic pure-Rust
cpu_reffirst, plus optional native CUDA (SIMT / Tile) and Apple Metal (df64) batch DC kernels validated againstcpu_ref.
# Build the CLI (or via superproject: ./dev build RustSpice --release)
cargo build --release -p rustspice-cli
# Run a CMOS ring oscillator transient simulation
target/release/rustspice run examples/cmos_ring_oscillator.sp --backend cpu
# Compute discrete adjoint sensitivities
target/release/rustspice adjoint examples/cmos_ring_oscillator.sp --target-node outSee Architecture, Benchmark Report, and GPU Batch Report.
- Device models: Supports resistors, capacitors, inductors, independent/controlled sources, diodes, and Level-1 MOS. BJT, JFET, MESFET, BSIM4, and IHP PSP103 compact models are not yet supported (so Ibex comparisons cover extracted RC networks, not full transistor-level Ibex).
- Session scope: Some single-host RC medians in the 2026-11-13 campaign carried
noisyflags; detailed session metadata is retained in Development Status. - Core independence:
rustspice-coreandrustspice-solvernever depend on Python or PyTorch (rustspice-pyis a separate optional adapter crate).
Apache-2.0 — see LICENSE.