Primal Method for ERM with Flexible Mini-batching Schemes and Non-convex Losses

Dominik Csiba, Peter Richtárik

Introduction

Further, let L1,…,Ln>0L_{1},\dots,L_{n}>0 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 ϵ\epsilon-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 ∇ϕi(Ai⊤w)\nabla\phi_{i}(A_{i}^{\top}w) for some randomly selected example ii. The quantity κ\kappa is the condition number. Typically one has κ=max⁡ili∥Ai∥2λ\kappa=\frac{\max_{i}l_{i}\|A_{i}\|^{2}}{\lambda} for methods picking ii uniformly at random, and κ=∑ili∥Ai∥2nλ\kappa=\frac{\sum_{i}l_{i}\|A_{i}\|^{2}}{n\lambda} for methods picking ii using a carefully designed data-dependent importance sampling. Computation of such a gradient typically involves work which is equivalent to reading the example AiA_{i}, that is, O(nnz(Ai))≤dmO(nnz(A_{i}))\leq dm 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 A1,…,AnA_{1},\dots,A_{n}, 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 pip_{i} is the probability that coordinate ii is updated in an iteration, v1,…,vn>0v_{1},\dots,v_{n}>0 are certain “stepsize” parameters of the method associated with the sampling and data (see (6)), and E(0)E^{(0)} 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 pi=1/np_{i}=1/n and vi=∥Ai∥2v_{i}=\|A_{i}\|^{2}, whereby we obtain one of the O(n+κ)log⁡(1/ϵ)O(n+\kappa)\log(1/\epsilon) 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 D(0)D^{(0)} 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 S^\hat{S}, which encodes a particular mini-batching scheme. Formally, a sampling S^\hat{S} is a set-valued random variable with values being the subsets of [n][n], 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 Prob(S)\mathbf{Prob}(S) assigned to every subset S⊆[n]S\subseteq[n] of the examples.

This relation is maintained for the following reason. If w∗w^{*} is the optimal solution to (1), then

and hence w∗=1λn∑i=1nAiαi∗w^{*}=\frac{1}{\lambda n}\sum_{i=1}^{n}A_{i}\alpha_{i}^{*}, where αi∗:=−∇ϕi(Ai⊤w∗)\alpha_{i}^{*}:=-\nabla\phi_{i}(A_{i}^{\top}w^{*}). So, if we believe that the variables αi\alpha_{i} converge to −∇ϕi(Ai⊤w∗)-\nabla\phi_{i}(A_{i}^{\top}w^{*}), it indeed does make sense to maintain (4). Why should we believe this? This is where the specific update of the “dual variables” αi\alpha_{i} comes from: αi\alpha_{i} is set a convex combination of its previous value and our best estimate so far of −∇ϕi(Ai⊤w∗)-\nabla\phi_{i}(A_{i}^{\top}w^{*}), namely, −∇ϕi(Ai⊤w(t−1))-\nabla\phi_{i}(A_{i}^{\top}w^{(t-1)}). Indeed, the update can be written as

Why does this make sense? Because we believe that w(t−1)w^{(t-1)} converges to w∗w^{*}. 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 Prob(∣S^∣≤τ)=1\mathbf{Prob}(|\hat{S}|\leq\tau)=1, inequality (6) holds with vi=τ∥Ai∥2v_{i}=\tau\|A_{i}\|^{2}.

Our result will be expressed in terms of the decay of the potential D(t)=defλ2B(t)+λ2n∑i=1n1Li2Ci(t)D^{(t)}\stackrel{{\scriptstyle\text{def}}}{{=}}\frac{\lambda}{2}B^{(t)}+\frac{\lambda}{2n}\sum_{i=1}^{n}\frac{1}{L_{i}^{2}}C_{i}^{(t)}, where Bi(t)B_{i}^{(t)} and C(t)C^{(t)} are defined in (7).

Assume that the average loss function, 1n∑i=1nϕi\frac{1}{n}\sum_{i=1}^{n}\phi_{i}, is convex. If (3) holds and we let

then the for t≥0t\geq 0 the potential D(t)D^{(t)} decays exponentially to zero as

Moreover, if we set θ\theta 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 E(t)=defλ2B(t)+12n∑i=1n1liCi(t)E^{(t)}\stackrel{{\scriptstyle\text{def}}}{{=}}\frac{\lambda}{2}B^{(t)}+\frac{1}{2n}\sum_{i=1}^{n}\frac{1}{l_{i}}C_{i}^{(t)}, where Bi(t)B_{i}^{(t)} and C(t)C^{(t)} are defined in (7).

Assume that all loss functions {ϕi}\{\phi_{i}\} are convex and satisfy (2). If we run Algorithm 1 with parameter θ\theta satisfying the inequality

then the for t≥0t\geq 0 the potential E(t)E^{(t)} decays exponentially to zero as

Moreover, if we set θ\theta equal to the upper bound in (10), then

The rate, θ\theta, 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 ∇ϕ(Ai⊤w)\nabla\phi(A_{i}^{\top}w) may differ through ii. This is caused by the data examples having varying degree of sparsity. We hence introduce a new sampling which mitigates this issue.

