Looped Transformers with Layer Normalization Provably Learn the Power Method

Lyumin Wu, Chenyang Zhang, Yuan CaoNeurIPS 2026

TL;DR

Why is Layer Normalization (LN) so indispensable in modern transformers? By studying a classic linear algebra task—finding the top principal component of a matrix—researchers proved that looped transformers with LN naturally discover and execute the "power method" algorithm from scratch. Strip away LN, however, and the model gets stuck in a suboptimal rut, unable to learn the exact algorithm even when explicitly spoon-fed the intermediate steps.

What Problem Does This Paper Address?

It’s late, so let's skip the usual fanfare: transformers run the world. A big reason why is their uncanny ability to learn and execute step-by-step algorithms in-context (like gradient descent or ridge regression). While theorists have started unpacking how transformers learn these algorithms during training, there has been a glaring blind spot: almost all existing theoretical analyses ignore Layer Normalization (LN).

In practice, LN (and its streamlined cousin, RMSNorm, used in Llama and Gemma) is critical for training stability and performance. Theoretically, however, LN introduces pesky input-dependent nonlinearities—dividing vectors by their norms—that make gradient dynamics notoriously hard to analyze. This paper bridges the gap between simplified theory and real-world architectures by providing the first theoretical analysis of how transformers with LN learn an algorithm during gradient descent.

Methods

As a clean testbed, the authors task a model with Principal Component Prediction: given a data matrix $\mathbf{X}$ and a random starting query vector $\mathbf{a}$, output a vector in the leading principal subspace of $\mathbf{X}\mathbf{X}^\top$ (i.e., find its top eigenvector).

They analyze a looped linear transformer—an architecture where a single linear self-attention layer (softmax removed, key/query and value/projection matrices consolidated) is stacked $L$ times with shared weights, recurrently feeding its output back into itself. Crucially, each layer ends with column-wise normalization structurally equivalent to RMSNorm.

The authors study two training setups using population gradient descent:

  1. End-to-end looped training: An $L$-layer looped model with LN is trained only to minimize the distance between its final output and the true principal subspace.
  2. Layerwise supervision (LN vs. No LN): Single-layer models with and without LN are explicitly supervised to output a single step of the classic power method—an iterative textbook algorithm where you repeatedly multiply a vector by $\mathbf{X}\mathbf{X}^\top$ and normalize it ($\frac{\mathbf{X}\mathbf{X}^\top \mathbf{a}}{\|\mathbf{X}\mathbf{X}^\top \mathbf{a}\|_2}$) to converge on the top eigenvector.

To tame the math of LN, the authors introduce new theoretical tools: using Schur’s lemma to prove that weight matrices maintain a clean, sparse block structure throughout training, and a dominated-convergence argument to keep input-dependent gradients well-behaved even as weight magnitudes grow to infinity.

Datasets

Because this is primarily a theoretical work, the authors validate their finite-sample predictions using two synthetic tasks ($d = 16$, $n = 32$, 10,000 training samples, 2,000 test samples, trained via SGD for 2,000 epochs):

  • Task 1 (Isotropic Sphere): Data matrices $\mathbf{X}$ where each column is sampled independently from a standard multivariate Gaussian and normalized to sit uniformly on the unit sphere.
  • Task 2 (Fixed Spectrum with Random Rotations): Data matrices $\mathbf{X} = \mathbf{R}\mathbf{U}$, multiplying a uniformly random orthogonal matrix $\mathbf{R}$ by a fixed basis matrix $\mathbf{U}$ with predetermined integer eigenvalues. No external benchmarks are used.

