Weight Tying and Recurrent Depth: Hidden State Iteration and Fixed-Point Solving
This article examines recurrent depth architectures that reuse a single set of core block weights across multiple steps. It explains why naive weight sharing tends to collapse or diverge, then walks through input injection, the fixed-point view of representation dynamics, stability techniques such as spectral normalization and learnable step size, truncated backpropagation for memory control, and practical guidance on choosing the number of steps.
A Question Raised During an Architecture Review
During a weekly meeting about a newly released model architecture, the lead looked at the structure diagram and quickly reached a verdict: so-called recurrent depth is nothing more than reusing the same layer weights over and over, trading inference time for model depth. That intuition is common, and it treats “parameter sharing” and “depth extension” as the same thing. After the meeting I rederived the whole thing from scratch and reached the opposite conclusion: with naive weight reuse alone, the hidden state usually collapses to a constant within a few steps, or the values diverge. What actually makes recurrence work is treating the inference process as a dynamical system over a feature space, combined with fixed-point solving and numerical stabilization.
The discussion below follows four threads: forward mechanism, representation dynamics, gradients and memory, and engineering practice.
1. Forward Computation: From Stacked Projections to Hidden State Iteration
In a standard decoder-only model, every layer owns independent parameters, and the output of layer l is determined by the hidden state of layer l-1, forming a cascade of projections across parameter subspaces. The hard constraint is that capacity is tightly bound to compute: increasing effective depth means increasing parameters and memory at the same time.
Recurrent structures break that binding. Only one set of core block parameters is kept (typically containing multi-head self-attention and a feed-forward network), and the same operator is called repeatedly for t = 1..T steps to update the hidden state. The naive form ht = F(h{t-1}) loses the original input information, so input injection is needed:
h_0 = Embedding(x)h_t = h_0 + G(h_{t-1}), t = 1..Ty = Norm(h_T)
Here G contains Pre-Norm, attention, and the feed-forward network. h_0 acts as a boundary condition and an anchor: throughout the repeated refinement, the operator keeps making residual updates around the original token semantics, avoiding drift away from the input manifold. In practice, the injection strength can also decay with the step count, strong anchoring early and weak anchoring later, balancing stability and expressiveness.
2. Representation Dynamics: The Fixed-Point View and Inference Depth
Writing the iteration as ht = h_0 + G(h{t-1}), its fixed point satisfies h = h_0 + G(h). When G is approximately contractive near h* (Lipschitz constant below 1), the iteration converges to a unique solution, and the number of inference steps T is effectively the solving precision: larger T yields a finer solution. This explains why complex reasoning tasks can approach higher-order logical solutions by adding steps, while simple tasks need fewer steps, forming a dynamic allocation of the compute budget.
Contractiveness, however, does not hold automatically. If the spectral radius of G is too large, the iteration diverges; if the output of G is insensitive to its input, the iteration collapses quickly. Common stabilization measures include spectral normalization or weight normalization on G, a learnable step size α on the residual branch (ht = h_0 + α·G(h{t-1})), using LayerNorm to control scale, and, when necessary, Anderson acceleration or steepest-descent-style corrections to speed up convergence.
3. Gradient Truncation and Memory Overhead
If backpropagation unrolls all T steps, memory and compute grow linearly with T, and long chains of multiplications easily cause vanishing or exploding gradients. In practice, truncated backpropagation is common: detach the hidden state every K steps, cutting the long chain into several short ones; or use stochastic depth, randomly dropping some iteration steps during training and adding steps back as needed at inference. This keeps peak memory under control while preserving an approximate gradient signal across steps.
A sketch of the training loop:
h = embed(x)for t in range(T):h = h0 + alpha * block(h) # input injection + residual updateif (t + 1) % K == 0:h = h.detach() # truncated backprop, release the graphlogits = norm(h) @ W_out
Practical points: too small a K weakens long-range dependencies, while too large a K strains memory; α can be initialized to a small value and gradually increased; signs of divergence can be monitored via the hidden state norm and the step-to-step difference ‖ht − h{t-1}‖, which can serve as a basis for early stopping or adaptive step counts.
4. Deployment Advice and Common Pitfalls
- Pitfall 1: recurrence equals free depth. Parameters are shared, but FLOPs and memory still grow with the step count, so cost control needs techniques such as distillation, quantization, and cache reuse.
- Pitfall 2: more steps are always better. Beyond the steps required for convergence, returns diminish and numerical noise can even make results worse, so a step-versus-accuracy curve should be evaluated.
- Pitfall 3: ignoring input injection. Naive iteration without an anchor collapses or diverges very easily; injection is the key to stability.
- Deployment path: first validate contractiveness and convergence on a small model, then introduce truncated backpropagation and adaptive step counts, and finally allocate T dynamically by task difficulty on the inference side.
Summary: the essence of recurrent depth is not simple reuse that “trades space for time,” but iterative refinement of feature representations from a dynamical systems perspective under a fixed parameter budget, obtaining adjustable inference depth through fixed-point solving. Understanding how hidden state iteration, input injection, and gradient truncation couple together is what makes this structure usable and reliable.
