Activation Functions Shape Token Clustering in Stochastic Transformer Dynamics

Nikita KaragodinNeurIPS 2026

TL;DR

Deep transformers have a notorious tendency to squash all token representations into a single, indistinguishable blob at deep layers—a failure mode called "token collapse." This paper reveals that your humble MLP activation function acts as the secret steering wheel of this geometry: while standard ReLU relentlessly drives tokens into total consensus, modern alternatives like $\text{ReLU}^2$, GELU, and SwiGLU actively sustain a rich, spread-out cloud of representations, provided the embedding dimension is large enough.

What Problem Does This Paper Address?

Picture tokens entering a transformer as a vibrant swarm of particles on a high-dimensional sphere. As they pass through layer after layer, you want them to organize meaningfully—not clump together into one dead point where every word looks identical.

Historically, theorists modeled this evolution as an interacting particle system driven purely by self-attention, which overwhelmingly predicted that tokens eventually synchronize and collapse. Recently, researchers (Agazzi et al., 2026) brought the MLP blocks into the picture, showing that wide, randomly initialized MLPs act like a shared random wind (common noise) blowing across all tokens simultaneously. Under basic assumptions, this shared wind actually accelerates collapse—a classic physics quirk called "synchronization by noise."

Meanwhile, practitioners have quietly migrated from ReLU (the original Transformer) to GELU (BERT, GPT), SwiGLU (LLaMA, PaLM), and $\text{ReLU}^2$ (Primer, nanochat) based largely on empirical trial-and-error and compute efficiency. The missing link: How does the specific choice of MLP activation function shape token geometry at depth, and can the right activation prevent collapse?

Methods

Building directly on the continuous-depth Stochastic Differential Equation (SDE) framework of Agazzi et al., the author models $n$ tokens evolving on a unit sphere $\mathbb{S}^{d-1}$ (mimicking post-layer RMSNorm). Attention provides a deterministic drift, while infinite-width MLPs at initialization inject a shared Brownian noise field.

What makes this tractable—and novel—is how the activation function enters the math: the covariance of the MLP noise between any two tokens depends solely on the angle between them, governed by the activation's normalized Neural Network Gaussian Process (NNGP) kernel, $\kappa$.

Using Itô calculus, the author tracks the pairwise inner product (correlation $\rho_{ij}$) between tokens:

  1. Pure Noise Regime: Turning attention off reduces the high-dimensional dance of two tokens to an exact 1D scalar diffusion. The author applies classical Feller boundary classification to determine when $\rho_{ij} = 1$ (collapse) acts as a trap versus a repeller.
  2. With Attention: Turning attention back on couples all the particles. Using concavity bounds on the kernel drift and pathwise SDE comparisons under Lipschitz attention assumptions, the author pits the MLP's geometric push against attention's pull.

Datasets

Not discussed in the paper. Because this is a theoretical investigation of signal propagation and stochastic dynamics at initialization, numerical validations are performed on synthetic token clouds initialized uniformly on the unit sphere (including finite-width simulations at nanoGPT scales, $d=768$).

Key Insights and Ideas

  • ReLU is uniquely collapsible: Among all standard activations tested, ReLU is the only one that forces tokens to synchronize in every embedding dimension $d \ge 3$. It sits right on a mathematical knife-edge where finite-dimensional noise fluctuations tip it toward total collapse.
  • Dimension unlocks diversity: For steeper activations ($\text{ReLU}^2$, $\text{ReLU}^3$, GELU, SiLU, tanh, SwiGLU), synchronization by noise breaks above an explicit critical embedding dimension $d_*$. Above $d_*$, tokens refuse to merge and instead settle into a stable, spread-out equilibrium distribution!
