skip to content

What is the linear scaling rule for the learning rate when the mini-batch size grows?

level: middleimportance: must knowfreq 68%

answer

  1. think about k consecutive updates
  2. assume the gradient barely moves
  3. the multiplier hits both knobs
  4. batch times 32, rate times 32

basics

~10 s

Multiply the learning rate by the same factor you multiply the batch size by. A run at batch 256 with rate 0.1 moved to batch 8,192 scales both by 32, giving rate 3.2.

solid answer

~50 s

The linear scaling rule says: multiply the mini-batch size by `k`, multiply the learning rate by `k`. Batch 256 at rate 0.1 becomes batch 8,192 at rate 3.2 for a 32-fold increase. The justification is that `k` successive small steps and one large step should cover the same ground: `k` steps at batch `n` and rate `lr` move the weights by `lr * (g_1 + ... + g_k)`, while one step at batch `k*n` and rate `k*lr` moves them by exactly the same sum — the only difference is that the small-batch version evaluates each gradient at the weights it actually reached. So the rule holds whenever the gradient barely changes across those `k` intermediate points. That is false in the opening steps, which is why a large-batch run needs its rate ramped in, and it degrades again at the extreme end of the batch range.

go deeper

for a junior

Be ready to state the rule and do the arithmetic: multiply the batch by a factor, multiply the learning rate by the same factor, leave the epoch count alone. Know that a big scaled rate is normal, not a typo.

for a middle

Explain the derivation — k small steps versus one large step covering the same sum of gradients — and name the assumption it rests on. An interviewer expects you to say why that assumption fails in the opening steps.

for a senior

Show that you verify it rather than trusting it: compare loss against examples processed for the baseline and scaled run, and recognise a divergent opening as a ramp problem versus a flat curve as a step-budget problem.

for a principal

Own the framing that the rule buys you a transfer of a tuned configuration, not a free lunch. Decide when a large-batch run is worth the extra compute per epoch and when the honest answer is to keep the batch smaller.

### What the rule says The linear scaling rule is a one-line recipe for transferring a tuned configuration to a bigger batch: **when you multiply the mini-batch size by `k`, multiply the learning rate by `k`.** A run that was tuned at batch 256 with learning rate 0.1 becomes, at batch 8,192 (`k = 32`), a run at learning rate 3.2. The momentum coefficient, the weight-decay coefficient, the shape of the decay schedule and the number of epochs are all normally left alone; only the rate moves. A rate of 3.2 sounds absurd if you are used to seeing rates near 0.1. It is not: the update it produces per *example seen* is the same as before. The step is bigger because it replaces 32 of the old steps. ### Why it is the right first guess Take `k` consecutive steps at batch `n` with rate `lr`. Write `g_i(w)` for the average gradient over the `i`-th small batch evaluated at weights `w`. After `k` steps: `w_k = w_0 - lr * (g_1(w_0) + g_2(w_1) + ... + g_k(w_(k-1)))` Now take a single step over the union of those batches, which has size `k*n`, at rate `k*lr`. The large batch's gradient is the average of the `k` small-batch gradients, all evaluated at the starting point: `w_1 = w_0 - k*lr * (1/k) * (g_1(w_0) + ... + g_k(w_0)) = w_0 - lr * (g_1(w_0) + ... + g_k(w_0))` The two right-hand sides are the same sum. The **only** discrepancy is *where* each gradient is evaluated: the small-batch trajectory evaluates `g_i` at the weights it had actually reached, the large-batch step evaluates everything at `w_0`. So the linear scaling rule is precisely the statement *one big step should travel as far as the `k` small steps it replaces*, and it is valid exactly when the gradient is approximately unchanged over that short stretch of the trajectory. That framing tells you immediately where it breaks. ### Where the assumption fails 1. **The opening of training.** Weights are far from any solution, the loss surface is changing fast, and the gradient at `w_0` is a poor stand-in for the gradient at `w_(k-1)`. Applying the full scaled rate from step zero is the standard way to blow a large-batch run up in the first few hundred iterations. The fix is to bring the rate up gradually rather than starting at its scaled value; the mechanics and length of that ramp are a topic of their own, but *that a large-batch run needs one* is part of the scaling rule's own fine print. 2. **While the rate itself is moving quickly.** When the learning rate changes sharply from step to step, a momentum buffer still holds gradients that were accumulated under the old rate, and that stale contribution is applied at the new one. Correcting the buffer for the change in rate is the known remedy. 3. **At the far end of the batch range.** The rule holds over a wide span and then stops paying. In the large-scale image-classification setting where it was popularized — a fixed 90-epoch budget, scaled from batch 256 outward — the scaled runs tracked the baseline closely across a broad range of batch sizes and then began to fall behind as the batch grew into the thousands and tens of thousands, *even with a correct ramp and a correctly scaled rate*. Beyond that point, pushing the rate further does not recover the gap; it makes things worse. ### What to do when it stops holding The reflex — 'scale the rate harder' — is wrong. The realistic options are: train for more epochs at the large batch, accept a smaller batch, or change the *form* of the update rather than its magnitude. Layer-wise adaptive schemes such as LARS and LAMB take the second route: they set a per-layer step size from the ratio of the layer's weight norm to its gradient norm, so that no single layer takes a step that is enormous relative to its own weights, which is one of the failure modes that shows up at very large batch. ### What the rule is not It is a statement about **matching optimization progress per example**, and nothing more. It does not promise that the large-batch run reaches the same loss in the same number of epochs once you are far outside the range where it holds, and it is not a claim about how the resulting model behaves on held-out data. Keep it in its lane: it moves your search range so that a single well-chosen run replaces a re-tune, and you should still sweep a small grid around the scaled value rather than trusting `k * lr` blindly. ### How to verify it worked Plot training loss against **examples processed**, not against steps, for the baseline and the scaled run. If the rule is holding, the two curves nearly overlap. If the scaled curve is above the baseline everywhere, you are outside the rule's range or your ramp is wrong; if it diverges early, the ramp is the first suspect.

  • Why does the argument behind linear scaling break down in the first steps of training?
    The derivation assumes the gradient is roughly the same at all `k` intermediate weight vectors that the large step skips over. Early in training the weights move fast and the loss surface changes sharply, so that assumption is badly violated, and a rate 32 times the tuned one produces a step far larger than the local geometry supports. The run diverges or spikes, which is why large-batch runs bring the rate up gradually instead of starting at its scaled value.
  • What actually happens if you quadruple the batch and leave the learning rate alone?
    You get a quarter as many updates per epoch and each one is the same size as before, so the run covers roughly a quarter of the ground it used to cover per epoch. It looks stable — often smoother than the baseline — and simply underfits under a fixed epoch budget. Teams misread this as 'big batches hurt the model' when it is a step-budget arithmetic problem.
  • Should the momentum coefficient be rescaled along with the learning rate?
    No, it is normally left unchanged; the rule targets the step size only. The subtlety is that a momentum buffer averages recent gradients, and when the rate changes rapidly the buffer still carries contributions accumulated under the old rate. Correcting the buffer for that change keeps the effective step consistent while the rate is moving, which matters most during the opening ramp of a large-batch run.

Thirty-two people each take one small step and adjust after every one; one person takes a single stride the length of all thirty-two combined. They end up in the same place only if the ground does not change direction under their feet along the way.

saying these in an interview costs you the question

  • Says batch size and learning rate are independent knobs
  • Thinks doubling the batch means halving the rate
  • Applies the fully scaled rate from step zero
  • Claims linear scaling holds at any batch size without limit
  • Treats a scaled rate as a substitute for more epochs

context