Primal Method for ERM with Flexible Mini-batching Schemes and Non-convex Losses
Dominik Csiba, Peter Richtárik
Introduction
Further, let be constants for which the inequality
In the last few years, a lot of research effort was put into designing new efficient algorithms for solving this problem (and some of its modifications). The frenzy of activity was motivated by the realization that SGD , not so long ago considered the state-of-the-art method for ERM, was far from being optimal, and that new ideas can lead to algorithms which are far superior to SGD in both theory and practice. The methods that belong to this category include SAG , SDCA , SVRG , S2GD , mS2GD , SAGA , S2CD , QUARTZ , ASDCA , prox-SDCA , IPROX-SDCA , A-PROX-SDCA , AdaSDCA , SDNA . Methods analyzed for arbitrary mini-batching schemes include NSync , ALPHA and QUARTZ .
In order to find an -solution in expectation, state of the art (non-accelerated) methods for solving (1) only need
steps, where each step involves the computation of the gradient for some randomly selected example . The quantity is the condition number. Typically one has for methods picking uniformly at random, and for methods picking using a carefully designed data-dependent importance sampling. Computation of such a gradient typically involves work which is equivalent to reading the example , that is, arithmetic operations.
2 Contributions
In this work we develop a new algorithm for the L2-regularized ERM problem (1). Our method extends a technique recently introduced by Shalev-Shwartz , which enables a dual-free analysis of SDCA, to arbitrary mini-batching schemes. That is, our method works at each iteration with a random subset of examples, chosen in an i.i.d. fashion from an arbitrary distribution. Such flexible schemes are useful for various reasons, including i) the development of distributed or robust variants of the method, ii) design of importance sampling for improving the complexity rate, iii) design of a sampling which is aimed at obtaining efficiencies elsewhere, such us utilizing NUMA (non-uniform memory access) architectures, and iv) streamlining and speeding up the processing of each mini-batch by means of assigning to each processor approximately even workload so as to reduce idle time (we do experiments with the latter setup).
In comparison with , our method is able to better utilize the information in the data examples , leading to a better data-dependent bound. For convex loss functions, our complexity results match those of QUARTZ in terms of the rate (the logarithmic factors differ). QUARTZ is a primal-dual method also allowing for arbitrary mini-batching schemes. However, while only characterize the decay of expected risk, we also give bounds for the sequence of iterates. In particular, we show that for convex loss functions, our method enjoys the rate (Theorem 2)
where is the probability that coordinate is updated in an iteration, are certain “stepsize” parameters of the method associated with the sampling and data (see (6)), and is a constant depending on the starting point. For instance, in the special case picking a single example at a time uniformly at random, we have and , whereby we obtain one of the rates mentioned above. The other rate can be recovered using importance sampling.
The advantage of a dual-free analysis comes from the fact that it guarantees convergence even for non-convex loss functions, as long as the average loss is convex. This is a step toward understanding non-convex models. In particular, we show that for non-convex loss functions, our method enjoys the rate (Theorem 1)
where is a constant depending on the starting point.
Finally, we illustrate through experiments with “chunking”—a simple load balancing technique—the utility of being able to design arbitrary mini-batching schemes.
Algorithm
We shall now describe the method (Algorithm 1).
The method encodes a family of algorithms, depending on the choice of the sampling , which encodes a particular mini-batching scheme. Formally, a sampling is a set-valued random variable with values being the subsets of , i.e., subsets of examples. In this paper, we use the terms “mini-batching scheme” and “sampling” interchangeably. A sampling is defined by the collection of probabilities assigned to every subset of the examples.
This relation is maintained for the following reason. If is the optimal solution to (1), then
and hence , where . So, if we believe that the variables converge to , it indeed does make sense to maintain (4). Why should we believe this? This is where the specific update of the “dual variables” comes from: is set a convex combination of its previous value and our best estimate so far of , namely, . Indeed, the update can be written as
Why does this make sense? Because we believe that converges to . Admittedly, this reasoning is somewhat “circular”. However, a better word to describe this reasoning would be: “iterative”.
Main Results
Tight and easily computable formulas for such parameters can be found in . For instance, whenever , inequality (6) holds with .
Our result will be expressed in terms of the decay of the potential , where and are defined in (7).
Assume that the average loss function, , is convex. If (3) holds and we let
then the for the potential decays exponentially to zero as
Moreover, if we set equal to the upper bound in (8), then
2 Convex loss functions
Our result will be expressed in terms of the decay of the potential , where and are defined in (7).
Assume that all loss functions are convex and satisfy (2). If we run Algorithm 1 with parameter satisfying the inequality
then the for the potential decays exponentially to zero as
Moreover, if we set equal to the upper bound in (10), then
The rate, , precisely matches that of the QUARTZ algorithm . Quartz is the only other method for ERM which has been analyzed for an arbitrary mini-batching scheme. Our algorithm is dual-free, and as we have seen above, allows for an analysis covering the case of non-convex loss functions.
Chunking
In this section we illustrate one use of the ability of our method to work with an arbitrary mini-batching scheme. Further examples include the ability to design distributed variants of the method , or the use of importance/adaptive sampling to lower the number of iterations .
One marked disadvantage of standard mini-batching (“choose a subset of examples, uniformly at random”) used in the context of parallel processing on multicore processors is the fact that in a synchronous implementation there is a loss of efficiency due to the fact that the computation time of may differ through . This is caused by the data examples having varying degree of sparsity. We hence introduce a new sampling which mitigates this issue.
Choose sets , such that and and is similar for every , i.e. . Instead of sampling coordinates we propose a new sampling, which on each iteration samples sets out of and uses coordinates as the sampled set. We assign each core one of the sets for parallel computation. The advantage of this sampling lies in the fact, that the load of computing for all is similar for all . Hence, using this sampling we minimize the waiting time of processors.
The algorithms returns the partition of into in a sense, that the first coordinates belong to , next coordinates belong to and so on. The main advantage of this approach is, that it makes a preprocessing step on the dataset which takes just one pass through the data. On Figure 1(a) through Figure 1(f) we show the impact of Algorithm 2 on the probability of the waiting time of a single core, which we measure by the difference
for the initial and preprocessed dataset respectively. We can observe, that the waiting time is smaller using the preprocessing.
Experiments
In all our experiments we used logistic regression. We normalized the datasets so that , and fixed . The datasets used for experiments are summarized in Table 1.
Experiment 1. In Figure 2(a) we compared the performance of Algorithm 1 with uniform serial sampling against state of the art algorithms such as SGD , SAG and S2GD in number of epochs. The real running time of the algorithms was 0.46s for S2GD, 0.79s for SAG, 0.47s for SDCA and 0.58s for SGD. In Figure 2(b) we show the convergence rate for different regularization parameters . In Figure 2(c) we show convergence rates for different serial samplings: uniform, importance and also 4 different randomly generated serial samplings. These samplings were generated in a controlled manner, such that random c has . All of these samplings have linear convergence as shown in the theory.
Experiment 2: New sampling vs. old sampling. In Figure 3(a) through Figure 3(l) we compare the performance of a standard parallel sampling against sampling of blocks output by Algorithm 2. In each iteration we measure the time by
for the standard and new sampling respectively. This way we measure only the computations done by the core which is going to finish the last in each iteration, and consider the number of multiplications with nonzero entries of the data matrix as a proxy for time.
Proofs
As a first approximation, our proof is an extension of the proof of Shalev-Shwartz to accommodate an arbitrary sampling . For all and we let and . We will use the following lemma.
For a fixed iteration and all we have:
Proof. It follows that for using the definition (7) we have
and for we have . Taking the expectation over we get the result.
Taking the expectation over , using inequality (6), and noting that
and which together yields
It follows that , and repeating this recursively we end up with This concludes the proof of the first part of Theorem 1. The second part of the proof follows by observing that is -smooth, which gives .
2 Convex case
For the next theorem we need an additional lemma:
Assume that are -smooth and convex. Then, for every ,
Proof. Let Clearly, is also -smooth. By convexity of we have for all . It follows that satisfies Using the definition of , we obtain
Summing these terms up weighted by and using (5) we get
3 Proof of Theorem 2
Using the convexity of we have and using Lemma 4, we have
This gives , which concludes the first part of the Theorem 2. The second part follows by observing, that is -smooth, which gives .