Bring the mental model from Computation Graphs; this page will reuse it instead of restarting from zero.
Reverse-Mode Automatic Differentiation
Reverse-mode autodiff computes gradients by sending cotangents backward through a computation graph.
01
Intuition
Build the mental picture first so the rest of the page has something to attach to.
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 key advantage is shape. 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 cotangents such as aˉ and xˉ. 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.
Copy-only prompts — each action copies a page-grounded prompt to your clipboard. Nothing is sent by this site.
02
Math
Translate the story into symbols, assumptions, and a derivation you can inspect.
Let a differentiable computation graph produce a scalar output L from intermediate variables v1,…,vn. 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 vj=f(vi), the chain rule sends sensitivity backward. When the operation producing vj is processed, vˉj already contains all downstream contributions:
For an operation with multiple inputs, such as vj=f(u,w), 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.
For vector nodes, choose column-vector cotangents. If vi∈Rn, vj=f(vi)∈Rm, vˉi∈Rn, vˉj∈Rm, and
then the reverse update is
This is the direction contrast:
For a scalar loss L:Rp→R, one forward evaluation records the needed values, and one reverse sweep gives the full gradient
assuming primitive backward rules are available. The cost 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.
Copy-only prompts — each action copies a page-grounded prompt to your clipboard. Nothing is sent by this site.
03
Code
Keep the implementation aligned with the notation so the algorithm is legible.
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 a receives two contributions: directly through L=a+b, and indirectly through b=sin(a). With x=2 and y=3, the output is approximately L=5.7206, ∂L/∂x=5.8805, and ∂L/∂y=3.9203.
Copy-only prompts — each action copies a page-grounded prompt to your clipboard. Nothing is sent by this site.
04
Interactive Demo
Use direct manipulation to connect the explanation to a moving system.
Live Concept Demo
Explore Reverse-Mode Automatic Differentiation
The stage is code-native and interactive. Use it to test the explanation against the mechanism.
Manipulate one control and predict the visible change.
Choose what to inspect in Reverse-Mode Automatic Differentiation. This shared fallback is an observation guide, not evidence of learning.
Use the sliders to change x and y, 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 Lˉ=1, 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.
Try the second preset after making a prediction. It changes the product regime so the same tape can expose a different cotangent-accumulation pattern.
Copy-only prompts — each action copies a page-grounded prompt to your clipboard. Nothing is sent by this site.
Concept: Reverse-Mode Automatic Differentiation
What is the smallest example that makes Reverse-Mode Automatic Differentiation click without losing the math?
Object contextCalculus
concept:calculus/reverse-mode-autodiffReverse-Mode Automatic Differentiation
What is the smallest example that makes Reverse-Mode Automatic Differentiation click without losing the math?
Start with the prediction checkpoint, then compare the reveal to the mental model.
Take this moveStudy modes
Keep the object fixed; change the lens.Route back through the notebook
Carry the same object through intuition, math, code, and demo.
Reverse-mode autodiff computes gradients by sending cotangents backward through a computation graph.
The next edge should feel earned: use the demo prediction here before following Backpropagation.
After The First Pass
Turn the concept into an inspected object.
The lower panels are one second act: keep the object fixed, inspect it visually, check source boundaries, practice transfer, then attach the research question.Mechanism Storyboard
See the idea move before the page explains it
Reverse-mode autodiff computes gradients by sending cotangents backward through a computation graph.

