The unifying theme of this course is replacing fixed-depth feed-forward computation with iterative, stateful computation — whether via recurrence, equilibrium solving, adaptive depth, explicit memory, or learned test-time updates — so that models can allocate effort where it is needed.
Start with a rough guess, then repeatedly correct it.
The iteration converges. Next question: how fast?
That local rate is governed by the derivative (or Jacobian) at the fixed point.
Local stability is controlled by $g'(r)$.
Input: a > 0, initial guess x > 0
repeat:
x_next = 0.5 * (x + a / x)
x = x_next
until converged
return x
def sqrt_bisection(x, lo=0.0, hi=None, tol=1e-10, max_iter=80):
if hi is None:
hi = max(1.0, x)
hist = []
for _ in range(max_iter):
mid = 0.5 * (lo + hi)
hist.append(mid)
if abs(mid*mid - x) < tol or (hi - lo) < tol:
break
if mid*mid < x:
lo = mid
else:
hi = mid
return hist
def sqrt_babylonian(x, u0, tol=1e-10, max_iter=20):
u = abs(u0)
hist = [u]
for _ in range(max_iter):
denom = u if abs(u) > 1e-12 else 1e-12
u_next = 0.5 * (u + x / denom)
hist.append(u_next)
if abs(u_next - u) < tol:
break
u = u_next
return hist
Every continuous function from a convex compact set $K$ to itself has a fixed point.
If $T$ is a contraction on a complete metric space, \[d(T(x), T(y)) \le q\,d(x,y),\; 0 \le q < 1\] then there is a unique fixed point $x^*$.
Computability claim: the fixed point is obtained algorithmically by iteration. Start from any $x_0$, apply $x_{n+1}=T(x_n)$, and $x_n\to x^*$.
Practical check (local): in 1D, $|T'(r)|<1$; in higher dimensions, $\left\|J_f(\vec{z}^{\,*})\right\|_2<1$ (or a uniform bound $\left\|J_f(\vec{z})\right\|_2\le q<1$ nearby) gives contraction. For the square-root map, $T'(\sqrt{a})=0$, matching the fast local convergence we observed.
Theorem (IFT, local). Let $F:\mathbb{R}^2\to\mathbb{R}$ be continuously differentiable near $(x_0,y_0)$ and satisfy $F(x_0,y_0)=0$. If $\dfrac{\partial F}{\partial y}(x_0,y_0)\neq 0$, then there exists a neighborhood of $x_0$ and a unique differentiable function $y(x)$ with $y(x_0)=y_0$ such that $F(x,y(x))=0$ for nearby $x$.
Taylor gives the approximation; the constraint gives the equality to zero.
# Algorithm 1: Original RBP
h* = fixed_point_solve(F, x, w_F)
y = G(w_G, h*)
L = loss(y)
g = (∂L/∂y · ∂y/∂h*)ᵀ # ← AD: VJP (seed)
∂L/∂w_F, ∂L/∂x = backward_rbp(g, x, w_F, h*, K, ε)
def backward_rbp(g, x, w_F, h_star, K, ε):
z = 0
for i in 1..K:
z_next = Jᵀ_F|_{h*} @ z + g # ← AD: VJP
if ‖z_next − z‖ < ε:
z = z_next
break
z = z_next
# z is the converged adjoint: z* = ∂L/∂h*
∂L/∂w_F = zᵀ @ ∂F/∂w_F(x, w_F, h*) # ← AD: VJP
∂L/∂x = zᵀ @ ∂F/∂x(x, w_F, h*) # ← AD: VJP (upstream)
return ∂L/∂w_F, ∂L/∂x
# Algorithm 2: Neumann-RBP (K-term)
h* = fixed_point_solve(F, x, w_F)
y = G(w_G, h*)
L = loss(y)
g = (∂L/∂y · ∂y/∂h*)ᵀ # ← AD: VJP (seed)
∂L/∂w_F, ∂L/∂x = backward_neumann(g, x, w_F, h*, K)
def backward_neumann(g, x, w_F, h_star, K):
z = g
v = g
for k in 1..K:
v = Jᵀ_F|_{h*} @ v # ← AD: VJP
z = z + v
∂L/∂w_F = zᵀ @ ∂F/∂w_F(x, w_F, h*) # ← AD: VJP
∂L/∂x = zᵀ @ ∂F/∂x(x, w_F, h*) # ← AD: VJP (upstream)
return ∂L/∂w_F, ∂L/∂x
# DEQ Forward + Backward
# ─── Forward ───
z* = RootFind(g_θ, x, ε_fwd) # g_θ(z) = f_θ(z, x) − z
y = h(z*) # readout
L = loss(y, target)
# ─── Backward ───
g = (∂L/∂z*)ᵀ # ← AD: VJP (seed)
∂L/∂θ, ∂L/∂x = backward_deq(g, x, z*, θ, ε_bwd)
def backward_deq(g, x, z_star, θ, ε_bwd):
p = LinearSolve(Jᵀ_gθ|_{z*}, −g, ε_bwd) # e.g., Broyden
∂L/∂θ = p @ ∂f_θ/∂θ(z*, x) # ← AD: VJP
∂L/∂x = p @ ∂f_θ/∂x(z*, x) # ← AD: VJP (upstream)
return ∂L/∂θ, ∂L/∂x
# Algorithm: Anderson Acceleration (window m)
def anderson(F, z_init, m, K, ε):
z = z_init
Z = []; R = [] # history buffers
for k in 0..K:
r = F(z) − z # residual
if ‖r‖ < ε: break
Z.append(z); R.append(r) # store history
if len(R) > 1:
# solve min_α ‖Σ αᵢ rᵢ‖² s.t. Σ αᵢ = 1
α = least_squares(R[-m:]) # small m×m problem
z = Σ αᵢ F(Z[-m:][i]) # optimal combination
else:
z = F(z) # plain FPI step
return z
def least_squares(R): # R: (N, m) on GPU
v = torch.inverse(R.T @ R) @ ones(m) # (m,) — tiny
return v / v.sum()
| Model | Test Perplexity | Memory |
|---|---|---|
| 18-layer Transformer | baseline | baseline |
| DEQ-Transformer | matches or beats | up to 88% less |
| 70-layer TrellisNet | baseline | baseline |
| DEQ-TrellisNet | matches or beats | far less |
| Comparison | Training | Inference |
|---|---|---|
| DEQ / 18-layer Transformer | 2.82× | 1.76× |
| DEQ / 70-layer TrellisNet | 2.40× | 1.64× |
| RBP | Neumann-RBP | CG-RBP | DEQ (Broyden) | |
|---|---|---|---|---|
| Backward solver | Fixed-point iteration | Truncated Neumann series ($K$ terms) | CG on normal equations | Broyden quasi-Newton |
| Convergence | Linear (depends on $\rho(J)$) | Exact after $K$ terms if $\rho(J)<1$ | Depends on $\kappa$ | Superlinear |
| Runtime | Variable | Fixed ($K$ steps) | Variable | Variable |
| Memory | $O(1)$ | $O(1)$ | $O(1)$ | $O(1)$ + rank-1 history |
| Architecture | RNNs | RNNs | RNNs | Weight-tied feedforward (transformers, TCNs) |
| Risk | Stalls near $\rho \approx 1$ | Truncation bias | Condition squaring | 2–3× wall-clock; growing iter. count |
# Algorithm 1: Reverse-mode derivative of an ODE IVP
def ode_adjoint(θ, t₀, t₁, z_t1, dL_dz_t1):
s₀ = [z_t1, dL_dz_t1, 0_{|θ|}] # augmented state
def aug_dynamics([z(t), a(t), ·], t, θ):
return [f(z(t), t, θ), # original dynamics
-a(t)ᵀ ∂f/∂z, # ← AD: VJP w.r.t. z
-a(t)ᵀ ∂f/∂θ] # ← AD: VJP w.r.t. θ
# Solve augmented ODE backward in time
[z(t₀), ∂L/∂z(t₀), ∂L/∂θ] = ODESolve(s₀, aug_dynamics, t₁, t₀, θ)
return ∂L/∂z(t₀), ∂L/∂θ
| Implicit Models (RBP/DEQ) | Neural ODE | |
|---|---|---|
| Starting point | Repeat a layer/cell until equilibrium | Residual blocks, shrink the step to zero |
| Limit object | Fixed point: $\vec{z}^{\,*} = f(\vec{z}^{\,*}, \vec{x})$ | ODE endpoint: $\vec{z}(t_1) = \vec{z}(t_0) + \int f\, dt$ |
| Forward solver | Fixed-point iter., Root finder | ODE solver (Dormand-Prince, Adams, ...) |
| Backward pass | Implicit diff at equilibrium | Adjoint ODE backwards in time |
| Memory | $O(1)$ in effective depth | $O(1)$ in effective depth |
| Depth | Infinite (converged) | Continuous (solver-chosen) |