Logarithmic Depth for Exact In-Context Gradient Descent with Linear Attention
Abstract
How much Transformer depth is needed to compute the result of k gradient-descent updates? Constructions assigning one update to each layer give a linear upper bound. We establish a tight Θ(log k) characterization for exact endpoint computation by attention-only, unnormalized linear self-attention with a fixed coordinate workspace. Each layer raises polynomial degree by at most a factor of three, giving a depth lower bound independent of width, heads and context length. A matching construction stores matrix columns in tokens and uses attention sums to implement doubling and increment operations on matrix powers and geometric sums. The construction covers arbitrary positive-definite quadratic objectives and extends to prediction from regression demonstrations at an unseen query. We also prove a barrier to uniform approximation before convergence and a lower bound for prediction risk in a scalar model with a supplied spectrum. Controlled experiments study polynomial approximation and spectral conditioning, while broader regression experiments examine endpoint accuracy across architectures and task families.