Abstract
We study the discrete dynamics of mini-batch gradient descent for least squares regression when sampling without replacement. We show that the dynamics and generalization error of mini-batch gradient descent depends on a sample cross-covariance matrix $Z$ between the original features $X$ and a set of new features $\widetilde{X}$, in which each feature is modified by the mini-batches that appear before it during the learning process in an averaged way. Using this representation, we rigorously establish that the dynamics of mini-batch and full-batch gradient descent agree up to leading order with respect to the step size using the linear scaling rule. We also study discretization effects that a continuous-time gradient flow analysis cannot detect, and show that mini-batch gradient descent converges to a step-size dependent solution, in contrast with full-batch gradient descent. Finally, we investigate the effects of batching, assuming a random matrix model, by using tools from free probability theory to numerically compute the spectrum of $Z$.
Introduction
In modern machine learning, mini-batch gradient descent (MBGD) is the workhorse of optimization. While theoretical analyses often assume data is sampled with replacement for mathematical simplicity, practitioners almost exclusively use random reshuffling (sampling without replacement). This discrepancy is significant because random reshuffling introduces complex dependencies between batches that standard stochastic gradient descent (SGD) theory fails to capture.
This paper provides an exact mathematical characterization of how MBGD with random reshuffling behaves in the context of least squares regression. By deriving the discrete-time dynamics, the authors reveal how batch size and learning rate interact to influence both training stability and generalization error.
The Sample Cross-Covariance Matrix $Z$
The core innovation of this work is the introduction of a novel mathematical object: the sample cross-covariance matrix $Z$. In full-batch gradient descent, the dynamics are governed by the standard sample covariance matrix $W = \frac{1}{n}X^T X$. However, the authors demonstrate that in the mini-batch setting, each data point is effectively "modified" by the batches that preceded it within the same epoch.
By defining a matrix $\tilde{X}$ of these modified features, the authors show that the dynamics of MBGD are actually governed by $Z = \frac{1}{n}\tilde{X}^T X$. This representation allows for the derivation of exact formulas (Theorems 3.3 and 3.9) for the evolution of the mean iterate and generalization error over any number of epochs.
Key Insights: Spectral Shrinkage and Stability
The "Shrinkage" Effect
The analysis reveals that batching causes a non-linear shrinkage of the data's spectrum. Specifically, the eigenvalues of $Z$ are systematically smaller than those of the standard covariance matrix $W$. In the regime where the number of samples $n$ is large and features $p$ are fixed, the authors prove that $Z$ and $W$ share eigenvectors, but the eigenvalues of $Z$ are scaled down by a factor related to the batching process. This suggests that mini-batching acts as a form of implicit regularization.
The Stability Paradox
Because of this spectral shrinkage, MBGD can exhibit a "stability paradox." The authors demonstrate cases where a specific learning rate causes full-batch gradient descent to diverge, yet MBGD—using the same effective learning rate—remains stable and converges. This implies that the discrete nature of mini-batching provides a buffer against the instabilities often found in full-batch methods with large step sizes.
Evaluating the Linear Scaling Rule
A common heuristic in deep learning is the linear scaling rule: if you double the batch size, you should double the learning rate. This paper rigorously tests this rule. The authors find that while the rule holds to leading order (approximating continuous-time gradient flow), it misses subtle higher-order discretization effects.
In the underparameterized regime ($p < n$) with noisy labels, MBGD with random reshuffling actually converges to a different solution than full-batch GD. This limit is explicitly dependent on the step size, a phenomenon that continuous-time models cannot detect.
High-Dimensional Analysis via Free Probability
To understand these dynamics in the "proportional regime" (where both $n$ and $p$ grow to infinity), the authors utilize tools from free probability theory. They treat the matrices as non-commutative random variables to compute the limiting spectral distribution of $Z$. Numerical simulations using standard Gaussian data confirm these theoretical predictions, showing a near-perfect match between the predicted spectral density and empirical histograms of eigenvalues.
Conclusion and Future Work
This work provides a rigorous foundation for understanding the discrete-time behavior of the most common optimization strategy in machine learning. By identifying the $Z$ matrix and the resulting spectral shrinkage, the authors explain why mini-batching is often more robust than full-batch methods.
While currently limited to linear least squares and Gaussian features, this framework sets the stage for future research into non-linear models and more complex data distributions. The discovery of spectral shrinkage also opens the door to designing optimized batch sizes and learning rate schedules based on the underlying geometry of the data.
Summary updated