UAT 462 Edge Artificial Intelligence for UAS
Worksheet 3 Quantise the model and measure the effect on accuracy
Objective
Quantise the group's model to INT8 with a representative calibration set, compare range methods and per-channel with per-tensor scales, and decide whether QAT or another compression method is needed
Equipment and materials
- The group's ONNX model
- A calibration set of at least 100 images covering dawn and evening, and a labelled validation set
- Python with onnxruntime, the example code at /downloads/uat-462/, and a target board for timing
Safety
- Desk work, no flying
- Use permitted images with no identifiable person, and store the data set according to personal-data guidance
- A board under full load is hot; do not touch the heat sink
Steps
- Quantise the model to static INT8 with at least 100 calibration images, then compare size, time and AP with the original
- Change the range method (MinMax, Entropy, Percentile) and compare accuracy
- Calibrate on one condition and test on another; report the accuracy lost
- Compare per-channel with per-tensor scales if the tool supports it
- Use Example 5 to compute M and M0 for one layer and check that the fixed-point multiply matches the floating one
- If accuracy is below the criterion, reduce what can be reduced first, then try QAT, pruning or distillation; record every step
Record of results
| Model | File size (MB) | p50 (ms) | p95 (ms) | Validation AP |
|---|---|---|---|---|
| Calibrated on | Range method | Per-channel or per-tensor | Tested on condition | AP | Change from FP32 (percentage points) |
|---|---|---|---|---|---|
Questions
Did the group's INT8 file shrink to exactly a quarter of FP32? If not, why? Does the time saved match the memory-bound layers found in module 1?
When calibrated on one condition and tested on another, how much did AP drop? Explain with the clipping value from the calibration set, and say which images a good calibration set for the group must contain.
Did the Percentile method help or hurt on the group's data? Are the rare high values in the data signal or noise, and how do you decide?
Why are per-channel scales better than per-tensor ones after folding BatchNorm? Explain with the number of levels a narrow channel can use.
Should the group use QAT? Give reasons from Tables 1 and 2 and the group's accuracy criterion.
Check before you hand in
What to hand in
- Table of size, time and accuracy before and after quantisation
- Table of the effect of range method and calibration set
- M and M0 results with the fixed-point check
- A conclusion on whether QAT or another method is needed, with reasons