Manuscript Offprint

arXiv:2610.19358

Asymptotic Behavior of Transformers

Katy Blumer, Da-Cheng Juan, Jon Kleinberg, Ravi Kumar, Cyrus Rashtchian, Andrew Tomkins

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

In this paper we study the behavior of transformer networks generating text over long periods of time. We show that even a three-token, single-layer attention-only transformer can fail to converge. We then study a rich class of transformers with arbitrary finite depth, layer normalization, MLPs, RoPE encodings, and an arbitrary mix of local and global layers. Every transformer in this class has a softmax temperature threshold above which its empirical cache distribution converges to a unique limit, independent of initial conditions. We show further that, while each transformer has a temperature threshold, the supremum of this set is infinite, so there is no global minimal temperature that forces all transformers to converge.

1 Introduction

In this paper we study what happens if an autoregressive transformer is allowed to generate for a very long time. Most theoretical analyses of transformers fix the sequence length, or ask how performance changes when the context window is extended (Kazemnejad et al., 2023; Huang et al., 2025; Sun et al., 2023). Here we ask a different question: we fix the model and study the generation process itself as the number of generated tokens tends to infinity.

As a side note, while we think this question is mathematically natural, we are also motivated by the observation that modern models sometimes seem to “lock in” to a particular state (Sharma et al., 2024; Huang et al., 2024). Sometimes this state is annoyingly bad, such that even with great efforts the model cannot be convinced to let a particular approach or argument go. Other times the state is pleasingly good, perhaps encoding an effective understanding of a problem that represents a useful starting point for many further explorations—in this case we might wish to checkpoint the model in this good state, to use it as a resource. These observations led us to wonder, even without a human in the loop, whether a model might enter a state that continues to influence its behavior forever. This paper provides a partial answer.

Single-Layer Transformers. Our first goal is to understand this question in a simple setting: a single-layer attention-only transformer without positional encodings, MLPs, or normalization (Vaswani et al., 2017; Kazemnejad et al., 2023; Wang et al., 2024). In this model, different occurrences of the same token are indistinguishable to attention, so the entire history is summarized

*katyblumer@gmail.com

†^{\dagger} {dacheng, cyroid}@google.com

‡^{\ddagger}kleinberg@cornell.edu

§^{§}ravi.k53@gmail.com

^{¶}atomkins@gmail.com by the empirical token distribution PtP_{t}. As t grows large, the change to the historical distribution in a single step goes to zero; hence, for fixed-size finite windows and sufficiently large t, we may view the historical state of the model as frozen.

The next token logits depend only on the current token and the history, so freezing the historical distribution at some P causes the simplified transformer to behave like a finite-state Markov chain with transition matrix MPM_P. The historical distribution will slowly drift towards the steady state of this Markov chain, π∗(P)\pi^*(P), but as it does so, the Markov chain itself will evolve, resulting in a new drift direction. We show that the empirical distribution PtP_t tracks the ODE almost surely (Benaïm, 1999)

dPdt=π∗(P)−P.\frac{dP}{dt}=\pi^{*}(P)-P.

Thus the long-run behavior of this model is described by a deterministic dynamical system, even though the underlying token sequence remains random.

The softmax temperature τ\tau enters this ODE in a particularly simple way. Differentiating the output softmax contributes a factor 1/τ1/\tau, and we use this to show that, for this model, there is a finite temperature above which the map P↦π∗(P)P \mapsto \pi^*(P) is a contraction. In this regime the ODE has a unique globally attracting fixed point and PtP_t converges to it almost surely, independently of the initial prompt; as τ→∞\tau \to \infty, this fixed point approaches the uniform distribution. At lower temperatures the ODE description remains valid, but uniqueness of the limiting set is no longer guaranteed; in fact, even this simplified model need not converge.

