Deep Equilibrium Models: How Implicit Layers and Root-Finding Eliminate Activation Memory in Deep Learning

Deep Equilibrium Models: How Implicit Layers and Root-Finding Eliminate Activation Memory in Deep Learning Deep neural networks derive their expressive capacity from composition. In conventional architectures, depth is explicit: an input vector is transformed sequentially through a chain of $L$ discrete layers, each parameterized by dedicated weights. While effective, this paradigm creates a fundamental computational dependency where training memory scales linearly with network depth ($O(L)$) b

9 min
Deep Equilibrium Models: How Implicit Layers and Root-Finding Eliminate Activation Memory in Deep Learning

Deep Equilibrium Models: How Implicit Layers and Root-Finding Eliminate Activation Memory in Deep Learning

Deep neural networks derive their expressive capacity from composition. In conventional architectures, depth is explicit: an input vector is transformed sequentially through a chain of LL discrete layers, each parameterized by dedicated weights. While effective, this paradigm creates a fundamental computational dependency where training memory scales linearly with network depth (O(L)O(L)) because standard backpropagation requires caching intermediate activations across every layer.

Deep Equilibrium Models (DEQs), introduced by Bai, Kolter, and Koltun (2019), present an alternative formulation known as implicit deep learning. Instead of stacking discrete layers, a DEQ formulates the forward pass as finding the fixed-point equilibrium of a single non-linear transformation. By decoupling the definition of a model's state from the algorithmic process used to compute it, DEQs compute exact analytical gradients via the Implicit Function Theorem (IFT). This mechanism eliminates intermediate activation caching entirely, enabling constant O(1)O(1) memory consumption regardless of effective receptive field or representation depth.

Deep Equilibrium Models Mechanism

1. The Mathematical Limitation of Explicit Depth

In a standard feedforward neural network or stacked Transformer, the hidden representations evolve according to a discrete recurrence relation:

zi+1=fθi(zi,x)z_{i+1} = f_{\theta_i}(z_i, x)

where xx represents the input context, ziRdz_i \in \mathbb{R}^d denotes the feature representation at layer ii, and θi\theta_i represents layer-specific parameters.

When training via backpropagation, the loss gradient with respect to parameter tensor θi\theta_i depends directly on the activation tensor ziz_i:

Lθi=Lzi+1fθi(zi,x)θi\frac{\partial \mathcal{L}}{\partial \theta_i} = \frac{\partial \mathcal{L}}{\partial z_{i+1}} \frac{\partial f_{\theta_i}(z_i, x)}{\partial \theta_i}

To compute this product during the reverse pass, the automatic differentiation engine must retain {z0,z1,,zL}\{z_0, z_1, \dots, z_L\} in GPU High Bandwidth Memory (HBM). For modern sequence models operating at long context lengths, activation memory dwarfs parameter memory, necessitating engineering mitigations such as activation checkpointing, sequence parallelism, and offloading.

Weight-Tied Limits and Fixed-Point Convergence

Empirical research in weight-tied models—such as ALBERT (Lan et al., 2019) and TrellisNet (Bai et al., 2019)—demonstrated that repeatedly applying the same layer transformation causes hidden activations to stabilize:

zi+1zias iz_{i+1} \approx z_i \quad \text{as } i \to \infty

Deep Equilibrium Models formalize this stationary behavior mathematically. Rather than computing an arbitrary number of discrete steps, a DEQ defines the network output directly as the infinite-depth equilibrium state zz^\star:

z=fθ(z,x)z^\star = f_\theta(z^\star, x)

Under this formulation, the model does not specify how many layers to execute; it specifies the equilibrium conditions that the final representation must satisfy.


2. Forward Pass: Root-Finding in Non-Linear Vector Fields

Computing the forward activation of a DEQ requires finding a state vector zz^\star that satisfies the fixed-point equation. This can be framed equivalently as finding the root of an objective residual function gθg_\theta:

gθ(z;x)=fθ(z,x)z=0g_\theta(z; x) = f_\theta(z, x) - z = 0

