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.
A 96-layer Transformer spends the same compute predicting "the" as it does predicting a rare technical term.
"The brain's 'layers' are not a pipeline — they are a recurrent, adaptive, depth-varying computation."
An RNN that applies the same transition function multiple times per input, with a learned halting probability at each "ponder" step.
Deterministic + differentiable: no sampling, no REINFORCE — just a sigmoid and an accumulator.
The network doesn't just decide when to stop — it interpolates over its intermediate states.
The halting weights $p_t^n$ sum to 1 by construction.
def ACT_step(x_t, s_prev, W_h, b_h, τ_max):
"""One time step of an ACT-augmented RNN."""
H = 0.0 # cumulative halting probability
s_bar = 0 # weighted output state
n = 0
while H < 1 - ε:
n += 1
s_n = RNN_cell(x_t, s_prev if n == 1 else s_n)
h_n = σ(W_h @ s_n + b_h) # halting probability
if H + h_n ≥ 1 - ε or n == τ_max: # halt
R = 1 - H # remainder
s_bar += R * s_n
break
else:
H += h_n
s_bar += h_n * s_n
ponder_cost = n + R # for the loss penalty
return s_bar, ponder_cost
But first: what happens when we transplant ACT into the Transformer?
A theoretical advantage, not always a practical one — but it means UTs can in principle generalize to arbitrary-length inputs, while standard Transformers cannot.
The win is primarily on generalization beyond training distribution — exactly what adaptive depth promises.
Same spirit, different mechanism. Both break fixed-depth — RBP via convergence, UT via learned halting.
Fix the total compute budget. Let the network learn which tokens pass through each layer.
"The compute budget is fixed, but its allocation is learned."
| ACT | Universal Transformer | Depth-Adaptive | Mixture-of-Depths | |
|---|---|---|---|---|
| Base arch. | RNN | Transformer | Transformer | Transformer |
| Shared layers? | Yes (RNN cell) | Yes | No | No |
| Compute budget | Variable (+ τ) | Variable (+ τ) | Variable (exit) | Fixed (top-k) |
| Decision type | Halting prob. | Halting prob. | Exit classifier | Router score |
| Granularity | Per time step | Per position | Per token/seq | Per layer × token |
| Differentiable? | Yes | Yes | Yes | Yes (STE) |
All three break the fixed-depth paradigm — each with a different tradeoff between guarantees, control, and efficiency.