Skip to content
AI360Xpert
Beta

Convergence of SGD in Non-Convex Settings

Non-convex SGD cannot promise a global minimum, so theory guarantees stationarity instead: the gradient shrinks at a one-over-root-T rate.

Noisy SGD steps shrink the average squared gradient at a one-over-root-T pace
Noisy SGD steps shrink the average squared gradient at a one-over-root-T pace

Why Does This Exist?

In convex optimization SGD chases the global minimum and theory tracks the distance to it. In non-convex training that target does not exist, yet SGD still works. The theory had to change its promise: instead of reaching the best point, SGD reaches a point where the gradient is small, called an approximate stationary point, and it does so at a quantified rate.

That rate guides every training budget. It tells you how many steps buy how much gradient shrinkage, how batch size trades noise for speed, and why decaying steps matter. Pair with saddle-point escape for second-order guarantees and PL condition for the faster linear regime.

The one idea you need first

An unbiased stochastic gradient gtg_t satisfies E[gt]=∇f(xt)\mathbb{E}[g_t] = \nabla f(x_t) with variance bounded by σ2\sigma^2. Mini-batches give exactly this: correct on average, noisy per step. See SGD variants for the estimators.

Think of It Like This

Finding flat ground while wearing blurry glasses

You want flat ground in dark hills, but your slope readings have static: each measurement is correct on average yet jittery. One reading might say tilt left when the true slope tilts right.

You cope by taking small steps and averaging over time. Small steps keep bad readings from throwing you off a cliff. Averaging washes out the static and reveals the true trend. The noisier your glasses, the smaller your steps must be, and the longer the walk takes.

Where the analogy stops: real SGD noise shrinks near interpolating minima, so late training sees clearer readings than early training.

How It Actually Works

Assume LL-smoothness and variance σ2\sigma^2. SGD with fixed step η≤1/L\eta \leq 1/L satisfies:

1T∑t=0T−1E∥∇f(xt)∥2≤2(f(x0)−f∗)ηT+Lησ2\frac{1}{T}\sum_{t=0}^{T-1}\mathbb{E}\|\nabla f(x_t)\|^2 \leq \frac{2(f(x_0) - f^*)}{\eta T} + L\eta\sigma^2

The two terms pull opposite ways: small η\eta kills the noise term but slows the first term. Setting η≈1/T\eta \approx 1/\sqrt{T} balances them and gives the headline O(1/T)O(1/\sqrt{T}) rate. That means halving the gradient takes four times the steps. Larger batches cut σ2\sigma^2 linearly, which buys a larger safe step, up to the point where hardware costs dominate.

Worked example

Take f(x)=x2f(x) = x^2 with gradient noise ±1\pm 1 each step (variance σ2=1\sigma^2 = 1), L=2L = 2, gap f(x0)−f∗=9f(x_0) - f^* = 9 from x0=3x_0 = 3, T=100T = 100 steps:

  • Optimal step: η=2×9/(2×1×100)=0.09=0.3\eta = \sqrt{2 \times 9 / (2 \times 1 \times 100)} = \sqrt{0.09} = 0.3, capped by 1/L=0.51/L = 0.5. Use 0.30.3.
  • Bound: first term 2×9/(0.3×100)=0.62 \times 9 / (0.3 \times 100) = 0.6. Noise term 2×0.3×1=0.62 \times 0.3 \times 1 = 0.6. Total average squared gradient ≤1.2\leq 1.2.
  • Double to T=400T = 400 with η=0.15\eta = 0.15: first term 2×9/(0.15×400)=0.32 \times 9/(0.15 \times 400) = 0.3, noise 2×0.15=0.32 \times 0.15 = 0.3, total 0.60.6. Four times the steps halved the bound, exactly the root-T pace.

Code

import numpy as np
rng = np.random.default_rng(1)

def sgd_trace(x0: float, steps: int, eta: float) -> float:    x = x0    sq = 0.0    for _ in range(steps):        g = 2.0 * x + rng.choice([-1.0, 1.0])  # true grad plus noise        x = x - eta * g        sq += (2.0 * x) ** 2    return sq / steps  # average squared true gradient

print(round(sgd_trace(3.0, 100, 0.3), 3))  # -> about 1.1, near the 1.2 boundprint(round(sgd_trace(3.0, 400, 0.15), 3))  # -> about 0.55, roughly halved

Watch Out For

Keeping the step size constant and expecting convergence

Fixed steps leave the noise term Lησ2L\eta\sigma^2 permanently on. The gradient norm plateaus at that floor no matter how long you train, which looks like a saddle but is just noise.

Decay the step (or raise the batch size) once the loss plateaus. Cosine or step decay schedules exist for exactly this transition.

Reading the last iterate instead of the average

The bound covers the average over iterates, not the final point. The last iterate can sit on a noise spike with a large gradient while the average is small.

Track a moving average of the gradient norm or validate on a held-out batch before declaring stationarity.

The Quick Version

  • Non-convex theory promises small gradients, not global minima, at an O(1/T)O(1/\sqrt{T}) rate.
  • Step size trades descent speed against noise: too large diverges, too small crawls.
  • Batches cut variance linearly and permit larger steps until hardware costs bind.
  • Decay steps or grow batches after plateaus to push past the noise floor.
  • Judge the averaged gradient norm, not a single noisy last step.