+-------------------------------------------------------------+
|                     DEQ Forward Pass                        |
|                                                             |
|  Input x ────> [ Root-Finding Algorithm ] ────> Output z*   |
|                      ▲               │                      |
|                      │   Iterative   │                      |
|                      └── Update ◄────┘                      |
|             (Broyden / Anderson Acceleration)               |
|                                                             |
|         Satisfies:  g_θ(z*; x) = f_θ(z*; x) - z* = 0        |
+-------------------------------------------------------------+

Limitations of Picard Iteration

The simplest approach to finding zz^\star is Picard fixed-point iteration (repeated forward evaluation):

z(k+1)=fθ(z(k),x)z^{(k+1)} = f_\theta(z^{(k)}, x)

By the Banach Fixed-Point Theorem, Picard iteration is guaranteed to converge to a unique fixed point if fθf_\theta is a strict contraction mapping (its Lipschitz constant Lip(fθ)<1\text{Lip}(f_\theta) < 1). However, enforcing strict contraction constraints restricts parameter expressivity. Furthermore, Picard iteration exhibits linear convergence rates, often requiring dozens of iterations to reach numerical tolerance.

Quasi-Newton Solvers: Broyden's Method and Anderson Acceleration

To achieve practical efficiency, DEQs decouple the model architecture from the numerical solver. Production DEQ implementations employ accelerated root-finding algorithms:

  1. Broyden's Method (Broyden, 1965): A quasi-Newton technique that iteratively updates a low-rank approximation of the inverse Jacobian Bk(gθz)1B_k \approx \left(\frac{\partial g_\theta}{\partial z}\right)^{-1}. Using the Sherman-Morrison formula, Broyden's method achieves superlinear convergence without computing or factorizing the full d×dd \times d Jacobian matrix:

Δzk=Bkgθ(zk)\Delta z_k = -B_k g_\theta(z_k) zk+1=zk+Δzkz_{k+1} = z_k + \Delta z_k Bk+1=Bk+ΔzkBkΔgkΔzkBkΔgkΔzkBkB_{k+1} = B_k + \frac{\Delta z_k - B_k \Delta g_k}{\Delta z_k^\top B_k \Delta g_k} \Delta z_k^\top B_k

  1. Anderson Acceleration (Anderson, 1965): Computes zk+1z_{k+1} as an optimal linear combination of the previous mm iterates {zkm,,zk}\{z_{k-m}, \dots, z_k\} that minimizes the norm of the linear residual, accelerating convergence in multi-dimensional vector spaces.

Because forward evaluation is treated as a black-box numerical search, the forward solver operates entirely under torch.no_grad(). Intermediate solver states are discarded immediately after convergence.


3. Backward Pass: Implicit Differentiation via the Implicit Function Theorem

If training a DEQ required unrolling the numerical root-finder and backpropagating through time (BPTT), the memory footprint would scale linearly with solver iterations (O(K)O(K)), negating the efficiency benefits of the implicit formulation.

DEQs resolve this by deriving analytical gradients directly at the equilibrium point using the Implicit Function Theorem (IFT) (Krantz & Parks, 2002).

+-------------------------------------------------------------+
|                     DEQ Backward Pass                       |
|                                                             |
|  Loss Gradient ∂L/∂z* ───> [ Linear Solver ] ───> Vector v  |
|                                                             |
|             Solves:  v^T = v^T (∂f_θ/∂z*) + ∂L/∂z*          |
|                                                             |
|                                                             |
|  Parameter Update:                                          |
|  ∂L/∂θ = v^T (∂f_θ(z*, x)/∂θ)                               |
|                                                             |
|  Activation Memory Stored: O(1) (Only z* and x retained)    |
+-------------------------------------------------------------+

Derivation of Equilibrium Gradients

Let z(θ)z^\star(\theta) denote the implicit function mapping parameters θ\theta to the unique equilibrium point satisfying gθ(z,x)=0g_\theta(z^\star, x) = 0. Differentiating both sides of the identity fθ(z(θ),x)z(θ)=0f_\theta(z^\star(\theta), x) - z^\star(\theta) = 0 with respect to θ\theta via the multivariate chain rule yields:

