Abstract
This paper investigates the impact of various normalization schemes on the representation dynamics of transformer models. By modeling tokens as interacting particles on a high-dimensional sphere, we characterize normalization as a "speed regulation" mechanism. We analyze Post-LN, Pre-LN, Peri-LN, and nGPT, demonstrating that Peri-LN provides an optimal balance between early-layer expressivity and deep-layer stability, preventing representation collapse while avoiding the "curse of depth."
1. Introduction
In the architecture of deep transformers, the placement of Layer Normalization (LN) is a critical design choice that significantly influences training stability and model performance. Historically, the original transformer design utilized Post-LN, which often suffers from training instability and "representation collapse"—a state where tokens become nearly identical too early in the network. To mitigate this, the industry transitioned to Pre-LN, which is now the standard for models like GPT-4 and LLaMA. However, Pre-LN introduces its own set of challenges, specifically the "curse of depth," where deeper layers perform near-identity transformations and contribute minimally to the final output.
This study provides a unified theoretical framework to explain these behaviors by treating transformer layers as a continuous dynamical system. We evaluate newer hybrid schemes, such as Peri-LN and nGPT, to determine how they regulate the evolution of token representations.
2. Theoretical Framework: Tokens as Interacting Particles
To analyze the evolution of token representations across layers, we model tokens as a system of interacting particles constrained to the surface of a high-dimensional sphere. By converting discrete transformer layers into a continuous-time Ordinary Differential Equation (ODE), we identify a "speed regulation factor" ($s_j(t)$) unique to each normalization scheme.
This framework allows for a rigorous comparison of Post-LN, Pre-LN, Mix-LN, Peri-LN, nGPT, and sqrt-scaling on a level playing field. Using Lyapunov stability and gradient flow analysis, we track the rate at which tokens "cluster" or synchronize, which serves as a proxy for representation collapse.
2.1 Simulation Methodology
Given the theoretical nature of this work, simulations were conducted using:
- Synthetic Initializations: Tokens were initialized with orthogonal symmetric configurations or sampled from a uniform distribution on a sphere.
- Random Weight Matrices: Kaiming initialization was employed to test dynamics across various dimensions ($d$) and temperatures ($eta$).
- NanoGPT-style Validations: Small-scale setups mimicking GPT-2 configurations were used to validate theoretical predictions in a practical context.
3. Normalization as Speed Control
The central insight of this work is that normalization functions primarily as a regulator of the "velocity" at which representations evolve through the network.
- Post-LN (Constant Speed): Post-LN maintains a constant evolution speed. While this ensures activity in every layer, it causes tokens to converge into a single cluster exponentially fast, leading to premature representation collapse in deep networks.
- Pre-LN (Sluggishness): Pre-LN slows down as the magnitude of representations grows. While this prevents collapse, it makes the model "lazy" in early layers, where movement occurs at a suboptimal pace ($O(\log n/d)$).
- Peri-LN (The "Goldilocks" Choice): Perimeter-LN (Peri-LN) achieves "order-one" (fast) movement in early layers while maintaining a polynomial (gradual) slowdown in later layers. This ensures that every layer, from the first to the last, contributes meaningfully to the computation without collapsing.
- nGPT (Adaptive Speed): The nGPT architecture utilizes a learnable parameter ($\alpha_t$), allowing the model to learn its own optimal speed regulation during the training process.
4. Key Results
Our mathematical analysis and simulations yield several critical findings:
- Asymptotic Clustering: We prove that under almost all normalization schemes, tokens will eventually synchronize into a single cluster if the network is sufficiently deep (Theorem 3.1).
- Initial Velocity Advantage: Theorem 4.2 demonstrates that Peri-LN and nGPT move tokens significantly further in the initial layers compared to Post-LN and Pre-LN, maximizing early-layer expressivity.
- Terminal Velocity Decay: We quantified the slowdown in deep layers. Pre-LN and Peri-LN exhibit a polynomial decay ($1/t^3$), which is significantly more stable for deep models than the aggressive exponential decay observed in Post-LN.
5. Limitations and Future Work
While this framework provides a robust lens for understanding attention dynamics, certain simplifications were made to maintain mathematical tractability. The current study omits Feed-Forward Network (FFN) layers and relies on specific assumptions regarding weight matrices (e.g., tied weights or specific norm constraints). Furthermore, the analysis focuses on forward dynamics; a companion study modeling gradient dynamics during backpropagation is currently in progress. Future research will also explore stochasticity to better capture the behavior of transformers during the active training process.
6. Conclusion
By reframing normalization as a speed regulation problem, we clarify why certain architectures succeed where others fail. Peri-LN and nGPT emerge as superior alternatives to standard Pre-LN by balancing the need for rapid initial representation development with long-term stability in deep architectures.
Summary updated