Key Insights and Ideas

  • Algorithmic Implicit Bias: There are many mathematical ways to compute a principal component. Yet when a looped transformer with LN is trained end-to-end just to predict that component, gradient descent naturally steers it to implement the exact $L$-step power method—with each attention pass executing one power iteration.
  • Diverging Weights Are a Feature, Not a Bug: Because each attention block has a residual connection, one layer computes $(\mathbf{I} + \rho_t \mathbf{X}\mathbf{X}^\top)\mathbf{a}$ before normalizing. To turn this into a pure power iteration ($\mathbf{X}\mathbf{X}^\top \mathbf{a}$), the learned scalar product $\rho_t$ must drown out the identity matrix $\mathbf{I}$. LN allows the model weights to safely diverge to infinity ($\rho_t \to \infty$) while keeping outputs normalized and optimization smooth!
  • Why Unnormalized Models Fail: Without LN, weights cannot diverge without blowing up the loss. Even when directly supervised with ideal power-iteration targets, an unnormalized transformer's weights freeze at a finite, suboptimal compromise, leaving residual identity noise that ruins exact algorithmic execution.

Key Results

  • Exact Power Method Rate: During end-to-end looped training with LN, active weight scalars grow polynomially at $\Theta(t^{1/4})$ (making their product $\rho_t$ grow at $\Theta(t^{1/2})$), while all off-target weight blocks stay strictly zero.
  • Layerwise Separation: Under single-step supervision, the LN model drives population loss arbitrarily close to zero ($\mathcal{L}(\boldsymbol{\theta}^{(t)}) \le \epsilon$). Without LN, the loss plateaus at a strictly positive floor, regardless of whether the target is normalized or unnormalized.
  • Out-of-Distribution (OOD) Generalization Gap: When unrolled for $L$ loops at test time on OOD data (requiring only unit-norm columns), the LN model achieves the theoretically optimal error contraction rate of $(\lambda_{r+1}/\lambda_1)^L$ (the ratio of the second-largest to largest distinct eigenvalues). The unnormalized model is stuck with a strictly slower contraction rate of $((1 + \gamma^\star \lambda_{r+1})/(1 + \gamma^\star \lambda_1))^L$. Empirical SGD plots closely match both the $\Theta(t^{1/4})$ weight scaling and the sharp gap in angular error decay over 25 inference loops.

Limitations and Future Work

The authors are upfront about the simplifying assumptions needed to make the math tractable:

  • Specific Initialization: The proofs rely on a specific block-identity initialization to ensure non-zero initial gradients and preserve sparse matrix structures; generalizing to random initializations remains an open question.
  • Simplified Architecture: The model uses linear attention (no softmax), omits MLP blocks, and drops the mean-centering step of standard LN (focusing on RMSNorm).
  • Population Gradients: Theoretical guarantees assume infinite-data population loss. Extending the proofs to finite-sample empirical gradients will require delicate perturbation analyses, which the authors leave for future work.

Summary updated

Abstract

Transformers have achieved remarkable success across a wide range of applications, and a growing body of work suggests that part of their strength comes from their ability to learn and execute algorithmic procedures. However, our understanding of how transformers learn such algorithms remains limited, especially in the presence of layer normalization (LN). In this work, we study principal component prediction as a concrete testbed for understanding the training dynamics of transformers with LN. We prove that a looped linear transformer with LN, trained by gradient descent, converges to a solution that implements the power method, with each self-attention layer performing one power iteration. Notably, the model is trained only for principal component prediction, rather than being explicitly supervised to implement the power method. Our finding thus reveals an ``algorithmic implicit bias'' of looped transformers with LN: principal-component prediction can in principle be achieved by many mechanisms, yet gradient descent selects one that realizes the power method. We further provide a concrete comparison between transformers with and without LN: even with layerwise guidance from power iterations, a transformer without LN cannot exactly learn the power method, whereas the corresponding transformer with LN can, leading to a provable performance gap in principal component prediction. Our results provide, to our knowledge, the first theoretical analysis of the training dynamics of looped and single-layer transformers with LN, and shed light on the role of LN in transformer models.
BibTeX
@inproceedings{wu2026looped,
  author = {Lyumin Wu and Chenyang Zhang and Yuan Cao},
  title = {{Looped Transformers with Layer Normalization Provably Learn the Power Method}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=oFm9j93SjQ},
}
Figure