Naveed Ali
‹ All blogs

On-device · May 2026 · 2 min read

Why quantising the detection head killed my YOLO model

Inside the work: one decision, four builds

Quantising everything halved the model. It also killed it.

Pick a build to see what each export did to the shelf detector, relative to the full-precision build.

Detector layers. Filled blocks are int8, outlined blocks keep higher precision

Leave the head alone. Keep the size and the speed.

Size½ size
Latency~3× faster · CPU
AccuracyWithin 1%

A small detector had to fit and run on a phone held in a store aisle. int8 quantisation was the obvious lever. It halved the model and tripled the speed, but the outputs became useless. The fix was to stop quantising one part of it.

The setup

Ultralytics YOLO detector, exported three ways: CoreML for iOS, ONNX Runtime for cross-platform CPU, TFLite for Android. Target was real-time inference on the scanning device itself, with no server in the loop and accuracy close enough to the fp32 baseline that downstream logic didn't have to change.

What collapsed

Quantising every layer to int8 produced a model that loaded, ran, and returned confidence scores that no longer separated anything. Detections technically existed; the ranking between them was noise. The failure is quiet. There is no exception and no warning, only a metric that falls off a cliff.

The head is where small numerical differences become large ranking differences. That's exactly what int8 is bad at.

The fix

Restrict quantisation to convolution layers and leave the head in higher precision. Nearly all of the size and latency win comes from the convolutional backbone anyway, so the trade is lopsided in your favour.

# conv-only QDQ, per-channel
quantize_static(
    model_input,
    model_output,
    calibration_data_reader=reader,
    quant_format=QuantFormat.QDQ,
    op_types_to_quantize=["Conv"],
    per_channel=True,
)
Use frames from the deployment distribution for calibration, because the calibration set matters as much as the flags.

Numbers

BuildSizeCPU speedAccuracy
fp321×baselinebaseline
int8, all layers½n/acollapsed
int8, conv-only QDQ½~3× fasterwithin 1%
The same export ran in real time on the Apple Neural Engine.

When this applies

Any architecture where a small output head turns features into scores or coordinates: detectors, rankers, retrieval scorers. If accuracy falls apart after quantisation, isolate the head before you touch anything else.

Have a project in mind? Let’s talk.

Open to contract and full-time work. Based in Lahore, working with teams in the UK, EU and US.