Where, When, and How Many Bits? Scaling Laws for SGD with Stochastic Rounding
Authors: Zhichao Wang, Michael W. Mahoney
Organizations: ICSI and Department of Statistics University of California, Berkeley, USA · ICSI, LBNL and Department of Statistics University of California, Berkeley, USA
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.
Figures & tables
Figure 1: (a) We round the features either at forward pass or backward pass in SGD dynamics ( 5 ) with one-bit precision and compare the SR-induced error over the corresponding risk without rounding. Solid lines evaluate the final model (last iterate); dashed lines evaluate the model obtained by averaging parameters over training (uniform average). Forward rounding causes more error for last iterate, while backward causes more error for the average. (b) Using three bits in the first half of training and one bit in the second, or the reverse, with nearly equal average precision. Each bar divides the SR-induced risk with higher precision early by that with higher precision late. Values above one indicate higher precision at late phase of training outperforms the case with higher precision at early phase of training. (c) Each point selects the smallest tested precision that keeps the final prediction risk no more than 1% higher than its value without rounding, at the same width and duration. Both locations use the same precision from 1 to 4 bits. Appendix F gives experimental details.
Feature precision (forward, backward)
Risk
Width M
Optimization time τ
Exact, exact
F−a+1b−1
Fa+11
Fa+1a
Finite, exact
F−a+1b−1
Fa+11
Fa+1a
Exact, finite
F−a+bb−1
Fa+bb
Fa+ba
Finite, finite
F−2ab−1
F1/2
F1/2
Table 1: Compute-optimal prediction risk Ravg(T) with fixed precisions, η,B , and compute budget F . Precisions pfw,pbw may differ when they are finite. Columns of M and τ show the orders attaining the compute-optimal risk. Here we only focus on the scaling order as F→∞ . 1<b<a .
Last iterate
Uniform average
Exact-arithmetic risk scale Dout
M1−b+ρsM
M1−b+ρsMM1−a
Forward coefficient Afw
ρMa−b
ρM1−b
Backward coefficient Abw
ρ(sM+M1−b)
ρ(sM+M1−b)
Joint coefficient A×
ρ2(sM+M1−b)Ma−1
ρMa−b
Table 2: Following Section 3.2 with τ≍Ma . Scaling definitions in ( 28 ) with sM defined in ( 19 ).
Figure 2: (a) With five mantissa bits in total, more forward bits reduce last-iterate error; averaged-output error is smallest at (pfw,pbw)=(2,3) . Errors are relative to the corresponding exact-arithmetic risks. (b) The orange schedule accounts for backward-rounding error using ( 31 ); the blue schedule uses the exact-arithmetic design ( 30 ). Both use one-bit backward SR; the dotted line is a constant learning rate. (c) Full last-iterate prediction risk under the precision-dependent design minus that under the exact-SGD design, at the same backward precision. Positive values favor the exact-SGD design. In (c), points average eight independent regression problems. Forward features are exact in (b,c). Appendix F.2 gives details.
Figure 3: Prediction risk of uniformly averaged outputs under a compute budget. (a,b) Exact-arithmetic and joint one-bit SR training ( pfw=pbw=1 ) at several widths. Black curves show the smallest prediction risks among tested widths and training durations. Red dashed curves use the optimal-compute scaling in Table 1 for exact-arithmetic training. (c) At a fixed budget F , joint SR permits a wider model and longer training with lower prediction risk. We average over three sketches. Appendix F.3 gives details.
Figure 4: Prediction risk under a fixedcompute budget with fresh and reused data. Uniformly averaged outputs at M=256 , using exact arithmetic or joint two-bit feature SR. (a) Full prediction risks at F=227 . (b) The difference between SR and exact prediction risks across budgets; negative values indicate SR is beneficial. (c) Reuse-minus-fresh risk differences at F=227 for different data sizes. For more details, see Appendix F.3 .
Figure 5: Rounding locations, shared activations and test-time prediction in neural networks. (a) Final transformer validation loss; the combined case rounds both activation computations, incoming gradients and forward weights to two bits, with seven-bit parameter storage. (b) Shared SR reuses the same forward-rounded activation in the weight-gradient computation. Points show final loss differences from same-seed training with SR and without SR. Negative values indicate lower loss than this baseline. (c) Each trained MLP is tested twice with its parameters fixed: with forward-activation SR disabled, and with SR enabled at its training precision. Both tests use the same examples. Appendix F.5 gives details and final performance values.
Appendix figures & tables3 assets
Supplementary material from the paper’s appendix.
Appendix
Figure 6: Supplementary precision comparisons. Figure 6 (a,b) shows SR-induced risk increases for last-iterate and uniformly averaged outputs at fixed duration, with fresh or reused data. The four categories use feature rounding alone, add temporary prediction-weight rounding, add stored-parameter rounding, or round at all six locations, as defined below. The vertical axes use different logarithmic ranges; bars show twice the standard error across eight task means. Figure 6 (c) compares four integer precision schedules with constant two-bit precision at the same feature location. Mean bit counts are shown; the realized budgets differ.
Training configuration
Validation loss
No added SR
4.1846±0.0049
Independent activations, 1 bit
4.2452±0.0034
Independent activations, 2 bits
4.2016±0.0082
Shared activations, 1 bit
4.2238±0.0019
Shared activations, 2 bits
4.1976±0.0036
Backpropagated gradients, 2 bits
4.1852±0.0051
Appendix
Table 3: Final transformer validation loss with added SR disabled at evaluation. The table covers Figure 5 (a,b) and a three-bit storage comparison.
Training configuration
Test loss SR off
Test loss SR on
Accuracy (%) SR off
No added SR
1.6198±0.0032
1.6198±0.0032
56.409±0.147
Forward activations, 1 bit
1.6237±0.0041
1.6721±0.0056
56.541±0.109
Forward activations, 2 bits
1.6210±0.0027
1.6338±0.0030
56.458±0.112
Forward activations, 3 bits
1.6212±0.0039
1.6242±0.0039
56.381±0.124
Independent activations, 1 bit
1.6208±0.0034
1.6706±0.0041
56.501±0.120
Independent activations, 2 bits
1.6223±0.0032
1.6356±0.0035
56.403±0.131
Appendix
Table 4: Final MLP test performance for Figure 5 (b,c). Entries are means ± two standard errors across 16 seeds. The two loss columns evaluate the same final parameters without or with SR; accuracy uses evaluation without SR.
Should low-precision transformer inference use stochastic rounding (SR) or round-to-nearest (RN)? The answer depends on where in the network you look. We isolate this effect by holding the numerical format fixed and varying only the rounding rule at individual operation sites. To enable experiments at freely chosen precisions, we extend the PRISM vectorized rounding library to arbitrary virtual precision via a variable-precision stochastic rounding (VPSR) algorithm, proving that the rounding decision is evaluated exactly in hardware floating point. We develop two analyses providing complementary insight into this site-level trade-off. First, a probabilistic forward-error bound for linear projections shows that SR's error envelope grows as O(nu) in reduction length n, versus O(nu) for RN, a gap that widens rapidly at low precision and is most pronounced in the long multilayer perceptron (MLP) down-projection. Second, a second-order decomposition of expected cross-entropy loss change at the output softmax into signed drift, drift curvature, and a Fisher-weighted variance penalty reveals why the two sites behave oppositely: MLP noise is predominantly a uniform logit shift to which softmax is invariant, so SR's variance is largely discounted; head noise is non-uniform across the vocabulary and is not. On DistilGPT-2 at t=6 significand bits, observations match theory: SR in the MLP raises perplexity to 1.15x the full-precision reference, versus 2.21x for RN. At the language-model head, the ordering reverses because SR introduces non-uniform variance, whereas deterministic RN carries none. In a mixed-precision configuration (MLP output at t=6), assigning SR to the MLP and RN to the head brings perplexity within 1.10x of the full-precision reference, a 28% reduction over matched-bit RN.
Yohan Chatelain, Pablo de Oliveira Castro
Krembil Centre for Neuroinformatics, CAMH, Toronto, Canada · Universite Paris-Saclay, UVSQ, LI-PaRAD, Versailles, France
Low-precision training often relies on stochastic rounding (SR) to keep quantized gradients unbiased and prevent small updates from rounding to zero. Standard SR draws an independent random threshold for every gradient element. However, accelerators generate random numbers on vector units whose throughput lags far behind their matrix units. Drawing one threshold per element saturates the vector unit and can make INT8 training with SR slower than BF16 training. Sharing random thresholds across tensor elements removes this cost but forces those elements to round in the same direction and shifts their rounding errors by a common offset. We find that this offset degrades training primarily through the activation gradient, which propagates the error backward into earlier layers. Because earlier layers cannot cancel an incoming offset using their own local rounding errors, the offset must be removed at the layer where it originates. We propose Structured Subspace Stochastic Rounding (S3R), which quantizes each upstream gradient once for both the activation and weight gradient matrix multiplications and shares a single threshold per token across the hidden dimension. Its error correction, S3R-EC, subtracts the structured mean rounding error from the activation and weight gradients while leaving the optimizer unchanged. In LLM pre-training experiments, uncorrected threshold sharing degrades convergence, whereas S3R-EC eliminates this degradation and matches the validation loss of independent SR. Furthermore, S3R-EC accelerates full INT8 training steps of dense LLMs on TPU v5p by 1.24x to 1.32x over BF16 and by 1.11x over independent SR.
We study scaling laws of signSGD under a power-law random features (PLRF) model that accounts for both feature and target decay. We analyze the population risk of a linear model trained with one-pass signSGD on Gaussian-sketched features. We express the risk as a function of model size, training steps, learning rate, and the feature and target decay parameters. Comparing against the SGD risk analyzed by Paquette et al. (2024), we identify a drift-normalization effect and a noise-reshaping effect unique to signSGD. We then obtain compute-optimal scaling laws under the optimal choice of learning rate. Our analysis shows that the noise-reshaping effect can make the compute-optimal slope of signSGD steeper than that of SGD in regimes where noise is dominant. Finally, we observe that the widely used warmup-stable-decay (WSD) schedule further reduces the noise term and sharpens the compute-optimal slope, when feature decay is fast but target decay is slow.
Jihwan Kim, Dogyoon Song, Chulhee Yun
Seoul National University & KAIST InnoCORE LLM · University of California, Davis · KAIST