Foundations to Frontier
Tests
E. Deep Learning › E3 Optimizers (one page each)

LARS

Layer-wise adaptive rate scaling (LARS) gives every layer its own learning rate, proportional to the ratio of that layer's weight norm to its gradient norm, the 'trust ratio'. Each layer then moves by about the same fraction of its weights per step, however different the layers' gradient scales. LARS made it possible to train ResNets with batches of 32 000 and more without losing accuracy. This page covers the trust ratio, the update with momentum and weight decay, its relative-step property, exclusions and schedules. In the exercises you show that LARS changes each layer by a fixed fraction lr·η per step regardless of scale, then train a network whose layers' weight-to-gradient ratios differ by more than a factor of 100 and find LARS reaches the target in about half the steps of tuned SGD with momentum.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Each layer at its own pace

In a deep network, some layers get gradients that are huge compared with their weights, and others get tiny ones. With a single learning rate, a step that is sensible for one layer can be reckless for another. LARS measures, for each layer, how big the weights are relative to the gradient, and scales that layer’s learning rate so that every layer changes by about the same percentage per step. That makes much larger learning rates, and so much larger batches, usable.

Optimizer lab: LARS versus plain gradient descent
LARS: final loss 0.011 (target reached at step 88) · gradient descent: final loss 2.2e-9 (step 22)
Orange: the chosen optimizer; grey dashed: plain gradient descent with the same learning rate. Darker shading means higher loss. On the ill-conditioned bowl, raise κ and watch gradient descent zig-zag across the narrow direction; on the saddle it stalls near the flat start; on the plateau its gradients are tiny. Adaptive methods rescale each direction; momentum methods build speed along consistent directions. The target is 1% of the starting loss (for the saddle, a loss below −0.2; its minima are at −0.25).
Why engineers care

Training perception models on large clusters uses very large batches to keep many accelerators busy. Large batches need large learning rates (E3-1), which plain SGD cannot use when layers differ greatly in scale. LARS and its Adam-based sibling LAMB (E3-15) are what made batches of tens of thousands workable for ImageNet-scale vision and BERT-scale language models.

📝 Quick check (Level 0)
0/3 answered
  1. 1. LARS assigns learning rates…
  2. 2. The trust ratio is based on…
  3. 3. LARS was developed to enable…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

By hand

  • Trust ratio: for layer l, λₗ = η·‖wₗ‖/(‖gₗ‖ + β‖wₗ‖), with a small trust coefficient η (about 0.001) and weight decay β. Example: ‖w‖ = 5, ‖g‖ = 0.5, η = 0.01 gives λ = 0.1.
  • Update with momentum: vₗ ← m·vₗ + γ·λₗ·(gₗ + βwₗ), then wₗ ← wₗ − vₗ, with global rate γ.
  • Relative change: ignoring momentum and decay, ‖Δwₗ‖ = γλₗ‖gₗ‖ = γη‖wₗ‖. Every layer changes by the fraction γη of its norm per step, whatever its gradient’s size.
  • Example: w = (3, 4), g = (0, 2), γ = 1, η = 0.1 gives a step of 0.1 × 5/2 × (0, 2) = (0, 0.5), so w becomes (3, 3.5), a 10% change of its norm.
  • Exclusions: biases and batch-norm parameters usually skip the trust ratio.
  • Schedule: You et al. used a polynomial decay γₜ = γ₀(1 − t/T)², plus warm-up.
📝 Quick check (Level 1)
0/3 answered
  1. 1. Trust ratio for ‖w‖ = 10, ‖g‖ = 1, η = 0.001?
  2. 2. LARS's per-step relative change of a layer is…
  3. 3. Usually excluded from LARS adaptation are…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.

LARS in code

Exercise 1.

  • A momentum-free LARS step changed a weight matrix by exactly 0.1% of its norm (γη = 0.001).
  • It did the same with 100 times larger gradients, and with 5 times larger weights.
  • LARS’s relative step is independent of the layer’s gradient and weight scales.

Practice.

  • Typical settings: η ≈ 0.001, momentum 0.9, a large base rate with warm-up (several epochs), and polynomial or cosine decay.
  • Apply the trust ratio per weight tensor (convolution kernel or linear matrix), not per scalar.
  • LARS pairs naturally with SGD and momentum for convolutional networks. For transformers and Adam-style training, use LAMB (E3-15).
  • Very large batches still hit the critical-batch-size limit (E3-1). LARS extends the regime where scaling works; it does not remove the limit.
