ADR-0003 — Julia trains, Rust infers; they share only safetensors, a manifest and golden vectors
Status: accepted
Context: Models (SSMs or similar) are trained in Julia but must run per sample on the real-time audio thread. General runtimes (ONNX Runtime, tract) are poor fits there, and Julia’s ONNX export doesn’t cover SSM scans. Details: Model pipeline.
Decision: Every learned or fitted model — a neural SSM as much as the fitted parameters of a physical model (piano fitting) — crosses from Julia to Rust this way. The architecture is implemented twice — Lux.jl for training, hand-written Rust for inference. Julia exports model.safetensors (f32 weights, fixed names), manifest.toml (architecture version, hyperparameters, shapes, provenance) and golden.safetensors (test inputs/outputs). Continuous-time parameters are exported and discretised in Rust for the host’s sample rate. Rust tests reproduce the golden vectors within tolerance.
Rejected alternative: ONNX (export gaps in Julia, runtime not real-time safe). Embedding Julia in the plugin (startup time, GC on the audio thread, deployment). A custom binary format (safetensors already is the minimal one, with readers on both sides).
Consequences: Every architecture change means changing two implementations and bumping the architecture version; the golden tests make drift visible. Inference stays allocation-free and fast.