4-Bit Training for Billion-Parameter LLMs? Yes, Really.

Training large language models (LLMs) at low precision has recently been a topic of significant interest in the field of artificial intelligence. Presently, most LLMs are trained using 32-bit or 16-bit floating point precision, which, while offering numerical accuracy and nuance, also results in substantial computational cost in terms of energy, time, memory, and money.

This video is from AI Coffee Break with Letitia.

However, a new research paper, titled “Optimizing Large Language Model Training Using FP4 Quantization,” explores the possibility of squeezing each weight and activation into just four bits during massive LLM training with barely any performance loss. This is a significant breakthrough because over 90% of the training cost for LLMs comes from one operation: matrix multiplications. With 4-bit numbers, the multiplication process becomes faster, allowing for more multiplications per GPU core, better cache usage, lower memory bandwidth, and potentially huge speedups if the hardware can support it.

The challenge, however, lies in the massive quantization error that results from reducing precision down to FP4. Training an FP4 fails miserably without proper handling of this error. The researchers overcame this hurdle by combining quantization strategies with hybrid precision for some parts of the training loop and tricks like gradient estimators that let you back propagate through quantization.

A key aspect of this approach is what’s known as mixed precision training. The biggest computational bottleneck in training is matrix multiplication, which accounts for over 95% of the total compute. So, the researchers decided to perform all those matrix multiplications in FP4, which means that the weights and the activations need to be quantized to FP4. However, sensitive parts of training like weight updates, optimizer states, and gradient accumulation are still done in FP8 or FP16, where you need a bit more precision to maintain stability over time.

Furthermore, activations are much harder to quantize than the weights because it’s impossible to know ahead of time what the weights multiplied to the input will produce. So, the authors use outlier clamping and compensation to keep FP4 activation stable. They identify the top 0.1% of the activation values and clamp everything above that threshold. They also store the residuals—the difference between the clamped and the original values—in a sparse matrix and compute the next layer’s computation with the residuals separately in high precision.

Another crucial component of making FP4 training work is the use of a differentiable gradient estimator. During the forward pass, they still use hard quantization to keep things efficient. But in the backward pass, they apply a smooth differentiable function that approximates the quantization operation. This provides gradient descent with enough of a signal to know into which direction to update the weights.

The researchers were able to train LLMs on a variety of sizes using this FP4 training framework, and the training curves almost look identical to BF-16. Evaluations on real-world tasks showed that FP4 consistently matched or even slightly outperformed BF-16.

However, one limitation is that there’s currently no GPU that supports native FP4 tensor cores, so the experiments were done using FP8 hardware emulating FP4. But Nvidia’s upcoming Blackwell GPUs will support native FP4 compute, which could double throughput compared to FB8 and reduce memory and energy use even further.

In conclusion, training in 4-bit precision is not only possible but practically viable. It challenges our assumptions about what’s needed to train powerful models. And who knows, in a few years, FP4 could be the new BF-16. As we continue to push the boundaries of what’s possible in artificial intelligence, it’s clear that low-precision training has an important role to play.

Frank

#DataScientist, #DataEngineer, Blogger, Vlogger, Podcaster at http://DataDriven.tv . Back @Microsoft to help customers leverage #AI Opinions mine. #武當派 fan. I blog to help you become a better data scientist/ML engineer Opinions are mine. All mine.