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

logger

Module-level logger.

Functions

run_benchmark(→ dict)

Benchmark a champion's PyTorch vs. ONNX Runtime paths.

main(→ None)

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.json metadata sidecar alongside it).

  • data_path (str) – Path to the data config (e.g. config/FI/data/wavlm.yaml) whose fi.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 with latency_ms and the metrics suite (mean_one_minus_mae, mean_ccc, etc.).

Return type:

dict

personalitylinmult.inference.onnx_benchmark.main() → None[source]

CLI entry point.