Skip to content
AI.info

Research

Continuous-Depth Transformers with Learned Control Dynamics

Overview Research area: Machine learning — continuous-depth neural networks (neural ODEs) applied to transformer language models, with a focus on inference-time controllable text generation. Technical

Continuous-Depth Transformers with Learned Control Dynamics
arXiv
2601.10007
Published
2026-01-15
Authors
Peter Jemley

AI summary

Overview

  • Research area: Machine learning — continuous-depth neural networks (neural ODEs) applied to transformer language models, with a focus on inference-time controllable text generation.
  • Technical level: Advanced. The paper assumes familiarity with residual networks, ODE initial value problems, the adjoint method, and activation-steering literature.
  • Scope: The paper presents a hybrid transformer in which middle layers are replaced by a continuous-depth ODE block steered by a learned low-dimensional control signal, validated through four experiments covering stability, semantic steering, solver invariance, and inference efficiency.

What This Paper Is About

Standard transformers process representations through a fixed number of discrete layers, and controlling generation attributes like sentiment typically requires prompt engineering, temperature adjustment, or rejection sampling. This paper asks whether depth can instead be treated as a continuous variable governed by a learned vector field, so that a small control signal injected into that field can steer generation at inference time without any weight updates. The goal is a steerable model that retains the stability and speed of an ordinary transformer while gaining continuous, mathematically inspectable control.

Key Contributions

  1. A hybrid architecture that sandwiches a continuous ODE block between discrete early layers (0–1) and discrete late layers (4–5), using a learned output scale α for stability and injecting the control signal u by explicit concatenation with the hidden state.
  2. Demonstrated controllability: the control signal steers sentiment with 98% accuracy for positive targets and 88% for negative targets.
  3. A proposed "Solver Invariance Test" — a Popperian diagnostic that measures trajectory divergence between the fixed-step training solver (Euler) and a high-precision adaptive solver (Dopri5) to falsify the hypothesis that a model has merely overfit to discrete layers; measured divergence was 0.068%.
  4. Efficiency and interpretability results: inference latency on par with a standard discrete baseline, plus a demonstration that adaptive solver function evaluations (NFE) can probe geometric structure in the learned dynamics.

Main Findings

  • Gradient stability: Across 500 training steps on WikiText-2, the hybrid model recorded zero exploding and zero vanishing gradient events. The learned scalar α was initialized to 0.1 for stability and converged to 0.065, a reduction of approximately 35%, indicating a preference for a conservative update regime.
  • Parameter and loss comparison: The baseline had 30,503,424 parameters; the hybrid ODE model had 29,781,249 (97.6% of baseline). Final loss over the last 50 steps was 6.471 for the baseline and 6.449 for the hybrid.
  • Gradient norms: Mean total gradient norm was 0.521 ± 0.140 for the baseline and 0.509 ± 0.142 for the hybrid. The ODE block's own gradient norm was 0.033 ± 0.021.
  • Sentiment steering: With u = +1.0, the model assigned 98.0% probability to "Good" and 0.2% to "Bad"; with u = −1.0, 0.2% to "Good" and 88.1% to "Bad". Under u = 0, the model's natural bias was 91.4% "Good" and 3.3% "Bad".
  • Solver invariance: Relative divergence between the fixed Euler training solver and the adaptive Dopri5 solver was 0.068%, which the paper presents as evidence of an intrinsic continuous vector field rather than discretization overfitting.
  • Continuous steering sweep: Sweeping u from −2 to +2 produced smooth sigmoid probability curves, with intermediate values yielding mixed sentiment states.
  • Latency parity: Inference took 519.83 ms/batch for the baseline and 507.19 ms/batch for the hybrid ODE, a relative speed of 0.98× (a −2.4% overhead), which the paper says outperforms the theoretical expectation of a 1.33× slowdown.
  • Asymmetric steering difficulty: Negative steering required more solver effort (NFE = 20) than positive steering (NFE = 14), attributed to greater curvature in the vector field needed to counteract the model's strong positive prior. Positive control needed only a +6.6% probability shift to reach saturation, whereas negative control shifted probability mass by more than 85 percentage points.
  • Probing intermediate depths: Linear probes trained on hidden states at τ = 0, 0.5, 0.67, and 1.0 found no spike in sentiment separability at τ ≈ 0.67, consistent with a global-bias interpretation in which the control signal tilts the vector field from the outset rather than at one layer.
  • Solver robustness checks: Two adaptive solvers (dopri5 and adaptive_heun) agreed on step counts within 15%. NFE scaled sublinearly with tolerance, going from 14 to 26 for a 1000× tighter tolerance, which the paper reads as smooth rather than fractal dynamics.
  • Memory: The adjoint method, implemented via odeint_adjoint from torchdiffeq, gives O(1) memory training regardless of integration depth.

Methodology in Plain English

