Abstract
8-bit integer inference is a promising direction for reducing both the latency and storage of deep neural networks. While significant progress has been made, existing systems still rely on 32-bit floating point (FP32) for certain complex functions (e.g., Softmax in Transformer) and make heavy use of quantization and de-quantization. In this work, we introduce the Integer Transformer, which utilizes a principled modification of the Transformer architecture to enable an (almost) fully 8-bit integer inference algorithm called Scale Propagation. By adopting de-quantization only when necessary, the network becomes significantly more efficient. Experiments on WMT translation tasks and WikiText-103 language modeling show that our fully 8-bit system achieves comparable performance to FP32 baselines while requiring nearly 4x less memory.
The Challenge of INT8 Inference
Transformers have revolutionized NLP but remain computationally and memory-intensive. Quantizing these models to 8-bit integers (INT8) is a standard approach for deployment on edge devices, yet it faces two primary hurdles:
- Scale Incompatibility: Operations like residual additions involve tensors with different quantization scales. Standard methods often convert these back to FP32 to perform the addition, creating a significant bottleneck.
- INT8-Unfriendly Functions: Core Transformer components like Softmax (exponential) and Layer Normalization (square root) are numerically unstable in low precision. This forces frequent "de-quantization" back to FP32, as shown in the practical inference flow below.
Proposed Method: Scale Propagation and the Integer Transformer
To maintain a continuous INT8 data flow, the authors propose two main innovations.
1. Scale Propagation
Instead of treating quantization as a wrapper around every operation, Scale Propagation allows scales to flow through the network. This involves:
- Scale Matching: Aligning the scales of input tensors before operations like addition to prevent overflow without leaving the INT8 domain.
- Re-scaling: Projecting results back into the INT8 range after operations like Matrix Multiplication (MatMul) that might expand the dynamic range.
This approach effectively eliminates the "de-quantization loop" found in canonical inference.
2. The Integer Transformer Architecture
The standard Transformer is modified to replace FP32-dependent functions with integer-friendly alternatives:
- Polynomial Attention: The exponential-based Softmax is replaced with a polynomial function: $Poly(x) = [ReLU(x + b)]^n + |\delta|$. This maintains the "sharpening" effect necessary for attention while being compatible with integer arithmetic.
- L1 Layer Normalization: The standard L2-norm (square root) is replaced with an L1-norm (absolute value) approach, which is significantly easier to compute in integer logic.
Experimental Results
The researchers evaluated the Integer Transformer on several benchmarks, including WMT16 En↔Ro, WMT14 En↔De, WMT14 En→Fr, and WikiText-103.
- Efficiency: The model achieved a 3.47× speedup and nearly 4× memory reduction compared to the FP32 baseline.
- Accuracy: On most translation tasks, the performance gap was negligible (0.1 to 0.4 BLEU points). Interestingly, the architectural tweaks themselves (Integer Transformer run in FP32) sometimes outperformed the vanilla Transformer.
- Robustness: Sensitivity analysis indicated that 8-bit is the optimal precision; performance drops significantly at 6-bit or lower.
Limitations and Future Work
While highly effective, the model showed a drop of over 1.0 BLEU point on the massive En→Fr task. The authors attribute this to the sensitivity of the final residual connections and layer normalization in very deep models. Future work will focus on mitigating precision loss in these final layers to close the gap on larger datasets. Additionally, while theoretical speedups are significant, actual gains are contingent on hardware support for INT8 instructions like VNNI.
Summary updated