Abstract
Stochastic Gradient Descent (SGD) is the most popular optimization algorithm for large-scale problems, typically estimating gradients via uniform sampling. While weighted non-uniform sampling can offer faster epoch-wise convergence by providing better gradient estimates, the per-iteration cost of maintaining such an adaptive distribution often exceeds the cost of calculating the full gradient itself—a dilemma we call the "chicken-and-the-egg" loop. In this paper, we break this barrier by introducing Locality Sensitive Hashing (LSH) sampled Stochastic Gradient Descent (LGD). LGD achieves superior gradient estimation while maintaining a per-iteration sampling cost similar to uniform sampling. We demonstrate the effectiveness of LGD on linear models and the non-linear BERT language model, showing significant reductions in actual running time.
The "Chicken-and-Egg" Problem in SGD
Stochastic Gradient Descent (SGD) is the backbone of modern machine learning, avoiding the $O(N)$ cost of full-batch updates by sampling small subsets of data. However, uniform sampling is inherently noisy because some data points are significantly more informative than others.
Researchers have long recognized that non-uniform (adaptive) sampling—specifically picking points with larger gradient norms—can reduce variance and accelerate convergence. The fundamental challenge is that identifying these high-norm points typically requires calculating gradients for the entire dataset, which costs $O(N)$ work. This creates a computational deadlock: adaptive sampling is intended to avoid $O(N)$ work, but requires $O(N)$ work to execute. Consequently, many theoretically "faster" sampling methods are actually slower in real-world wall-clock time.
LGD: Breaking the Loop with LSH-Sampling
We propose LGD (LSH-sampled Stochastic Gradient Descent) to resolve this deadlock. The core innovation lies in reframing Locality Sensitive Hashing (LSH) as a probabilistic sampler rather than a traditional search tool.
The Mechanism
For many common models, including linear regression and the final layers of neural networks, the $L_2$ norm of the gradient is monotonic to the inner product between model parameters ($\theta$) and the data point ($x$). LGD leverages this property through a three-step process:
- Preprocessing: Data points are hashed into buckets such that points with high inner products (and thus high gradient norms) are likely to cluster together.
- Sampling: In each iteration, the current model parameters $\theta$ serve as a "query" to the hash table. LGD retrieves a sample from the resulting bucket in near-constant $O(1)$ time.
- Unbiased Estimation: Because LSH collision probabilities are known, we can precisely re-weight the sampled gradient to ensure the estimator remains unbiased.
Key Results and Empirical Evaluation
LGD was evaluated across several large-scale tasks, including linear regression on the Million Song Dataset (YearPredictionMSD) and CT image data (Slice), as well as fine-tuning BERT on the MRPC and RTE corpora.
Superior Gradient Quality
Empirical results confirm that LGD identifies more informative samples than uniform SGD. As shown in the comparisons below, LGD samples consistently exhibit higher $L_2$ norms and significantly higher cosine similarity to the "true" full gradient.
Wall-Clock Speedup
Crucially, LGD translates these better estimates into real-world speedups. On the YearPredictionMSD dataset, LGD reached a target loss in approximately 20,000ms, whereas standard SGD required nearly 80,000ms to reach the same level. This demonstrates that LGD successfully breaks the $O(N)$ barrier, making adaptive sampling competitive in wall-clock time.
Deep Learning and BERT
In non-linear models like BERT, hidden representations do not change drastically every iteration. This allowed us to periodically update hash tables rather than re-hashing at every step. In fine-tuning tasks, LGD achieved higher testing accuracy faster than standard Adam or SGD, proving that the "important" samples identified by LSH lead to better generalization.
Conclusion and Future Work
LGD provides the first generic scheme where the per-iteration cost of maintaining an adaptive distribution is $O(1)$. By treating LSH as a sampler, we can achieve the variance reduction of importance sampling without the prohibitive computational overhead. Future work will focus on developing efficient GPU-based LSH implementations to further reduce the hardware overhead currently associated with CPU-based hashing in deep learning pipelines.
Summary updated