The authors take a 6-layer transformer with d = 256 and 4 attention heads and replace layers 2–3 with a single continuous block. Instead of applying one fixed transformation per layer, the hidden state evolves over a continuous depth variable τ from 0 to 1 according to a differential equation whose right-hand side is a neural network — a "vector field" — scaled by a learned factor α initialized to 0.1. The control signal u, a low-dimensional vector, is broadcast and concatenated directly to the hidden state before entering that network, so every step of the integration is conditioned on it; the authors argue this prevents the control from being washed out by normalization layers.

Training uses 4 fixed Euler steps, and backpropagation is done with the adjoint method, which reconstructs gradients by integrating a backward ODE rather than storing every intermediate state, giving constant memory cost. For the steering experiment, embeddings and the output head are frozen so that only the ODE block is trained, forcing the vector field itself to absorb the sentiment semantics. Validation proceeds through four experiments: training stability and gradient flow on WikiText-2 for 500 steps, sentiment steering on the prompt "The movie was…" with u = +1, −1, and 0, a continuity check comparing Euler and Dopri5 trajectories plus a sweep of u from −2 to +2, and a latency benchmark. Finally, the authors use adaptive solver step counts and linear probes at several depths as interpretability tools. Code is available at https://github.com/PeterJemley/Continuous-Depth-Transformers-with-Learned-Control-Dynamics.

Why This Matters

Impact on research: The paper reframes controllable generation as trajectory control in a learned dynamical system, positioning it against activation-steering work such as Turner et al. (2023) and Zou et al. (2023), which derives steering vectors post-hoc at fixed layer positions. Here the control dynamics are learned end-to-end and influence the representation continuously across depth. The proposed Solver Invariance Test offers a quantitative falsification criterion for continuous-depth architectures, and the use of adaptive solver behavior as a probe suggests a route to interpretability that discrete transformer stacks do not provide.

Real-world applications:

  • Steering assistant or chat responses toward a desired tone or sentiment at inference time without retraining or prompt rewrites.
  • Safety and moderation systems that need to shift generation away from harmful outputs using a control input rather than rejection sampling.
  • Variable-compute deployment, where adaptive solvers could allocate more integration steps to harder inputs.
  • Any setting where a single frozen model must serve multiple behavioral modes specified at runtime.

Industry relevance: The efficiency result matters for deployment: continuous-depth models are often assumed to carry a substantial integration overhead, but this hybrid reports latency parity (507.19 ms/batch vs 519.83 ms/batch) with fewer parameters than the baseline, attributed to the MLP-based vector field being simpler than the self-attention it replaces and to improved cache locality during integration. Constant-memory training via the adjoint method also lowers the memory barrier to training such models.

Future Directions

  • Scale: Experiments use a roughly 30M-parameter model; the paper states that scaling to GPT-2 (124M) or larger remains future work.
  • Adaptive computation: The authors list dynamic step counts at inference as future work, since training used a fixed 4 Euler steps even though the model is compatible with adaptive solvers.
  • Multi-dimensional control: Only sentiment was validated. Extending to multiple control axes such as formality and creativity is described as requiring richer training objectives.
  • Interpreting the asymmetric dynamics: The finding that negative sentiment lives in a higher-curvature region and requires higher NFE (20 vs 14) raises the open question of how to design control signals that intervene efficiently against strong model priors.

Target Audience

This paper is most useful to machine learning researchers and graduate students working on neural ODEs, continuous-depth architectures, or controllable text generation. Practitioners interested in activation steering and inference-time model control will find the comparison to post-hoc steering methods relevant, and engineers evaluating whether continuous-depth blocks are deployable will benefit from the latency and parameter benchmarks. Readers without a background in differential equations or the adjoint method will find the mathematics in Sections 3.1–3.5 demanding.

Authors’ abstract

We present a hybrid transformer architecture that replaces discrete middle layers with a continuous-depth Neural Ordinary Differential Equation (ODE) block, enabling inference-time control over generation attributes via a learned steering signal. Unlike standard transformers that process representations through fixed discrete layers, our approach treats depth as a continuous variable governed by a learned vector field $F_θ(H, τ, u)$, where $u$ is a low-dimensional control signal injected via explicit concatenation. We validate the architecture through four experiments: (1) gradient flow stability with zero exploding/vanishing gradient events, (2) semantic steering achieving 98\%/88\% accuracy for positive/negative sentiment control, (3) continuous interpolation validated by a negligible 0.068\% trajectory divergence between fixed and adaptive solvers, and (4) efficiency benchmarking demonstrating latency parity with standard discrete baselines. Additionally, we show that adaptive ODE solvers reveal geometric structure in the learned dynamics: the control signal partitions the vector field into distinct dynamical regimes with different curvature characteristics. The adjoint method enables $O(1)$ memory training regardless of integration depth. Our results demonstrate that continuous-depth dynamics with learned control signals provide a viable, efficient mechanism for steerable language generation.

Read the original paper