Theory of Scaling Laws for In-Context Regression: Depth, Width, Context and Time

Blake Bordelon, Mary Letey, Cengiz Pehlevan

Introduction

Researchers have developed a solvable mathematical model to understand how Transformers learn linear regression "in-context." A key discovery from this work is that while model width and context length consistently improve performance, depth only becomes essential when the model faces a diverse set of tasks with varying data statistics. This insight provides a theoretical foundation for determining the "optimal shape" of a Transformer.

The Problem: Beyond Parameter Counts

Scaling up Transformers—making them wider, deeper, and training them longer—leads to predictable improvements in performance. This phenomenon is the basis of the famous "Scaling Laws" (such as the Chinchilla law) used to train large language models like GPT-4.

However, most existing theories treat width and depth as a single "parameter count" variable. They fail to explain why we should prefer a deep, narrow model over a shallow, wide one for a specific compute budget. Furthermore, while empirical evidence shows that depth helps in practice, some simple mathematical models of In-Context Learning (ICL) suggest that a single layer is often sufficient. This paper tackles the open question of what determines the optimal shape (width vs. depth) of a Transformer and how these dimensions interact with context length and training time.

Methodology: A Solvable Toy Model

The authors study In-Context Learning (ICL), a setting where a model learns to solve a task (like linear regression) purely by observing examples in its prompt, without any weight updates.

To make the mathematics tractable, they utilize a Deep Linear Self-Attention model. While simpler than a full GPT architecture, it captures the core dynamics of the residual stream. They analyze this model using Dynamical Mean Field Theory (DMFT)—a technique borrowed from the physics of disordered systems—to track how the model's internal representations evolve during pre-training.

The model is tested under three data regimes using synthetic datasets for in-context linear regression (where the model predicts $y$ for a new $x$ based on preceding $(x, y)$ pairs):

  1. ISO (Isotropic): Data is uniform and simple.
  2. FS (Fixed Structured): Data has a specific, fixed correlation structure.
  3. RRS (Randomly Rotated and Structured): Data correlations change from one context to the next, mimicking the diversity of real-world data.

Key Insights: When Does Depth Matter?

The study reveals that depth is not merely a memory bank, but an algorithm. In simple settings (ISO/FS), a shallow model can "memorize" the data statistics and perform perfectly if given enough context, rendering depth redundant.

However, diversity demands depth. In the RRS setting, the model cannot memorize a single data structure because it changes every time. To succeed, the model must learn to perform an algorithm akin to Iterative Gradient Descent inside its own forward pass. Each layer of the Transformer acts like a step in that iterative algorithm. This explains why depth becomes a critical bottleneck in diverse environments.

Theoretical predictions matching SGD simulations across varying depths.

The authors' mathematical predictions match the results of actual Stochastic Gradient Descent (SGD) simulations with remarkable precision. Furthermore, the theory predicts that for a fixed compute budget, the optimal depth $L$ should scale with width $N$ according to a specific power ($L \propto N^\nu$), where $\nu$ depends directly on the complexity of the data.

The "Chinchilla" Law for ICL

The authors derive a unified power law that accounts for four distinct resources: training time ($t$), width ($N$), depth ($L$), and context length ($P$).

$$\mathcal{L}(t, N, L, P) \approx c_t t^{-\beta_t} + c_N N^{-\beta_N} + c_L L^{-\beta_L} + c_P P^{-\beta_P}$$

This formula demonstrates that each resource contributes a separate "bottleneck" to the final error.

Training dynamics showing loss decreasing over time for different model depths.

Although the core theory is built on linear attention, the authors show experimentally that the same "depth-is-better-for-diverse-tasks" behavior holds for standard Softmax Attention models used in real LLMs. They also identified a new scaling limit that allows researchers to simulate these models much faster than previous theoretical frameworks.

Limitations and Future Work

  • Linearity: The model relies on linear attention and linear regression. While this allows for exact mathematics, real-world LLMs process highly non-linear language data.
  • Online Learning: The study focuses on "online" training, where the model never sees the same data twice. Future work is needed to understand how "offline" training and data repetition (overfitting) alter these scaling laws.
  • Architecture: The paper primarily examines the residual stream and attention mechanisms; the role of Feed-Forward Networks (MLPs) in this specific scaling context remains an important area for deeper exploration.

Summary updated

BibTeX
@inproceedings{bordelon2026theory,
  author = {Blake Bordelon and Mary Letey and Cengiz Pehlevan},
  title = {{Theory of Scaling Laws for In-Context Regression: Depth, Width, Context and Time}},
  booktitle = {International Conference on Learning Representations},
  year = {2026},
  url = {https://openreview.net/forum?id=qA42mWsnbl},
}
Figure