Ordering for Non-Replacement SGD

Yuetong Xu, Baharan MirzasoleimanarXiv 2023 · DOI

Abstract

While Stochastic Gradient Descent (SGD) typically relies on random shuffling, this paper demonstrates that deterministic data ordering can significantly accelerate convergence. We prove that when using a decreasing learning rate, processing data points with the largest initial gradients first leads to the fastest error reduction. This "decreasing gradient" strategy is validated across convex, strongly convex, and deep learning tasks, showing substantial improvements over standard random shuffling.

Introduction

Stochastic Gradient Descent (SGD) is the engine behind modern machine learning. In practice, most implementations utilize "Without-Replacement" SGD, commonly known as Random Shuffling, where a permutation of the dataset is processed in each epoch. While shuffling is theoretically superior to sampling with replacement, the choice of the specific permutation has largely remained heuristic. This paper addresses whether an "optimal" deterministic ordering exists that can reach the minimum faster than simple random shuffling.

Theoretical Framework and Methods

The researchers analyze the distance between the current iterate and the optimal solution by deriving tighter upper bounds for this distance. Their core contribution identifies how the sequence of gradients interacts with the learning rate (step size) schedule.

Step Size and Ordering Synergy

The study identifies two distinct regimes based on the learning rate schedule:

  1. Constant Step Size: In this case, the ordering of data points is shown to be irrelevant; random, increasing, and decreasing orderings all yield the same convergence rate.
  2. Decreasing Step Size: For both convex and strongly convex functions, ordering data by the decreasing norm of the gradient (calculated at the start of the epoch) provides the tightest bound on error. This "front-loading" strategy pairs the largest steps with the most informative directions.
Convergence behavior under different step size regimes and data orderings: (a) constant step size, (b) decreasing per iteration, and (c) decreasing per epoch.

Scaling to Deep Learning

To mitigate the computational cost of calculating full gradients for every sample in deep networks, the authors propose using the norm of the logits (the raw output of the final layer) as a proxy for gradient magnitude. They also extend the logic to mini-batch SGD, suggesting variants that sort the entire dataset before batching or sort within each batch.

Experimental Results

The proposed strategy was validated across a spectrum of complexity, from synthetic vectors to ResNet models on CIFAR-10/100.

Convergence and Accuracy

On synthetic and classical datasets (Iris, Boston Housing), the "decreasing gradient" ordering consistently reached lower loss values faster than random or increasing orderings under decreasing step sizes. In deep learning tasks on MNIST and Fashion MNIST, the proposed ordering combined with mini-batching resulted in the highest training and testing accuracy.

CIFAR Performance

For ResNet models on CIFAR-10 and CIFAR-100, starting the deterministic ordering later in training (e.g., at epoch 140) led to lower training error and competitive test accuracy with fewer total iterations. On CIFAR-10, the "mini-ordered" approach achieved ~92.3% test accuracy, comparable to the full random baseline but with a significantly sharper drop in training loss.

Discussion and Limitations

While the strategy offers clear benefits, it requires the model to be somewhat "close" to the optimal solution to ensure initial gradients are informative. Additionally, the computational overhead of sorting—the "sorting tax"—must be balanced against convergence speedups. While logit proxies and delayed switching help, a rigorous wall-clock time analysis is necessary for practical deployment. Furthermore, while empirical results on neural networks are promising, the theoretical proofs currently rely on convexity, leaving a gap for non-convex landscapes.

Conclusion

Strategic data ordering, specifically processing high-gradient examples first during periods of high learning rates, provides a principled method to speed up SGD. This approach bridges the gap between simple random shuffling and optimal deterministic sequences, offering a practical tool for improving training efficiency in modern machine learning.

Summary updated

BibTeX
@misc{xu2023ordering,
  author = {Yuetong Xu and Baharan Mirzasoleiman},
  title = {{Ordering for Non-Replacement SGD}},
  year = {2023},
  eprint = {2306.15848},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2306.15848},
}
Figure