4ビット整数を用いたTransformerの学習
Training Transformers with 4-bit Integers
June 21, 2023
著者: Haocheng Xi, Changhao Li, Jianfei Chen, Jun Zhu
cs.AI
要旨
活性化、重み、勾配を4ビットに量子化することは、ニューラルネットワークの学習を加速する上で有望な手法です。しかし、既存の4ビット学習手法は、現代のハードウェアではサポートされていないカスタム数値フォーマットを必要とします。本研究では、すべての行列乗算をINT4演算で実装したトランスフォーマーの学習手法を提案します。超低精度のINT4での学習は困難を伴います。これを実現するために、我々はトランスフォーマーの活性化と勾配の特定の構造を注意深く分析し、それらに特化した量子化器を提案します。順伝播では、外れ値の問題を特定し、ハダマード量子化器を提案して外れ値を抑制します。逆伝播では、勾配の構造的スパース性を活用し、ビット分割とレバレッジスコアサンプリング技術を提案して勾配を正確に量子化します。我々のアルゴリズムは、自然言語理解、機械翻訳、画像分類など幅広いタスクで競争力のある精度を達成します。従来の4ビット学習手法とは異なり、我々のアルゴリズムは現在の世代のGPUで実装可能です。プロトタイプの線形演算子実装は、FP16の対応する実装に比べて最大2.2倍高速であり、学習を最大35.1%高速化します。
English
Quantizing the activation, weight, and gradient to 4-bit is promising to
accelerate neural network training. However, existing 4-bit training methods
require custom numerical formats which are not supported by contemporary
hardware. In this work, we propose a training method for transformers with all
matrix multiplications implemented with the INT4 arithmetic. Training with an
ultra-low INT4 precision is challenging. To achieve this, we carefully analyze
the specific structures of activation and gradients in transformers to propose
dedicated quantizers for them. For forward propagation, we identify the
challenge of outliers and propose a Hadamard quantizer to suppress the
outliers. For backpropagation, we leverage the structural sparsity of gradients
by proposing bit splitting and leverage score sampling techniques to quantize
gradients accurately. Our algorithm achieves competitive accuracy on a wide
range of tasks including natural language understanding, machine translation,
and image classification. Unlike previous 4-bit training methods, our algorithm
can be implemented on the current generation of GPUs. Our prototypical linear
operator implementation is up to 2.2 times faster than the FP16 counterparts
and speeds up the training by up to 35.1%.