personalitylinmult.inference.onnx_benchmark¶
Compare a champion’s PyTorch and ONNX Runtime paths: speed and accuracy.
Answers the two questions ONNX export exists to answer: is it actually
faster, and how much (if any) test-set accuracy does the export cost. Runs
both paths over the real test split from a built fi.h5, using the exact
metrics suite training reports (1-MAE, Pearson r, CCC, R2, std_ratio) so the
comparison is apples-to-apples against the numbers already recorded for the
champion in README.md’s “Pretrained models” table.
Usage:
uv run python -m personalitylinmult.inference.onnx_benchmark \\
--checkpoint results/FI/bigfive/fi_lint_wavlm-ccc-bs256/checkpoints/best.ckpt \\
--onnx results/FI/bigfive/fi_lint_wavlm-ccc-bs256/checkpoints/best.onnx \\
--data config/FI/data/wavlm.yaml
Attributes¶
Module-level logger. |
Functions¶
|
Benchmark a champion's PyTorch vs. ONNX Runtime paths. |
|
CLI entry point. |
Module Contents¶
- personalitylinmult.inference.onnx_benchmark.logger¶
Module-level logger.
- personalitylinmult.inference.onnx_benchmark.run_benchmark(checkpoint_path: str, onnx_path: str, data_path: str, n_timing_runs: int = 20) dict[source]¶
Benchmark a champion’s PyTorch vs. ONNX Runtime paths.
- Parameters:
checkpoint_path (str) – Path to the trained
.ckpt.onnx_path (str) – Path to the exported
.onnx(with a.onnx.jsonmetadata sidecar alongside it).data_path (str) – Path to the data config (e.g.
config/FI/data/wavlm.yaml) whosefi.h5/test split this benchmark evaluates against.n_timing_runs (int) – Forward passes averaged for the per-sample latency numbers (accuracy always runs over the full test split regardless of this value).
- Returns:
{"pytorch": {...}, "onnx": {...}}, each withlatency_msand the metrics suite (mean_one_minus_mae,mean_ccc, etc.).- Return type:
dict