Paper commentary
Quantization and Training of Neural Networks for Efficient Integer-Arithmetic-Only Inference
Integer-only quantization lets MobileNets run faster on phone CPUs with little accuracy loss
- Problem Quantized networks rarely speed up on real hardware, and they are usually tested on large models like AlexNet or VGG rather than efficient mobile models like MobileNets. Mobile devices need accurate models that also respond quickly.
- Method The authors map weights and activations to 8-bit integers with a scale and zero-point, and keep biases at 32 bits. Training simulates this rounding in floating point, so inference runs with integer-only arithmetic.
- Results Integer-only MobileNets reach higher top-1 accuracy than floating-point MobileNets at the same latency on Snapdragon 835 LITTLE cores. The gap is about 10% at 33 ms.
Why quantize efficient models on phones
Models intended for smartphones and AR/VR hardware must fit small memory budgets and respond within a short latency, so the authors judge architectures by accuracy and runtime together. Many quantization studies use AlexNet, VGG or GoogleNet, which are large enough that compression is easy and the experiments remain proofs of concept. The authors therefore argue that the meaningful test is to quantize architectures that already balance latency and accuracy well, such as MobileNets.
Weight-only quantization mainly reduces storage, and binary, ternary and bit-shift schemes give little benefit on hardware whose multiply-add instructions are already fast. Multiplication cost falls only when both weights and activations are narrow, and the schemes that quantize both to 1 bit rarely report on-device timings and often degrade accuracy.
The study therefore targets the latency-accuracy tradeoff of MobileNets on common mobile CPUs, with ImageNet classification and COCO detection as the evaluation tasks.
The affine quantization scheme
Each quantized array is related to its real values by \( r = S(q - Z) \), where q is the stored integer, S is a positive scale and Z is the zero-point. All values in one activation array or one weight array share the same S and Z, and different arrays keep their own parameters. Weights and activations are stored as 8-bit integers, while bias vectors are stored as 32-bit integers, so only the biases need the wider type.
The zero-point is the quantized value that stands for the real value 0, which makes 0 exactly representable. Exact zero matters because neural network operators often pad arrays at their borders, and an inexact zero would bias those padded values.
Integer matrix multiplication with a fixed multiplier
For two quantized N by N matrices with scales S1 and S2 whose product is quantized with S3, the output integer is the output zero-point plus a multiplier M times the sum of the zero-point-shifted products. The multiplier is \( M = S_1 S_2 / S_3 \), which depends only on the scales and can therefore be computed offline. Because M is always below 1 in the authors' measurements, it is written as \( M = 2^{-n} M_0 \) with M0 in [0.5, 1) and n a non-negative integer.
Subtracting the zero-points inside every product would cost time, so the expression is expanded so that the core sum uses only the raw quantized values. The row sums of the weights and the column sums of the activations cost only O(N^2) additions, and the core accumulation is the only O(N^3) part, so zero-point handling adds little overhead.
Fused layer: bias, rescaling and clamping
Weights and activations are uint8 in this implementation, so each product is accumulated into an int32 value. The bias is quantized to int32 with zero zero-point and a scale equal to the product of the weight and input-activation scales, so it adds straight into the accumulator. The authors keep the bias at higher precision because a bias error is added to many outputs and would act as a systematic offset.
The accumulator is scaled down by the multiplier M, rounded through a bit shift and cast to uint8 with saturation to [0, 255]. ReLU and ReLU6 are only clamps, so they are fused as an extra clamp to a sub-interval of [0, 255]; training tends to use the whole range, which makes the clamp nearly inactive.
Training with simulated quantization
Post-training quantization of small models loses substantial accuracy, mainly because weight ranges differ by more than 100 times across output channels of one layer and because outlier weights make the other weights less precise. The authors instead simulate quantization in the forward pass, while backpropagation and the stored weights and biases remain in floating point.
Each quantized value is produced by clamping to [a; b], dividing by the step s(a, b, n) = (b - a)/(n - 1), rounding to the nearest integer and returning to the real scale, with n = 2^8 for 8-bit quantization.
Weight ranges are set from the minimum and maximum of the weights, but are adjusted so that the int8 values stay in [-127, 127] and never reach -128, which the authors use for a faster kernel. Activation ranges are collected during training and smoothed with exponential moving averages whose smoothing parameter is close to 1. Because the averaged ranges adapt slowly when they shift quickly, activation quantization is disabled at the start of training for a long period before it is switched on.
The boundaries are nudged so that 0.0 is exactly representable, and the resulting scale and zero-point become the S and Z of equation 1.
Batch normalization is folded into the convolution weights before quantization, so the quantized weights are those of the folded inference graph, scaled by gamma and divided by the square root of the moving-average variance plus a small epsilon. Fake quantization operations are inserted where tensors would be cast to fewer bits, and the network is trained in simulated mode until convergence before the inference graph is created.
Quantized training on ResNets and Inception v3
On ImageNet, ResNet-50 reaches 74.9% with integer-quantized training against 76.4% for floating point.
Among ResNet-50 results from other schemes, the integer-only model with 8-bit weights and 8-bit activations scores 74.9%, above the FGQ scheme with 2-bit weights and 8-bit activations at 70.8%. INQ, with 5-bit weights and floating-point activations, scores 74.8%, close to this result, but the authors' run-time gains are measured only for their own scheme.
For Inception v3, the 8-bit ReLU6 model reaches 75.4% against 78.4% for floating point, and the 7-bit ReLU6 model reaches 75.0%. With ReLU, the 8-bit model reaches 74.2% against 78.3% floating point, and the 7-bit model reaches 73.7%, so the ReLU6 variants lose less accuracy in this comparison. The authors attribute this to ReLU6 giving activations a fixed interval of [0, 6], which is easier to quantize precisely than the wider and channel-dependent ranges of ReLU.
MobileNet latency against accuracy on Snapdragon CPUs
MobileNets with varying depth-multipliers and input resolutions were timed on three Qualcomm cores: the Snapdragon 835 LITTLE core, the Snapdragon 835 big core and the Snapdragon 821 big core. Each model was compared in floating point and in 8-bit integer-only form, and the results are plotted as top-1 accuracy against latency.
At the 33 ms latency needed for 30 fps on Snapdragon 835 LITTLE cores, the integer-only MobileNets reach higher accuracy than the floating-point models, and the floating-point accuracy gap is about 10%. The authors stress that this tradeoff depends on how fast floating-point arithmetic is on a given chip, so the Snapdragon 821, where floating point is better optimized, shows a smaller latency reduction.
COCO detection and face detection
The COCO experiments use MobileNet SSD in which the regular convolutions of the prediction layers are replaced by separable convolutions, and quantized training is delayed by 500 thousand steps. At 100% depth-multiplier the mAP is 22.1 in floating point and 21.7 at 8 bits, with latency 778 ms and 687 ms on LITTLE cores and 370 ms and 272 ms on big cores.
At 50% depth-multiplier the mAP is 16.7 and 16.6, with latency 270 ms and 146 ms on LITTLE cores and 121 ms and 61 ms on big cores. Quantized training and inference reduce running time by up to 50% with a relative mAP loss of -1.8%, as stated for the single-thread runs.
For the face detectors, the 25% model drops from 100 ms to 67 ms on a LITTLE core and from 44 ms to 28 ms on a big core, one thread each. The authors report that the 25% detector runs at about 36 fps after quantization, against about 23 fps for the floating-point model on a single big core. The average precision cost is about 2%, and running on four cores gives a 1.5 to 2.2 times speedup.
Quantization is described as close to a 2x latency reduction, but the 25% model's own figures are smaller than that, so the 2x applies more clearly to larger models.
Bit depth ablation on face attributes
The face attribute MobileNet was trained for each combination of weight and activation bit depths from 8 down to 4 and compared with floating point. Relative average category precision changes range from -0.3% to -14.0%, and age precision at a 5-year difference shows larger drops in its own table.
The authors conclude that weights are more sensitive to lower bit depth than activations, that 8-bit and 7-bit models perform close to floating point, and that equal bit depths for weights and activations are preferable at equal total bit depth.
Limitations
Latency was measured only on Qualcomm Snapdragon cores, and the authors note that the benefit depends on the relative speed of floating-point and integer arithmetic in that hardware. The ResNet and Inception v3 experiments measure accuracy only, and the ImageNet latency comparisons are plotted rather than tabulated in the text. Activation functions are fused only when they are clamps, while mathematical functions are not fused into the quantized layers.
The bit-depth ablation was run only on the face attribute model with weights and activations between 4 and 8 bits.
Paper info
- Authors
- Benoit Jacob, Skirmantas Kligys, Bo Chen, Menglong Zhu, Matthew Tang, Andrew Howard, Hartwig Adam, Dmitry Kalenichenko
- Venue
- arXiv · Preprint
- First published
- 2017-12-15
- Added
- 2026-11-12
- Updated
- 2017-12-15
- Version
- v1
- arXiv
- 1712.05877
- Category
- cs.LG · stat.ML
- Original paper terms
- arXiv non-exclusive 1.0
- What we show
- Paper info and commentary
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Quote from the paper
Benoit Jacob, Skirmantas Kligys, Bo Chen, Menglong Zhu, Matthew Tang, Andrew Howard, Hartwig Adam, Dmitry Kalenichenko (2017). Quantization and Training of Neural Networks for Efficient Integer-Arithmetic-Only Inference. arXiv:1712.05877v1. https://arxiv.org/abs/1712.05877v1
BibTeX
@misc{jacob2017quantization,
title = {{Quantization and Training of Neural Networks for Efficient Integer-Arithmetic-Only Inference}},
author = {Benoit Jacob and Skirmantas Kligys and Bo Chen and Menglong Zhu and Matthew Tang and Andrew Howard and Hartwig Adam and Dmitry Kalenichenko},
year = {2017},
eprint = {1712.05877},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/1712.05877v1}
}