Abstract: While neural networks have advanced the frontiers in many machine learning applications, they often come at a high computational cost. Reducing the power and latency of neural network inference is vital to integrating modern networks into edge devices with strict power and compute requirements. Neural network quantization is one of the most effective ways of achieving these savings, but the additional noise it induces can lead to accuracy degradation. In this white paper, we present an overview of neural network quantization using AI Model Efficiency Toolkit (AIMET). AIMET is a library of state-of-the-art quantization and compression algorithms designed to ease the effort required for model optimization and thus drive the broader AI ecosystem towards low latency and energy-efficient inference. AIMET provides users with the ability to simulate as well as optimize PyTorch and TensorFlow models. Specifically for quantization, AIMET includes various post-training quantization (PTQ) and quantization-aware training (QAT) techniques that guarantee near floating-point accuracy for 8-bit fixed-point inference. We provide a practical guide to quantization via AIMET by covering PTQ and QAT workflows, code examples and practical tips that enable users to efficiently and effectively quantize models using AIMET and reap the benefits of low-bit integer inference.
Introduction
While deep learning has revolutionized AI, the computational cost of running these models—especially on battery-powered edge devices like smartphones or drones—is immense. Moving from standard 32-bit floating-point (FP32) math to 8-bit integer (INT8) math can reduce memory overhead by 4x and improve performance-per-watt by up to 16x.
However, this transition isn't free. Reducing precision introduces "quantization noise," which often leads to significant drops in model accuracy. The challenge is finding a way to compress these models without breaking them, especially for sensitive architectures like MobileNet that use depth-wise separable convolutions.
The AIMET Framework
AIMET is an open-source library from Qualcomm designed to automate and simplify the quantization pipeline for popular deep learning frameworks. It provides a unified interface that allows developers to bridge the "accuracy gap" when deploying neural networks to edge devices.
As illustrated in the architecture above, AIMET consists of framework-specific extensions for PyTorch and TensorFlow, alongside a core Model Optimization Library. This library contains the algorithmic implementations for techniques like compression and quantization, accessible via both framework-specific and general Algorithm APIs.
Core Quantization Techniques
AIMET enables developers to achieve near-floating-point accuracy in 8-bit formats through several key techniques:
- Quantization Simulation (QuantSim): Before deploying to hardware, AIMET inserts "quantizer" nodes into the model graph to simulate how the model will behave on an actual fixed-point accelerator.
- Cross-Layer Equalization (CLE): A data-free technique that scales weights between layers to reduce the dynamic range of weights, making them easier to quantize. This is particularly effective for MobileNet-style architectures.
- AdaRound (Adaptive Rounding): Instead of simply rounding to the nearest integer (which is often sub-optimal), AdaRound uses a small amount of unlabeled data to learn the best way to round weights to minimize loss.
- Bias Correction: This method identifies and fixes systematic shifts in the mean and variance of layer outputs caused by quantization noise.
- Quantization-Aware Training (QAT): For models where post-training methods aren't enough, AIMET supports training the model with quantization noise in the loop using the Straight-Through Estimator (STE) to bypass non-differentiable rounding operations.
Evaluation and Results
AIMET’s techniques were validated across several standard benchmarks, demonstrating that quantized models can remain within 1% of their original FP32 accuracy:
- MobileNetV2 (ImageNet): FP32 accuracy was 71.72%. Naive quantization crashed it to 0.09%. Using AIMET’s PTQ (CLE + Bias Correction) recovered it to 71.08%, while QAT further improved this to 71.23%.
- ADAS Object Detection: Standard rounding resulted in 49.85% mAP. AdaRound boosted this to 81.21%, nearly matching the FP32 baseline of 82.20%.
- DeepSpeech2: The Word Error Rate (WER) only increased slightly from 9.92% (FP32) to 10.22% (8-bit QAT), showing that even complex sequence models can be quantized effectively.
Key Insights
- Rounding Matters: The success of AdaRound proves that choosing whether to round up or down based on local loss optimization can recover significant accuracy in low-bit regimes compared to naive "round-to-nearest" approaches.
- The "MobileNet Problem": Depth-wise separable layers are notoriously hard to quantize because their weight distributions are often imbalanced. CLE provides a data-free solution to equalize these distributions.
- Simulation First: By using QuantSim, developers can identify exactly which layers are sensitive to quantization before they ever touch the target hardware.
- Batch Normalization Folding: AIMET automatically "folds" BN layers into preceding convolutional layers, ensuring the simulation matches how the model is actually executed on-device.
Limitations and Future Work
While AIMET is a powerful tool, users must consider hardware specificity; for instance, "per-channel" quantization is not supported by all commercial hardware. Additionally, while QAT provides the best results, it requires labeled data and significant compute time compared to "push-button" PTQ methods. Future developments in the toolkit may further explore mixed-precision quantization (e.g., combining 4-bit and 8-bit layers) to push efficiency even further.
Summary updated