Manuscript Offprint
arXiv:2610.19358Asymptotic Behavior of Transformers
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
{dacheng, cyroid}@google.com
atomkins@gmail.com by the empirical token distribution . 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 . The historical distribution will slowly drift towards the steady state of this Markov chain, , but as it does so, the Markov chain itself will evolve, resulting in a new drift direction. We show that the empirical distribution tracks the ODE almost surely (Benaïm, 1999)
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 enters this ODE in a particularly simple way. Differentiating the output softmax contributes a factor , and we use this to show that, for this model, there is a finite temperature above which the map is a contraction. In this regime the ODE has a unique globally attracting fixed point and converges to it almost surely, independently of the initial prompt; as , 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 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 , the finite local-attention windows imply that only a fixed number W of recent tokens is needed in addition to the current RoPE phase . The resulting process over W-grams is governed by a sequence of phase-dependent transition matrices .
Again with frozen history , 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 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 : the average distribution over all RoPE phases of the next cache vector when the current cache is frozen at . Since the empirical cache changes by only at each step, a natural time scale for state evolution is
On this scale we obtain the measure-valued ODE
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 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 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 , scaling its output embeddings by 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.
For vectors, and denote the Euclidean inner product and norm; for matrices, denotes the induced operator norm. For distributions , denotes the total variation distance, and denotes the 1-Wasserstein distance. Two distances on distributions are equivalent if they differ by at most constant factors. We use , for the Kronecker delta and for the unit point mass at .
Stochastic Approximation. We repeatedly use the dynamical systems approach to stochastic approximation of Benaïm (1999). Informally speaking, for an update of the form
where the step sizes are decreasing and satisfy and , the process, viewed on the accumulated time scale , tracks the ODE over every fixed interval of -time. Under the usual boundedness and noise conditions, its limiting set is an internally chain transitive (ICT)* set of this ODE. We use this framework in Section 2 to obtain the ODE for the empirical token distribution, and in Section 3 to obtain the analogous ODE for the empirical cache distribution. Once the corresponding ODE has a unique globally attracting fixed point, this tracking gives convergence of the stochastic process. We also use Benaïm's result that stochastic approximation does not converge to a linearly unstable equilibrium under nondegenerate noise in Section 4.
2 Single-Layer Transformer
In this section we study a simple transformer model. The model has a single layer with one attention head, and lacks positional embeddings (NoPE), layer normalization, and MLPs. Let be the hidden dimension. The model is parameterized by fixed input and output embedding matrices , and standard attention projection matrices .
At step , the state is given by the current token and the historical context. With NoPE, attention to each token of the history is independent of the token's location and so, the history is captured by the empirical distribution , where is the frequency of token up to time .
For a query token u and key/value token w, the unnormalized attention score is . The attention weight that u pays to w over history is:
Let denote the value vector for token . The self-attention output is . The probability of generating the next token given query and history , sampled at temperature , defines the transition matrix (see Figure 1):
2.1 Limiting Dynamics
We first describe the asymptotic evolution of the empirical distribution by an ordinary differential equation (ODE). Observe that updates iteratively as:
*A non-empty compact set is an internally chain transitive set (ICT) of the ODE if for every , every , and every , there exists points and times such that , where is the solution of the ODE.
Full-Sequence Attention

