tyger-onnx / scripts /README.md
matthiastl's picture
TYGER for CPUs: 8-bit ONNX port, runtime, scripts and results
ff502d1
|
Raw History Blame Contribute Delete
2.61 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 re-test; using the model needs none of them. Run them from this
folder.
They ran in two Python 3.12 environments:
- **A** (export and the original): `torch==2.15.0 transformers==5.23.0 onnx==1.23.2 safetensors pyarrow soundfile`
- **B** (the port and the scores): `onnxruntime==1.32.0 onnx==1.23.2 torch==2.15.0 numpy safetensors pyarrow soundfile pytest`
```bash
# TYGER, and the test calls (CallHome is gated: accept its terms on its page first).
hf download nineninesix/tyger --include config.json model.safetensors "nemotron/*.json" --local-dir data/tyger
hf download talkbank/callhome eng/data-00000-of-00005.parquet --repo-type dataset --local-dir data/callhome
# Export (A), then quantize (B): export/l15.int8.onnx, export/turn_taker.onnx, export/mel_filters.npy.
A/bin/python -I export.py --out export
B/bin/python -I export.py --quantize export
# Layer-15 frames of the 28 calls: the original (A, about 35 minutes), then the 8-bit port (B).
A/bin/python -I tyger_ref.py features --out runs/ref --threads 1
B/bin/python -I port.py features --model export/l15.int8.onnx --out runs/int8
# The rule (results/RULE.md): decisions and events, then speed.
B/bin/python -I turns.py --reference runs/ref --port runs/int8 --out results/gate.json
B/bin/python -I port.py speed --model export/l15.int8.onnx --threads 4
A/bin/python -I tyger_ref.py speed --threads 1
# The runtime gives the scored port's events.
B/bin/python -I -m pytest test_runtime.py
# The streaming attempt (results/streaming-attempt.json).
B/bin/python -I stream.py export --out export
B/bin/python -I stream.py check
B/bin/python -I stream.py features --out runs/stream-fp32
B/bin/python -I turns.py --reference runs/ref --port runs/stream-fp32 --out results/streaming-attempt.json
```
| Script | What it does |
|---|---|
| `tyger_ref.py` | the original, as tyger-s2s's CPU reference runs it: 8 s windows, layer 15, per-hop frames |
| `l15.py` | Nemotron's encoder to layer 15 in plain PyTorch, and the log-mels in numpy |
| `export.py` | ONNX export of `l15.py` and of the turn-taker, and the 8-bit quantization |
| `port.py` | the port's frames with ONNX Runtime, and its speed |
| `turns.py` | the decisions and events of both, and the pass/fail numbers |
| `stream.py` | the streaming encoder that was tried and failed the rule |
| `test_runtime.py` | `tyger_onnx.py` against the scored port |
| `check_release.py` | refuses to publish a folder that names the machine it was made on |