Skip to main content
AI / MLTraining & TuningDiagramBeginner

Backpropagation

KO: 역전파·EN: Backpropagation·JA: 誤差逆伝播法(Backpropagation)

The core algorithm that applies the calculus chain rule backward from the output loss to compute exact gradients for every weight in a neural network efficiently

Table of Contents

Structure Diagram

Neural Network Training Step: Forward → Loss → Backward → Update
Autograd1. Forward P…2. Compute L…3. Backprop4. Weight Up…
3/43. Backprop
Chain-rule gradients
Quick Answer

What is Backpropagation?

The core algorithm that applies the calculus chain rule backward from the output loss to compute exact gradients for every weight in a neural network efficiently. It is a core concept in Training & Tuning within AI / ML.

Core Principles

Computing gradients one weight at a time in a billion-parameter network is intractable. Backpropagation caches intermediate activations during the forward pass and applies the chain rule backward from the loss in a single reverse sweep, computing exact gradients for every parameter at roughly the cost of one forward pass.

Practical Takeaways

  • Use Gradient Checkpointing for long sequences: Storing all forward activations dominates training VRAM. Checkpointing discards selected activations and recomputes them during backprop, cutting memory by >60% for ~25% extra compute.
  • Understand Residual Connections & Normalization: Deep transformers train stably because skip connections (x + f(x)) give backpropagated gradients an unimpeded highway, preventing vanishing gradients.
  • Wrap inference in no_grad / inference_mode: Disabling autograd graph tracking during serving avoids massive wasted activation memory.

Notable Examples

  • PyTorch Autograd & JAX: Automatically record computation graphs and execute reverse-mode autodiff via loss.backward().
  • Transformer Residual Streams: Preserve gradient magnitude across dozens of attention and MLP blocks.
  • BF16 / FP16 Mixed Precision: Uses BF16's wide dynamic range (or FP16 loss scaling) to prevent gradient underflow during backprop.