Transformers traineren met 4-bit gehele getallen
Training Transformers with 4-bit Integers
June 21, 2023
Auteurs: Haocheng Xi, Changhao Li, Jianfei Chen, Jun Zhu
cs.AI
Samenvatting
Het kwantiseren van activaties, gewichten en gradiënten naar 4-bit is veelbelovend om de training van neurale netwerken te versnellen. Bestaande 4-bit trainingsmethoden vereisen echter aangepaste numerieke formaten die niet worden ondersteund door hedendaagse hardware. In dit werk stellen we een trainingsmethode voor voor transformers waarbij alle matrixvermenigvuldigingen worden uitgevoerd met INT4-rekenkunde. Trainen met een ultra-lage INT4-precisie is uitdagend. Om dit te bereiken, analyseren we zorgvuldig de specifieke structuren van activaties en gradiënten in transformers om toegewijde kwantisatoren voor hen voor te stellen. Voor forward propagatie identificeren we de uitdaging van uitschieters en stellen we een Hadamard-kwantisator voor om de uitschieters te onderdrukken. Voor backpropagatie benutten we de structurele sparsity van gradiënten door bit-splitsing en leverage score sampling technieken voor te stellen om gradiënten nauwkeurig te kwantiseren. Ons algoritme behaalt concurrerende nauwkeurigheid op een breed scala aan taken, waaronder natuurlijke taalverwerking, machinaal vertalen en beeldclassificatie. In tegenstelling tot eerdere 4-bit trainingsmethoden kan ons algoritme worden geïmplementeerd op de huidige generatie GPU's. Onze prototypische implementatie van lineaire operatoren is tot 2,2 keer sneller dan de FP16-tegenhangers en versnelt de training met tot 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%.