Paper commentary
HOGWILD!: A Lock-Free Approach to Parallelizing Stochastic Gradient Descent
Lock-free parallel SGD can run on shared memory with little loss
- Problem Parallel SGD has been hard to speed up because the locks that protect shared writes slow every processor down. Each update depends on the previous one, so splitting the work across cores normally needs synchronization.
- Method Hogwild! lets several processors write to shared memory without locks, so they can overwrite each other's work. It works when each gradient update touches only a few variables, so overwrites rarely matter.
- Results Hogwild! outperforms locking schemes by an order of magnitude in the paper's experiments. On DBLife with 10 cores it reached a ninefold speedup, while RR reached only a factor of 5.
Why locking limits parallel SGD
SGD is attractive for large learning problems because it needs little memory and learns quickly, but each step depends on the result of the previous one, so it is difficult to split across processors. Many large data sets are preprocessed with MapReduce, yet MapReduce handles iterative numerical work poorly because fault tolerance adds overhead to every pass.
A single multicore workstation offers shared main memory at over 12GB/s and fast disk reads, so the limit on parallel SGD there is synchronization between processors rather than data movement.
Hogwild! answers this by dropping the lock: processors share one decision variable and write individual components whenever they need to. Overwrites between processors can discard progress, so the question is whether the damage stays small when each step touches only a few coordinates.
Sparse cost functions and the lock-free update
The objective is written as a sum over terms, each of which depends only on a subvector of the decision variable. The method relies on the number of terms and the number of variables both being large while each term touches only a few variables, which the authors call sparsity. Sparse SVMs, matrix completion and graph cut problems all fit this form, and each induces a hypergraph whose hyperedges are the variable subsets of the terms.
Three statistics summarize how sparse the hypergraph is: Ω is the largest hyperedge size, ∆ is the largest fraction of hyperedges containing one variable, and ρ is the largest fraction of hyperedges that intersect a given hyperedge. For the sparse SVM, ∆ is the largest frequency of a feature among examples, and for matrix completion both ∆ and ρ are of order log(n_r)/n_r.
Each processor samples a term e uniformly at random, reads the components of x that e touches, computes the term's gradient, and writes each component with a scaled update. The write for component v takes the form below, and only components in e are changed. \[ x_v \leftarrow x_v - \gamma\, b_v^{T} G_e(x), \quad v \in e \] Each single component update is treated as an atomic addition, which common hardware supports without a separate lock, whereas updating many components at once needs an auxiliary lock.
Convergence under bounded gradient lag
The analysis assumes each term is convex, the gradient of f is Lipschitz with constant L, f is strongly convex with modulus c, and the squared norm of sampled gradients is bounded by M almost surely. To make the proofs tractable, the analysis uses with-replacement sampling, where a term is drawn for every update, rather than the without-replacement partitioning used in the experiments.
Proposition 4.1 assumes the lag between computing a gradient and using it is at most tau, and sets the stepsize gamma by a formula involving rho, Omega, Delta and L, M and c. Under that stepsize, after k component updates the expected gap E[f(x_k)-f*] is at most epsilon once k satisfies the bound stated in the proposition. When tau equals zero the bound reduces to the serial SGD rate, and the analysis states that a lag proportional to the number of processors still gives nearly the serial rate while the number of processors stays below n^{1/4}.
The argument first shows a recursion for a_j, half the expected squared distance to x*, of the form in which an effective curvature c_r smaller than c appears because of the update errors. Without-replacement sampling is used in the experiments, but no tractable analysis is given for it, and the authors note that existing analyses of that scheme predict up to a factor of |E| more steps.
Robust 1/k rates from stepsize backoff
The method runs with a fixed stepsize and then reduces it by a constant factor beta in (0, 1) after each epoch, so the stepsize stays below 1/c throughout. Working through the recursion gives an iteration count for the first phase that depends only logarithmically on the initial distance, and a backoff parameter of about 0.37 minimizes the cost of the later phase.
Compared with the serial stepsize gamma_0/k of Nemirovski et al., the constant stepsize protocol has a leading constant of 1.34 when beta is about 0.37, while the Theta-based protocol reaches 1 at Theta = 2. The fix proposed by Nemirovski et al. gives rates of 1/sqrt(k), and the authors state that robust 1/k rates are still possible with the backoff scheme.
Speedups on the RCV1 sparse SVM
The sparse SVM was trained on Reuters RCV1 for the binary CCAT task, with 804,414 examples and 47,236 features, and the training and test sets were swapped to test scaling. Here rho is 0.44 and Delta is 1.0, values that the authors describe as a poor case for Hogwild!. Hogwild! reached a factor of 3 speedup, while RR got worse as more threads were added and was slower than a serial implementation for fast gradients.
For the averaging scheme of Zinkevich et al., each thread touches every example in each pass, so 10 threads do ten times the gradient work of the serial run. The training error after each pass was the same whether run serially or with ten instances, and the authors conclude that averaging gave no advantage on this problem.
All of these runs use a constant stepsize reduced by a factor of 0.9 at the end of each pass over 20 passes.
Matrix completion and the Jumbo problem
The Netflix Prize matrix has 17,770 rows and 100,198,805 revealed entries, and the KDD Cup 2011 task 2 data has 624,961 rows and 1,000,990 columns. The synthetic Jumbo instance is a rank-10 matrix with 1e7 rows and columns and 2e9 revealed entries, and its rho and Delta are both around 1e-7.
With 10 threads, RR is 12% slower than serial on KDD Cup 2011 and 62% slower on Netflix Prize. Hogwild! attains a near linear speedup on KDD Cup 2011 and Jumbo even when data is read from disk, because these datasets do not fit in the allotted memory.
Graph cut speedups
The DBLife multiway cut has 18,167 entities and 180,110 mentions, and each stochastic gradient step computes a Euclidean projection onto a simplex of dimension 18,167, which makes steps slow. Even so, rho is 8.6e-3 and Delta is 4.2e-3, and Hogwild! achieves a ninefold speedup with 10 cores, while RR reaches only a factor of 5.
Effect of gradient delay on RR and Hogwild!
To test slow gradients, an artificial delay was added at the end of each gradient computation on RCV1, and wall clock time was measured across delays. A gradient must take longer than about one millisecond before RR is on par with Hogwild!, and at that cost only about a million stochastic gradients can be computed per hour.
Limitations
The convergence analysis covers only with-replacement sampling, while the experiments use without-replacement partitioning of edges across processors. The experiments show that implementations outperform the theoretical bounds, including a speedup on RCV1 where rho is large. The delayed-gradient protocol that avoids coalescing threads is described but not implemented, so its effect is untested.
Paper info
- Authors
- Feng Niu, Benjamin Recht, Christopher Re, Stephen J. Wright
- Venue
- arXiv · Preprint
- First published
- 2011-6-28
- Added
- 2026-11-12
- Updated
- 2011-11-11
- Version
- v2
- arXiv
- 1106.5730
- Category
- math.OC · cs.LG
- Original paper terms
- arXiv non-exclusive 1.0
- What we show
- Paper info and commentary
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Quote from the paper
Feng Niu, Benjamin Recht, Christopher Re, Stephen J. Wright (2011). HOGWILD!: A Lock-Free Approach to Parallelizing Stochastic Gradient Descent. arXiv:1106.5730v2. https://arxiv.org/abs/1106.5730v2
BibTeX
@misc{niu2011hogwild,
title = {{HOGWILD!: A Lock-Free Approach to Parallelizing Stochastic Gradient Descent}},
author = {Feng Niu and Benjamin Recht and Christopher Re and Stephen J. Wright},
year = {2011},
eprint = {1106.5730},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/1106.5730v2}
}