# torch: no built-in LARS; common implementations wrap SGD and rescale each parameter's gradient by its trust ratio
🐍 Exercise 1: the trust ratio
Implement the LARS trust ratio and update, and show that a LARS step changes each layer by the same relative amount whatever its gradient or weight scale.
📝 Quick check (Level 2)
0/3 answered
  1. 1. LARS's trust ratio is computed per…
  2. 2. For transformers trained with Adam, the layer-wise method is…
  3. 3. Does LARS remove the critical batch size?

Level 3: Advanced

★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.

Theory

Why layers need different rates. For gradient descent to be stable and efficient, each layer’s step should be small relative to its own scale. In deep networks, ‖g‖/‖w‖ varies by orders of magnitude across layers: input layers with large inputs, normalised layers, the final classifier. A global rate must suit the most sensitive layer, so the others crawl. You, Gitman and Ginsburg (2017) measured ratios differing by over 100× in AlexNet and ResNet, which made large-batch training diverge without warm-up.

Normalisation and scale invariance. For layers followed by batch normalisation, the loss is invariant to rescaling the weights, so only the direction of w matters, and the effective learning rate scales like γ/‖w‖². LARS’s relative step makes training independent of this scale. That also explains why it interacts with weight decay, which shrinks ‖w‖.

Results. LARS trained ResNet-50 on ImageNet with batches of 32k (later 64k), matching small-batch accuracy, with LARS plus warm-up and polynomial decay.

Caveats. The trust ratio uses the noisy mini-batch gradient norm. Very small gradient norms (late in training) give huge local rates, which the momentum and the global schedule must tame. Some later studies found well-tuned standard optimisers match LARS at moderate batch sizes (Nado et al., 2021).

📝 Quick check (Level 3)
0/3 answered
  1. 1. With batch norm, a layer's loss is invariant to…
  2. 2. LARS trained ResNet-50 with batch sizes of…
  3. 3. Nado et al. (2021) found that at moderate batch sizes…

Level 4: Expert

★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.

Layers with very different scales

History.

  • Y. You, I. Gitman and B. Ginsburg (2017) introduced LARS and trained AlexNet and ResNet-50 with batches up to 32k.
  • Y. You et al. (2020) introduced LAMB for BERT.
  • Large-batch ImageNet training in minutes (2018–2019) relied on LARS.
  • Z. Nado et al. (2021) revisited the baselines.

Exercise 2. A 2–32–32–3 tanh network on spirals whose inputs are multiplied by 30, so the first layer’s gradient is very large relative to its weights. Full-batch training (600 points) runs for 250 steps, with SGD with momentum and with LARS (η = 0.001, momentum 0.9), each over a grid of learning rates. The ratio ‖w‖/‖g‖ per weight matrix at step 1 was 0.051, 7.64 and 2.10, a 150-fold spread.

method γ steps to loss < 0.1 final loss
SGD + momentum 0.01 169 0.052
SGD + momentum 0.03 67 0.011
SGD + momentum 0.1 199 0.101
SGD + momentum 0.3 161 0.446
LARS 3 60 0.000
LARS 10 33 0.000
LARS 30 21 0.177
LARS 100 — 1.384
  • One global rate could not suit all layers. Above 0.03, SGD became erratic: the first layer’s huge gradients made larger steps unstable, so the other layers were held to tiny steps.
  • LARS reached the target in half the steps (33 against 67) and drove the loss to zero, because every layer moved by the same relative amount per step.
  • LARS has its own stability limit. At γ = 30 it hit the target fastest (21 steps) but did not stay there, and at 100 it failed. The trust ratio relocates the learning-rate choice; it does not remove it.
🐍 Exercise 2 (research): layers with very different scales
Train a network whose first layer's gradients dwarf its weights with SGD + momentum and with LARS over learning-rate grids; record per-layer weight-to-gradient ratios, steps to target and final loss.

LARS in AI, robotics and aerospace

  • Large-scale perception training on clusters, where large batches keep many accelerators busy, uses LARS for convolutional backbones.
  • Self-supervised pre-training (SimCLR, BYOL) commonly uses LARS with very large batches.
  • Heterogeneous inputs: models mixing raw sensor channels with very different scales benefit from layer-wise rate scaling, or from proper input normalisation.

References

  1. Y. You, I. Gitman, B. Ginsburg (2017). “Large batch training of convolutional networks.” arXiv:1708.03888.
  2. Y. You et al. (2020). “Large batch optimization for deep learning: training BERT in 76 minutes.” Proc. ICLR.
  3. T. Chen, S. Kornblith, M. Norouzi, G. Hinton (2020). “A simple framework for contrastive learning of visual representations.” Proc. ICML.
  4. Z. Nado, J. Gilmer, C. Shallue, R. Anil, G. Dahl (2021). “A large batch optimizer reality check: traditional, generic optimizers suffice across batch sizes.” arXiv:2102.06356.