sava-onnx / scripts /README.md
matthiastl's picture
Name the device (Apple M4 Max) instead of 'the Mac'
f27cfec verified
|
Raw History Blame Contribute Delete
2.63 kB

Scripts

The working copies of the code that produced the files and numbers in this repository. They are here as a record and to let you rebuild or re-test; using the model needs none of them.

They expect to sit in one folder together with sava_onnx.py, and they write to build/:

uv venv --python 3.12
uv pip install inworld-sava onnx onnxruntime onnxscript pytest pyarrow scikit-learn scipy
.venv/bin/python export.py      # build/sava.onnx        (published as sava.onnx)
.venv/bin/python quantize.py    # build/sava.int8.onnx   (published as sava-int8.onnx)
.venv/bin/python -m pytest test_parity.py
Script What it does
export.py exports the PyTorch model's one-frame streaming step to ONNX and names its learned linear layers
quantize.py makes the 8-bit file by quantizing only those layers
test_parity.py checks the export against the reference logits in the upstream repository's tests/fixtures (copy that folder to fixtures/)
drift.py measures how far a smaller version's outputs move from the full-precision export
bench.py scores the PyTorch model and the ONNX files on the TEN-VAD and pipecat smart-turn test sets, clean and through a simulated phone line
telephony.py the simulated phone line bench.py uses: 8 kHz, 4th-order Butterworth band-pass at 300-3400 Hz, G.711 mu-law, back to 16 kHz
speed.py times one 40 ms frame of each ONNX file and of the PyTorch streaming step on one CPU thread

The test sets: TEN-VAD's from the testset/ folder of TEN-framework/ten-vad (bench.py tenvad --root), and pipecat-ai/smart-turn-data-v3.2-test (bench.py pipecat --root).

Speed tests

  • ios-bench/: the small iOS app behind the native iPhone numbers. Add the ONNX Runtime xcframework from the official onnxruntime-c CocoaPods archive under vendor/, copy sava.onnx, sava-int8.onnx, the test recording and expected.json into Resources/, set your own team in project.yml, then xcodegen generate and build for a device. It runs on launch and prints one SAVABENCH_RESULT line per file.
  • web-bench/: the page and local server behind the WebAssembly numbers. Put the two model files, the test recording and expected.json next to index.html, run python3 serve.py, and open the page from the device to test.

expected.json holds the per-frame logits of each file on the test recording, as produced by native ONNX Runtime on an Apple M4 Max; both tests compare against it.