Figure 1: A stripped-down model of a transformer with NoPE, no MLPs, and an unbounded context window parameterized by historical distribution .
To analyze the long-run behavior of , we appeal to the theory of stochastic approximation. To show that the discrete stochastic process tracks a deterministic limiting ODE, we verify the standard conditions for stochastic approximation (Benaïm, 1999):
(i) Step-size sequence: The update step size satisfies the conditions: and .
(ii) Compact state space: lies in the simplex , which is compact.
(iii) Smoothness: The ODE has drift , where is the stationary distribution of . Since and the logits are bounded on the simplex, each entry in is bounded away from zero; thus, is uniformly ergodic. Since also depends smoothly on , is continuously differentiable (and hence Lipschitz) on the simplex.
(iv) Markovian state noise and martingale difference: Since the next token is sampled from row of , its conditional expectation given is rather than . We therefore decompose the update increment as:
Lemma 1. For every fixed , the empirical distribution tracks the ODE a.s.
Hence, the limiting set of is an ICT of this ODE a.s.
Proof. Using (iv), the update is given by
where
Note that is a bounded martingale difference, and so converges (a.s.) as from (i).
For the Markovian term , uniform ergodicity from (iii) implies that there is a uniformly bounded function , Lipschitz-continuous in , satisfying
Thus
where
is a bounded martingale difference. After multiplication by , the first two terms telescope up to a boundary term, which vanishes, and errors of order and , which are summable. Also, converges (a.s.). Hence the accumulated Markovian noise has vanishing tails.
Since is Lipschitz, the proof follows from stochastic approximation (Benaïm, 1999).
2.2 Jacobian
In this section, we study the limiting behavior of our simple transformer. In particular, we show that there is a temperature threshold above which the limit of the empirical distribution is a unique fixed point.
From Lemma 1, the transformer tracks the ODE in the limit, so we study now whether all solutions converge to the same limit, or whether different limiting sets are possible. To do this, we analyze the Jacobian of the map . This Jacobian characterizes how the steady state of the Markov chain moves in response to a local change in the history. Its entries are .
Note that taking a partial derivative with respect to a single component while holding all other components constant points in a direction that leaves the probability simplex (since the sum of the components will no longer equal 1). Since the formulas above extend smoothly to a neighborhood of the simplex, we can use these derivatives to assemble the full Jacobian in . Since , only perturbations whose coordinates sum to zero correspond to valid changes of the probability distribution. Restricting the Jacobian to these perturbations gives the correct local behavior on the simplex.
Lemma 2. It holds that
Proof. We trace the chain of derivatives with respect to :
(i) We differentiate the normalization term in (1):
Applying the quotient rule to in (1):
Summing over all k to find the shift in the attention output :
(ii) Let be the logit for token . Its derivative is linear: . The transition probability is a softmax over these logits scaled by . Applying the standard softmax derivative, the chain rule, and using (2),
Let be the expected output embedding over the entire vocabulary for query . Rewriting, we obtain
(iii) Finally, we derive the Jacobian of the stationary distribution . Since is the stationary distribution of , it satisfies the equilibrium condition . Differentiating,
Let denote the row vector corresponding to the th column of the Jacobian , and let represent the direct perturbation vector. Rearranging the terms gives:
To isolate , we define , which satisfies . Multiplying both sides of (4) by on the right yields:
Furthermore, since is the derivative of a probability distribution, its elements sum to zero, i.e., . This cancels the rank-one term , yielding a closed-form solution for the Jacobian column:
We next show a bound on the norm of the Jacobian, in terms of the temperature.
Lemma 3. There exist constants such that, for all ,
Proof. By (2), is uniformly bounded over . Since all remaining factors in (3) except are bounded on the simplex, we obtain
As , every row of converges uniformly in to the uniform distribution . Since ,
so uniformly as well. Hence uniformly in , so remains uniformly bounded for all sufficiently large . Using , and since and are bounded, we obtain for every column of . Since there are only columns, .
Using these, we show that a temperature threshold exists, which is the main result in this section.
Theorem 4. There is a temperature such that is a contraction for all . Hence, it has a unique fixed point , which is globally attracting under the ODE.
Proof. Choose , where are the constants in Lemma 3. Since the simplex is convex, is a contraction and has a unique fixed point . Writing the ODE as , let . Since and using
we have
Integrating this inequality,
so is globally attracting. Since decreases strictly away from , is the only ICT set of the ODE.
Combining Lemma 1 and Theorem 4, for every , we have (a.s.). Moreover, as , converges to the uniform distribution, since converges uniformly in to the transition matrix with every row uniform. For , however, the above argument no longer guarantees uniqueness of the limiting set. Multiple limiting ICT sets are not ruled out and the behavior in this below-threshold temperature regime may depend on the specific model parameters.
2.3 A Simple Example
Let us consider a trivial example that shows three surprising facts about this simple transformer:
-
It may non-deterministically approach one of multiple limits.
-
The likelihood of each limit may depend on the starting conditions.
-
As the temperature increases, the same transformer will transition into approaching a single limit, independent of starting conditions.
Our example has only two tokens, and the hidden dimension is one, so embeddings and weight matrices are simply scalars. For , the model is fully specified by these values:
Let be the fraction of token 1 in the history. Uniform attention gives , and every row of assigns probability
to token 1. Hence and, with , the limiting ODE becomes
For , the right-hand map is a contraction and is the unique globally attracting fixed point. For , is unstable and two symmetric attracting fixed points appear. Thus even this two-token example exhibits the temperature-dependent transition underlying Theorem 4. Note that Mori and Hisakado (2015); Hisakado and Mori (2012) present a similar analysis exhibiting the same variation in steady state.
Despite the interesting dynamics of the steady state, the historical token distribution for these models does approach a limit for every positive temperature, even if this limit might be a random variable. In Section 4, we show that even this is not guaranteed by giving an explicit three-token construction with a proof of non-convergence of the token distribution.
3 Multi-Layer Transformer
The analysis for a single-layer transformer uses the fact that, without position encodings, the history is summarized by the empirical token distribution. This does not hold for a multi-layer transformer, where the key and value vectors stored at a historical position depend on the context in which that position was generated. Nevertheless, for a fixed-width, fixed-depth transformer, each historical position contributes only a fixed-dimensional vector to the global KV cache. We therefore represent the unbounded history by an empirical distribution over these vectors.
Throughout this section, the number of layers and heads is fixed, and every local attention layer is causal with a fixed window of width at most w. Besides the global KV cache, the model has no recurrent state other than the finite KV caches used to power the local layers. As in a standard transformer block, the keys and values stored by an attention layer are computed from the input to that layer, before its attention output is produced. All projections, MLPs, residual maps, and normalization maps are assumed to be uniformly Lipschitz on the reachable set and all reachable hidden states, queries, keys, values, local cache states, and pre-temperature output logits are uniformly bounded. All constants below may depend on the architecture and its weights, but not on the generation time. For local RoPE layers, attention depends only on relative offsets within the fixed local window, so no absolute phase state is needed.
High temperature:
Low temperature:

