Skip to main content
QUICK REVIEW

[Paper Review] Signal Propagation in Transformers: Theoretical Perspectives and the Role of Rank Collapse

Lorenzo Noci, Sotiris Anagnostidis|arXiv (Cornell University)|Jun 7, 2022
Neural Networks and ApplicationsComputer Science4 citations
TL;DR

This paper investigates signal propagation in Transformers, identifying rank collapse at initialization as a root cause of vanishing gradients in queries and keys. It proposes depth-dependent residual scaling to stabilize token representation rank and gradient flow, while revealing asymmetric gradient norms across query/key vs. value parameters, explaining the efficacy of adaptive optimizers in Transformers.

ABSTRACT

Transformers have achieved remarkable success in several domains, ranging from natural language processing to computer vision. Nevertheless, it has been recently shown that stacking self-attention layers - the distinctive architectural component of Transformers - can result in rank collapse of the tokens' representations at initialization. The question of if and how rank collapse affects training is still largely unanswered, and its investigation is necessary for a more comprehensive understanding of this architecture. In this work, we shed new light on the causes and the effects of this phenomenon. First, we show that rank collapse of the tokens' representations hinders training by causing the gradients of the queries and keys to vanish at initialization. Furthermore, we provide a thorough description of the origin of rank collapse and discuss how to prevent it via an appropriate depth-dependent scaling of the residual branches. Finally, our analysis unveils that specific architectural hyperparameters affect the gradients of queries and values differently, leading to disproportionate gradient norms. This suggests an explanation for the widespread use of adaptive methods for Transformers' optimization.

Motivation & Objective

  • Understand the causes and effects of rank collapse in self-attention layers during Transformer initialization.
  • Investigate how rank collapse hinders training by causing vanishing gradients in query and key parameters.
  • Propose a depth-dependent residual scaling strategy to preserve the rank of token representations and stabilize signal propagation.
  • Analyze how architectural hyperparameters differentially affect gradient norms of queries, keys, and values.
  • Provide theoretical and empirical justification for the widespread use of adaptive optimizers in training deep Transformers.

Proposed method

  • Derive theoretical expressions for expected gradients of queries, keys, and values in a single self-attention layer at initialization using random matrix theory.
  • Formulate a depth-dependent residual scaling scheme that stabilizes the cosine similarity between token representations, preventing rank collapse.
  • Show that the gradient norm of queries and keys scales cubically with input norm, while values scale linearly, leading to disproportionate gradient magnitudes.
  • Introduce a temperature-scaled softmax in attention to empirically balance gradient norms between queries and values.
  • Use theoretical analysis and empirical validation across toy tasks and IWSLT’14 translation to verify gradient dynamics and stability.
  • Train models with learnable residual scaling and monitor correlation, activation norms, and gradient flow to validate theoretical predictions.

Experimental results

Research questions

  • RQ1How does rank collapse at initialization affect the gradients of query and key parameters in deep Transformers?
  • RQ2What architectural mechanisms can prevent rank collapse and stabilize signal propagation across depth?
  • RQ3Why do adaptive optimizers like Adam perform better in Transformers, and is this explained by gradient norm disparities?
  • RQ4How do input correlation, sequence length, and embedding dimension influence the relative gradient norms of queries, keys, and values?
  • RQ5Can depth-dependent residual scaling stabilize the rank of token representations and improve training dynamics in deep Transformers?

Key findings

  • Rank collapse at initialization causes vanishing gradients in query and key parameters, severely impairing learning in deep Transformers.
  • Depth-dependent residual scaling stabilizes the cosine similarity between token representations, preserving rank and preventing degeneracy even in the infinite-depth limit.
  • The gradient norm of queries and keys scales cubically with input norm, while values scale linearly, leading to a significant imbalance in gradient magnitudes.
  • Empirical results confirm that without proper scaling, increasing depth leads to higher token alignment and worse training performance, as shown in Figure 1.
  • Introducing a temperature-scaled softmax with $ au = 8.5$ balances gradient norms between queries and values, validating theoretical predictions.
  • In trained models, residual scaling parameters $eta_1, eta_2$ adapt during training, and token correlation remains low, supporting the theoretical stability of the proposed scaling.

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.