I-BERT: Integer-only BERT Quantization

Sehoon Kim, Amir Gholami, Zhewei Yao, Michael W. Mahoney, Kurt Keutzer
1/5/2021
513 citations
cs.CL
transformer-attention

Official code: huggingface/transformers (169,409 stars, Python, Apache-2.0, PyTorch, last commit 2026-04-30). 1 more implementation below.

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.

Show full abstract

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.

View on arXivView PDF

Code Implementations(2)

Code implementations of this paper
RepositoryTypeStarsLanguageLicenseLast commit
huggingface/transformersOfficial169,409PythonApache-2.02026-04-30
kssteven418/I-BERTOfficial271PythonMIT2023-01-29
PyTorchApache-2.0

🤗 Transformers: the model-definition framework for state-of-the-art machine learning models in text, vision, audio, and multimodal models, for both inference and training.

169,40935,271Python, DockerfileOct 29, 20187 months agoApache-2.0
audiodeep-learningdeepseekgemmaglm+14 more
kssteven418/I-BERTOfficial100%
MIT

[ICML'21 Oral] I-BERT: Integer-only BERT Quantization

27142Python, CudaSep 22, 20203 years agoMIT
bertefficient-modelefficient-neural-networksmodel-compressionnatural-language-processing+2 more

Similar Papers

Cite this paper

@article{kim2021ibert,
  title  = {I-BERT: Integer-only BERT Quantization},
  author = {Sehoon Kim and Amir Gholami and Zhewei Yao and Michael W. Mahoney and Kurt Keutzer},
  year   = {2021},
  eprint = {2101.01321},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2101.01321}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2101.01321.svg)](https://codeofpaper.com/paper/2101.01321)

Discussion