Distributed Mini-Batch SDCA
Martin Takáč, Peter Richtárik, Nathan Srebro
Introduction
Stochastic optimization approaches have significant theoretical and empirical advantages in training linear Support Vector Machines (SVMs) and other regularized loss minimization problems, and are often the methods of choice in practice. Such methods use a single, randomly chosen, training example at each iteration. In the context of SVMs, many variations of stochastic gradient descent (SGD) have been suggested, based on primal stochastic gradients (e.g. Pegasos , NORMA , SAG , MISO , S2GD , mS2GD and Prox-SVRG ). In this paper we focus on SDCA—stochastic dual coordinate ascent—which is based on improvements to the dual problem, again considering only a single randomly chosen training example, and thus only a single randomly chosen dual variable, at each iteration . Especially when accurate solutions are desired, SDCA has better complexity guarantee, and often performs better in practice than SGD .
The inherent sequential nature of such approaches becomes a problematic limitation in parallel and distributed settings as the predictor must be updated after each training point is processed, providing very little opportunity for parallelization. A popular remedy is to use mini-batches: the use several training points at each iteration, calculating the update based on each point separately and aggregating the updates. The question is then whether basing each iteration on several points can indeed reduce the number of required iterations, and thus yield parallelization speedups.
For SGD with a non-smooth loss, mini-batching does not reduce the number of worst-case required iterations and thus does not allow parallel speedups in the worst case. However, when the loss function is smooth, mini-batching can be beneficial and linear speedups can be obtained, even when the mini-batch sizes scales polynomially with the total training set size . Alternatively, even for non-smooth loss, linear speedups can also be ensured if the data is reasonably well-spread, as measured by the spectral norm of the data, as long as the mini-batch size is not larger then the inverse of this spectral norm .
For SDCA, using a mini-batch corresponds to updating multiple coordinates concurrently and independently. If appropriate care is taken with the updates (see Section 6), then using a mini-batch size as large as the inverse spectral norm leads to a reduction in the number of iterations, and allows linear parallelization speedups, even when the loss is non-smooth . This parallels the SGD mini-batch analysis for non-smooth loss. But can mini-batching also be beneficial for SDCA with smooth losses and without a data-spread (spectral norm) assumptions, as with SGD? What mini-batch sizes allow for parallel speedups? In this paper we answer these questions and show that as with SGD, when the loss function is smooth, using mini-batches with SDCA yields a linear reduction in the number of iterations and thus allows for linear parallelization speedups, up to similar polynomial limits on the mini-batch size. Furthermore, we provide an analysis that combines the benefits of smoothness with the data-dependent benefits of a low spectral norm, and thus allows for even large mini-batch sizes when the loss is smooth and the data is well-spread.
Another issue that we address is the way mini-batches are sampled. Straight-forward mini-batch analysis, including previous analysis of mini-batch SDCA , assume that at each iteration we pick a mini-batch of size uniformly at random from among all subsets of training examples. In practice, though, data is often partitioned between machines, and at each iteration points are samples from each machine, yielding a mini-batch that is not uniformly distributed among all possible subsets (e.g. we have zero probability of using points from the same machine as a mini-batch). Other architectural restrictions might lead to different sampling schemes. The analysis we present can be easily applied to different sampling schemes, and in particular we consider distributed sampling as described above and show that essentially the same guarantees (with minor modification) hold also for this more realistic sampling scheme.
Finally, we compare our optimization guarantees to those recently established for CoCoA+ . CoCoA+ is an alternative dual-based distributed optimization approach, which can be viewed as including mini-batch SDCA as a special case, and going beyond SDCA to potentially more powerful optimization. At each iteration of CoCoA+, several groups of dual variables are updated. We focus on CoCoA+SDCA, where each group is updated using some number of SDCA iterations. When each group consists of a single variable, this reduces exactly to mini-batch SDCA. Allowing for multiple SDCA iterations on larger groups of variables yields a method that is more computationally demanding that mini-batch SDCA, and intuitively should be better than SDCA (and does appear better in practice). However, we show that our mini-batch SDCA analysis strictly dominates the CoCoA+ analysis: that is, with the same number of total dual variables updated per iteration, and thus less computation, our mini-batch SDCA guarantees are strictly better than those obtained for CoCoA+. Mini-batch SDCA is thus a simpler, computationally cheaper method, with better guarantees than those established for CoCoA+.
Although SDCA is a dual-method, improving the dual at each iteration, following the analysis methodology of , all our guarantees are on the duality gap, and thus on the primal sub-optimality, that is on the actual regularized error we care about.
Setup and Preliminaries
We consider the problem of minimizing the regularized empirical loss
SDCA is a coordinate ascent algorithm optimizing the dual (D). At -th iteration of SCDA a coordinate is chosen at random and then a new iteration is obtained by updating only the -th coordinate and keeping all other coordinates of unchanged i.e. , where
Assumptions on Loss Function
Mini-Batched SDCA
At each iteration of mini-batched SDCA, a subset of the coordinates is chosen at random (see below for a discussion of the sampling distribution) and a new dual iterate is obtained by independently updating only the chosen coordinates. Since each coordinate is updated independently, mini-batch SDCA is amenable to parallelization.
The naïve approach is to use the same update rule for each coordinate as in serial case: the update is then given by where is given by (1). Such a naïve approach could be fine if the mini-batch size is very small and the data is “spread-out” enough . However, more generally, not only might such a mini-batch iteration not be better than an iteration based on only a single point, but such a naïve mini-batch update might actually be much worse. In particular, it is easy to construct an example with just two examples where a naïve mini-batch approach will never reach the optimum solution, and diverging behavior frequently occurs in practice on real data sets . The problem here is that the independent updates on multiple similar points might combine together to “overshoot” the optimum and hurt the objective.
An alternative that avoids this problem is to average the updates instead of adding them up, , but such an update is overly conservative: it is not any better than just updating a single dual variable, and cannot lead to parallelization speedups. Following , the approach we consider here is to use a summed update , where the independent updates are derived from a relaxation of the dual:
When , the update exactly agrees with the dual-optimizing update (1). But as we shall see, when larger mini-batches are used, larger values of are required, resulting in smaller steps. The update (2) generalizes where a single parameter was used—here we allow to vary between dual variables, accommodating differences in .
To summarize, the mini-batch SDCA algorithm we consider takes as input data , loss functions , a distribution over subsets , which we will refer to as the random sampling , and a weight vector , and proceeds as shown on Algorithm 1.
We will refer to several sampling distributions , yielding different variants of mini-batch SDCA: Serial SDCA. is a uniform distribution over singletons. That is, contains a single coordinate chosen uniformly at randomly. Setting yields standard SDCA. Standard Mini-batch SDCA. is a uniform distribution over subsets of size . Distributed SDCA. Consider a setting with machines, total data points and a mini-batch size , where for simplicity and are both integer multiples of . For a partition of the coordinates into equal sized subsets , consider the following sampling distribution : for each , choose a subset uniformly and independently at random among all such subsets of size , and then take their union. We refer to such a sample as a -distributed sampling. Such a sampling is suitable in a distributed environment when samples are equally partitioned over computational nodes in a cluster . When we obtain the Standard Mini-batch sampling.
The main question we now need to address is what weights are suitable for use with each of the above sampling schemes, and what optimization guarantee to they yield. To answer this question, in the next Section we will introduce the notion of Expected Separable Overapproximations.
Expected Separable Overapproximation
In this Section we will make use of the Expected Separable Overapproximation (ESO) theory introduced in and further extended e.g. in .
Consider the -th iteration of mini-batch SDCA. Our current iterate is and we have chosen a set of coordinates which we will update in current iteration. We need to compute the updates to those coordinates, i.e. we need to compute . Maybe the natural way how to define the updates would be to define them such that is as large as possible, i.e. that we maximize . However, this e.g. for hinge loss would lead to a QP, hence the computation cost would be substantial. The main disadvantage of this approach is the fact that the updates for different coordinates are dependent on each other, i.e. the value of depends on all coordinates in . This make it hard to parallelize. Considering the fact that is a random set, maybe one would like to define the updates so that the updates doesn’t depend on current choice of and that they maximize the expected value of at next iteration. In this case we are facing following maximization problem
2 Lower-bound
Let us first state the definition of ESO.
Now we can derive the expected lowerbound of as follows
where in the first inequality for the first part we have used the fact that the function is separable (see Theorem 4 in ). If we define
3 Computing ESO Parameter
Serial SDCA. In this simplest case we can define . Standard Mini-batch SDCA. In standard mini-batch we can choose . If the data matrix is sparse, we can define . Distributed SDCA. In distributed case we can choose , provided that and if . A simple upper-bound valid for any can be derived as follows .
Convergence Guarantees
We are now ready to present optimization guarantees for Algorithm 1 based on the ESO parameters studied in the previous Section. These theorems extends the serial case of to mini-batch setting. The Theorems are based on weights are chosen such that admits -ESO for a sampling used in the Algorithm 1. Proofs are provided in the supplemental material.
If the losses are -smooth and admits -ESO for the sampling , then for a desired duality gap , using Algorithm 1, if we choose
If the losses are -Lipschitz and admits -ESO for the sampling , then for a desired duality gap , using Algorithm 1, denoting , if we choose
Guarantees and Speedups for Specific Sampling Distributions
Theorems 3 and 2 are stated in terms of ESO parameter . Let us now consider the specific sampling distribution of interest. Assume for simplicity , and define
for the serial, standard and distributed sampling schemes respectively, with overall mini-batch size and distribution over machines. Using the weights , we then have the following obtain the following iteration complexities:
-Lipschitz Continuous Loss. Combining equations (10) and (11), and again ignoring logarithmic factors, we get an iteration complexity of:
Plugging in into (13) recovers the previous analysis of Lipschitz loss with standard sampling.
Both the Lipschitz and smooth cases involve two terms: the first term, , always displays a linear improvement as we increase the mini-batch size. However, in the second term, we also have a dependence on the data-dependent , which depends on the mini-batch size . We will have a linear improvement in the second term, i.e. potential for linear speedup, as long as . For standard sampling we have that , and so we obtain linear speedups as long as , as discussed in (13). We can now also quantify the effect of distributed sampling and see that it is quite negligible and yields almost the same speedups and the same maximum allows mini-batch size as with standard sampling. Note that typically we will have , as we would like to process multiple example on each machine—otherwise communication costs would overwhelm computational costs . The analysis supports this choice as well as the extreme choice .
Focusing on the smooth loss, it is possible to obtain a linear reduction in the iteration complexity (corresponding to linear speedups) for SGD with mini-batch size of up to without any data-dependent assumption, that is regardless of the value of . Is this possible also with SDCA? Indeed, even if we don’t account for the data dependent quantity , since we always have , then the iteration complexity of SDCA for mini-batch SDCA with smooth loss is: a larger mini-batch scales the second term (unconditional on any data dependence), and as long as it is the dominant term, we get linear speedups. Now, to get the min-max learning guarantee, we need to set (see ). Plugging this in, we see that we get linear speedups up to a mini-batch of size . Unsurprising, this is the same as the mini-batch SGD guarantee. Now, if we do take data-dependence into account, we have (where is as defined above). As long as , we get linear speedps even if the term is dominant, i.e. regardless of the scaling of lambda relative to . This is good, because in practice, and especially when the expected error is low, the best lambda is often closer to and not . Returning to the worst-case rate and : we now have an allowed mini-batch size of up to while still getting linear scaling. That is, we can combined the benefits of both smoothness, where we can scale the mini-batch size by , and the data dependence, to get an additional scaling by .
Comparison with CoCoA+
CoCoA+ is a recently presented framework and analysis for distributed optimization of the dual (D): Data (and hence dual variables) are partitioned among machines (as in our distributed sampling), defining subproblems, one for each machine. At each iteration, the set of dual variables of each of the machines are updated independently, and then communicated and aggregated across machines. Different local updates can be used, and the CoCoA+ analysis depends on how well the update improves the local subproblem. Here we will consider using local SDCA updates in conjunction with CoCoA+: at each iteration, on each of the machines, dual variables are selected (as in our distributed sampling), and iterations of SDCA are performed sequentially on these points (in parallel on each of the machines, and while considering all other dual variables, including all variables on other machines, as fixed).
Setting and , both minibatch SDCA and CoCoA+ perform the same number of SDCA updates (same amount of computation) at each iteration, but while minibatch SDCA’s updates are entirely independent, each group of CoCoA+ updates (the updates on the same machine) are performed sequentially. We would therefore expect CoCoA+’s updates to be better, and therefore require less iterations. Unfortunately, the CoCoA+ analysis does not show this.
And so, even though CoCoA+ with SDCA updates should be a more powerful algorithm, its analysis fails to show benefits over the simpler mini-batch SDCA, and out analysis here of mini-batch SDCA even dominates the CoCoA+ analysis. The reason for this is that CoCoA+ aims to be a more general framework capable of including arbitrary local solvers. Hence, necessarily, the analysis must be more conservative.
Numerical Experiments
In this Section we show that the cost of distribution is negligible (in terms of # iterations) when compared to standard mSDCA. We also show that if , then CoCoA+ is faster than mSDCA in practice. We have run experiments on 4 datasets (see Table 1). Note that most of the datasets are sparse (e.g, news20: an average tsample depends on 385 features out of 1.3M).
Standard vs. Distributed SDCA. Figure 1 (top row) compares standard and distributed SDCA. Recall that distributed sampling with and standard mini-batch sampling coincide. On the -axis is the parameter and on the -axis we plot how much more data-accesses we have to as or grow, to get achieve the same accuracy. We see that the lines are almost identical for various choices of , which implies that the cost of using distributed mSDCA does not affect the number of iterations significantly. This is also supported by the theory (notice that in (12) we have ). Also note that, for news20 for instance, increasing to implies that the number of data-accesses (epochs) will increase by a factor of 11, which implies that # iterations will decrease almost by 1,000 for when compared with .
mSDCA vs. CoCoA+. In Figure 1 (bottom row) we compare the mSDCA with CoCoA+ with SDCA as a local solver. We plot the duality gap as a function of epochs (if communication is negligible then the main cost is in computation) or iterations (if the communication cost is significant than this is the correct measure of performance). As the results suggest, is the communication cost it negligible then the mSDCA with small is the best (as expected), however, if communications cost is significant, then CoCoA+ with large values of significantly outperforms mSDCA.
References
Appendix A Technical Results
Following Lemma is a minibatch extension of Lemma 1 in .
Assume that is -strongly convex ( can be also zero). Then, for any and any we have
and .
Following lemma is a small extension of Lemma 4 in to obtain more tide bounds in case each sample has different norm or when ESO bound is used. For example, in serial case we will have that .
Suppose that for all , is -Lipschitz continuous. Then
Appendix B Proofs
Let us define as an unique maximizer of a function defined in (7), i.e.
,
.
Convex conjugate maximal property implies that
Let us estimate the expected change of dual objective.
Using -strong convexity of we have that
Substituting the definition of duality gap (G) we obtain
Multiplying both sides by we obtain (15).
B.2 Proof of Theorem 3
At first let us estimate expected change of dual feasibility.
Choice of and will lead to
Following the proof in we are now going to show that
Clearly, (24) implies that (25) holds for . Now imagine that it holds for any then we show that it also has to hold for . Indeed, using we obtain
In the last inequality we have used the fact that geometric mean is less or equal to arithmetic mean. If is defined as (9) then we obtain that
Now, if such that we obtain
Using we obtain that
To have this quantity we obtain that has to satisfy (10). The fact that implies that right-hand site of (26) is .
B.3 Proof of Theorem 2
Therefore if we denote by we have that
Right hand site will be smaller than some if
Moreover, to bound the duality gap we have
Therefore . Hence if then . Therefore after
iterations we have duality gap less than and the first part of the proof is done. To show the second part of Theorem let us sum (30) over to obtain
Now, if we choose to be either average vectors or a randomly chosen vector over , then we have
To get a high probability result we use Lemma 8 with , (see (29)) and to obtain that after