Skip to main content
QUICK REVIEW

[Paper Review] Pre-RMSNorm and Pre-CRMSNorm Transformers: Equivalent and Efficient Pre-LN Transformers

Zixuan Jiang, Jiaqi Gu|arXiv (Cornell University)|May 24, 2023
Natural Language Processing TechniquesComputer Science3 citations
TL;DR

This paper proposes Pre-RMSNorm and Pre-CRMSNorm Transformers as equivalent, more efficient variants of standard Pre-LN Transformers by eliminating redundant mean computation in LayerNorm. By recentering main-branch activations and applying lossless compression to zero-mean vectors, the authors achieve 1%-10% faster training and inference without performance drop, unifying LayerNorm and RMSNorm in a theoretically equivalent, functionally identical framework.

ABSTRACT

Transformers have achieved great success in machine learning applications. Normalization techniques, such as Layer Normalization (LayerNorm, LN) and Root Mean Square Normalization (RMSNorm), play a critical role in accelerating and stabilizing the training of Transformers. While LayerNorm recenters and rescales input vectors, RMSNorm only rescales the vectors by their RMS value. Despite being more computationally efficient, RMSNorm may compromise the representation ability of Transformers. There is currently no consensus regarding the preferred normalization technique, as some models employ LayerNorm while others utilize RMSNorm, especially in recent large language models. It is challenging to convert Transformers with one normalization to the other type. While there is an ongoing disagreement between the two normalization types, we propose a solution to unify two mainstream Transformer architectures, Pre-LN and Pre-RMSNorm Transformers. By removing the inherent redundant mean information in the main branch of Pre-LN Transformers, we can reduce LayerNorm to RMSNorm, achieving higher efficiency. We further propose the Compressed RMSNorm (CRMSNorm) and Pre-CRMSNorm Transformer based on a lossless compression of the zero-mean vectors. We formally establish the equivalence of Pre-LN, Pre-RMSNorm, and Pre-CRMSNorm Transformer variants in both training and inference. It implies that Pre-LN Transformers can be substituted with Pre-(C)RMSNorm counterparts at almost no cost, offering the same arithmetic functionality along with free efficiency improvement. Experiments demonstrate that we can reduce the training and inference time of Pre-LN Transformers by 1% - 10%.

Motivation & Objective

  • To resolve the ongoing debate on whether LayerNorm or RMSNorm is superior in Pre-LN Transformers by establishing equivalence between them.
  • To eliminate the computational redundancy in Pre-LN Transformers, where mean recentering is inherently redundant due to normalization.
  • To propose Compressed RMSNorm (CRMSNorm) as a lossless compression of zero-mean vectors to further improve efficiency.
  • To formally prove that Pre-LN, Pre-RMSNorm, and Pre-CRMSNorm Transformers are arithmetically equivalent in both training and inference.
  • To enable seamless, cost-free conversion of Pre-LN models into more efficient Pre-(C)RMSNorm counterparts for deployment and training.

Proposed method

  • Identify that the main-branch vectors in Pre-LN Transformers are always normalized, making the mean component redundant and removable.
  • Replace LayerNorm with RMSNorm by recentering the main-branch input before normalization, preserving model functionality while reducing computation.
  • Introduce Compressed RMSNorm (CRMSNorm), which takes a d−1-dimensional vector, decompresses it to a zero-mean d-dimensional vector, and applies RMSNorm on the decompressed vector.
  • Propose the Pre-CRMSNorm Transformer, which applies CRMSNorm to zero-mean activations and parameters, enabling lossless compression and efficiency gains.
  • Formally prove the arithmetic equivalence of Pre-LN, Pre-RMSNorm, and Pre-CRMSNorm Transformers in both training and inference through mathematical derivation.
  • Implement and benchmark the proposed variants on ViT and GPT models to validate efficiency gains and equivalence.

Experimental results

Research questions

  • RQ1Can LayerNorm in Pre-LN Transformers be replaced with RMSNorm without loss of model functionality or performance?
  • RQ2Is there a lossless compression method for zero-mean vectors that can further improve efficiency in normalization layers?
  • RQ3Can Pre-RMSNorm and Pre-CRMSNorm Transformers be formally proven equivalent to Pre-LN Transformers in both training and inference?
  • RQ4What is the practical efficiency gain in training and inference when replacing Pre-LN with Pre-(C)RMSNorm variants?
  • RQ5How does the efficiency improvement scale across different model sizes and architectures like ViT and GPT?

Key findings

  • The Pre-RMSNorm variant reduces training time by 2.36% on ViT models by replacing LayerNorm with RMSNorm after removing redundant mean computation.
  • The Pre-CRMSNorm variant achieves a 1.74% training speedup over the original Pre-LN model by eliminating recentering layers and using compressed normalization.
  • On GPT-3 models, the Pre-RMSNorm variant reduces inference time by up to 10% in smaller models, with a 4% reduction observed in GPT-3 XL and 2.7B variants under int8 quantization.
  • The speedup is consistent across both training and inference, with relative gains of 1%-2.5% for ViT and 1.5%-1.8% for GPT-3 Small and Medium models.
  • Normalization accounts for 10%-15% of training time in ViTs, making the efficiency gains from (C)RMSNorm particularly impactful in data-intensive training pipelines.
  • The proposed method is orthogonal to existing efficiency techniques such as quantization and knowledge distillation, enabling cumulative performance improvements.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.