Linear Algebra
15.27 min read

Circuit Model — Nodes, Wires, Functions

To formalize backpropagation, we model computation as a circuit. Data enters on the left as input wires t1,,tnt_1, \ldots, t_n (collected as vector t\mathbf{t}). Values flow left to right. The circuit has a single output wire, and the whole thing computes f(t)f(\mathbf{t}).

A function node takes one or more input wires, applies some scalar function, and outputs a single wire. For example, x=s1s2x = s_1 \cdot s_2, or x=sin(s1)x = \sin(s_1), or x=s1+s2+s3x = s_1 + s_2 + s_3. Each node is named after its output wire (so the node and its output wire share the same name).

A splitter node copies one input wire into two identical output wires. This is needed whenever a value is used in multiple downstream computations. The splitter for input ss with outputs x1,x2x_1, x_2 behaves as x(s)=[s,s]t\mathbf{x}(s) = [s,\, s]^t.

Notice that every function node outputs exactly one scalar. The circuit as a whole also outputs a single scalar f(t)f(\mathbf{t}).

Formal View

Definition 15.2 — Function Node
A function node named xx with input wires s1,,sks_1, \ldots, s_k (vector s\mathbf{s}) computes a scalar output x=x(s)x = x(\mathbf{s}). Both the node and the value on its output wire are called xx.
Definition 15.3 — Splitter Node
A splitter node with input ss produces two identical outputs x1=x2=sx_1 = x_2 = s. In vector form: x(s)=[s,s]t\mathbf{x}(s) = [s,\, s]^t. Splitters let one wire feed multiple downstream nodes.
Remark 15.2 — Notation Overloading
We use the symbol ff for both the full circuit and for "cut circuit" variants. f(t)f(\mathbf{t}) is the original output; f(x,t)f(x, \mathbf{t}) is the circuit with the xx-wire replaced by a free input. The argument list disambiguates.

Why This Matters

Any differentiable computation — loss functions, solvers, renderers — can be expressed as such a circuit, making backprop universally applicable.

  • Neural network layers (linear transform + activation function) as function nodes
  • Differentiable physics simulators expressed as large circuits
  • PyTorch and JAX internally represent computations as circuit DAGs
  • Compiler optimizations that exploit DAG structure

Quiz

Question 1

What does a splitter node do?

Question 2

A function node can produce multiple output values.

Question 3

If t1t_1 feeds into two different downstream nodes, the circuit must contain:

Question 4

Node xx computes x=s12+3s2x = s_1^2 + 3s_2. What type of node is this?

Common Mistakes

  • Forgetting splitter nodes when a value feeds multiple places — every fan-out requires one.
  • Thinking function nodes can return vectors — each outputs exactly one scalar in this model.
  • Confusing the circuit diagram (computation structure) with the graph of ff (input-output shape).