Choose sets G1,…,Gk⊂[n]G_{1},\dots,G_{k}\subset[n], such that ∪i=1kGi=[n]\cup_{i=1}^{k}G_{i}=[n] and Gi∩Gj=∅ ∀i,jG_{i}\cap G_{j}=\emptyset~{}\forall i,j and ψ(i):=∑j∈Ginnz(Aj)\psi(i):=\sum_{j\in G_{i}}\text{nnz}(A_{j}) is similar for every ii, i.e. ψ(1)≈⋯≈ψ(k)\psi(1)\approx\dots\approx\psi(k). Instead of sampling τ\tau coordinates we propose a new sampling, which on each iteration tt samples τ\tau sets G(1)(t),…,G(τ)(t)G_{(1)}^{(t)},\dots,G_{(\tau)}^{(t)} out of G1,…,GkG_{1},\dots,G_{k} and uses coordinates i∈∪i=1τG(i)(t)i\in\cup_{i=1}^{\tau}G_{(i)}^{(t)} as the sampled set. We assign each core one of the sets G(i)(t)G_{(i)}^{(t)} for parallel computation. The advantage of this sampling lies in the fact, that the load of computing ∇ϕ(Ai⊤w)\nabla\phi(A_{i}^{\top}w) for all i∈Gji\in G_{j} is similar for all j∈[k]j\in[k]. Hence, using this sampling we minimize the waiting time of processors.

The algorithms returns the partition of [n][n] into G1,…,GkG_{1},\dots,G_{k} in a sense, that the first gg coordinates belong to G1G_{1}, next gg coordinates belong to G2G_{2} 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 max⁡i∥Ai∥=1\max_{i}\|A_{i}\|=1, and fixed λ=1/n\lambda=1/n. 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 λ\lambda. 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 (max⁡i pi)/(min⁡i pi)<c(\max_{i}~{}p_{i})/(\min_{i}~{}p_{i})<c. 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 G1,…,GkG_{1},\dots,G_{k} 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 ii and tt we let ui(t−1)=−∇ϕi(Ai⊤w(t))u_{i}^{(t-1)}=-\nabla\phi_{i}(A_{i}^{\top}w^{(t)}) and zi(t−1)=αi(t−1)−ui(t−1)z_{i}^{(t-1)}=\alpha_{i}^{(t-1)}-u_{i}^{(t-1)}. We will use the following lemma.

For a fixed iteration ttand all ii we have:

Proof. It follows that for i∈Sti\in S_{t} using the definition (7) we have

and for i∉Sti\notin S_{t} we have Ci(t−1)−Ci(t)=0C_{i}^{(t-1)}-C_{i}^{(t)}=0. Taking the expectation over StS_{t} we get the result.

Taking the expectation over StS_{t}, using inequality (6), and noting that

and P(w(t−1))−P(w∗)≥λ2∥w(t−1)−w∗∥2,P(w^{(t-1)})-P(w^{*})\geq\frac{\lambda}{2}\|w^{(t-1)}-w^{*}\|^{2}, which together yields

It follows that E[D(t)]≤(1−θ)D(t−1)\mathbf{E}[D^{(t)}]\leq(1-\theta)D^{(t-1)}, and repeating this recursively we end up with E[D(t−1)]≤(1−θ)tD(0)≤e−θtD(0).\mathbf{E}[D^{(t-1)}]\leq(1-\theta)^{t}D^{(0)}\leq e^{-\theta t}D^{(0)}. This concludes the proof of the first part of Theorem 1. The second part of the proof follows by observing that PP is (L+λ)(L+\lambda)-smooth, which gives P(w)−P(w∗)≤L+λ2∥w−w∗∥2P(w)-P(w^{*})\leq\frac{L+\lambda}{2}\|w-w^{*}\|^{2}.

2 Convex case

For the next theorem we need an additional lemma:

Assume that ϕi\phi_{i} are LiL_{i}-smooth and convex. Then, for every ww,

Proof. Let gi(x)=ϕi(x)−ϕi(Ai⊤w∗)−∇ϕi(Ai⊤w∗)⊤(x−Ai⊤w∗).g_{i}(x)=\phi_{i}(x)-\phi_{i}(A_{i}^{\top}w^{*})-\nabla\phi_{i}(A_{i}^{\top}w^{*})^{\top}(x-A_{i}^{\top}w^{*}). Clearly, gig_{i} is also lil_{i}-smooth. By convexity of ϕi\phi_{i} we have gi(x)≥0g_{i}(x)\geq 0 for all xx. It follows that gig_{i} satisfies ∥∇gi(x)∥2≤2ligi(x).\|\nabla g_{i}(x)\|^{2}\leq 2l_{i}g_{i}(x). Using the definition of gig_{i}, we obtain

Summing these terms up weighted by 1/li1/l_{i} and using (5) we get

3 Proof of Theorem 2

Using the convexity of PP we have P(w∗)−P(w(t−1))≥(w(t−1)−w∗)⊤∇P(w(t−1))P(w^{*})-P(w^{(t-1)})\geq(w^{(t-1)}-w^{*})^{\top}\nabla P(w^{(t-1)}) and using Lemma 4, we have

This gives E[E(t)]≤(1−θ)E(t−1)\mathbf{E}[E^{(t)}]\leq(1-\theta)E^{(t-1)}, which concludes the first part of the Theorem 2. The second part follows by observing, that PP is (L+λ)(L+\lambda)-smooth, which gives P(w)−P(w∗)≤L+λ2∥w−w∗∥2P(w)-P(w^{*})\leq\frac{L+\lambda}{2}\|w-w^{*}\|^{2}.

References