Abstract
Normalization layers like LayerNorm are standard in deep Transformers for stability. This paper introduces Dynamic Tanh (DyT), a simple element-wise operation that replaces statistical normalization with a learnable squashing function. DyT matches or exceeds standard performance across vision, language, and speech while reducing computational complexity and improving inference speed.
Introduction
Since the introduction of Batch Normalization in 2015, normalization layers have been considered essential for stabilizing deep learning models. In Transformers, Layer Normalization (LN) ensures that activations do not explode or vanish as they pass through dozens of layers. However, normalization requires calculating statistics (mean and variance) across dimensions, creating computational overhead and synchronization bottlenecks in distributed training. This work explores whether the same stabilizing effect can be achieved with a simpler, element-wise operation.
The Dynamic Tanh (DyT) Method
By analyzing trained models like ViT and LLaMA, the authors discovered that LayerNorm often produces an S-shaped mapping in deeper layers. This mapping effectively "squashes" extreme outliers while remaining nearly linear for values near zero, behaving remarkably like a tanh function.
Based on this observation, the authors propose Dynamic Tanh (DyT) as a drop-in replacement for normalization layers:
$$DyT(x) = \gamma * \tanh(\alpha x) + \beta$$
In this formulation, $\alpha$ is a learnable scalar that scales the input before the squashing function, while $\gamma$ and $\beta$ are standard affine parameters (scale and shift). Unlike LayerNorm, DyT is strictly element-wise, treating every value in the tensor independently without needing to calculate statistics across tokens or channels.
Experimental Results
DyT was validated across an extensive range of domains, including computer vision (ImageNet-1K), large language models (LLaMA), generative AI (Diffusion Transformers), and speech processing (wav2vec 2.0).
- Performance: DyT-based models consistently matched or slightly outperformed their normalized counterparts. For example, a ViT-B with DyT achieved 82.5% top-1 accuracy on ImageNet, compared to 82.3% for standard LayerNorm.
- Scaling and Stability: The method successfully scaled to LLaMA-70B and enabled stable training in very deep architectures (e.g., ViT-L) where unnormalized models typically diverge.
- Efficiency: DyT is significantly faster at the layer level because it avoids reduction operations. For a LLaMA-7B model, the DyT layer itself is 52.4% faster in inference than RMSNorm.
Discussion and Limitations
The primary benefit of normalization in deep networks appears to be the non-linear squashing of outliers rather than the statistical normalization itself. DyT provides this squashing without the associated computational baggage. During training, the learnable parameter $\alpha$ naturally evolves to track the inverse standard deviation of activations, effectively "learning" the necessary scale.
However, limitations remain. DyT struggled to replace Batch Normalization in classic ConvNets like ResNet-50, likely due to the higher frequency of normalization layers in those architectures. Additionally, while theoretically faster, the speed advantage of DyT may be minimized by modern compiler optimizations like torch.compile. Finally, the initialization of the learnable parameter $\alpha$ is sensitive to model width, requiring careful tuning for large-scale models.
Summary updated