Abstract
Low precision (LP) datatypes such as MXFP4 can accelerate matrix multiplications (GEMMs) and reduce training costs. However, directly using MXFP4 instead of BF16 during training significantly degrades model quality. In this work, we present the first near-lossless training recipe that uses MXFP4 GEMMs, which are $2\times$ faster than FP8 on supported hardware. Our key insight is to compute unbiased gradient estimates with stochastic rounding (SR), resulting in more accurate model updates. However, directly applying SR to MXFP4 can result in high variance from block-level outliers, harming convergence. To overcome this, we use the random Hadamard transform to theoretically bound the variance of SR. We train GPT models up to 6.7B parameters and find that our method induces minimal degradation over mixed-precision BF16 training. Our recipe computes $>1/2$ the training FLOPs in MXFP4, enabling an estimated speedup of $>1.3\times$ over FP8 and $>1.7\times$ over BF16 during backpropagation.
Introduction
The computational cost of training Large Language Models (LLMs) is a major bottleneck in AI research, often requiring massive GPU clusters for extended periods. While 8-bit floating-point (FP8) formats have become a standard for accelerating training, moving to 4-bit precision (MXFP4) offers the potential to double throughput again. However, 4-bit quantization is notoriously difficult due to its limited dynamic range and high quantization noise. Outliers in weights and activations often lead to significant bias or training instability, causing models to diverge or perform poorly compared to 16-bit (BF16) baselines.
The MXFP4 Training Recipe
To enable stable 4-bit training, we developed a recipe focused on producing unbiased, low-variance gradient estimates during the backward pass. Our approach combines two primary techniques:
- Unbiased Quantization with Stochastic Rounding (SR): Instead of rounding-to-nearest, SR rounds values probabilistically. This ensures that the expected value of the quantized tensor remains equal to its high-precision original, eliminating systematic bias.
- Random Hadamard Transform (RHT): While SR is unbiased, it can introduce high variance, particularly when data contains extreme outliers. We apply a block-wise RHT to "smear" these outliers across the block before quantization. This concentrates the data distribution and provides a theoretical bound on the variance introduced by stochastic rounding.
By applying these transforms block-wise, we maintain low computational overhead while ensuring the training process remains stable even at extremely low precision.
Experimental Results
We evaluated our recipe by pretraining GPT models of various sizes, ranging from 345M to 6.7B parameters. The models were trained on the GPT2 Wikipedia corpus and evaluated on standard benchmarks and instruction-following tasks.
Our primary finding is that the combination of RHT and SR allows MXFP4 training to match the performance of BF16. As shown in the training curves for the 6.7B parameter model, the validation perplexity of our MXFP4 recipe is virtually indistinguishable from the high-precision baseline.
Beyond perplexity, we observed that models pretrained with MXFP4 maintained their downstream capabilities. After fine-tuning on the Tulu V2 dataset, the 6.7B model performed within 0.3% of the BF16-pretrained version across various reasoning and knowledge benchmarks (e.g., ArcC, PiQA, BoolQ).
Efficiency and Speedups
The backward pass typically accounts for more than half of the total training FLOPs. By offloading these computations to MXFP4, we achieve significant efficiency gains. On supported hardware, we estimate our method provides a 1.7× speedup over BF16 and a 1.3× speedup over FP8 during the backward pass. This makes 4-bit training a highly attractive option for large-scale model development.
Conclusion and Future Work
We have demonstrated the first near-lossless recipe for training LLMs using 4-bit microscaling precision. By addressing the fundamental issues of bias and variance through stochastic rounding and the Random Hadamard Transform, we enable significant speedups without sacrificing model quality. Future work will explore extending these techniques to the forward pass and optimizing implementations for upcoming hardware architectures that natively support MXFP4.
Summary updated