ChatPaper.aiChatPaper

Addestramento di Transformer con interi a 4 bit

Training Transformers with 4-bit Integers

June 21, 2023
Autori: Haocheng Xi, Changhao Li, Jianfei Chen, Jun Zhu
cs.AI

Abstract

La quantizzazione di attivazioni, pesi e gradienti a 4 bit rappresenta una promettente soluzione per accelerare l'addestramento delle reti neurali. Tuttavia, i metodi esistenti per l'addestramento a 4 bit richiedono formati numerici personalizzati che non sono supportati dall'hardware contemporaneo. In questo lavoro, proponiamo un metodo di addestramento per trasformatori in cui tutte le moltiplicazioni matriciali sono implementate utilizzando l'aritmetica INT4. L'addestramento con una precisione INT4 ultra-bassa è impegnativo. Per raggiungere questo obiettivo, analizziamo attentamente le strutture specifiche delle attivazioni e dei gradienti nei trasformatori per proporre quantizzatori dedicati. Per la propagazione in avanti, identifichiamo la sfida rappresentata dagli outlier e proponiamo un quantizzatore Hadamard per sopprimerli. Per la retropropagazione, sfruttiamo la sparsità strutturale dei gradienti proponendo tecniche di suddivisione dei bit e campionamento basato su punteggi di leverage per quantizzare i gradienti in modo accurato. Il nostro algoritmo raggiunge un'accuratezza competitiva su un'ampia gamma di task, tra cui comprensione del linguaggio naturale, traduzione automatica e classificazione di immagini. A differenza dei precedenti metodi di addestramento a 4 bit, il nostro algoritmo può essere implementato sulla generazione attuale di GPU. La nostra implementazione prototipale dell'operatore lineare è fino a 2,2 volte più veloce rispetto alle controparti FP16 e accelera l'addestramento fino al 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%.
PDF225December 15, 2024