Skip to main content
QUICK REVIEW

[Paper Review] I-BERT: Integer-only BERT Quantization

Sehoon Kim, Amir Gholami|arXiv (Cornell University)|Jan 5, 2021
Topic ModelingComputer Science86 references16 citations
TL;DR

I-BERT proposes a novel integer-only quantization framework for BERT and RoBERTa models that enables end-to-end inference using only integer arithmetic, eliminating floating-point operations. By introducing lightweight polynomial approximations for non-linear layers like GELU, Softmax, and LayerNorm, I-BERT achieves comparable or slightly improved accuracy on GLUE benchmarks and up to 4.0× speedup on T4 GPUs compared to FP32 inference.

ABSTRACT

Transformer based models, like BERT and RoBERTa, have achieved state-of-the-art results in many Natural Language Processing tasks. However, their memory footprint, inference latency, and power consumption are prohibitive efficient inference at the edge, and even at the data center. While quantization can be a viable solution for this, previous work on quantizing Transformer based models use floating-point arithmetic during inference, which cannot efficiently utilize integer-only logical units such as the recent Turing Tensor Cores, or traditional integer-only ARM processors. In this work, we propose I-BERT, a novel quantization scheme for Transformer based models that quantizes the entire inference with integer-only arithmetic. Based on lightweight integer-only approximation methods for nonlinear operations, e.g., GELU, Softmax, and Layer Normalization, I-BERT performs an end-to-end integer-only BERT inference without any floating point calculation. We evaluate our approach on GLUE downstream tasks using RoBERTa-Base/Large. We show that for both cases, I-BERT achieves similar (and slightly higher) accuracy as compared to the full-precision baseline. Furthermore, our preliminary implementation of I-BERT shows a speedup of 2.4-4.0x for INT8 inference on a T4 GPU system as compared to FP32 inference. The framework has been developed in PyTorch and has been open-sourced.

Motivation & Objective

  • Address the inefficiency of floating-point inference in edge and integer-only hardware for large NLP models like BERT.
  • Overcome the challenge of performing non-linear operations (GELU, Softmax, LayerNorm) in integer-only arithmetic without accuracy degradation.
  • Enable deployment of BERT-like models on hardware without floating-point units, such as ARM Cortex-M and NVIDIA Turing Tensor Cores.
  • Develop a quantization scheme that maintains model accuracy while maximizing speed and efficiency on integer-only accelerators.
  • Demonstrate that integer-only inference can outperform mixed-precision inference in latency and energy efficiency on modern hardware.

Proposed method

  • Propose i-GELU, a second-order polynomial approximation for GELU that enables accurate integer-only computation with a maximum error of 1.8×10⁻².
  • Design an integer-only Softmax approximation using a lightweight polynomial with a maximum error of 1.9×10⁻³.
  • Implement integer-only LayerNorm using a known algorithm for integer square root computation to avoid floating-point operations.
  • Integrate these approximations into a full quantization pipeline where all parameters and activations are represented in INT8, with INT32 accumulation for matrix multiplications.
  • Use a hybrid quantization strategy: INT8 weights and activations, INT32 accumulations, and integer-only non-linear operations with post-requantization to maintain precision.
  • Ensure all operations remain in integer format throughout the computational graph, avoiding any casting to floating point.

Experimental results

Research questions

  • RQ1Can non-linear operations like GELU, Softmax, and LayerNorm be accurately approximated using only integer arithmetic?
  • RQ2What level of approximation error is acceptable for maintaining model accuracy in BERT-like models when using integer-only inference?
  • RQ3Can integer-only inference achieve significant speedup on hardware optimized for integer operations, such as T4 GPUs and ARM processors?
  • RQ4Does integer-only quantization lead to accuracy degradation compared to full-precision or mixed-precision baselines?
  • RQ5How does the proposed i-GELU approximation compare to other integer-only GELU approximations in terms of accuracy and efficiency?

Key findings

  • I-BERT achieves a maximum inference speedup of 4.0× on a Tesla T4 GPU for BERT-Large with INT8 inference compared to FP32.
  • The average latency speedup across different sequence lengths and batch sizes is 3.08× for BERT-Base and 3.56× for BERT-Large.
  • I-BERT maintains or slightly improves GLUE average scores—0.3 and 0.5 points higher than the full-precision baseline for RoBERTa-Base and RoBERTa-Large, respectively.
  • The i-GELU approximation outperforms the h-GELU approximation by 0.7 points on average across four downstream tasks, with no accuracy loss compared to full-precision GELU.
  • The ablation study confirms that i-GELU provides better accuracy than both h-GELU and even the full-precision GELU in some cases, suggesting potential benefits beyond mere approximation.
  • The framework is fully open-sourced in PyTorch and supports deployment on integer-only hardware, enabling efficient inference on edge devices without floating-point units.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.