Why Minibatch Noise Changes the Optimization Question
Motivation
Training a foundation model on n = 10^9 examples never evaluates the exact gradient \nabla f(\mathbf{x}) = \frac{1}{n}\sum_{i=1}^n \nabla f_i(\mathbf{x}):
The cost of exact gradients: Reaching six digits of accuracy on \tfrac12(x_1^2 + 1000\,x_2^2) takes \approx 7{,}000 full-batch steps—requiring 7 \times 10^{12} example evaluations.
The minibatch shortcut: Averaging over a random minibatch \mathcal{B} of size b = 256 is roughly 4 \times 10^6 times cheaper per step and points in the right direction on average.
The price of gradient noise: On f(x) = \tfrac12 x^2 with unit-variance gradient noise and constant step \eta = 0.1, the iterate never converges to x^\star = 0.
Instead, its mean square settles at \mathbb{E}[x_k^2] \to \frac{0.1}{1.9} \approx 0.053, wandering at distance \approx 0.23 from the minimum forever.
Gradient noise shifts the central question from how many steps an optimizer needs to how close to the minimum a given step size and budget can get.
Minibatch Gradients and the 1/b Variance Law
Minibatch Statistics
For b independent example gradients with per-example covariance \boldsymbol{\Sigma}, the minibatch average \hat{\mathbf{g}}_b(\mathbf{x}) = \frac{1}{b}\sum_{i \in \mathcal{B}}\nabla f_i(\mathbf{x}) is unbiased with variance:
Square-root amplitude law: RMS noise amplitude falls as 1/\sqrt{b}, so cutting noise 10\times requires 100\times larger batches.
Gradient-noise scale: Signal and noise have equal power at b_{\mathrm{noise}} = \operatorname{tr}\boldsymbol{\Sigma}/\|\nabla f(\mathbf{x})\|^2.
Empirical Verification of the 1/b Noise Law
Minibatch Statistics
On \ell_2-regularized logistic regression (n = 200 examples, d = 5 features) evaluated at \mathbf{x} = \mathbf{0}, single-example noise power is \operatorname{tr}\boldsymbol{\Sigma} \approx 1.1, and 10{,}000 random minibatches per size match \operatorname{tr}\boldsymbol{\Sigma}/b across all scales:
tr Sigma = 1.131
b = 1: measured 1.1188, tr Sigma / b = 1.1311, ratio 0.989
b = 4: measured 0.2847, tr Sigma / b = 0.2828, ratio 1.007
b = 16: measured 0.0699, tr Sigma / b = 0.0707, ratio 0.989
b = 64: measured 0.0177, tr Sigma / b = 0.0177, ratio 1.003
Sampling without replacement (standard epoch shuffling) multiplies this variance by the finite-population factor (n - b)/(n - 1), which is nearly 1 whenever b \ll n.
Exact Second-Moment Recursion Under Gradient Noise
The Noise Floor
On a scalar mode f(x) = \tfrac12\lambda x^2 with noisy gradient g_k = \lambda x_k + \xi_k(\mathbb{E}[\xi_k \mid x_k] = 0, \mathbb{E}[\xi_k^2 \mid x_k] = \sigma^2), the second moment e_k = \mathbb{E}[x_k^2] obeys (\rho = 1 - \eta\lambda):
e_{k+1} = \rho^2\,e_k + \eta^2\sigma^2
Orthogonal noise injection: The cross term \mathbb{E}[x_k\xi_k] = 0 vanishes by iterated expectations.
Physical balance: Every step contracts existing variance by \rho^2 while injecting fresh noise power \eta^2\sigma^2.
Closed-Form Trajectory and the Stationary Noise Ball
The Noise Floor
When 0 < \eta < 2/\lambda(|\rho| < 1), the linear recurrence e_{k+1} = \rho^2 e_k + \eta^2\sigma^2 has a unique stationary fixed point V = \rho^2 V + \eta^2\sigma^2:
Two-phase dynamics: A deterministic transient \rho^{2k}(e_0 - V) decays geometrically into a stationary noise ball of RMS radius \sqrt{V} \propto \sqrt{\eta}.
Additive Loss Floors and Linear Batch-Size Scaling
The Noise Floor
In deep learning we care about the expected suboptimality gap \mathbb{E}[f(\mathbf{x}_k)] - f^\star rather than parameter distance:
Curvature cancellation in the loss floor: For a scalar mode f(x) = \tfrac12\lambda x^2, multiplying V by \tfrac12\lambda cancels \lambda in the small-step regime (\eta\lambda \ll 1):\mathbb{E}[f(x_\infty)] = \tfrac12\lambda V = \frac{\eta\,\sigma^2}{2(2 - \eta\lambda)} \approx \frac{\eta\,\sigma^2}{4} Flatter directions let the iterate wander farther (\propto 1/\lambda), by the exact factor that flatness discounts from the loss (\propto \lambda).
Summing across d eigenmodes: On \tfrac12\mathbf{x}^\top\mathbf{A}\mathbf{x} with minibatch covariance \boldsymbol{\Sigma}/b, the mode variances sum to \sum_{i=1}^d \sigma_i^2 = \operatorname{tr}\boldsymbol{\Sigma}/b, giving total expected loss floor: \mathbb{E}[f(\mathbf{x}_\infty)] = \sum_{i=1}^d \frac{\eta\,\sigma_i^2}{2(2 - \eta\lambda_i)} \approx \frac{\eta\,\operatorname{tr}\boldsymbol{\Sigma}}{4b}
Linear scaling rule: Because the floor depends on (\eta, b) only through \eta/b, doubling batch size b and halving learning rate \eta lower the noise floor by the exact same factor.
Speed vs. Accuracy on the κ = 1000 Valley
Running Benchmark
On f(\mathbf{x}) = \tfrac12(x_1^2 + 1000\,x_2^2) with \eta = 1/L = 10^{-3} and unit noise (\sigma_1^2 = \sigma_2^2 = 1):
Flat mode (\lambda_1 = 1): Contracts at \rho_1 = 0.999, taking \approx 3{,}450 steps to decay its transient to the floor \tfrac12\lambda_1 V_1 = 2.5 \times 10^{-4}(33\%).
Steep mode (\lambda_2 = 1000): Contracts in 1 step (\rho_2 = 0), but because 2 - \eta\lambda_2 = 1, it contributes \tfrac12\lambda_2 V_2 = 5.0 \times 10^{-4}(67\% of the total 7.5 \times 10^{-4} loss floor).
Breaking the Floor: The Robbins–Monro Conditions
Step-Size Decay
To break the constant-step noise floor, a decaying schedule \eta_k \to 0 must balance two series:
On our \ell_2-regularized logistic regression benchmark (n = 200, d = 5, b = 8), compare constant steps \eta = 0.8 and \eta = 0.4 against the decaying schedule \eta_k = 0.8 / (1 + k/100):
mean gap, last 1000 steps: 1.4e-02, 5.9e-03, 4.1e-04
floor(0.8) / floor(0.4) = 2.35, floor(0.8) / decay = 34
Halving the constant step from 0.8 to 0.4 cuts the asymptotic loss plateau in half (confirming V \propto \eta on a non-quadratic objective), while the 1/k schedule drops 20\times–90\times lower and keeps descending.
Why the Constant c in a c/k Schedule Is Critical
Step-Size Decay
Substituting \eta_k = c/t(t = k + k_0) into the second-moment recursion gives:
Catastrophic slowdown (2c\mu < 1): Steps shrink faster than the iterate contracts, degrading the rate to \Theta(k^{-2c\mu}).
Sensitivity of 1/k Schedules and Condition Number
Step-Size Decay
The threshold 2c\mu > 1 explains why raw 1/k decay is fragile in deep learning and why modern pipelines prefer slower decay schedules or iterate averaging:
Optimal constant c^\star = 1/\mu: Minimizing A(c) = \frac{c^2\sigma^2}{2c\mu - 1} over c > \frac{1}{2\mu} selects c^\star = \frac{1}{\mu}, achieving the minimax rate e_k \approx \frac{\sigma^2}{\mu^2 k}.
Asymmetric sensitivity: Choosing c twice too large (c = 2/\mu) raises A by only 33\%(A = \frac{4}{3}\frac{\sigma^2}{\mu^2}), whereas choosing c four times too small (c = 1/(4\mu)) ruins the exponent from O(k^{-1}) to O(k^{-1/2}).
Ill-conditioning re-enters via k_0: On \tfrac12(x_1^2 + 1000\,x_2^2), setting c = 1/\mu = 1 for the flat mode while keeping \eta_0 = c/k_0 < 2/L = 2/1000 for the stiff mode forces k_0 > 500, starving the flat mode of early progress.
Modern Schedule Shapes: Cosine and WSD
Practical Schedules
Over a fixed training horizon of K steps starting from base learning rate \eta_0, modern pretraining favors schedules that stay large early and decay smoothly to zero at k = K:
Warmup–Stable–Decay (WSD): Hold \eta_0 constant for 80\% of the budget, then decay linearly over the final 20\%, allowing checkpoints from the plateau to be branched to any horizon K.
Ranking Schedule Shapes via the Exact Recursion
Practical Schedules
Because e_{k+1} = (1 - \eta_k\lambda)^2 e_k + \eta_k^2\sigma^2 holds step-by-step for any time-varying sequence \eta_k, we can compute the exact expected loss curve \mathbb{E}[f(x_k)] = \tfrac12\lambda e_k over K = 2000 steps with zero sampling noise:
floor 0.0882 constant c/k cosine WSD
E f at 80% 8.82e-02 2.36e-03 7.87e-03 8.82e-02
E f at end 8.82e-02 1.90e-03 1.68e-03 6.13e-03
WSD sits on the constant-step floor (0.0882) for the first 1{,}600 steps, then drops 14.4\times during its 400-step linear cooldown; cosine and c/(k+k_0) decay continuously to reach \approx 1.8 \times 10^{-3}.
Fixed Compute Budgets: Transient vs. Noise Balance
Fixed-Budget Rates
When the compute budget K is fixed in advance and \mu = 0 (no strong convexity), what constant learning rate \eta minimizes the final error?
Optimal budget scaling: Equalizing the two competing terms always selects \eta^\star \propto 1/\sqrt{K}, yielding an overall convergence rate of O(1/\sqrt{K}).
Proving the O(1/√K) Rate for Convex SGD
Convex Budget Proof
For convex f with \|\mathbf{x}_0 - \mathbf{x}^\star\| \le D and \mathbb{E}[\|\mathbf{g}_k\|^2 \mid \mathbf{x}_k] \le G^2, telescoping the distance expansion and applying Jensen to \bar{\mathbf{x}}_K = \frac{1}{K}\sum_{k=0}^{K-1}\mathbf{x}_k gives:
Minimax budget step: Setting \eta^\star = \frac{D}{G\sqrt{K}} equalizes the two terms and achieves \mathbb{E}[f(\bar{\mathbf{x}}_K)] - f^\star \le \frac{DG}{\sqrt{K}} without requiring smoothness.
Nonconvex SGD: The Ghadimi–Lan Stationarity Bound
Nonconvex Budget Proof
For nonconvex neural networks, assume f is L-smooth with \Delta = f(\mathbf{x}_0) - f^\star, and stochastic gradients satisfy \mathbb{E}[\mathbf{g}_k \mid \mathbf{x}_k] = \nabla f(\mathbf{x}_k) and \mathbb{E}[\|\mathbf{g}_k - \nabla f(\mathbf{x}_k)\|^2 \mid \mathbf{x}_k] \le \sigma^2:
Step 1: Stochastic descent lemma: Plug \mathbf{x}_{k+1} = \mathbf{x}_k - \eta\mathbf{g}_k into the L-smoothness quadratic ceiling and use \mathbb{E}[\|\mathbf{g}_k\|^2 \mid \mathbf{x}_k] \le \|\nabla f(\mathbf{x}_k)\|^2 + \sigma^2: \mathbb{E}\big[f(\mathbf{x}_{k+1}) \mid \mathbf{x}_k\big] \le f(\mathbf{x}_k) - \eta\left(1 - \frac{L\eta}{2}\right)\|\nabla f(\mathbf{x}_k)\|^2 + \frac{L\eta^2\sigma^2}{2}
Step 2: Telescope for \eta \le 1/L (so 1 - L\eta/2 \ge \tfrac12): Summing over k = 0, \ldots, K-1 and dividing by \eta K / 2 bounds the average squared gradient norm: \frac{1}{K}\sum_{k=0}^{K-1}\mathbb{E}\big[\|\nabla f(\mathbf{x}_k)\|^2\big] \le \frac{2\Delta}{\eta K} + L\eta\sigma^2
Optimal Nonconvex Step and Sample Complexity
Nonconvex Budget Proof
Returning a uniformly drawn iterate \mathbf{x}_R(R \sim \mathrm{Uniform}\{0, \ldots, K-1\}) with \eta^\star = \min\!\big(\frac{1}{L}, \sqrt{\frac{2\Delta}{L\sigma^2 K}}\big) certifies:
Why random stopping? SGD cannot observe exact \|\nabla f(\mathbf{x}_k)\| to pick the best iterate, so sampling R turns the average into an expectation.
O(1/\epsilon^4) sample complexity: Halving \mathbb{E}\|\nabla f\|^2 by 100\times (so RMS gradient drops 10\times) requires 10^4\times more steps.
Measuring the Nonconvex Rate on a tanh Neuron
Empirical Verification
Training a nonconvex single-neuron regression model f(\mathbf{x}) = \frac{1}{n}\sum_{i=1}^n \big(\tanh(\mathbf{a}_i^\top\mathbf{x}) - y_i\big)^2(n = 64, d = 5) with \eta = 0.5/\sqrt{K} across budgets K \in \{125, 500, 2000, 8000\} tracks the theoretical K^{-1/2} law:
random iterate 1.9e-01 8.3e-02 3.6e-02 1.7e-02 slope -0.58
best iterate 9.0e-03 2.1e-03 3.9e-04 4.9e-05 slope -1.25
The random-iterate metric \mathbb{E}\|\nabla f(\mathbf{x}_R)\|^2 decays with log–log slope \approx -0.60, closely tracking the worst-case -0.50 guarantee.
Finite-Sum Objectives and Interpolation vs. Noise
Variance Reduction
Why does constant-step SGD stall on a noise floor? At the global minimizer \mathbf{x}^\star, the average gradient vanishes (\nabla f(\mathbf{x}^\star) = \frac{1}{n}\sum_{i=1}^n \nabla f_i(\mathbf{x}^\star) = \mathbf{0}), but individual example gradients \nabla f_i(\mathbf{x}^\star) generally do not:
The interpolation regime (\nabla f_i(\mathbf{x}^\star) = \mathbf{0} for all i): When an overparameterized network fits every training example with zero loss, every component gradient vanishes at \mathbf{x}^\star. The noise variance \operatorname{tr}\boldsymbol{\Sigma}(\mathbf{x}^\star) = 0 vanishes automatically at the optimum, and constant-step SGD converges linearly with no noise floor.
Non-interpolating finite sums (\nabla f_i(\mathbf{x}^\star) \neq \mathbf{0}): When individual examples disagree at \mathbf{x}^\star, we can cancel their persistent variance using a Monte Carlo control variate—subtracting a correlated gradient whose exact mean over the n examples is known.
SVRG: Snapshot Control Variates Shrink Variance
Variance Reduction
SVRG periodically saves a snapshot \tilde{\mathbf{x}} with exact full gradient \nabla f(\tilde{\mathbf{x}}) and forms the unbiased control-variate estimator:
Vanishing variance: By L_{\max}-smoothness of each f_i, \mathbb{E}_i\|\tilde{\mathbf{g}}_i(\mathbf{x}) - \nabla f(\mathbf{x})\|^2 \le L_{\max}^2\|\mathbf{x} - \tilde{\mathbf{x}}\|^2.
Linear convergence at fixed \eta: As \mathbf{x}, \tilde{\mathbf{x}} \to \mathbf{x}^\star, the gradient noise vanishes without decaying \eta.
SVRG vs. SGD on Ridge Regression
Variance Reduction
Comparing single-example SGD and SVRG at the same constant step \eta = 0.02 and the same budget of 3n example gradients per epoch on ridge regression (n = 300, d = 12):
SGD: predicted floor 1.9e-02, mean gap in epochs 4-12 2.0e-02
SVRG: gap after epochs 1, 4, 12: 4e-01, 7e-04, 3e-11
SGD stalls permanently at the exact theoretical noise floor \sum_i \frac{\eta\sigma_i^2}{2(2-\eta\lambda_i)} \approx 2 \times 10^{-2}, whereas SVRG contracts geometrically by \sim 8\times per epoch down to machine precision (10^{-11}).
Concept Check: Noise Floors, Schedules, and Budgets
Concept Check
Test your understanding of stochastic gradient dynamics:
On a scalar quadratic with \lambda = \sigma = 1, what is the expected loss floor at \eta = 0.3, and by what factor does the floor drop if we simultaneously halve \eta to 0.15 and double the batch size b?
Suppose a strongly convex objective has minimum curvature \mu = 0.25. What condition must c satisfy for the schedule \eta_k = c/(k + k_0) to achieve an O(1/k) rate, and what choice of c minimizes the asymptotic constant?
For a smooth nonconvex loss with L = \Delta = \sigma = 1 and budget K = 10^6, what step size \eta and stationarity bound does the Ghadimi–Lan theorem prescribe?
Answers:(1) At \eta = 0.3, the loss floor is \frac{\eta\sigma^2}{2(2 - \eta\lambda)} = \frac{0.3}{3.4} \approx 0.0882. Halving \eta and doubling b cuts \eta/b by a factor of 4\times (and slightly more, \approx 4.3\times, because 2 - \eta\lambda increases from 1.7 to 1.85). (2) Requiring 2c\mu > 1 with \mu = 0.25 forces c > 2; below c = 2, convergence slows to O(k^{-c/2}). The optimal constant is c^\star = 1/\mu = \mathbf{4}. (3)\eta = \sqrt{2\Delta/(L\sigma^2 K)} = \sqrt{2} \times 10^{-3} \approx \mathbf{0.00141}, guaranteeing \mathbb{E}\|\nabla f(\mathbf{x}_R)\|^2 \le 2 \times 10^{-6} + 2\sqrt{2} \times 10^{-3} \approx \mathbf{0.00283}.
Summary: Stochastic Gradient Methods and Rates
Key Takeaways
Regime / Algorithm
Step Size / Estimator
Convergence Rate / Floor
Key Mechanism & Practical Takeaway
Constant-Step SGD
Fixed \eta \in (0, 2/L), minibatch b
Transient \rho^{2k} \to loss floor \approx \frac{\eta \operatorname{tr}\boldsymbol{\Sigma}}{4b}
Fast initial descent, stalls in a noise ball \propto \eta/b