Choosing a mode is arithmetic, not preference
complexity▲▲△Reverse mode is not simply better than forward mode. For , price both, decide which wins for four different tasks, and say what reverse mode pays for its advantage.
Hint
A forward sweep propagates a derivative with respect to one input; a reverse sweep propagates the derivative of one output. Count how many of each you need to fill a Jacobian.
Solution
The rule. Forward mode carries for one input through the whole graph, so it fills one column of the Jacobian per sweep: sweeps. Reverse mode carries for one output, filling one row per sweep: sweeps. That is I.6.T2, and everything else follows from it.
| task | forward | reverse | cheaper | ||
|---|---|---|---|---|---|
| training a network | 1 | 1 | reverse | ||
| a scalar of few inputs | 3 | 1 | 3 | 1 | reverse |
| sensitivity of an ODE | 4 | 4 | forward | ||
| Jacobian of a layer | 1024 | 1024 | 1024 | 1024 | tie |
| one directional derivative | 1 | forward |
Training. in the hundred millions, . Reverse mode is cheaper by a factor of — the entire parameter count. This is the case the field is built around, and it is why “autodiff” and “backpropagation” are used interchangeably even though the first is much more general than the second.
The last row is the interesting one. Both and are enormous, yet forward mode wins outright, because only one direction is wanted rather than the whole Jacobian. A single forward sweep seeded with that direction returns — a Jacobian–vector product — at the price of one evaluation. Reverse mode has no way to produce it in fewer than sweeps.
What reverse mode pays. Memory. Forward mode carries one extra value alongside each node and never looks back, so nothing is stored: values live at any moment for the model of I.6.B05. Reverse mode must keep the whole tape to have the local Jacobians on the way back: values, more, exactly the depth of the network.
That is the trade in one line — reverse mode buys a factor of in arithmetic with a factor of in memory, and the exchange is worth it precisely because .
Where neither is cheap. The middle row: a full Jacobian costs 1024 sweeps either way. There is no mode that produces a dense Jacobian cheaply, and a method that needs one — some second-order and some sensitivity-analysis methods — is expensive for a reason no implementation detail will fix.