fθ(z,x)zdzdθ+fθ(z,x)θdzdθ=0\frac{\partial f_\theta(z^\star, x)}{\partial z^\star} \frac{d z^\star}{d \theta} + \frac{\partial f_\theta(z^\star, x)}{\partial \theta} - \frac{d z^\star}{d \theta} = 0

Factoring out the total derivative dzdθ\frac{d z^\star}{d \theta}:

(Ifθ(z,x)z)dzdθ=fθ(z,x)θ\left( I - \frac{\partial f_\theta(z^\star, x)}{\partial z^\star} \right) \frac{d z^\star}{d \theta} = \frac{\partial f_\theta(z^\star, x)}{\partial \theta}

Assuming the Jacobian matrix (Ifθ(z,x)z)\left( I - \frac{\partial f_\theta(z^\star, x)}{\partial z^\star} \right) is non-singular, inverting yields:

dzdθ=(Ifθ(z,x)z)1fθ(z,x)θ\frac{d z^\star}{d \theta} = \left( I - \frac{\partial f_\theta(z^\star, x)}{\partial z^\star} \right)^{-1} \frac{\partial f_\theta(z^\star, x)}{\partial \theta}

The Adjoint Fixed-Point System

For a scalar loss function L(z)\mathcal{L}(z^\star), applying the chain rule gives the total gradient:

Lθ=Lzdzdθ=Lz(Ifθ(z,x)z)1vfθ(z,x)θ\frac{\partial \mathcal{L}}{\partial \theta} = \frac{\partial \mathcal{L}}{\partial z^\star} \frac{d z^\star}{d \theta} = \underbrace{\frac{\partial \mathcal{L}}{\partial z^\star} \left( I - \frac{\partial f_\theta(z^\star, x)}{\partial z^\star} \right)^{-1}}_{v^\top} \frac{\partial f_\theta(z^\star, x)}{\partial \theta}

Computing the matrix inverse explicitly is computationally intractable (O(d3)O(d^3)). Instead, DEQs define the adjoint vector vv^\top:

v=Lz(Ifθ(z,x)z)1v^\top = \frac{\partial \mathcal{L}}{\partial z^\star} \left( I - \frac{\partial f_\theta(z^\star, x)}{\partial z^\star} \right)^{-1}

Multiplying both sides by (Ifθ(z,x)z)\left( I - \frac{\partial f_\theta(z^\star, x)}{\partial z^\star} \right) and rearranging terms yields a linear fixed-point system:

v=vfθ(z,x)z+Lzv^\top = v^\top \frac{\partial f_\theta(z^\star, x)}{\partial z^\star} + \frac{\partial \mathcal{L}}{\partial z^\star}

This equation is a linear system of the exact same form as the forward pass. It can be solved iteratively for vv using Broyden's method, GMRES, or Richardson iteration. Crucially, evaluating vfθzv^\top \frac{\partial f_\theta}{\partial z^\star} requires only a single vector-Jacobian product (VJP), which standard autodiff frameworks evaluate in O(d)O(d) time via backward automatic differentiation through a single layer evaluation at zz^\star.

Once vv is computed, the final parameter gradient is obtained by backpropagating vv through fθ(z,x)f_\theta(z^\star, x):

Lθ=vfθ(z,x)θ\frac{\partial \mathcal{L}}{\partial \theta} = v^\top \frac{\partial f_\theta(z^\star, x)}{\partial \theta}

Because this calculation requires only the converged state zz^\star, the input xx, and the model parameters θ\theta, memory consumption during training is strictly O(1)O(1).


4. Architectural Paradigms: Vision and Sequence Modeling

The implicit formulation extends beyond single-layer vector representations to complex multi-dimensional modalities.

Explicit Layered Network:
Input ──> [ Layer 1 ] ──> [ Layer 2 ] ──> ... ──> [ Layer L ] ──> Output
Act Mem:     z_1             z_2                     z_L          Total: O(L)

Deep Equilibrium Network:
Input x ──┐
          ▼
   ┌─> [ Non-Linear Transformation f_θ ] ──┐
   │                 ▲                     │
   │                 └─────────────────────┘
   │               Iterative Convergence
   └────────────────> Equilibrium State z* ──> Output
Act Mem:                     z* only                              Total: O(1)

