arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2306.11987cs.LGcs.NE
收藏

使用4位整数训练Transformer

Training Transformers with 4-bit Integers

Tsinghua University(清华大学)

Haocheng Xi, Changhao Li, Jianfei Chen, Jun Zhu

AI总结:

提出一种使用INT4算术训练Transformer的方法,通过Hadamard量化器抑制前向传播中的异常值,并利用位拆分和杠杆分数采样精确量化梯度,在多种任务上达到竞争性精度,且可在当前GPU上实现,训练速度提升高达35.1%。

摘要:

将激活、权重和梯度量化为4位有望加速神经网络训练。然而,现有的4位训练方法需要自定义数值格式,这些格式不受当代硬件支持。在这项工作中,我们提出了一种Transformer训练方法,其中所有矩阵乘法均使用INT4算术实现。以超低INT4精度进行训练具有挑战性。为实现这一目标,我们仔细分析了Transformer中激活和梯度的特定结构,为它们提出了专门的量化器。对于前向传播,我们识别了异常值的挑战,并提出了一种Hadamard量化器来抑制异常值。对于反向传播,我们利用梯度的结构稀疏性,提出了位拆分和杠杆分数采样技术来精确量化梯度。我们的算法在包括自然语言理解、机器翻译和图像分类在内的广泛任务上取得了具有竞争力的精度。与之前的4位训练方法不同,我们的算法可以在当前一代GPU上实现。我们的原型线性算子实现比FP16对应实现快达2.2倍,并将训练速度提高了高达35.1%。

英文摘要:

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%.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