Journal of Machine Learning Research 18(153), 1–43. Grounds reverse mode as the efficient way to compute gradients of scalar losses with many parameters, at a small constant multiple of one evaluation.
Reverse-Mode Automatic Differentiation
Reverse-mode autodiff computes gradients by sending sensitivities (cotangents) backward through a computation graph, so one backward pass gives the gradient of a scalar loss.
Intuition
The idea in plain words, before the symbols.
Suppose one scalar loss depends on millions of parameters. Do you need to run one derivative computation for each parameter to know how to change them all?
Reverse-mode automatic differentiation is the bookkeeping trick that makes the answer no.
The previous idea, computation graphs, makes dependencies visible. Reverse-mode AD adds an execution rule: during the forward pass, record the primitive operations and the intermediate values they will need later. During the reverse pass, start from the final question, "how much does the loss change if this output changes?", and walk backward through the recorded operations. Each local backward rule converts an output sensitivity into input sensitivities.
The advantage comes from the shape of the problem: many inputs, one output. If one scalar loss depends on many parameters, reverse mode can compute all parameter gradients in one backward sweep through the graph. Forward mode would ask, one input direction at a time, how the output changes.
The useful mental model is a tape plus a register file. The tape remembers what primitive operations ran. The registers store the sensitivities, also called cotangents, such as and . The model breaks if you imagine symbolic simplification: reverse mode does not expand the formula by hand; it accumulates local contributions on the graph that actually ran.
Study prompts for this section: Intuition
Each button copies a prompt about this section to your clipboard, for an AI assistant you already use. Nothing is sent by this site.
Mathematics
Definitions, assumptions and the derivation.
Let a differentiable computation graph produce a scalar output from intermediate variables . Reverse mode stores, for each node, an adjoint or cotangent
Before the reverse sweep, initialize every non-output cotangent register to zero. Then seed the scalar output with
For scalar nodes and a local operation , the chain rule sends sensitivity backward. When the operation producing is processed, already contains all downstream contributions:
For an operation with multiple inputs, such as , each input receives its own local derivative:
The plus-equals matters. If a value is reused by several later nodes, all downstream paths contribute to its total sensitivity. Reverse mode is therefore not symbolic simplification; it is graph-local accumulation of vector-Jacobian products (VJPs): each step multiplies a vector of sensitivities by the transpose of one local Jacobian.
For vector nodes, choose column-vector cotangents. If , , , , and
then the reverse update is
Forward mode runs the other way. It carries a tangent , the change in each node along one chosen input direction, forward with Jacobian-vector products (JVPs). The two directions side by side:
For a scalar loss , one forward evaluation records the needed values, and one reverse sweep gives the full gradient
assuming primitive backward rules are available. The time is a small constant multiple of one evaluation of , whatever is: Baydin et al. (2018), citing Griewank and Walther (2008), give a constant below 6 and typically 2 to 3. The price is memory for saved forward values on a tape, or extra compute if some values are recomputed. An autodiff engine automates this bookkeeping by recording primitive operations during the forward pass and executing their local backward rules in reverse topological order.
These equations assume the recorded primitives are differentiable at the saved forward values. For nonsmooth primitives, an implementation must choose a convention, use a subgradient, or report that the derivative is undefined. If the program has control flow, reverse mode differentiates the branch that actually ran.
Study prompts for this section: Mathematics
Each button copies a prompt about this section to your clipboard, for an AI assistant you already use. Nothing is sent by this site.
Code
The same calculation as runnable code, in the notation of the derivation.
import math
x, y = 2.0, 3.0
# Forward graph:
# a = x * y
# b = sin(a)
# L = a + b
a = x * y
b = math.sin(a)
L = a + b
# Reverse-mode table: each bar_* stores dL/d(node).
# Start with empty cotangent registers, then seed the output.
bar_L = 0.0
bar_a = 0.0
bar_b = 0.0
bar_x = 0.0
bar_y = 0.0
bar_L = 1.0
# Read the tape backward.
# L = a + b sends one unit of sensitivity to both inputs.
bar_a += bar_L * 1.0
bar_b += bar_L * 1.0
# b = sin(a) contributes another path back into a.
bar_a += bar_b * math.cos(a)
# a = x * y sends sensitivity to both inputs.
bar_x += bar_a * y
bar_y += bar_a * x
print("L:", round(L, 4))
print("dL/dx:", round(bar_x, 4))
print("dL/dy:", round(bar_y, 4))
The code initializes every cotangent register and then uses += for local contributions. The reused node receives two contributions: directly through , and indirectly through . With and , the output is approximately , , and .
Study prompts for this section: Code
Each button copies a prompt about this section to your clipboard, for an AI assistant you already use. Nothing is sent by this site.
Demo
Change an input, predict the result, and see which quantities respond.
Explore Reverse-Mode Automatic Differentiation
Observation guide
Optional and ungraded. Opening a guide saves nothing.
Choose what to inspect in Reverse-Mode Automatic Differentiation, then open its guide.
Use the sliders to change and , then compare the three phases.
Forward tape mode records the primitive operations and the saved values that local backward rules will need. Reverse sweep mode reads the same tape backward, starts from , and fills the cotangent registers. Cost shape mode highlights the main reason reverse mode matters for deep learning: when many inputs feed one scalar loss, one reverse sweep gives the whole gradient vector.
The second preset, Product sample, moves and to a different product . The tape is the same, but the two paths into combine differently; predict again before you reveal.
Study prompts for this section: Demo
Each button copies a prompt about this section to your clipboard, for an AI assistant you already use. Nothing is sent by this site.
Concept: Reverse-Mode Automatic Differentiation
What is the smallest example of Reverse-Mode Automatic Differentiation you can work through by hand, and what does it show?
DetailsCalculus
Reference id
concept:calculus/reverse-mode-autodiffAfter the first pass
Go deeper
Optional material for a second reading. Sources are always shown; the other panels open from their headings or from these links, and closing one keeps what you wrote or revealed.What to look for in each sectionChoose a section and what you expect to see in it, then read short advice.
Section by section
Choose what to look for in each section
Reverse-mode autodiff computes gradients by sending sensitivities (cotangents) backward through a computation graph, so one backward pass gives the gradient of a scalar loss.

