vision-inference-bench

MobileNetV3‑Small · PyTorch → ONNX FP32 → static INT8

2.07× faster, 73% smaller —
and the prediction changed.

A CPU benchmark of one small vision model, quantized end to end. The speedup is real and repeatable. The accuracy isn't established, and the repo says so instead of hiding it.

Apple M4 Pro · macOS 26.7.1 arm64 · ONNX Runtime 1.31.0 · CPUExecutionProvider · 1 thread · 20 warm‑up / 200 measured

Median latency
1.495 ms
from 3.095 ms
Median speedup
2.07×
p95: 3.300 → 1.603 ms
Model size
2.69 MiB
−73.1% from 9.99 MiB
Held-out accuracy
not measured
camel → pinwheel on the sample

Median inference (ms, lower is better)

FP32
3.095
INT8
1.495

Model file (MiB, lower is better)

FP32
9.99
INT8
2.69

What the numbers do and don't say

A quantization result is two claims: it got faster, and it still works. Only the first one is measured here.

The sample prediction changed class — 354 Arabian camel (FP32) → 723 pinwheel (INT8), with a maximum absolute logit difference of 21.43 and a mean of 3.32. One image proves nothing about accuracy either way, which is exactly why held‑out accuracy is reported as null rather than skipped.
  • The camel → pinwheel disagreement needs bisecting across PyTorch, exported FP32, prepared FP32 and INT8 before anyone says "accuracy‑preserving".
  • Labelled evaluation images must map Imagenette's 0–9 to ImageNet's 0–999; the guard rejects reused calibration paths but not a copied file.
  • One matching top‑1 prediction would still not establish accuracy.
  • Calibration and sample images aren't bundled, and the snapshot has no hashes — exact reproduction isn't possible from this repo alone.
  • CPU only: no GPU/DSP, Snapdragon, headset, power, or camera‑to‑result latency claims.
  • The latency table compares ONNX FP32 vs ONNX INT8 — not PyTorch vs ONNX.

Recorded conditions

Every one of these moves the number. Re‑measure on your machine before quoting it.

CPU / OSApple M4 Pro / macOS 26.7.1, arm64
RuntimeONNX Runtime 1.31.0 · CPUExecutionProvider · sequential
Inputbatch 1 · float32 [1, 3, 224, 224]
Threadsintra 1 / inter 1
Loop20 warm‑up · 200 measured
StackPython 3.14.0 · PyTorch 2.14.1 · TorchVision 0.29.1
Calibration200 Imagenette images · 10 classes × 20 · 320 px split

Run it

# python3 -m venv .venv && source .venv/bin/activate
$ pip install torch torchvision onnx onnxruntime \
    onnxscript pillow numpy jupyterlab
$ python -m jupyterlab train.ipynb

# first cell: sample image, calibration dir,
# warm-up/measured runs, thread counts
# run top to bottom → artifacts/ + results JSON

Peak process RSS (MiB)

FP32
85.375
INT8
69.578

Whole process, fresh run per model — interpreter and runtime included, not model memory alone.