Northeastern University · CS 7150 · Fall 2026
How an autograd engine turns an expression into gradients: building the computation graph as Python runs, the forward pass in topological order, and the chain rule applied one node at a time on the way back, as in Rumelhart, Hinton & Williams 1986 and the modular view of Bottou and Gallinari 1990. The chain rule for a single path is worked in Quiz 0.
Type a PyTorch-style expression and watch it become a graph of nodes, each pointing
to its inputs. Run the forward pass in topological order, then loss.backward(), zooming in on
each node to see the upstream gradient arrive, the local gradients it computes from its own inputs,
and the downstream shares it adds into each input. Ends with a finite-difference check.
Why the backward pass multiplies by Aᵀ. The forward product drawn as wires, then run in reverse: the gradient g deals one entry to each row of A, the scaled rows add up to ∂L/∂x = Aᵀg, and the product rule on each wire gives the weight gradient ∂L/∂A = g xᵀ. The left panel replays the matrix × vector animation on Aᵀ and g; click any wire to see the product rule on it.
Open the explainer →