ResiDual: Transformer with Dual Residual Connections

Shufang Xie, Huishuai Zhang, Junliang Guo, Xu Tan, Jiang Bian, Hany Hassan Awadalla, Arul Menezes, Tao Qin, Rui Yan · DOI

Abstract

Transformer architectures typically rely on either Post-Layer Normalization (Post-LN) for performance or Pre-Layer Normalization (Pre-LN) for stability. ResiDual introduces a "Dual Residual Connection" architecture that fuses these approaches. By maintaining parallel residual paths, ResiDual avoids both gradient vanishing and representation collapse, enabling stable training of deep models with high representational capacity without requiring complex training tricks like extensive learning rate warm-up.

Introduction

Residual connections and Layer Normalization (LN) are fundamental to the success of Transformer networks. However, the placement of LN creates a significant trade-off:

  1. Post-LN (The Original): Applies LN after the residual addition. While it offers high representational capacity, it is notoriously difficult to train in deep configurations because gradients "vanish" (shrink to near zero) before reaching early layers.
  2. Pre-LN (The Modern Standard): Applies LN before the residual block. This is the standard for stability in large models like GPT-3, but it suffers from representation collapse: as the model gets deeper, hidden states become increasingly similar, limiting the effective capacity of the added depth.

ResiDual addresses this "residual dilemma" by proposing an architecture that is as stable as Pre-LN and as expressive as Post-LN.

The ResiDual Architecture

The core innovation is the Pre-Post-LN (PPLN) structure. Instead of choosing one path, ResiDual maintains two parallel residual connections:

  • The Post-LN Path: Ensures each layer continues to refine hidden representations with high diversity, preventing the "collapse" seen in Pre-LN.
  • The Pre-LN Path: Acts as a "gradient highway," allowing signals to flow freely from output to input by bypassing the multiple LN operations that usually squash signal magnitude.
Comparison of Post-LN, Pre-LN, and the proposed ResiDual architecture.

The final output of a ResiDual block is the sum of a normalized Post-LN-style state and a normalized "dual" residual state. Notably, this design adds zero additional parameters to the model; it simply optimizes how existing components are wired together.

Key Insights and Stability

The authors provide theoretical and empirical evidence that ResiDual achieves the "best of both worlds." It maintains a lower bound on gradients (preventing vanishing) and a lower bound on representation variance (preventing collapse).

Empirical evidence showing ResiDual maintains stable gradient norms and high representation diversity compared to Pre-LN and Post-LN.

A significant practical benefit is warm-up independence. One of the most frustrating aspects of Post-LN is the need for a "warm-up" period where the learning rate is kept very low. ResiDual is so stable that it can be trained effectively even with a linear learning rate or no warm-up at all—a feat standard Post-LN cannot achieve.

Experimental Results

ResiDual was evaluated across several machine translation benchmarks to test scalability:

  • WMT (German-English): A deep ResiDual model (18 encoder/18 decoder layers) achieved 27.65 BLEU, significantly outperforming Pre-LN (26.57). In this deep setting, standard Post-LN failed to converge entirely.
  • OPUS-100: On this massive multilingual dataset, ResiDual outperformed the Pre-LN baseline by 0.7 BLEU points.
  • Training Robustness: In experiments without learning rate warm-up, ResiDual maintained high accuracy (35.76 BLEU on IWLST), while Post-LN failed to train and Pre-LN saw a significant performance drop.

Conclusion and Future Work

ResiDual offers a robust foundation for deep Transformer models by resolving the structural limitations of standard LN placements. While currently validated on translation tasks, its stability and capacity make it a promising candidate for large-scale language models (LLMs). Future work includes addressing FP16 overflow issues in extremely deep models and scaling to hundreds of billions of parameters to see if these stability benefits hold at the extreme edge of scale.

Summary updated

BibTeX
@misc{xie2023residual,
  author = {Shufang Xie and Huishuai Zhang and Junliang Guo and Xu Tan and Jiang Bian and Hany Hassan Awadalla and Arul Menezes and Tao Qin and Rui Yan},
  title = {{ResiDual: Transformer with Dual Residual Connections}},
  year = {2023},
  eprint = {2304.14802},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2304.14802},
}
Figure