Multi-Layer Transformers. We next consider fixed-depth transformers, allowing arbitrary mixtures of global and fixed-window local attention layers (Beltagy et al., 2020; Zaheer et al., 2020), RoPE positional encodings (Su et al., 2024), MLPs, residual connections, and normalization. Here the empirical token distribution is no longer sufficient to describe the history. The key/value vectors stored at a position depend on the context in which that position was generated, so two occurrences of the same token can contribute different entries to the global KV cache.

Nevertheless, each historical position contributes only a fixed-dimensional vector to this cache. We therefore represent the unbounded global cache by the empirical distribution ηt\eta_{t} of these vectors. The dimension of an individual cache vector depends on the fixed architecture but not on the generation time. In this sense the entire historical state remains fixed-dimensional at each historical position even though the number of stored positions grows without bound.

RoPE position encodings introduce an additional state variable: the current rotation phase. With the global cache frozen at η\eta, the finite local-attention windows imply that only a fixed number W of recent tokens is needed in addition to the current RoPE phase ω\omega. The resulting process over W-grams is governed by a sequence of phase-dependent transition matrices Qη,ωQ_{\eta,\omega}.

Again with frozen history η\eta, at any fixed positive temperature, every output token has a probability bounded away from zero. Every W-gram can be reached from every other in W steps, and the effect of the initial W-gram decays geometrically. This gives a unique phase-dependent family πη(ω)\pi_{\eta}(\omega) describing the asymptotic distribution of the recent tokens. We show that this frozen-cache description remains accurate over sufficiently long blocks that the local state at the start of the block is forgotten as the system moves towards the frozen-cache limiting behavior.

The RoPE phase itself does not converge, but the averages along its orbit do. Averaging the phase-dependent local behavior therefore defines a map Γ(η)\Gamma(\eta): the average distribution over all RoPE phases of the next cache vector when the current cache is frozen at η\eta. Since the empirical cache changes by only 1/(t+1)1/(t+1) at each step, a natural time scale for state evolution is

st=∑j=1t1j=log⁡t+O(1).s_{t}=\sum_{j=1}^{t}\frac{1}{j}=\log t+O(1).

On this scale we obtain the measure-valued ODE

dηds=Γ(η)−η.\frac{d\eta}{d s}=\Gamma(\eta)-\eta.

We prove that the actual empirical cache process almost surely tracks this ODE over every fixed interval of the s-time scale. Thus the long-run behavior of the full multi-layer transformer is again reduced to a deterministic dynamical system, now over probability distributions on a fixed-dimensional cache space.

This description by itself does not imply convergence: the ODE may (and in fact does) have more complicated non-convergent trajectories. We therefore return to the role of temperature. The feed-forward ordering of transformer layers gives a useful triangular structure: the cache vector written by a global layer can depend only on the caches of earlier global layers. Using a weighted distance across layers, this triangular dependence can be made arbitrarily small. The remaining feedback through token sampling is suppressed by the 1/τ1/\tau derivative of the output softmax. We use these two facts to show that every fixed transformer in our model has a finite temperature threshold above which Γ\Gamma is a contraction. Above this threshold the cache ODE has a unique globally attracting fixed point, and the empirical cache converges to it almost surely.

The threshold, however, cannot be chosen uniformly over all transformers. We give an explicit three-token example showing that even a single-layer, NoPE, attention-only transformer with no MLP can fail to converge almost surely. Moreover, for every finite temperature τ\tau, scaling its output embeddings by τ\tau leaves the next token probabilities unchanged. Thus for every finite temperature there is such a simplified transformer that fails to converge, even though every fixed transformer converges once its temperature is sufficiently large.

The order of quantifiers is important. For every fixed transformer, sufficiently high temperature forces convergence; but for every fixed finite temperature there is some transformer that fails to converge. Hence there is no universal finite temperature that guarantees convergence over the entire class.

Our results therefore give two complementary descriptions of long-generation behavior. First, slowly changing empirical state turns the stochastic generation process into a deterministic ODE on an appropriate time scale. Second, sufficiently high temperature controls the feedback in this ODE and forces convergence for each fixed model, while no single temperature can do so uniformly for all models.

References (38)