Figure 1: Histograms of all pair correlations ρij(T) in clouds of n = 256 tokens at T = 500 (τ = 1, V = 0, σ = 0.3). Bold/faint curves show three independent clouds; colors identify d. Black curves are invariant single-pair densities πd for d > d∗; dotted lines mark ακ. A cloud’s histogram remains random under shared noise. Arrows label clipped-bin mass within 1/30 of ±1. Uniform initialization; projected Euler–Maruyama with dt ≤0.05.
  • Why gating (SwiGLU) is so repulsive: Everything hinges on the kernel slope at consensus, $\chi_1 = \kappa'(1)$. Gated MLPs multiply a nonlinear branch by a linear projection, which transforms the kernel into $\rho\,\kappa(\rho)$ and adds $+1$ to the slope $\chi_1$. This makes SwiGLU fiercely anti-collapsing, keeping tokens nearly orthogonal on average.
  • Sparsity twins, geometric opposites: Practitioners often group ReLU and $\text{ReLU}^2$ together because both yield sparse activations for fast inference. Dynamically, however, they are polar opposites: ReLU erases token differences, whereas $\text{ReLU}^2$ actively protects them—even when attention tries to pull tokens together.

Key Results

The theory yields crisp, quantitative thresholds (evaluated at standard LeCun initialization scale $\tau = 1$):

  • Critical Dimensions ($d_*$): The minimum integer dimension $\lfloor d_* \rfloor + 1$ required to escape noise-induced collapse is 5 for SwiGLU ($\chi_1 \approx 2.07$), 6 for $\text{ReLU}^3$ ($\chi_1 = 1.8$), 10 for $\text{ReLU}^2$ ($\chi_1 = 1.33$), 15 for tanh, 31 for GELU ($\chi_1 \approx 1.07$), and 34 for SiLU. For ReLU ($\chi_1 = 1$), $d_* = \infty$.
Critical dimensions and limiting correlations across activations
  • Surviving Attention: Under bounded, Lipschitz attention (strength $v$, query-Lipschitz constant $L$), ReLU forces all pairs to collapse exponentially fast whenever $v(1+L) < \sigma^2$ (where $\sigma$ is MLP noise strength). Conversely, for $d \ge 10$, $\text{ReLU}^2$ guarantees no pair of tokens collapses if $v < \frac{\sigma^2(d-9)}{6(1+L)}$.
  • Finite-Width Reality Check: Simulating actual finite-width post-LN transformers at nanoGPT scale ($d=768$, hidden width $m=3072$, 96 layers) closely tracks the infinite-width SDE predictions, with mean pairwise correlation discrepancies no larger than $\sim 0.035$.
Figure 2: Finite post-normalized transformer at nanoGPT widths: d = 768, m = 3072, n = 128, τ ≈0.55, with matched MLP branch variance (h = 0.131). Solid curves and shading: stack means ±2 SE over 24 seeds; dashed: SDE estimates. (a) Attention off; hollow markers use LayerNorm (8 seeds), and dotted lines are long-time guides (consensus for ReLU). (b) Tied, non-causal softmax attention. Mean discrepancies reach about 0.035. The configuration, time conversion and numerical checks are specified in Appendix G.

Limitations and Future Work

  • Initialization vs. Trained Weights: The SDE models fresh, centered random MLP weights across layers—capturing signal propagation at initialization rather than learned feature transformations after training.
  • Worst-Case Attention Bounds: When attention is active, the non-collapse guarantees rely on worst-case magnitude and Lipschitz bounds rather than exploiting the fine-grained clustering structure of specific query-key matrices.
  • Technical & Open Questions: Rigorous discrete-to-SDE convergence for super-linear activations ($\text{ReLU}^p$ for $p \ge 2$) and gated blocks still requires formal pre-limit truncation arguments. Furthermore, the author poses an open conjecture: that ReLU collapses tokens under any row-stochastic attention weights (dropping the Lipschitz requirement) so long as $\|V\|_{\text{op}} < \sigma^2/2$.

Summary updated

BibTeX
@inproceedings{karagodin2026activation,
  author = {Nikita Karagodin},
  title = {{Activation Functions Shape Token Clustering in Stochastic Transformer Dynamics}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=do7lcGzKAH},
}
Figure