AI and Machine Learning · Inference and deployment
Model Optimisation
Also known as model optimization, model compression, graph optimisation, pruning, knowledge distillation
Model optimisation covers the techniques that make a trained model cheaper to run, in latency, memory or power, while keeping accuracy acceptable: graph rewrites and fusion, reduced precision and quantisation, pruning and sparsity, and knowledge distillation.
Explanation
Optimisations fall into two groups. Graph optimisations change how a model is computed rather than what it computes: constant folding, removal of redundant nodes, and fusing sequences such as convolution and batch normalisation into one kernel. ONNX Runtime applies these when a session is created, and TensorRT applies its own when it builds an engine.
Model-changing techniques trade some accuracy for efficiency and require re-validation: quantisation to FP16, INT8 or smaller types; pruning, which removes weights, channels or attention heads; structured sparsity such as NVIDIA's 2:4 pattern; and knowledge distillation, in which a large teacher model trains a smaller student. NVIDIA Model Optimizer bundles these techniques for export to TensorRT and other runtimes.
Gains depend on hardware and runtime: an operation that is fast on one accelerator may be unsupported or slow on another, and optimised artefacts are often tied to one device. Effective optimisation starts from a measured baseline on the target, changes one thing at a time, and checks both accuracy and runtime metrics under identical conditions.
How it works
A typical loop: profile the FP32 model on target hardware to find the bottleneck; apply runtime graph optimisations; try FP16, then INT8 with calibration or quantisation-aware training; consider pruning or distillation if still over budget; rebuild the engine. After each step, re-run the accuracy suite, for example mAP or mIoU, and the latency, memory and power measurements under the same clocks and power mode.
Automotive applications
- Meeting frame-rate budgets on ADAS ECUs
- Reducing memory so several networks share one SoC
- Lowering power for always-on in-cabin models
- Shrinking model downloads in OTA updates
Example
A detector misses its 33 ms per-frame budget on the target. Graph fusion and FP16 bring it close; INT8 quantisation of the backbone meets the budget, but pedestrian mAP falls, so the detection head stays in FP16 and the result is re-benchmarked with locked clocks.
An illustrative example: any figures in it are worked numbers, not measurements.
References
- Graph Optimizations in ONNX Runtime (opens in a new tab)
- Model Optimizer: Overview (opens in a new tab)
- Performance Benchmarking (opens in a new tab)
Definitions are original summaries. Standards text is not reproduced; follow the links for the official publications.