nGPT: Normalized Transformer with Representation Learning on the Hypersphere

Ilya Loshchilov, Cheng-Ping Hsieh, Simeng Sun, Boris Ginsburg

TL;DR

The normalized Transformer (nGPT) reimagines the Transformer architecture by constraining all internal vectors—embeddings, weights, and hidden states—to the surface of a unit hypersphere. By treating the model as a variable-metric optimizer on this sphere, nGPT achieves a staggering 4x to 20x speedup in training convergence compared to standard GPT models.

The Problem with Standard Transformers

Standard Transformer architectures, like those powering GPT-4 or Llama, are notoriously sensitive to the scale of their internal representations. To keep training stable, researchers have layered on "band-aids" like LayerNorm, RMSNorm, and weight decay. Despite these additions, hidden state norms can still fluctuate wildly, and weight matrices often become "ill-conditioned"—meaning they effectively lose rank and waste capacity.

Furthermore, there is a growing theoretical consensus that representation learning works best on a hypersphere (where all vectors have a length of 1), as it improves separability and training stability. However, previous attempts to "sphericalize" Transformers were often piecemeal. The authors of nGPT sought to unify these observations into a single, principled architecture where "unit norm" isn't just a feature, but the fundamental rule.

The nGPT Architecture

The core innovation of nGPT is that everything is a unit vector.

  1. Hyperspherical Parameters: All weight matrices (embeddings, MLP, and attention) are normalized along their embedding dimension. Because the weights are always unit-norm, traditional weight decay becomes unnecessary and is removed entirely.
  2. Spherical Updates: In a standard Transformer, a block's output is added to the input ($h \leftarrow h + \text{MLP}(h)$). In nGPT, the hidden state $h$ must remain on the sphere. The update is rewritten as a form of spherical interpolation: $$h \leftarrow \text{Norm}(h + \alpha(h_{block} - h))$$ This moves the token representation along the surface of the hypersphere toward a target prediction.

  3. Eigen Learning Rates: The $\alpha$ in the equation above is a learnable diagonal matrix. These "eigen learning rates" allow the model to independently tune how much each dimension contributes to the update at every layer.

  4. Scaling Factors: Because non-linear functions like SiLU or Softmax depend on the magnitude of their inputs, nGPT introduces learnable scaling parameters to "restore" the necessary variance lost during normalization.

Key Insights

  • The "Traveler" Metaphor: Think of a token as a point traveling on the surface of a globe. Each layer of the Transformer doesn't "add" information in the Euclidean sense; instead, it provides a displacement (a nudge) toward the next destination on the sphere.
  • Better Conditioning: Standard GPT models often develop "rank deficiency," where their weight matrices become redundant. nGPT's matrices maintain much lower condition numbers, meaning the model uses its parameters far more efficiently.
  • Implicit Optimization: The paper demonstrates that nGPT effectively performs a multi-step Riemannian optimization. It’s a specialized optimizer designed to find the best path across the hypersphere to predict the next token.

Key Results

The researchers trained and evaluated nGPT at 0.5B and 1B parameter scales using OpenWebText for pre-training and evaluated on standard downstream benchmarks.

Validation loss across 1K, 4K, and 8K context lengths, demonstrating nGPT's faster convergence compared to standard GPT.
  • Massive Speedup: nGPT reaches the same validation loss as a standard GPT model using significantly fewer steps. The speedup factor scales with sequence length: 4x for 1k context lengths, 10x for 4k, and a whopping 20x for 8k context lengths.
  • Superior Extrapolation: Standard GPT models usually fail immediately when asked to process sequences longer than their training window. nGPT maintains stable perplexity even when extrapolated to 32k tokens (32x its training length) without specialized modifications to its positional embeddings (RoPE).
  • Efficiency at Scale: While nGPT has a higher computational cost per step (about 60-80% more due to frequent normalization), the massive reduction in required training steps means the total compute budget to reach a certain accuracy is much lower.
Zero-shot performance on downstream benchmarks showing nGPT achieves higher accuracy with fewer training tokens.

As shown above, this accelerated pre-training directly translates to faster convergence and higher accuracy on downstream zero-shot tasks like ARC-Easy, Hellaswag, Winogrande, WSC273, and LAMBADA.

Limitations and Future Work

  • Implementation Overhead: The current implementation involves many small normalization operations which aren't yet fully optimized in standard deep learning libraries. This makes the time per step higher than standard Transformers, though better kernel fusion should close this gap.
  • Scale Ceiling: Experiments topped out at 1 billion parameters. The scaling laws for nGPT at the 7B, 70B, or 400B parameter scale remain an open question.
  • Complexity of Scaling Factors: While nGPT removes the need for weight decay and learning rate warmups, it introduces new scaling parameters that require careful initialization.

In summary, nGPT suggests that by respecting the geometry of the hypersphere, we can build language models that are not only more stable but vastly more efficient learners.

Summary updated

BibTeX
@inproceedings{loshchilov2025ngpt,
  author = {Ilya Loshchilov and Cheng-Ping Hsieh and Simeng Sun and Boris Ginsburg},
  title = {{nGPT: Normalized Transformer with Representation Learning on the Hypersphere}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=se4vjm7h4E},
}
Figure