Quantization-Aware Training
Overview
Quantization-Aware Training (QAT) — a technique where operations simulating quantization (fake quantization) are introduced into the forward pass of the model. This allows the model to adapt to the precision loss that occurs when transitioning to low-precision representations (e.g., INT8) and maintain quality after actual quantization.
Comparison with Post-Training Quantization
| Parameter | Post-Training Quantization (PTQ) | Quantization-Aware Training (QAT) |
|---|---|---|
| Accuracy | Lower with aggressive quantization | Higher, closer to original |
| Time | Minute, no training required | Requires full training cycle |
| Data | Small calibration dataset | Training dataset |
| Application | Quick deployment | Production with strict latency requirements |
Process
- Initialize the model with floating-point precision.
- Insert nodes for quantization/dequantization into the graph.
- Train with backpropagation; gradients pass through quantization nodes using the straight-through estimator.
- After training, perform actual quantization of weights and activations.