Start with the picture, metaphor, or geometric mechanism.
Choose what you expect to see in this section of Reverse-Mode Automatic Differentiation.
Questions to ask of the pictureChoose a part of the picture and what you expect, then read short advice.
Looking at the picture
Questions to ask of the picture
Reverse-mode autodiff computes gradients by sending sensitivities (cotangents) backward through a computation graph, so one backward pass gives the gradient of a scalar loss.
Which part of the picture should you look at first?
Pick the part of the picture you expect to explain Reverse-Mode Automatic Differentiation.
Sources
References for this page
A reference shows where an idea comes from; it does not vouch for every step on this page.SIAM. A standard textbook on automatic differentiation, including the reverse mode, its cost bounds and checkpointing.
BIT Numerical Mathematics 16(2), 146–160. With the author's 1970 master's thesis, often cited as the first published description of the reverse mode.
What each claim rests on1 claim, each with its sources, where it appears on this page, and its caveats.
Claims and sources
Reverse-mode autodiff computes gradients by sending sensitivities (cotangents) backward through a computation graph, so one backward pass gives the gradient of a scalar loss.
The checks were made by this site, not by an independent reviewer.
Baydin et al. describe reverse mode as running code forward to populate intermediate variables and record graph dependencies, then propagating adjoints backward. Their example shows incremental adjoint accum...
Checks reverse-mode bookkeeping for one executed differentiable computation: forward tape/saved values, then reverse cotangent sweep with primitive backward rules. Not checkpointing, recomputation, nonsmooth...
Checked Baydin et al. 3.2: reverse mode runs code forward to populate intermediates and record dependencies, then propagates adjoints backward. The example starts from output adjoint 1, accumulates reused-variable cotangents from downstream paths, and gets both input derivatives in one reverse pass. Baydin says for f:R^n->R one reverse application computes the full gradient. The page's equations, code and demo follow these steps: recorded values, seed adjoint 1, += accumulation, VJP/J^T notation and a scalar loss.
Explain it without the pageWrite your own explanation before asking for feedback. Your draft and any hints stay while this page is open.
Practice · Reverse-Mode Automatic Differentiation
Try the idea in your own words
Reverse-mode autodiff computes gradients by sending sensitivities (cotangents) backward through a computation graph, so one backward pass gives the gradient of a scalar loss.
Concept · Selected for practice
Reverse-Mode Automatic Differentiation
What it rests on: Sources: Automatic differentiation in machine learning: a survey; Evaluating Derivatives: Principles and Techniques of Algorithmic Differentiation...
Context and links
Calculus
Explain the mechanism
For Reverse-Mode Automatic Differentiation: What is the smallest example of Reverse-Mode Automatic Differentiation you can work through by hand, and what does it show? Explain your answer, including what changes, why, and which assumption matters.
A rough first thought is enough. Your draft stays when you change tasks.
Your draft stays on this page and is cleared when you leave or reload.
A little help · Explain
Open one hint at a time. These are suggestions, not your answer or a grade.
0 of 3 hints shown for this question.
Clearing your answer keeps this help record. Outside help is your own report; this page cannot check it.
Where am I stuck? (optional)
Take your draft to a feedback conversation
No AI feedback runs here. You can copy a prompt to use elsewhere; nothing is sent automatically. Review the text before sharing, and leave out private information.
Write an attempt before copying a feedback prompt.
A draft, or an AI reply to it, is not a test of what you have learned. To check that, try a different case later without help.
Ask about this pagePick one item on this page and copy a prompt about it into an AI assistant you already use. Notes you write here stay in this browser.
x, y = 2.0, 3.0Your question
Choose what your question is about
Pick the idea, equation, source, code, claim, misconception or demo state you want to ask about. The prompt you copy includes it, so the answer can stay on that item.Open the draft below to save one note and next action in this browser.
Reverse-Mode Automatic Differentiation
What is the smallest example of Reverse-Mode Automatic Differentiation you can work through by hand, and what does it show?
Fixed prompts generated from this item. They are not comments from people or independent reviews.
The 3 cited sources must support this exact item, not just the surrounding topic.
Connect the definition to one equation, piece of code or demo before widening the discussion.
Change one input, then check that the same relationship holds in the mathematics, the code and the demo.
You can state the mechanism in your own words
Local action draftNo local draft saved yetOpen when you are ready to write one next action
This draft stays in this browser and is attached to this item only.
- What the 3 cited sources say about this exact item
- The definition, its prerequisites, and a contrasting concept
- The equation or code that makes the concept concrete
- One demo state that shows what stays the same as the inputs change
- You can state the mechanism in your own words
- You can name the prerequisite that would clear up the confusion
- You can predict how the result changes when one input changes
Reference id
concept/concept-notebook/calculus/reverse-mode-autodiff
concept:calculus/reverse-mode-autodiff