unique globally attracting equilibrium

two stable equilibria and one unstable equilibrium
Figure 2: A two-token example illustrating the temperature transition: and . For , the uniform state is the unique globally attracting equilibrium. For , it becomes unstable and two symmetric stable equilibria appear.
We consider a transformer with both global attention layers, whose attention window has the full history, and local attention layers with a fixed window. Let and be the numbers of global and local attention layers respectively, each with h heads of dimension d.
Let be the RoPE frequencies of head , and define the RoPE rotation as:
where
For each historical position p, let be the unrotated key, and let
be the rotated key. The collection of global cache quantities generated at position p is
Let Z be the closure of the set of all reachable ; by the boundedness assumption, Z is compact.
Let denote the collection of RoPE frequencies across all global heads, and let denote the vector of current RoPE phases. Let
be the empirical distribution of global cache vectors, where denotes a unit point mass at z. Thus, the global cache changes slowly: each new token changes its empirical distribution by only .
For each , let and denote its key and value coordinates for global layer and head . For a query , the corresponding global attention output is
Since the reachable queries and keys are bounded, the denominator in (5) is bounded away from zero uniformly in t.
Thus, once the RoPE rotation is incorporated into the stored key, its historical location is no longer needed. To characterize long-run RoPE phases, let
be the closure of phases visited in the limit. Let denote the uniform probability distribution on . We now show that averages along the RoPE phases converge to the average under .
Lemma 5. For any continuous function ,
Proof. Consider . For an integer vector of the same dimension as , let . Then,
The average of the same function under the uniform distribution on has the same value. Since finite linear combinations of uniformly approximate every continuous function on , the result follows. The same calculation with instead of differs only by the factor , whose absolute value is one, so the convergence is uniform in .
To understand the impact of the local layers, note that each such layer has width at most w, and so its output can introduce dependence on at most additional earlier token positions. Thus, once the global attention outputs are fixed, the remaining computation depends only on the most recent tokens. Let be this W-gram (with fixed padding when ). Any fixed transformer in our model may be viewed as a function mapping from and the global cache state to a new and global KV cache column output.
3.1 Frozen Cache Dynamics
In this section, we first hold the global cache fixed and study the evolution of over a block of steps. The motivation for this approach is as follows. Each new output modifies the global cache by only , so for , ; thus the cache does indeed behave as if frozen. Once we understand the frozen cache behavior, we study how the drift during the frozen regime will eventually result in a new global cache state (possible, as diverges), and what the trajectory over these evolving global cache states will look like.
Let be a probability distribution on Z representing the (frozen) global cache state. With the global cache fixed, the recent W tokens and the current RoPE phase determine the next step. For
and phase , let be the next token distribution produced by the transformer. For , define the transition matrix:
Thus only if is obtained from by dropping its first symbol and appending one new token. We first establish a uniform lower bound on next token probabilities. This will imply that every -gram can be reached from every other in steps and hence the product of the transition matrices contract.
We assume that . By the boundedness assumption, there is a constant such that every pre-temperature output logit satisfies for all , , and . Therefore,
Since the phase changes by after each step, the m-step transition matrix starting at phase is
Starting from any W-gram, any particular W-gram can be reached in W steps by generating . By (6), each of these tokens has conditional probability at least . Hence
for every , uniformly in and .
Let . Since every entry of the W-step transition matrix is at least , for any two probability distributions on , we have
Thus, with the cache fixed, the effect of the initial W-gram decays geometrically. Since the RoPE phase changes at each step, the process is governed by a sequence of transition matrices rather than by one fixed matrix; we study its limiting behavior.
Lemma 6. For every fixed , (i) there is a unique family of probability distributions such that and (ii) for every initial distribution ,
Proof. Fix and any distribution on . Consider
If a longer product is used, its last transition matrices are the same as those in (8), but with a possibly different distribution at their starting point. By (7), changing that starting distribution changes the result by at most . Hence (8) converges as , and its limit does not depend on . Define this limit to be .
Shifting by in (8) gives (i). Finally, apply (7) to and ; (ii) now follows from (i). Uniqueness also follows from the same bound.
Since only a fixed number of recent positions enter the local computation and all computations are Lipschitz, replacing the cache states used at those positions by the current cache changes the next step distribution by . Recalling is the history up to time ,
We next show that this frozen cache description remains accurate over time intervals on which the empirical cache changes only slightly.
Lemma 7. (i) There is a constant such that
(ii) Moreover, let satisfy and . Then .
Proof. We first prove (i). Under our assumptions, there is a constant such that
Indeed, for the first global layer this follows directly from (5): its terms are uniformly bounded and Lipschitz in z, and the denominator is uniformly bounded away from zero. The resulting attention output therefore changes by . Repeating this argument through the fixed number of layers, using the Lipschitz assumptions, proves (9).
Combining (9) with (7) gives (i): comparing the products defining and term by term, a change steps in the past is reduced geometrically in , and summing these changes gives the stated bound. Similarly, continuity of in implies continuity of in .
We now return to the actual cache, which changes after every step t. From the definition of ,
Since each cache update has size ,
Therefore, by (9),
Comparing the two k-step products one step at a time, the errors from replacing by add up to . The error in the actual one-step transition accumulates to , which is smaller. Hence, conditioned on , the distribution of differs by from the distribution obtained by holding the cache fixed at . Lemma 6 thus gives
Both terms vanish under and , proving (ii).
Thus, over a block that is long enough for the recent tokens to forget their initial state but short enough that the global cache changes little, their distribution is determined asymptotically by the cache state at the start of the block and the current RoPE phase. Although the instantaneous distribution may depend on the RoPE phase, Lemma 5 allows this phase dependence to be averaged over a long block.
3.2 Slow Cache Dynamics
Lemma 7 describes the recent token distribution while the global cache changes only slightly. We now use this to study the average evolution of the cache itself.
For a fixed , , , and a generated token , let denote the new global cache vector inserted at the next position, whose RoPE phase is . The Lipschitz assumptions above mean that is Lipschitz in with respect to and in . Define
Thus is the average distribution of the next cache vector when the recent tokens have adjusted to the frozen cache and the RoPE phase is averaged.
Since the empirical cache updates with step size , its natural continuous time scale is ; we use for this slow time variable. The corresponding equation for the empirical cache is
Since is a probability distribution rather than a finite-dimensional vector, we interpret (10) by testing it against Lipschitz functions: for every ,
For a Lipschitz , let
Thus, is the average value of under the current cache distribution and is the expected value of on the next cache entry, given frozen cache, current local state, and current phase. The next theorem shows that, over a long block on which the cache changes only slightly, the average change of is asymptotically .
Theorem 8. Let satisfy and . Then, for every Lipschitz ,
where
Proof. As noted before Lemma 7,
Over a block of k steps beginning at time p,
By the Lipschitz bounds above, we may therefore replace by at a total averaged cost . The same comparison used in the proof of Lemma 7 gives, uniformly for ,
for a constant C. Averaging over j therefore gives
(11)
The function
is continuous. These functions depend continuously on and . Since the possible cache distributions form a compact set, this family can be uniformly approximated by finitely many such functions. Lemma 5 therefore applies uniformly over this family and the RHS of (11) converges to
Also, since for ,
Combining these estimates completes the proof.
Thus gives the average change of the empirical cache on the s-time scale; but nothing here requires solutions of (10) to converge. Note that the bounds above also imply that is Lipschitz with respect to : for some , . Indeed, this follows by comparing the corresponding factors , , in the definition of . Thus (10) has a unique solution for any initial cache distribution.
Let interpolate the values linearly between consecutive 's. Theorem 8 identifies the average change of the cache over short blocks. The next result shows that these local approximations combine to describe the full cache trajectory on the s-time scale.
Corollary 9. Let be the solution of (10) with . Then, for every fixed ,
Thus tracks (10) a.s.
Proof. For a Lipschitz function , the empirical cache update gives
By Theorem 8, over blocks that grow to infinity but remain short relative to the current time, the average conditional change is , where is the cache state at the start of the block. Since the cache changes by across such a block and is Lipschitz, we can use the current cache state within the block. Partitioning any fixed interval of the s-time scale into such blocks, Theorem 8 therefore shows that the accumulated difference between the conditional change and tends to zero.
The remaining random term is bounded and has conditional mean zero. After multiplying by , its weighted sum converges (a.s.) because . The approximation error used in Section 3.1 contributes only after multiplication by the step size, and is therefore summable as well.
Since Z is compact, controlling finitely many 1-Lipschitz test functions up to an arbitrarily small error is enough to control ; hence the same bounds hold uniformly in the definition of . Consequently, over every fixed interval of the s-time scale, satisfies
where the error tends to zero uniformly for in the distance .
The exact solution satisfies the same equation without the term. Since is Lipschitz, their distance is at most
Repeated substitution in this inequality shows that, uniformly for ,
the RHS vanishes (a.s).
3.3 High-Temperature Convergence
Corollary 9 shows that the empirical cache tracks (10), but does not imply that solutions of (10) converge. We now show that convergence does hold at sufficiently high temperature for every fixed transformer.
In this section we make the dependence on the temperature explicit, writing , , , and . Let be the cache vector where contains the keys and values stored by the jth global layer, and let be the corresponding marginal of . Likewise, let .
For , define
and let denote the 1-Wasserstein distance induced by this norm. Since the number of layers is finite, and are equivalent. We can now show the following contraction result on the expected next cache state for two different histories:
Lemma 10. For every small , there are and with as such that
Proof. By the ordering of the layers, can depend on the global cache only through global layers . Hence there are constants such that
\left\|G^{(j)}(\eta,u,\omega,a)-G^{(j)}(\eta^{\prime},u,\omega,a)\right\|\leq\sum_{i<j}C_{ji}d_{1}^{(i)}(\eta^{(i)},\eta^{\prime}^{(i)}),uniformly in , where denotes the distance on the cache coordinates of layer . This follows from (5) and the Lipschitz assumptions, applied through the layers; in particular, does not depend on .
A function of that is 1-Lipschitz in that coordinate is -Lipschitz under . Therefore,
d_{1}^{(i)}(\eta^{(i)},\eta^{\prime}^{(i)})\leq\delta^{-(i-1)}\cdot d_{1,\delta}(\eta,\eta^{\prime}).It follows that
where
Thus as .
We next consider the next token distribution. The argument used for (9), stopped just before the final softmax, shows that the pre-temperature output logits are Lipschitz in . Since the derivative of softmax( ) is , for every fixed there is a constant such that, for all sufficiently large ,
The same bound therefore holds for the corresponding transition matrices .
For sufficiently large , the lower bound in (6), and hence the contraction in (7), can be chosen uniformly in . Repeating the proof of Lemma 6 therefore gives
after increasing if necessary.
We can now compare and .
(i) If the weights are kept fixed and only the point is replaced by , the change is at most .
(ii) If the points are kept fixed and the weights are changed, the bounds above give a change of at most . Hence
We have the ingredients to prove high-temperature convergence.
Theorem 11. For every transformer satisfying the assumptions of this section, there is a finite such that, for every , has a unique fixed point . Every solution of converges exponentially to , and a.s.
Proof. Choose small enough that , and choose large such that all the preceding large temperature bounds hold and . By (12), for every , is a contraction under ; let be its contraction constant. Since is compact, iterating gives a unique fixed point .
Let be any solution of the ODE. Its integral form is
Using and the contraction bound,
and repeated substitution gives
It remains to return to the stochastic cache process. Since and are equivalent, Corollary 9 also gives uniform tracking in over every fixed interval of the s-time scale. Choose and let ; choose times so that . Applying Corollary 9 on each interval and using (13),
Hence (a.s.) The same bound on the intervals between consecutive yields (a.s.) Now, the equivalence of and completes the proof.
Thus every fixed transformer has a sufficiently high-temperature regime in which the empirical cache converges. The threshold may depend on the architecture and its weights.
4 Non-Convergence
We now give an example showing that even the simplified single-layer transformer of Section 2 need not converge. Let , , and temperature . Define
and let . Set
All attention scores are then zero, so for every query token the attention output is
Fix a constant and choose the output embeddings cyclically as
Since
the output logits, up to a common additive constant, are
Thus every row of is the same distribution , where, with indices interpreted cyclically,
Consequently and the limiting ODE is
This ODE has a unique fixed point
Indeed, at any fixed point,
If, for example, , then , which implies , which in turn implies , a contradiction. Hence all three coordinates must be equal.
The fixed point is unstable when . The Jacobian of at , restricted to the tangent plane , is
The two eigenvalues of the Jacobian of on this plane are
Their real parts are positive for , so is a linearly unstable equilibrium.
Finally, the stochastic process itself cannot converge. Since is uniformly bounded away from zero on the simplex, the sampling noise is nondegenerate in every direction tangent to the simplex. The standard non-convergence result for linearly unstable equilibria in stochastic approximation (Benaïm, 1999, Section 9) therefore gives
By Lemma 1, if converged, its limit would have to be a fixed point of the ODE. Since is the only fixed point, does not converge almost surely.
Note that the limiting ODE in this construction is a cyclic three-strategy logit best-response dynamic, closely related to the rock-paper-scissors models studied by Hommes and Ochea (2012). Our contribution is to realize this dynamic within an explicit single-layer, attention-only transformer and establish the non-convergence of its empirical token frequencies.
Thus, we have a single-layer, NoPE, attention-only transformer that fails to converge almost surely at temperature 1. To extend this to any given temperature , we multiply all of its output embeddings by . Since output logits are divided by before the softmax, the next token distribution is unchanged by this operation. Thus the same ODE and the same non-convergence argument apply at temperature . We obtain the following stronger statement.

