Abstract
Training large-scale Transformer models requires immense computational resources and memory. While quantization is a standard technique for optimizing inference, applying it during the pre-training phase—from scratch—presents significant stability challenges. This paper investigates a systematic "recipe" for quantizing weights, activations, gradients, and optimizer states during the pre-training of a 124M parameter GPT-2 model. Our findings indicate that 8-bit quantization is highly robust and can even provide a regularizing effect, whereas 4-bit quantization introduces instabilities linked to sharper loss landscapes and activation outliers. We provide a detailed analysis of where quantization yields the most significant memory and execution gains.
Introduction
The computational cost of training Large Language Models (LLMs) has become a primary bottleneck in AI research, with models like GPT-3 requiring thousands of GPUs and massive energy consumption. Quantization—the process of reducing the precision of numerical representations (e.g., from 16-bit floating point to 8-bit integers)—offers a promising path toward efficiency. However, most existing literature focuses on Post-Training Quantization (PTQ) or quantization during fine-tuning.
Quantizing from "step zero" is inherently more difficult because the model’s parameters and internal distributions shift rapidly during the early stages of training. The noise introduced by low-precision arithmetic can lead to training divergence or a significant degradation in final model perplexity. This study maps the boundaries of Transformer quantization, identifying which components can be compressed and which require high-precision maintenance to ensure convergence.
Methodology
Experimental Setup
The researchers utilized a GPT-2 Small (124M parameters) architecture as the primary testbed. To evaluate the impact of quantization, the models were trained on the OpenWebText corpus. Performance was measured using perplexity across standard benchmarks (WikiText-103, PTB, 1BW) and accuracy on downstream tasks including GLUE, ARC, and Hellaswag.
Quantization Approach
The study employed linear quantization, mapping continuous values to a discrete integer grid. To isolate the mathematical effects of precision loss from hardware-specific implementation details, the authors used Fake Quantization. This technique simulates low-precision error while performing the actual underlying calculations in FP16 or BF16.
Four distinct areas of the Transformer were analyzed:
- Weights: The static parameters of the model.
- Activations: The dynamic intermediate outputs of each layer.
- Gradients: The error signals propagated backward to update weights.
- Optimizer States: The momentum and variance tracked by the Adam optimizer.
Additionally, the study compared different levels of granularity: per-tensor (one scaling factor for an entire matrix), per-channel (individual scaling for rows or columns), and per-token (dynamic scaling for activations).
Key Insights and Stability Analysis
The 8-bit "Sweet Spot"
The most significant finding is the robustness of 8-bit quantization. Applying 8-bit precision to weights and activations resulted in performance nearly identical to the floating-point baseline. Interestingly, 8-bit per-channel weight quantization occasionally outperformed the baseline, suggesting that the discretization noise may act as a form of regularization that prevents overfitting.
The 4-bit Barrier and Loss Landscape Sharpness
Pushing weights to 4-bit precision introduced a noticeable performance gap (dropping average accuracy from ~36.4% to ~31.5%). Analysis of the loss landscape revealed that 4-bit models tend to converge to "sharper" minima. These regions of the loss function are more sensitive to small perturbations, leading to higher final loss and reduced generalization compared to the "flatter" regions found by higher-precision training.
Activation Outliers and Optimizer Fragility
Two specific technical hurdles were identified for ultra-low precision training:
- Persistent Outliers: Specific channels in the activations develop massive outlier values early in training and persist throughout. In 4-bit settings, these outliers dominate the scaling factor, effectively "crushing" the precision of the remaining values and causing the model to diverge unless per-channel strategies are used.
- Adam's Second Moment: While the first moment (momentum) of the Adam optimizer is resilient to 4-bit quantization, the second moment (variance) is not. Because the second moment appears in the denominator of the update rule, quantizing small values to zero can cause the update steps to explode, leading to immediate training failure.
Results and Efficiency Gains
Downstream Performance
Models trained with 8-bit per-channel weights and 8-bit per-token activations achieved parity with the baseline across the GLUE, ARC, and Hellaswag benchmarks. This confirms that 8-bit precision is a viable default for pre-training without sacrificing model quality.
Resource Profiling
Profiling the training process revealed that activations are the primary memory bottleneck, accounting for 70-80% of peak GPU memory usage. Consequently, quantizing activations provides the most substantial practical benefit, enabling larger batch sizes or longer sequence lengths on existing hardware. Furthermore, linear layers account for over 80% of execution time, indicating that hardware-accelerated quantized matrix multiplication (GEMM) could significantly reduce training wall-clock time.
Conclusion and Future Work
This research provides a clear "recipe" for 8-bit pre-training: per-channel weights and per-token activations are stable and efficient. However, 4-bit training remains a challenge due to gradient sparsity and the fragility of optimizer states. Future work should explore more sophisticated quantization schemes, such as NormalFloat4 (NF4) or non-linear mappings, and implement custom CUDA kernels to translate these theoretical memory savings into actual training speedups. As models continue to scale, managing activation outliers will be the primary hurdle for sub-8-bit training regimes.
Summary updated