Multiscale Deep Equilibrium Models (MDEQ)

In computer vision tasks such as semantic segmentation and object detection, explicit networks (e.g., HRNet, U-Net) maintain feature representations at multiple spatial resolutions simultaneously.

Bai et al. (2020) extended DEQs to multi-scale feature hierarchies by formulating the equilibrium state as a tuple of feature maps at varying spatial resolutions:

z=(z(1),z(2),z(3),z(4))\mathbf{z}^\star = \left( z^{(1)\star}, z^{(2)\star}, z^{(3)\star}, z^{(4)\star} \right)

where z(i)z^{(i)} represents feature maps downsampled by 2i12^{i-1}. The transformation function fθf_\theta executes intra-resolution residual convolutions and inter-resolution cross-scale message passing. Solving for the joint equilibrium z=fθ(z,x)\mathbf{z}^\star = f_\theta(\mathbf{z}^\star, x) forces all resolution scales to reach simultaneous consistency, matching state-of-the-art vision backbones while consuming a fraction of activation memory.

Equilibrium Transformers (MDEQ-Transformer)

Standard Transformers stack NN self-attention and feed-forward network (FFN) blocks. Bai et al. (2021) formulated the Equilibrium Transformer, where sequence representations converge under an equilibrium multi-head self-attention layer:

z=LayerNorm(FFN(SelfAttn(z))+x)z^\star = \text{LayerNorm}\left( \text{FFN}(\text{SelfAttn}(z^\star)) + x \right)

By driving self-attention updates to fixed points, Equilibrium Transformers capture deep contextual dependencies across long sequence horizons without instantiating multi-layer KV-cache checkpoints during training.

Monotone Operator Equilibrium Networks (MonDEQ)

A theoretical vulnerability of unconstrained DEQs is that a fixed point is not mathematically guaranteed to exist or remain unique for arbitrary parameter configurations.

To guarantee well-posedness, Winston and Kolter (2020) introduced MonDEQ, parameterizing fθf_\theta via strongly monotone operators. By structuring the layer Jacobian to satisfy a negative definite constraint:

uv,fθ(u)fθ(v)muv2(m>0)\langle u - v, f_\theta(u) - f_\theta(v) \rangle \le -m \|u - v\|^2 \quad (m > 0)

MonDEQ guarantees that the root-finding problem possesses a unique, globally stable equilibrium that can be found via forward-backward operator splitting (e.g., Peaceman-Rachford or Douglas-Rachford splitting) without numerical divergence.


5. Architectural Comparison

Explicit Deep Networks (ResNets / Standard Transformers)

  • Mathematical Formulation: Discrete layer composition: zi+1=fθi(zi,x)z_{i+1} = f_{\theta_i}(z_i, x) across LL physical layers.
  • Depth Parameterization: Explicit integer depth LL fixed prior to training and inference.
  • Training Memory Complexity: O(L)O(L) scaling linearly with layer count, requiring intermediate activation retention for backpropagation.
  • Backward Pass Mechanism: Standard reverse-mode automatic differentiation (Backpropagation Through Time) unrolled across all LL layers.
  • Inference Execution: Fixed deterministic computation requiring exactly LL sequential layer evaluations.

Neural Ordinary Differential Equations (Neural ODEs)

  • Mathematical Formulation: Continuous parameterization: dz(t)dt=fθ(z(t),t)\frac{dz(t)}{dt} = f_\theta(z(t), t) over continuous depth t[t0,t1]t \in [t_0, t_1].
  • Depth Parameterization: Continuous integration time horizon.
  • Training Memory Complexity: O(1)O(1) memory achieved via the continuous Adjoint Sensitivity Method integrating backward in time.
  • Backward Pass Mechanism: Reverse-time numerical integration of the joint adjoint state differential equation.
  • Inference Execution: Adaptive step size numerical ODE solvers (such as Dormand-Prince / RK45).