Figure 3: Phase portrait of the three-token example in Section 4, with c = 7. The unique equilibrium is a repelling focus. The teal curve is a numerically computed attracting periodic orbit of the limiting ODE. Trajectories starting inside (orange) and outside (gray) the orbit spiral toward it in a counterclockwise direction. The shaded sectors indicate the most probable next token: red for token 1, green for token 2, and blue for token 3. The trajectories represent the limiting deterministic dynamics, not individual stochastic sample paths.
Theorem 12. For every temperature , there is a single-layer, NoPE, attention-only transformer with no MLP whose empirical token distribution fails to converge almost surely when sampled at temperature .
Recall Theorem 11, which fixes the transformer and then takes the temperature sufficiently large. In contrast, in Theorem 12, the temperature is fixed and the transformer is allowed to depend on . Thus every fixed transformer has a high temperature convergence regime, but there is no finite temperature that guarantees convergence uniformly over all transformers.
5 Related Work
Dynamical and mean-field analyses of attention. Several recent works study self-attention as a dynamical or mean-field system. This includes work on clustering in self-attention (Geshkovski et al., 2023), mean-field models with layer normalization (Burger et al., 2025), meta-stable clustering (Bruno et al., 2025), synchronization phenomena (Polyanskiy et al., 2025), and broader mean-field formulations of transformer dynamics (Rigollet, 2026; Tembine et al., 2024). Other work gives exact mean-field analyses in simplified attention models (Dohmatob, 2025) and studies mean-field descriptions of in-context feature learning (Kim and Suzuki, 2024). These papers primarily analyze the evolution of representations across layers, training, or an idealized population. Our setting instead follows a fixed autoregressive model forward in generation time, where the empirical history itself changes after every generated token.
There are also other mathematical views of attention. Katharopoulos et al. (2020) show that linearized autoregressive attention admits a recurrent formulation, Ramsauer et al. (2021) relate softmax attention to modern Hopfield networks and associative memory, and Dong et al. (2021) study rank collapse under repeated pure self-attention. Our use of stochastic approximation follows Benaïm (1999) to compare a slowly changing stochastic process with an ODE.
Related dynamical analyses. Other works include symmetry breaking in attention (Silverstein et al., 2026), synchronization-inspired transformer architectures (Liu et al., 2026), and residual-aware cumulative attention dynamics (Herasimchyk et al., 2026). These works study related dynamical phenomena, but not the infinite-generation limit we consider.
Transformers and positional information. Vaswani et al. (2017) use absolute sinusoidal position encodings while later work use relative position representations, e.g., directly into self-attention (Shaw et al., 2018), combining a recurrent memory across segments (Dai et al., 2019), or adding a distance-dependent linear bias to the attention scores (Press et al., 2022). RoPE rotates query and key vectors as a function of position so that their inner product depends on relative position (Su et al., 2024).
The choice of positional representation is closely related to length generalization. Kazemnejad et al. (2023) compare several positional schemes, including RoPE, ALiBi, and NoPE, and observe good length generalization for NoPE on many tasks.
This phenomenon has also been studied theoretically for NoPE (Wang et al., 2024), and more broadly for length generalization in causal transformers (Huang et al., 2025). Randomized positional encodings have also been used in this context (Ruoss et al., 2023).
Length extrapolation and RoPE. A different line of research asks how a model trained at one context length can be used at a larger one. Sun et al. (2023) study architectural choices for length extrapolation. Position interpolation rescales position indices for pretrained RoPE models (Chen et al., 2023), YaRN modifies RoPE scaling to extend context windows efficiently (Peng et al., 2024), and LongRoPE uses non-uniform interpolation and progressive extension to reach longer contexts (Ding et al., 2024). Other work studies limitations and variants of RoPE itself, including the relation between the RoPE base and usable context length (Xu et al., 2024), the distribution of information across RoPE frequencies (Oka et al., 2026), and wavelet-based rotary encodings (Reid et al., 2026). These works are concerned with extrapolating a trained model to longer inputs. We, on the other hand, study the limiting behavior of a fixed model.
Long-context attention and memory. Another line of work changes the attention or memory mechanism itself. Transformer-XL reuses hidden states from previous segments (Dai et al., 2019), and the Compressive Transformer stores older states in compressed form (Rae et al., 2020). Longformer combines local windowed attention with selected global attention (Beltagy et al., 2020), while BigBird uses a sparse mixture of local, random, and global connections (Zaheer et al., 2020). Memorizing Transformers augment the model with retrieval from a memory of past key-value representations (Wu et al., 2022). StreamingLLM retains a small set of initial “attention sink” tokens together with a recent window (Xiao et al., 2024), while Infini-attention combines local attention with a bounded compressive memory (Munkhdalai et al., 2024). In contrast, we keep ordinary global attention and study the statistics of its growing KV cache.
6 Conclusion
We studied the long-run behavior of transformers through the slowly changing empirical state generated by their own outputs. In both the single-layer and multi-layer settings, the stochastic process tracks an ODE on an appropriate time scale. For every fixed transformer in our model, sufficiently high temperature makes this ODE contractive and forces convergence to a unique limiting state. This threshold is model-dependent: at every fixed finite temperature, some transformer can have a limiting ODE that does not converge. Thus temperature controls long-run stability, but there is no universal finite temperature that guarantees convergence for all transformers.
AI use statement
In this work, we used generative AI tools only to formulate mathematical claims; provide critical ingredients for proving mathematical claims; assist in the writing of proofs. We have not used generative AI tools to help develop theoretical models or conceptual frameworks; propose or refine hypotheses; interpret results; generate synthetic data sets; design or provide feedback on research methodology or experiments; implement methods; assist with translation; clean and reformat datasets; support qualitative and thematic data analysis are not applicable to this work. Additionally, we used generative AI tools to draft parts of a research paper; identify relevant literature. All LLM-assisted proofs were checked and fully rewritten by the authors. We take responsibility for the final content of this work, including text, claims, or artifacts produced with the aid of generative AI.
References
Iz Beltagy, Matthew E. Peters, and Arman Cohan. Longformer: The long-document transformer. arXiv, 2004.05150, 2020.
Michel Benaïm. Dynamics of stochastic approximation algorithms. In Séminaire de Probabilités XXXIII, volume 1709, pages 1–68. Springer, 1999.
Giuseppe Bruno, Federico Pasqualotto, and Andrea Agazzi. Emergence of meta-stable clustering in mean-field transformer models. In ICLR, 2025.
Martin Burger, Samira Kabri, Yury Korolev, Tim Roith, and Lukas Weigand. Analysis of mean-field models arising from self-attention dynamics in transformer architectures with layer normalization. Phil. Trans. Royal Soc. A: Math., Phys., Engg. Sci., 383(2298), 2025.
Shouyuan Chen, Sherman Wong, Liangjian Chen, and Yuandong Tian. Extending context window of large language models via positional interpolation. arXiv, 2306.15595, 2023.
Zihang Dai, Zhilin Yang, Yiming Yang, Jaime Carbonell, Quoc Le, and Ruslan Salakhutdinov. Transformer-XL: Attentive language models beyond a fixed-length context. In ACL, pages 2978–2988, 2019.
Yiran Ding, Li Lyna Zhang, Chengruidong Zhang, Yuanyuan Xu, Ning Shang, Jiahang Xu, Fan Yang, and Mao Yang. LongRoPE: Extending LLM context window beyond 2 million tokens. In ICML, pages 11091–11104, 2024.
Elvis Dohmatob. Understanding softmax attention layers: Exact mean-field analysis on a toy problem. In NeurIPS, 2025.
Yihe Dong, Jean-Baptiste Cordonnier, and Andreas Loukas. Attention is not all you need: Pure attention loses rank doubly exponentially with depth. In ICML, pages 2793–2803, 2021.
Borjan Geshkovski, Cyril Letrouit, Yury Polyanskiy, and Philippe Rigollet. The emergence of clusters in self-attention dynamics. In NeurIPS, 2023.
Hanna Herasimchyk, Robin Labryga, Tomislav Prusina, and Sören Laue. A structural theory of position bias in transformers. arXiv, 2602.16837, 2026.
Masato Hisakado and Shintaro Mori. Two kinds of phase transitions in a voting model. J. Phys. A: Math. Theor., 45(34):345002, 2012.
Cars H. Hommes and Marius I. Ochea. Multiple equilibria and limit cycles in evolutionary games with Logit Dynamics. Games Econ. Behav., 74(1):434–441, 2012.
Jie Huang, Xinyun Chen, Swaroop Mishra, Huaixiu Steven Zheng, Adams Wei Yu, Xinying Song, and Denny Zhou. Large language models cannot self-correct reasoning yet. In ICLR, 2024.
Xinting Huang, Andy Yang, Satwik Bhattamishra, Yash Sarrof, Andreas Krebs, Hattie Zhou, Preetum Nakkiran, and Michael Hahn. A formal framework for understanding length generalization in transformers. In ICLR, 2025.
Angelos Katharopoulos, Apoorv Vyas, Nikolaos Pappas, and François Fleuret. Transformers are RNNs: Fast autoregressive transformers with linear attention. In ICML, pages 5156–5165, 2020.
Amirhossein Kazemnejad, Inkit Padhi, Karthikeyan Natesan Ramamurthy, Payel Das, and Siva Reddy. The impact of positional encoding on length generalization in transformers. In NeurIPS, 2023.
Juno Kim and Taiji Suzuki. Transformers learn nonlinear features in-context: nonconvex mean-field dynamics on the attention landscape. In ICML, 2024.
Jingkun Liu, Yisong Yue, Max Welling, and Yue Song. Krause synchronization transformers. In ICML, 2026.
Shintaro Mori and Masato Hisakado. Correlation function for generalized Pólya urns: Finite-size scaling analysis. Phy. Rev. E, 92(5):052112, 2015.
Tsendsuren Munkhdalai, Manaal Faruqui, and Siddharth Gopal. Leave no context behind: Efficient infinite context transformers with infini-attention. arXiv, 2404.07143, 2024.
Yui Oka, Kentaro Hanafusa, Taku Hasegawa, Kyosuke Nishida, and Kuniko Saito. Probing rotary position embeddings through frequency entropy. In ICLR, 2026.
Bowen Peng, Jeffrey Quesnelle, Honglu Fan, and Enrico Shippole. YaRN: Efficient context window extension of large language models. In ICLR, 2024.
Yury Polyanskiy, Philippe Rigollet, and Andrew Yao. Synchronization of mean-field models on the circle. arXiv, 2507.22857, 2025.
Ofir Press, Noah A. Smith, and Mike Lewis. Train short, test long: Attention with linear biases enables input length extrapolation. In ICLR, 2022.
Jack W. Rae, Anna Potapenko, Siddhant M. Jayakumar, Chloe Hillier, and Timothy P. Lillicrap. Compressive transformers for long-range sequence modelling. In ICLR, 2020.
Hubert Ramsauer et al. Hopfield networks is all you need. In ICLR, 2021.
Isaac Reid, Arijit Sehanobish, Cederik Höfs, Bruno Kacper Mlodozeniec, Leonhard Vulpius, Federico Barbero, Adrian Weller, Krzysztof Marcin Choromanski, Richard E. Turner, and Petar Veličković. Rotary position encodings for graphs. In ICML, 2026.
Philippe Rigollet. The mean-field dynamics of transformers. In ICM, pages 389–404, 2026.
Anian Ruoss, Grégoire Delétang, Tim Genewein, Jordi Grau-Moya, Róbert Csordás, Mehdi Bennani, Shane Legg, and Joel Veness. Randomized positional encodings boost length generalization of transformers. In ACL, 2023.
Mrinank Sharma, Meg Tong, Tomasz Korbak, David Duvenaud, Amanda Askell, Samuel R. Bowman, Esin Durmus, Zac Hatfield-Dodds, Scott R. Johnston, Shauna Kravec, Timothy Maxwell, Sam McCandlish, Kamal Ndousse, Oliver Rausch, Nicholas Schiefer, Da Yan, Miranda Zhang, and Ethan Perez. Towards understanding sycophancy in language models. In ICLR, 2024.
Peter Shaw, Jakob Uszkoreit, and Ashish Vaswani. Self-attention with relative position representations. In NAACL, pages 464–468, 2018.
Eva Silverstein, Daniel Kunin, and V. Shyam. Symmetry breaking in transformers for efficient and interpretable training. arXiv, 2601.22257, 2026.
Jianlin Su, Murtadha H. M. Ahmed, Yu Lu, Shengfeng Pan, Wen Bo, and Yunfeng Liu. Roformer: Enhanced transformer with rotary position embedding. Neurocomputing, 568:127063, 2024.
Yutao Sun, Li Dong, Barun Patra, Shuming Ma, Shaohan Huang, Alon Benhaim, Vishrav Chaudhary, Xia Song, and Furu Wei. A length-extrapolatable transformer. In ACL, pages 14590–14604, 2023.
Hamidou Tembine, Manzoor Ahmed Khan, and Issa Bamia. Mean-field-type transformers. Mathematics, 12(22):3506, 2024.
Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. In NIPS, 2017.
Jie Wang, Tao Ji, Yuanbin Wu, Hang Yan, Tao Gui, Qi Zhang, Xuanjing Huang, and Xiaoling Wang. Length generalization of causal transformers without position encoding. In ACL (Findings), 2024.
Yuhuai Wu, Markus N. Rabe, DeLesley Hutchins, and Christian Szegedy. Memorizing transformers. In ICLR, 2022.
Guangxuan Xiao, Yuandong Tian, Beidi Chen, Song Han, and Mike Lewis. Efficient streaming language models with attention sinks. In ICLR, 2024.
Mingyu Xu, Xin Men, Bingning Wang, Qingyu Zhang, Hongyu Lin, Yaojie Lu, Xianpei Han, and Weipeng Chen. Base of rope bounds context length. In NeurIPS, pages 87386–87410, 2024.
Manzil Zaheer, Guru Guruganesh, Kumar Avinava Dubey, Joshua Ainslie, Chris Alberti, Santiago Ontanon, Philip Pham, Anirudh Ravula, Qifan Wang, Li Yang, and Amr Ahmed. Big bird: Transformers for longer sequences. In NeurIPS, 2020.