How stochastic rounding affects training accuracy and computation cost
Where, When, and How Many Bits? Scaling Laws for SGD with Stochastic Rounding
Machine LearningArtificial Intelligence
Summary
Training AI models with low numerical precision saves time but causes errors due to rounding numbers. The authors study how a method called stochastic rounding influences prediction errors as the model size, training length, and number of bits vary. They prove mathematical bounds for error and find which parts of training need more precision to get the best results for a given compute budget. Their experiments confirm how decisions about rounding forward or backward data, and averaging parameters, affect performance in real models.
What this means in practice
- •For machine learning engineers: Optimize training efficiency by choosing where and when to use lower precision rounding in large models to balance speed and accuracy.
- •For hardware designers for ai chips: Design numeric precision and rounding strategies in AI accelerators informed by theoretical bounds on error and compute tradeoffs.
Tested on simulated data.
Authors
Zhichao Wang, Michael W. Mahoney
Abstract
Low-precision training reduces computation but introduces additional rounding error. We theoretically study how stochastic rounding (SR) affects prediction risk as model size, training time, and precision change. We consider a two-layer linear network with a fixed random first layer, trained by mini-batch SGD on fresh Gaussian data with power-law spectra. At each SGD step, the features used in forward and backward computations are rounded independently. We prove matched upper and lower bounds on prediction error for the final model and for uniform parameter averaging, with general learning-rate and precision schedules chosen before training. For fixed precisions and constant learning rates with parameter averaging, we derive how the smallest prediction error decreases with compute, and we identify model sizes and training times that achieve this optimal-compute scaling. Rounding only the forward features preserves the compute scaling of exact arithmetic, while rounding backward features changes it. Averaging parameters can change which computation needs higher precision and when higher precision is useful. Our results also give bit requirements for a given accuracy tolerance and show how backward rounding can change learning-rate schedule design. At a fixed compute budget, lower precision can improve prediction when the benefit of a larger model or longer training outweighs the additional SR-induced error. Model simulations illustrate these tradeoffs, and experiments with an MLP and a small transformer examine rounding choices beyond the theoretical model.