NeurIPS 2026QuestionsPapersAreasAboutMarkdown

Logarithmic Depth Suffices for In-Context Gradient Descent

Yingze Li, Dong Wang, Xianglong Liu, Qingyun Zou, Chunnan Wang, Zhiyu Liang, Hongzhi Wang

NeurIPS page · OpenReview · Open on the map

Category: Interpretability & Model Adaptation › Transformer In-Context Reasoning · Type: theory · Keywords: in-context learning, gradient descent, transformer depth, logarithmic depth, linear self-attention

Areas: LLM Reasoning › Efficient Reasoning › Transformer Circuits; Model Architectures & Sequence Modeling › Language Model Architectures › Transformer Structural Properties

Summary

The paper proves that Transformers need only logarithmic depth to perform k gradient-descent updates in-context, and validates this with experiments on linear attention and standard Transformers.

Explained to a 5-year-old

A computer brain called a transformer can learn new things without forgetting old ones. When it sees new information, it can adjust its behavior without starting over. In the past, people thought it needed as many layers as the number of adjustments it wanted to make. This paper asks whether the layers are just counting steps or if they can do more. The secret is that each layer helps the next one, so they work together like a fast ladder.

Explained to a 5-year-old, longer

A transformer is a kind of computer program that can learn from examples. When it sees new information, it can adjust its behavior without starting over. In the past, people thought it needed as many layers as the number of adjustments it wanted to make. This paper asks whether the layers are just counting steps or if they can do more. The authors looked at a simpler version of a transformer that uses only linear attention. They discovered that each layer builds on the work of the previous one, like stacking blocks. Because of this stacking, the whole system can finish many learning steps using only a few layers. The number of layers needed grows only logarithmically with the number of steps, which is much slower than before. They tested this idea on a simple math problem where the answer is a smooth curve. The computer experiments showed the expected behavior, confirming the theory. They also tried it on regular transformers and on a big language model called Qwen2.5. All the tests showed that the shortcut works, making transformers more efficient.

For a technical reader

The paper shows that a transformer can perform many gradient-descent updates in-context using only O(log k) layers instead of O(k). This is achieved because each layer compounds the algebraic capacity of the previous ones, effectively compressing many steps into fewer layers. The authors prove this bound for linear self-attention on diagonal quadratic tasks and verify it with experiments on both synthetic and real models. The findings suggest that depth in transformers is not merely a step counter but a computational resource that can be reused. The work provides both a theoretical insight and empirical validation that could lead to more efficient transformer designs.

Problem

It is unclear whether a Transformer's depth merely counts optimizer updates or can be reduced to achieve the same in-context learning. The paper investigates whether logarithmic depth suffices to compute the result of many gradient-descent steps.

Method

The authors analyze linear self-attention models, showing each layer compounds the algebraic capacity of previous layers, yielding a Θ(log k) depth characterization for k gradient-descent steps on diagonal quadratic tasks. They also run controlled experiments on trained linear-attention models, kernel and oracle comparisons, and broader tests on standard Transformers and Qwen2.5 to confirm the depth signal.

Results

The approach exhibits a logarithmic depth transition matching the theoretical prediction, and polynomial degree is identified as the bottleneck; the depth signal persists across standard Transformers, broader ICL tasks, and early-exit probes on Qwen2.5.

Contributions

Provides a tight Θ(log k) depth characterization for in-context gradient descent, showing depth compounds algebraically rather than merely counting steps, and validates this theoretically and empirically across multiple settings.

This page was written by language models from the title and abstract of each paper, and the answers were checked by two other models. It can be wrong: check the paper itself. Suggest a correction