Halting in Recurrent Sequence Models

Simon DrägerarXiv 2026

Recurrent neural networks (RNNs) and State Space Models (SSMs) are excellent at generating sequences, but they face a subtle "halting problem." During training, the End-of-Sequence (EOS) token is treated just like any other word or character. There is no special "stop" loss or explicit timer. So, how does a model actually decide when it’s time to stop talking?

In a new paper titled "Halting in Recurrent Sequence Models," Simon Dräger from the Salk Institute dives into the hidden dynamics of these models to uncover the internal "clocks" that trigger the EOS token.

TL;DR

This paper reveals that recurrent models develop distinct geometric mechanisms to track time: tanh RNNs maintain a linear "countdown" subspace that tracks remaining steps, while linear SSMs rely on the precise phase alignment of internal rotation blocks. By intervening in these hidden states, the author demonstrates that these representations causally control when a model stops.

What Problem Does This Paper Address?

When a model generates text or code, it must eventually emit an EOS token to signal completion. While we use this behavior every day, the transition-level mechanism—how a model "counts" its progress and translates that into a stopping decision—is poorly understood.

Existing research often treats EOS as a probability threshold, but this paper asks a deeper structural question: What specific features of the hidden state represent the "time remaining," and how do these features interact with the model's output layer to trigger a halt?

Methods

The author uses a simplified repeat-copy task to isolate the halting mechanism. The model is given a sequence of 8 symbols and an instruction to repeat that sequence $K$ times (where $K$ is 2, 3, or 4), followed by an EOS token.

To peek under the hood, the study employs two primary architectures:

  1. tanh RNNs: Standard recurrent networks with a non-linear activation.
  2. Linear SSMs: Models that process sequences through constrained linear transitions (specifically, 64 learned $2 \times 2$ rotation blocks).

The core analytical tool is the trajectory difference ($\Delta_t^{JK}$). By comparing the hidden states of the same model performing different repeat counts (e.g., 3 repeats vs. 4 repeats) on the identical input sequence, the author can isolate the specific part of the hidden state that represents the "count" instruction.

Datasets

The study uses a synthetic repeat-copy dataset:

  • Content: Sequences of $L=8$ symbols, where each symbol is a 4-bit vector (16 possible tokens).
  • Instructions: A one-hot token encoding the repeat count $K \in \{2, 3, 4\}$.
  • Evaluation: The models were tested on 512 held-out sequences to ensure they weren't just memorizing specific patterns.

Key Insights and Ideas

  • The RNN "Countdown" Subspace: In tanh RNNs, the number of tokens remaining is encoded in a low-dimensional linear subspace. Interestingly, hidden states with the same number of remaining steps converge to a shared representation, regardless of how many copies they were originally told to make. It’s not just tracking "where am I?", but "how much longer?"
  • SSM Phase Alignment: Linear SSMs work differently. They decompose the problem into two-dimensional rotation planes. During the copying phase, the contributions of these planes to the EOS score cancel each other out. As the model nears the stopping time, these rotations align (cohere), suddenly pushing the EOS score above the threshold.
  • Causal Decoupling: The "timer" and the "content" are represented separately. In SSMs, you can scramble the phases of the rotation blocks to break the stopping behavior entirely while the model continues to copy the content perfectly.

Key Results

  • RNN Intervention: The author designed an affine transformation (a mathematical "nudge") to shift the RNN's hidden state at a copy boundary. This intervention successfully tricked the model into stopping exactly one copy early in 94.4% of cases, while maintaining perfect content accuracy for the preceding copies.
  • SSM Coherence: The study found that the "coherence" of rotation planes increases significantly at the moment of halting. When the phases were rotated independently (scrambled), the stopping accuracy plummeted to between 1.5% and 4.7%, yet the content accuracy remained at 99.9%–100%.
  • Dimensionality: For both architectures, the "halting" signal is surprisingly low-dimensional. In RNNs, just two principal components capture most of the variation related to the remaining count.

Limitations and Future Work

  • Fixed Sequence Length: Because the input sequences were always 8 symbols long, the model could be counting total steps remaining rather than the number of copies. Future work with variable sequence lengths is needed to see if the model learns a more abstract "copy counter."
  • Simple Architectures: The study focused on tanh RNNs and linear SSMs. Modern "gated" models like LSTMs, GRUs, or non-linear SSMs (like Mamba) might use more complex, perhaps non-linear, halting primitives.
  • Scale: The models used had a hidden width of 128. It remains to be seen if these geometric primitives (linear subspaces and phase alignment) persist in massive Large Language Models (LLMs).

Summary updated

Abstract

Recurrent sequence models, such as recurrent neural networks (RNNs) and state space models (SSMs), are often trained to emit an end-of-sequence (EOS) token when their output sequence is complete. During training, EOS is treated as another token without a special loss term or incentive. Although this training paradigm is widely used, it is not understood how models decide to output EOS. We study a minimal version of the EOS halting problem in which networks are trained to emit a given input sequence an instructed number of times, followed by EOS. We train tanh RNNs and linear SSMs on this task, finding that the RNNs encode the number of tokens left to copy in a linear subspace, of which two principal components capture most of the variation. Hidden states with the same remaining count converge to a shared representation regardless of their instructed repeat count. By modulating the hidden state using an affine transformation at the boundary between copied sequences, we shift the RNN's state to the representation shared by states with one fewer copy remaining. The unchanged network emits EOS one copy earlier while reproducing the shortened target sequence in 94.4% of new sequences, revealing that this representation causally determines the stopping time. In the SSMs, the difference between trajectories with different repeat counts is separated across two-dimensional rotation planes whose contributions to the EOS comparison cancel during copying and align near the stopping time. Rotating the planes independently removes most of the intended stopping while preserving the copied content, which shows that the stopping time depends on the planes' relative phases. These results identify two candidate primitives of EOS halting in recurrent models: a shared encoding of the number of remaining tokens in tanh RNNs and phase alignment across fixed rotations in linear SSMs.
BibTeX
@misc{drager2026halting,
  author = {Simon Dräger},
  title = {{Halting in Recurrent Sequence Models}},
  year = {2026},
  eprint = {2611.20377},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.20377},
}
Figure