One gradient, running from the accuracy of a heartbeat classifier all the way back to the fabrication parameters of the transistor its synapses are made from.
Tesseract Hackathon 2026 (Pasteur Labs & ISI) · Track 3: Hybrid ML + Mechanistic Models
A spiking neural network classifies heartbeats from an ECG. A spiking network is one whose neurons communicate in discrete pulses over time rather than in continuous numbers, which makes it a natural fit for hardware: you can build its synapses out of real devices instead of simulating them in software.
The device here is a ferroelectric transistor. A ferroelectric is a material that holds an electrical polarization after you remove the field that created it, and flips to the other polarization when you push hard enough the other way. Put a film of one in a transistor's gate and the transistor's conductance remembers which state it was left in, which is what makes it usable as a synapse. How the device behaves depends on how it was manufactured: how thick that ferroelectric film is, how long the gate is, how heavily the channel is doped. Each of those changes the device, and therefore changes how well the network classifies.
That dependency is normally broken by hand. A device engineer picks a figure of merit, maximises it in a physics simulator, and hands over a device. An ML engineer takes the device as given and trains on whatever arrives. Neither one ever sees the other's objective.
This repository closes that loop with a derivative. It takes the classification loss at the far end and pushes it backwards through the spiking network, through the circuit that turns a device into a neuron, and into the device simulator itself, arriving at ∂L/∂(process parameters): a number for how much the classifier improves per nanometre of ferroelectric film. Then it runs gradient descent on those numbers and finds a better device.
The last hop is the hard one. The simulator is Synopsys Sentaurus, a TCAD solver (Technology
Computer-Aided Design: the physics codes the semiconductor industry uses to predict how a device
will behave before anyone fabricates it). It is a closed-source Fortran and C++ binary with no
derivative of any kind, and it is driven from csh over an SSH hop to a CentOS 7 host carrying
Python 2.7.5 and nothing else. So the gradient in this repository crosses three mutually unaware
automatic-differentiation regimes (none, PyTorch, JAX), that SSH hop, and that binary.
Every forward value here is ground truth from the real solver. Only the derivative is manufactured, by directed finite-difference probes of that same solver: poke each input, watch how the outputs move, and assemble a Jacobian out of the answers.
Descending that gradient took balanced cross-entropy from 1.3996 to 1.0177 and accuracy from 0.250 to 0.688 (16 intra-patient beats; on the inter-patient DS2 test set, balanced accuracy is 0.302, see below), in 64 solver calls. On the device side the same descent widened the memory window (the voltage gap between the two remembered states) from 0.415 to 0.576 V, and paid for it in switching sharpness, 71 to 97 mV/dec.
theta (4 fabrication knobs, normalised to [0,1]^4)
| G : R^4 -> R^7 Sentaurus / DEVSIM. NO adjoint, and never will have one.
v (T1 sentaurus-fefet | T2 devsim-fefet, via T3 adjoint-shim)
y (7 figures of merit)
| H : R^7 -> R^5 DPI transducer. Pure JAX, exact, free.
v
phi (beta, g_min, g_max, th_th, sig_w)
| F : R^5 -> R LSNN classifier. PyTorch.
v
L (class-balanced cross-entropy)
Reading it downwards: theta is the four manufacturing parameters. y is the seven figures of
merit, the summary numbers that describe how the finished device behaves (memory window,
switching sharpness, on and off conductance, and so on). H is the transducer, a small exact
circuit model that converts those device numbers into the five parameters a neuron needs. F is
the classifier, and L is its loss. An adjoint is the reverse-mode derivative that lets you
run that chain backwards; a closed binary has none, which is what T3 exists to supply.
A Tesseract is the unit of packaging this hackathon is built around: a component sealed in a
container behind a fixed input/output schema and a standard set of endpoints, so that pieces
written in different languages and frameworks can be composed and differentiated together.
apply runs the component forward. abstract_eval reports the shape of the output without doing
the work. jacobian, jvp and vjp are the derivative endpoints, and a component that cannot
differentiate itself simply does not publish them. vjp (vector-Jacobian product) is the one
backpropagation needs; jvp is its forward-mode counterpart.
| Name | Wraps | Differentiation | Endpoints | |
|---|---|---|---|---|
| T1 | sentaurus-fefet |
Synopsys Sentaurus 2023.12, Preisach ferroelectric | none (closed binary) | apply ,abstract_eval |
| T2 | devsim-fefet |
DEVSIM 2.11.0 (Apache-2.0) + clean-room Miller FE gate | none | apply ,abstract_eval |
| T3 | adjoint-shim |
trust-region finite differences + Broyden black-box adjoint | NumPy/JAX | apply ,abstract_eval ,jacobian ,jvp ,vjp |
| T4 | snn-lif-ecg |
thesis LSNN (100 leaky integrate-and-fire neurons + 60 adaptive, delayed synapses) on 2000 MIT-BIH ECG beats | PyTorch autograd | apply ,abstract_eval ,vjp , jvp |
T1 and T2 are the same device in two solvers, one commercial and closed, one open. T3 is the piece that manufactures a derivative for whichever of them is in play. T4 is the network, taken from the author's thesis rather than invented here, trained on beats from MIT-BIH, the standard public arrhythmia database.
T3 proxies its forward pass straight to whichever oracle ORACLE_URL points at, so the forward
value is never a surrogate; only vjp is.
The design vector is the four fabrication knobs: ferroelectric thickness, gate length, channel doping, interfacial-layer thickness. Remanent polarization and coercive field, the two numbers describing how strongly the film polarises and how hard you must push to flip it, are locked to the measured HZO film (P_r = 32 µC/cm², P_s = 40 µC/cm², E_c = 1.4 MV/cm) and the optimiser refuses to move them.
That restriction is the point, not a limitation. P_r and E_c are properties of a deposited film: you change them by depositing a different film and re-calibrating, not by asking a fab for a different number. An optimiser given them will widen the memory window by changing the material and present it as a design result. Every result here is obtained on one fixed film.
The ECG number, and what it is. The headline accuracy 0.688 is measured on 16 beats (4 per class) from an intra-patient split: a random 1664/336 split of 2000 curated beats, so one patient's beats can sit on both sides. The shared network is fitted on those same 16 beats, so 0.688 is not a held-out score. It is the number the optimiser improves, and it is only good for comparing devices against each other.
Inter-patient re-baseline (standard MIT-BIH split, de Chazal 2004: 22 records to train, 22 different records to test, paced records left out). Same 4-knob optimum, same network recipe, fitted on DS1 only and scored on DS2 only, nothing retuned on DS2. Balanced accuracy (mean of the per-class recalls; 0.25 is chance for 4 classes) is 0.302, down from 0.688. The headline got worse, and it was never a held-out number to begin with.
| DS2 recall | N | F | S | V | balanced accuracy |
|---|---|---|---|---|---|
| 4-knob optimum, fitted on DS1 | 0.878 | 0.010 | 0.008 | 0.310 | 0.302 |
| start device, same weights | 1.000 | 0.000 | 0.000 | 0.005 | 0.251 |
Beats per class (N / F / S / V; Q too few to score): DS1 45,854 / 414 / 944 / 3,788 (Q 8);
DS2 44,246 / 388 / 1,837 / 3,220 (Q 7). For context, the same old network on its own 336
held-out intra-patient beats at the optimum scores 0.482 balanced accuracy, so the 0.688 was
already optimistic before the patient split. The beats were cut from PhysioNet and delta-encoded
again (the thesis files carry no record id), so this is a re-encoding, not the thesis files.
Script: scripts/inter_patient_ecg_rebaseline.py; numbers in
results/runs/inter_patient_ecg_rebaseline.json.
Details and the full before/after: docs/D3_RECALIBRATION.md.
The four tiers differ in what you have to install and what you are allowed to run. Tier A needs nothing but Python. Tier B adds Docker. Tier C replays banked commercial-solver output with neither. Tier D is for readers who hold a Sentaurus license themselves.
Tier A: no Docker, no license. The complete pipeline against an analytic mock oracle,
in-process via Tesseract.from_tesseract_api(). Proves every wire, every schema, every gradient hop.
uv sync --extra snn --group dev && uv run pytest
--extra snn is not optional: T4 is the PyTorch end of the gradient path, so torch is a
requirement of Tier A, and uv sync --group dev alone leaves the test collection failing on
ModuleNotFoundError: No module named 'torch'.
Timed on a fresh clone into a fresh venv, not estimated: uv sync 74 s, then 352 s cold /
314 s warm for the 152 tests that run (6 skip without DEVSIM). The cold/warm gap is small because
results/cache/mock/ is only 124 KiB. Nearly all of that time is the spiking network itself, 111
timesteps per beat in float64. Budget six minutes, not two.
Tier B: Docker, no license. The solver moves into a container, and the machine running the pipeline stops needing one. Three commands, no login:
docker pull ghcr.io/hozaifa1/devsim-fefet:latest
tesseract serve ghcr.io/hozaifa1/devsim-fefet:latest --port 8101 -e MKL_NUM_THREADS=1 -e OMP_NUM_THREADS=1 -e MKL_THREADING_LAYER=SEQUENTIAL -e DIFFSILICON_CACHE_ROOT=/tmp/diffsilicon-cache
The first three are not decoration. MKL picks its pivoting by thread count, and on a machine where that count is large the factorization inside DEVSIM dies with a divide-by-zero after Newton has already converged to 1e-13. The solves here are small, so one thread costs nothing. The fourth gives the container's cache somewhere writable. Without it the records are not kept and the returned values are identical.
ORACLE_URL=http://localhost:8101 uv run pytest tests/test_tier_b_served.py -v
Note what is not in that environment: no --extra devsim, no BLAS, no license. The solver is in
the container; the host only orchestrates.
Swapping the closed-source commercial solver for the open one is one environment variable.
Nothing else in the pipeline changes (not the shim, not the transducer, not the network, not the
optimiser) because sentaurus-fefet and devsim-fefet publish a byte-identical frozen schema.
tests/test_tier_b_served.py is that claim tested across the wire
rather than asserted: the served container's OpenAPI schema against the frozen one, the returned
figures of merit against the values DEVSIM gave on the development machine (1%, on a different OS
with a different BLAS underneath), a guard that fails if anything falls back to the analytic mock,
and jax.grad all the way to dL/dθ with nine container solves in the middle. It runs on every
push as the Tier B job in CI.
That job pulls the published image with docker logout ghcr.io in front of it, so a package that
quietly went private fails there, before it ever reaches you.
All five images are on GHCR and public. The digests below were read with an
anonymous pull token, so they are what an unauthenticated clone resolves too, and
the devsim-fefet line is the exact image the green Tier B job pulled and ran the
gradient through. Pin by digest, as ghcr.io/hozaifa1/<image>@<digest>. A digest
never moves; latest moves on every push to main, which is why this table
exists. Read 31 Aug 2026:
| Tesseract | Image | Pinned digest |
|---|---|---|
| T1 | ghcr.io/hozaifa1/sentaurus-fefet |
sha256:941bfd927135ad365885e0c1c6d7d4b4b528e6f611ea0e1721ea3d3e3e4eeec5 |
| T2 | ghcr.io/hozaifa1/devsim-fefet |
sha256:c627349d17001b57494394545ad5c962fd1966067142bf4a62216a9296c864d6 |
| T3 | ghcr.io/hozaifa1/adjoint-shim |
sha256:1510e1a6ba26f7bb2d35db65502da8e5adb358482f81fb8a6200c283ec20f7f4 |
| T4 | ghcr.io/hozaifa1/snn-lif-ecg |
sha256:2452910c10f88f89f14486e78b91adea3509a51c803f1fad50275f2762664ee1 |
| mock | ghcr.io/hozaifa1/mock-oracle |
sha256:9df1c6e23005057e81bddfb51a2cd5bfd0d692d001a1ab17861ae7d452c6eaf6 |
An earlier revision of this table pinned the 30 Aug builds. Those digests still
pull, and the devsim-fefet one among them cannot solve: it predates the mkl
line in tesseracts/devsim-fefet/tesseract_requirements.txt, so it loads DEVSIM,
serves the frozen schema, and then has nothing that can factor a matrix.
python scripts/run_flagship.py --backend devsim --d 4 --max-oracle-calls 120 --trust-radius 0.08 --theta0 0.05,0.80,0.90,0.70 --tag flagship
That is the exact command behind every headline number here: balanced
cross-entropy 1.3996 -> 1.0177 and accuracy 0.250 -> 0.688 in 64
solver calls, banked at results/runs/flagship-d4-fixed/. --d 3 is refused
on purpose: it exposes P_r and E_c, which are locked material constants.
The run starts from a deliberately poor corner of the design box: a thin, weakly polarised film
whose memory window is too small to separate the two conductance states. It is capped by solver
calls rather than by a convergence criterion, because a finite-difference Jacobian over a commercial
solver is bought by the call and a budgeted run is one you can start before bed. It writes
steps.jsonl and result.json as it goes, and the per-step trust-region ratios in that file are
validation item V5.
Tier C: regenerates every Sentaurus number with no license and no network.
results/cache/sentaurus/ is a content-addressed replay of every Sentaurus call ever made: each
result is filed under a hash of the inputs that produced it, populated as a side effect of every
run rather than reconstructed at the end.
uv run python scripts/tier_c_replay_d6.py
This is checked, not claimed. The script blocks socket and subprocess and strips every
SENTAURUS_* variable from the environment before it touches project code, then regenerates
164 of 164 float64 values bit-identically (every figure of merit in
rebaseline_d3_sentaurus.json and every entry of the V4 cross-solver Jacobian) in 1.4 s,
standing in for 0.93 h of commercial-solver time. If anything came off the solver rather than
the cache it fails with a traceback instead of returning a number.
Figure 3 replays the same way, from results/cache/devsim/, with no solver call:
uv run python scripts/fig3_hysteresis_descent.py
Figure 4 does not. It needs the 2000 curated MIT-BIH beats, and this repository deliberately
does not ship them: they are the thesis' own preprocessing of a public database, and this repo
is public. Set DIFFSILICON_ECG_DIR to the folder holding up/ and down/ and it runs; without
it, the numbers behind the figure are banked in results/runs/fig4_spike_raster.json. The network
weights it needs are committed (results/cache/w0/), so nothing is retrained either way.
Tier D: bring your own license. See docs/T1_CONTAINER.md and
.env.example. t1/Dockerfile expects the Sentaurus tree bind-mounted at /opt/synopsys and takes
SNPSLMD_LICENSE_FILE for license-server passthrough; the flagship itself runs uncontainerised, and
that document explains why.
Every figure and every banked measurement carries a sha256 in
results/manifest.json, so you can tell whether the figure you are
looking at is the one the writeup describes:
uv run python scripts/make_manifest.py --check
docs/WRITEUP.md:the case-study report. The composition, the adjoint, the results, the limitations, and the two upstream bugs.docs/D1_FINDINGS.md: every gate result, every measured number, and the eleven places where a measurement overruled the plan.docs/D2_FINDINGS.md: the open oracle, and the four things that were wrong underneath it: a body that punched through, a stiff equation the device did not need, three silent traps in DEVSIM's expression language, and a classifier that was never trained.docs/D3_RECALIBRATION.md: locking the material, and wiring the device under the thesis' own validated LSNN instead of a network invented for this project.docs/D3_FINDINGS.md·docs/D4_FINDINGS.md·docs/D5_FINDINGS.md·docs/D6_FINDINGS.md: the daily measurement logs, including the corrections. D4 section 6 is superseded by D5 and carries a banner saying so.docs/T1_CONTAINER.md: why the flagship Tesseract runs uncontainerised, and what the driver has to survive on a csh-only CentOS 7 host.docs/UPSTREAM.md: two bugs found by using the toolkit rather than reading it, with the motivating case in this repository.
The same descent as thirteen seconds of footage rather than one static panel. Every frame is a
design point DEVSIM actually solved, replayed from results/cache/devsim/; nothing between two
steps is interpolated. scripts/anim_descent.py redraws it, and anim_descent.mp4 is the same
animation in a smaller file.
Gate numbers (G2, G3, ...) and validation items (V3, V4, V5) are this project's own checklist labels, defined in the findings documents above.
| Contract | frozen :OracleInput /OracleOutput , seven smooth FoMs |
| Extraction | all seven within 0.5 % of a closed-form reference across the design box |
| Smoothness (G4) | ~5e-7 against a 0.15 threshold; the metric halves exactly under grid refinement |
| V3 check-gradients | 0 failures / 56 checks on the shim, in CI on every push, under the central-difference refresh the checker assumes. SeeWRITEUP §3 for the two conditions and the default-mode number |
| Open oracle (G2) | DEVSIM converges a pn diode, 5.9 decades of rectification |
| Open oracle (G5) | passed : hysteretic Id–Vg, memory window0.394 V against a 0.1 V gate, ~20 s per design point, one thread (median of 4, seeSolver timing ) |
| Containers (G3) | all five build and push to GHCR from CI |
| Tier B (served container) | green : the published image pulled with no login, served, andjax.grad taken through it in 94 s: schema over the wire, no mock fallback, every component of dL/dθ finite and non-zero |
| Tier C (Sentaurus replay) | verified : 164 of 164 float64 values bit-identical, with sockets and subprocesses blocked; zero orphan cache entries |
| Provenance (G10) | 5,910 forward evaluations logged with backend and input hash (snapshot of results/runs/provenance_audit_d6.json , 29 Aug 2026; the live log keeps growing); all 15 flagship steps present, a real solver wrote every one |
| Tests | 158 , lint clean |
One design point is one double Id-Vg sweep: 96 gate voltages per branch (NVG = 96 in
src/diffsilicon/shared/contract.py), forward and reverse. DEVSIM only, one thread
(OMP_NUM_THREADS, MKL_NUM_THREADS, OPENBLAS_NUM_THREADS all set to 1), no cache.
Measured 2 Dec 2026 on an Intel Core i5-1135G7 (2.40 GHz, Windows 11), DEVSIM 2.11.0, Python 3.12.10.
| Design point | Seconds |
|---|---|
| Nominal | 23.8 |
| Nominal + 0.15 on every knob | 19.6 |
| Nominal - 0.15 on every knob | 19.4 |
| Nominal scaled by 1.2 / 0.8 / 1.1 / 0.9 | 18.5 |
| Median | 19.5 |
The earlier "36 s" figure came from the D2 write-up and was not a one-thread measurement; the median of the solver times in the provenance log is 18.4 s for all 5,661 DEVSIM evaluations in it. The one Sentaurus run is about 306 s (D1).
| Name | File code | What was done | Outcome |
|---|---|---|---|
| Single-thread solver timing | scripts/time_single_thread.py |
Solved 4 design points with DEVSIM 2.11.0 on one thread, cache off | Median 19.5 s per design point |
| Inter-patient ECG re-baseline | scripts/inter_patient_ecg_rebaseline.py |
Cut and delta-encoded MIT-BIH beats by record, fitted the network on DS1 (22 records), scored the 4-knob optimum on DS2 (22 other records), no retuning | Balanced accuracy 0.302 on DS2 (N 0.878, F 0.010, S 0.008, V 0.310), against 0.688 on the old 16 intra-patient beats |
Apache-2.0. Only self-authored input decks and numeric outputs are published here: no Synopsys
binaries, no Synopsys-shipped parameter files, no .cmd fragments from Synopsys documentation.