Deep Equilibrium Models (DEQs)

  • Mathematical Formulation: Non-linear root-finding: finding equilibrium state zz^\star satisfying z=fθ(z,x)z^\star = f_\theta(z^\star, x).
  • Depth Parameterization: Implicit infinite depth (LL \to \infty) defined by stationary fixed-point convergence.
  • Training Memory Complexity: O(1)O(1) constant memory via the Implicit Function Theorem, retaining only input xx and equilibrium state zz^\star.
  • Backward Pass Mechanism: Direct linear fixed-point solver: $v^\top = v^\top \left(\frac{\partial f_\theta}{\partial z^\star}\right) + \frac{\partial \mathcal{L}}{\partial z^\star}$.
  • Inference Execution: Accelerated quasi-Newton root-finding (Broyden's method or Anderson acceleration) until fθ(z,x)z<ϵ\|f_\theta(z, x) - z\| < \epsilon.

6. Engineering Challenges and Practical Bottlenecks

While DEQs resolve the activation memory bottleneck, deploying implicit models in production environments introduces distinct engineering trade-offs:

  1. Computational Overhead (Compute vs. Memory Trade-Off): While explicit models evaluate a layer exactly once, DEQ root-finding typically requires 15 to 35 solver iterations during the forward pass and 10 to 20 iterations during the backward adjoint solve. On compute-bound workloads, DEQs run 2x to 4x slower than equivalent-parameter explicit networks.
  2. Jacobian Conditioning and Spectral Norm Drift: If the Jacobian matrix fθz\frac{\partial f_\theta}{\partial z^\star} develops eigenvalues with magnitude λ1|\lambda| \ge 1, the linear system (IJ)(I - J) becomes ill-conditioned, leading to numerical divergence in Broyden's solver. Mitigating this requires explicit Jacobian regularization (Geng et al., 2021), penalizing the Frobenius norm JfF\|J_f\|_F or applying weight normalization to constrain the spectral radius ρ(Jf)<1\rho(J_f) < 1.
  3. Hardware Vectorization and Dynamic Halting: In batched GPU inference, different batch items converge to numerical tolerance in different numbers of iterations. Naive batching forces all samples to wait for the slowest converging sample (the tail-latency problem). Efficient deployment requires asynchronous execution kernels or fixed-iteration warm-starting.

Summary

Deep Equilibrium Models demonstrate that architectural depth does not require stacking discrete physical layers. By reframing feature extraction as numerical root-finding and computing gradients via the Implicit Function Theorem, DEQs achieve the representational capacity of infinite-depth networks with constant O(1)O(1) activation memory. As memory bandwidth remains a primary constraint in large-scale machine learning hardware, implicit formulations offer a mathematically rigorous path toward training ultra-deep architectures within fixed hardware budgets.


Sources

Written by

More to read

  • Linus Torvalds Credits AI in Linux Kernel Commit After 24-Patch Driver Debug Session

    In a notable public milestone for AI-assisted systems programming, Linux creator Linus Torvalds credited an artificial intelligence model with doing the heavy analytical work during an intensive driver debugging session, allowing the model to author the commit message merged into the upstream kernel. The commit, titled drm/xe: Don't hand out the flat CCS storage as usable VRAM (commit 818bebeb63dd6bf5f4e07e145f6cdbace520a34c), resolves a memory allocation bug in the Intel Xe Direct Rendering Ma

    1 min
  • SGLang v0.5.18 Cuts LLM Cold Starts by 2.4x with Overlapped Weight Loading and CUDA Graph Capture

    The open-source LLM serving engine SGLang has released version 0.5.18, introducing an overlapped startup engine that significantly reduces cold-start latency for large language models, alongside communication kernel optimizations and expanded architecture support. Comprising 710 pull requests from 212 contributors, the release addresses operational overheads in LLM infrastructure where autoscaling, rolling cluster deployments, and worker node recovery frequently pay steep restart penalties. O

    1 min
  • Active RAG in Production: Dynamic Triggering, Forward-Looking Queries, and Interleaved Retrieval Architectures

    Standard Retrieval-Augmented Generation (RAG) relies on a static, single-shot execution model: the system takes a user prompt, executes a vector or hybrid search upfront, prepends the retrieved chunks into the prompt context, and executes autoregressive generation. While this pattern suffices for short question-answering workloads, it breaks down systematically in complex, long-horizon generation tasks such as comprehensive technical reports, multi-step agent trajectories, and iterative problem

    1 min