Sandwich Normalization for Scaling Deep Transformers

This direction is no longer present in the current build. Its last version stays readable and citable here.

Version 1 of 111 papers18 conceptsfrozen 2026-10-04

As Transformer models scale to billions of parameters and hundreds of layers, they encounter a fundamental stability bottleneck. While the standard "Pre-LN" architecture (placing Layer Normalization before the sub-layer) is more stable than the original "Post-LN" design, it suffers from a phenomenon where activation values grow exponentially as they pass through successive residual blocks. This "value explosion" leads to numerical overflow in mixed-precision training (FP16/BF16) and eventual training collapse.

To solve this, researchers have converged on a strategy of "sandwiching" sub-layers between multiple normalization steps or carefully repositioning normalization to clamp signal growth.

The Stability-Capacity Tradeoff

The placement of Layer Normalization (LN) defines the signal flow of a Transformer. In the original Post-LN Transformer, LN is placed after the residual addition. As Hongfei Xu and colleagues explain in Lipschitz Constrained Parameter Initialization for Deep Transformers, this preserves representational capacity by preventing the identity path from dominating, but it makes the model notoriously difficult to converge at great depths without specialized initialization.

Most modern models shifted to Pre-LN for stability. However, Pre-LN has a hidden cost: because the output of each sub-layer is added directly to the residual stream without being normalized first, the magnitude of the hidden states tends to increase with depth. In very large models, these activations can exceed the range of half-precision floating-point formats.

Clamping Activations with Sandwich LayerNorm

The "Sandwich" approach introduces an additional normalization layer at the end of the residual branch, right before the addition.

In CogView: Mastering Text-to-Image Generation via Transformers, Chang Zhou and Ming Ding found that for a 4-billion parameter model, standard Pre-LN was insufficient to prevent value explosion. By adding an extra LN at the end of each residual branch, they effectively "sandwiched" the attention and feed-forward blocks. This ensures that the values being added to the main residual stream are always at a consistent scale, preventing the total variance from spiraling out of control.

This dual-normalization strategy has become a cornerstone for multi-modal scaling. For instance, Le Zhuo and the team behind Lumina-Next : Making Lumina-T2X Stronger and Faster with Next-DiT utilized RMSNorm both before and after attention blocks. This "Next-DiT" architecture allows for stable training of models exceeding 5 billion parameters, even when using aggressive mixed-precision settings.

Finding the Goldilocks Placement

The research direction has evolved from simply adding more layers to finding the "Goldilocks" placement that balances stability and gradient flow.

  1. Peri-LN: In Peri-LN: Revisiting Normalization Layer in the Transformer Architecture, Jeonghoon Kim and collaborators formalize the "dual-normalization" intuition. By normalizing both the input and output of sub-layers, Peri-LN prevents the massive activation spikes seen in Pre-LN while avoiding the vanishing gradient issues that plague deep Post-LN models.
  2. Res-Post-LN: When scaling vision models to 3 billion parameters, Han Hu and the Swin Transformer V2: Scaling Up Capacity and Resolution team moved the normalization layer from the start of the block to the end of the residual branch. This architectural shift ensures that the main trunk of the network stays normalized, which is critical for handling ultra-high-resolution images where activation variance is high.

Why It Works: Numerical Range and Quantization

The primary benefit of these techniques is numerical. By keeping activations within a tight bound, the model becomes more robust to the precision bottlenecks of modern hardware.

This stability has downstream benefits for deployment. Aohan Zeng and the authors of GLM-130B: An Open Bilingual Pre-trained Model demonstrated that using a stabilized Post-LN variant (with modified initialization) allowed a 130-billion parameter model to be quantized to INT4 with almost no loss in performance. Because the activations are well-behaved and lack extreme outliers, they map more cleanly to low-precision integers, enabling massive models to run on consumer-grade hardware.

Papers in this version

History & citationVersion 1 · 2026-10-04

No longer present in the current build · Permanent link

View frozen version 1

Cite this direction

Latest version (a living page):

@misc{lacuna_sandwich_normalization_for_scaling_deep__0ad7c6ed,
  title = {Sandwich Normalization for Scaling Deep Transformers},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/sandwich-normalization-for-scaling-deep-transformers/rdr_0ad7c6edbdc84476a118299e9ca10587},
  note = {Latest version of a living research direction; cite a version for a fixed text. Accessed 2026-12-04},
}

This exact version (version 1, frozen text):

@misc{lacuna_sandwich_normalization_for_scaling_deep__0ad7c6ed_v1,
  title = {Sandwich Normalization for Scaling Deep Transformers},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/sandwich-normalization-for-scaling-deep-transformers/rdr_0ad7c6edbdc84476a118299e9ca10587/v/1},
  note = {Version 1, frozen 2026-10-04. Accessed 2026-12-04},
}