Start with the picture, metaphor, or geometric mechanism.
Before reading further, choose the kind of change Reverse-Mode Automatic Differentiation should make visible.
Visual Inquiry
Make the image answer a mathematical question
Reverse-mode autodiff computes gradients by sending cotangents backward through a computation graph.
Which visible object should carry the first intuition?
Pick the cue that should make Reverse-Mode Automatic Differentiation easier to reason about before the page gives the answer.
Source Grounding
Canonical references for the mechanism on this page.
What is the smallest example that makes Reverse-Mode Automatic Differentiation click without losing the math?
concept:calculus/reverse-mode-autodiffsources: baydin-2018-ad-survey
Open the closest source note before trusting the local explanation.
1 selected-object source shown first; 1 reference total.
Audit the claim boundary, then ask from the same selected object.
Grounds reverse mode as the efficient way to compute gradients of scalar losses with many parameters.
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 incre...
Checks reverse-mode bookkeeping for one executed differentiable computation: forward tape/saved values, then reverse cotangent sweep with primitive backward rules. Not checkpointing, reco...
Claim Review
Reverse-mode autodiff computes gradients by sending cotangents backward through a computation graph.
What is the smallest example that makes Reverse-Mode Automatic Differentiation click without losing the math?
concept:calculus/reverse-mode-autodiffsources: baydin-2018-ad-survey
Treat every claim as provisional until source support and a local witness agree.
1 structured claim check on this concept.
Run the prediction or practice transfer before asking for a grounded review.
Publisher-side editorial review is not independent replication. Claims without it still need exact source-support review. 1 reference and 3 local witnesses are available for inspection.
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. Local witnesses match tape values, bar L=1, += pullbacks, VJP/J^T notation, and scalar-loss shape.
Reviewer: codex+oracle; reviewed 2026-05-07Practice notebook
Use the idea, then test it somewhere new
Reverse-mode autodiff computes gradients by sending cotangents backward through a computation graph.
What is the smallest example that makes Reverse-Mode Automatic Differentiation click without losing the math?
concept:calculus/reverse-mode-autodiffsources: baydin-2018-ad-survey
Use one state from Reverse-Mode Automatic Differentiation to explain what changes, why it changes, and which assumption the explanation needs.
No learner move yet; no learning state is inferred.
Write first, use only the help you need, then try a new case without it.
Use one state from Reverse-Mode Automatic Differentiation to explain what changes, why it changes, and which assumption the explanation needs.
Reveal when your model needs a nudge.
Reveal when your model needs a nudge.
Reveal when your model needs a nudge.
Write an attempt before asking the companion.
0 of 3 progressive hints opened.
This draft and any AI response do not establish mastery; a later unassisted case can.
- ObjectConceptReverse-Mode Automatic Differentiation
- PredictBefore revealReverse-Mode Automatic Differentiation prediction
- WitnessCompare codeReverse-Mode Automatic Differentiation code witness 1
- RoomAsk groundedChecking local snapshot
Research Room
Attach the question to an exact object
Pick the concept, equation, source, code witness, claim, misconception, or demo state before asking for help. The handoff stays grounded to that object.Open the draft below to save one note and next action in this browser.
Reverse-Mode Automatic Differentiation
What is the smallest example that makes Reverse-Mode Automatic Differentiation click without losing the math?
These are fixed, deterministic perspectives derived from the selected object. They do not represent people, community contributions, or independent review.
Source ids baydin-2018-ad-survey must support the exact object, not just the surrounding topic.
Treat this as a mechanism object: connect the definition to one equation, code witness, or demo before broadening the discussion.
Ask the learner to perturb one representation, then check whether the same invariant survives in math, code, and demo.
The learner can state the mechanism in their own words
Local action draftNo local draft saved yetExpand only when ready to capture one local next action
This draft stays locally in this browser for concept:calculus/reverse-mode-autodiff.
- Source ids to inspect: baydin-2018-ad-survey
- Definition, prerequisite, and contrast concept links
- The equation or code witness that makes the concept operational
- One demo state that shows the invariant instead of a slogan
- The learner can state the mechanism in their own words
- The learner can name the prerequisite that would repair confusion
- The learner can predict how the mechanism changes under one perturbation
I am working in Continuous Function's research reading room. Object: concept - Reverse-Mode Automatic Differentiation Object key: concept:calculus/reverse-mode-autodiff Context: Calculus Anchor id: concept/concept-notebook/calculus/reverse-mode-autodiff Open question: What is the smallest example that makes Reverse-Mode Automatic Differentiation click without losing the math? Evidence to inspect: - Source ids to inspect: baydin-2018-ad-survey - Definition, prerequisite, and contrast concept links - The equation or code witness that makes the concept operational - One demo state that shows the invariant instead of a slogan Deterministic role lenses for this object: - Boundary: fixed perspectives, not people, community contributions, or independent review - Source-checking summary: Treat this as a mechanism object: connect the definition to one equation, code witness, or demo before broadening the discussion. - Proposed experiment: Ask the learner to perturb one representation, then check whether the same invariant survives in math, code, and demo. - Teach/transfer move: Turn the mechanism into one sentence that predicts a neighboring concept. - Assumptions: - Source ids baydin-2018-ad-survey must support the exact object, not just the surrounding topic. - The stable content-object key lets local drafts, prompts, and route memory attach without changing the source page. - The concept explanation is local atlas prose until checked against its math, code, and source support. - Prerequisite gaps should become a repair route, not a reason to leave the object vague. - Role-lens requests: - Learner: ask for "Ask what would make "Reverse-Mode Automatic Differentiation" feel predictable rather than familiar." | assumption: Source ids baydin-2018-ad-survey must support the exact object, not just the surrounding topic. | next action: The learner can state the mechanism in their own words - Researcher: ask for "Source ids to inspect: baydin-2018-ad-survey" | assumption: The stable content-object key lets local drafts, prompts, and route memory attach without changing the source page. | next action: The learner can name the prerequisite that would repair confusion - Experimenter: ask for "Choose one variable or condition to perturb before asking for an explanation." | assumption: The concept explanation is local atlas prose until checked against its math, code, and source support. | next action: The learner can predict how the mechanism changes under one perturbation - Professor: ask for "Find the smallest transferable rule a learner could reuse without the AI." | assumption: Prerequisite gaps should become a repair route, not a reason to leave the object vague. | next action: Teach or transfer: Turn the mechanism into one sentence that predicts a neighboring concept. What would resolve this: - The learner can state the mechanism in their own words - The learner can name the prerequisite that would repair confusion - The learner can predict how the mechanism changes under one perturbation Answer as a careful research tutor: stay source-grounded, separate verified evidence from assumptions, name the relevant math objects, and end with one next action. Current deterministic role lens for this object: - Role lens: Learner - Evidence request: Ask what would make "Reverse-Mode Automatic Differentiation" feel predictable rather than familiar. - Assumption to keep visible: Source ids baydin-2018-ad-survey must support the exact object, not just the surrounding topic. - Proposed experiment: Ask the learner to perturb one representation, then check whether the same invariant survives in math, code, and demo. - Next action: The learner can state the mechanism in their own words
concept/concept-notebook/calculus/reverse-mode-autodiff
concept:calculus/reverse-mode-autodiff