Byzantine-Tolerant Machine Learning

Peva Blanchard, El Mahdi El Mhamdi, Rachid Guerraoui, Julien Stainer

Introduction

Machine learning has received a lot of attention over the past few years. Its applications range all the way from images classification, financial trend prediction, disease diagnosis, to gaming and driving . Most major companies are currently investing in machine learning technologies to support their businesses . Roughly speaking, machine learning consists in giving a computer the ability to improve the way it solves a problem with the quantity and quality of information it can use . In short, the computer has a list of internal parameters, called the parameter vector, which allows the computer to formulate answers to several questions such as, “is there a cat on this picture?”. According to how many correct and incorrect answers are provided, a specific error cost is associated with the parameter vector. Learning is the process of updating this parameter vector in order to minimize the cost.

The increasing amount of data involved as well as the growing complexity of models has led to learning schemes that require a lot of computational resources. As a consequence, most industry-grade machine-learning implementations are now distributed . For example, as of 2012, Google reportedly used 16.000 processors to train an image classifier . However, distributing a computation over several machines induces a higher risk of failures, including crashes and computation errors. In the worst case, the system may undergo Byzantine failures , i.e., completely arbitrary behaviors of some of the machines involved. In practice, such failures may be due to stalled processes, or biases in the way the data samples are distributed among the processes.

A classical approach to mask failures in distributed systems is to use a state machine replication protocol , which requires however state transitions to be applied by all processes. In the case of distributed machine learning, this constraint can be seen in two ways: either (a) the processes agree on a sample of data based on which they update their local parameter vectors, or (b) they agree on how the parameter vector should be updated. In case (a), the sample of data has to be transmitted to each process, which then has to perform a heavyweight computation to update its local parameter vector. This entails communication and computational costs that defeat the entire purpose of distributing the work. In case (b), the processes have no way to check if the chosen update for the parameter vector has indeed been computed correctly on real data (a Byzantine process could have proposed the update). Byzantine failures may easily prevent the convergence of the learning algorithm. Neither of these solutions is satisfactory in a realistic distributed machine learning setting.

In fact, most learning algorithms today rely on a core component, namely stochastic gradient descent (SGD) , whether for training neural networks , regression , matrix factorization or support vector machines . In all those cases, a cost function – depending on the parameter vector – is minimized based on stochastic estimates of its gradient. Distributed implementations of SGD typically take the following form: a single parameter server is in charge of updating the parameter vector, while worker processes perform the actual update estimation, based on the share of data they have access to. More specifically, the parameter server executes synchronous rounds, during each of which, the parameter vector is broadcast to the workers. In turn, each worker computes an estimate of the update to apply (an estimate of the gradient), and the parameter server aggregates their results to finally update the parameter vector. Today, this aggregation is typically implemented through averaging , or variants of it .

The question we address in this paper is how a distributed SGD can be devised to tolerate ff Byzantine processes among the nn workers.

We first show in this paper that no linear combination (current approaches) of the updates proposed by the workers can tolerate a single Byzantine worker. Basically, the Byzantine worker can force the parameter server to choose any arbitrary vector, even one that is too large in amplitude or too far in direction from the other vectors. Clearly, the Byzantine worker can prevent any classic averaging-based approach to converge. Choosing the appropriate update from the vectors proposed by the workers turns out to be challenging. A non-linear, distance-based choice function, that chooses, among the proposed vectors, the vector “closest to everyone else” (for example by taking the vector that minimizes the sum of the distances to every other vector), might look appealing. Yet, such a distance-based choice tolerates only a single Byzantine worker. Two Byzantine workers can collude, one helping the other to be selected, by moving the barycenter of all the vectors farther from the “correct area”.

We formulate a Byzantine resilience property capturing sufficient conditions for the parameter server’s choice to tolerate ff Byzantine workers. Essentially, to guarantee that the cost will decrease despite Byzantine workers, we require the parameter server’s choice (a) to point, on average, to the same direction as the gradient and (b) to have statistical moments (up to the fourth moment) bounded above by a homogeneous polynomial in the moments of a correct estimator of the gradient. One way to ensure such a resilience property is to consider a majority-based approach, looking at every subset of n−fn-f vectors, and considering the subset with the smallest diameter. While this approach is more robust to Byzantine workers that propose vectors far from the correct area, its exponential computational cost is prohibitive. Interestingly, combining the intuitions of the majority-based and distance-based methods, we can choose the vector that is somehow the closest to its n−fn-f neighbors. Namely, the one that minimizes a distance-based criteria, but only within its n−fn-f neighbors. This is the main idea behind our choice function we call KrumKrum, in Greek \acctonosµ, ωας α Βυλγαριαν Κηαν οφ τηε ενδ οφ τηε ειγητη ςεντυρψ, ωηο υνδερτοοϰ οφφενςιε ατταςϰς αγαινςτ τηε Βψζαντινε εμπιρε. Βυλγαρια δουβλεδ ιν ςιζε δυρινγ ηις ρειγν.. Assuming 2f+2<n2f+2<n, we show (using techniques from multi-dimensional stochastic calculus) that our Krum function satisfies the resilience property aforementioned and the corresponding machine learning scheme converges. An important advantage of the Krum function is that it requires O(n2⋅(d+log⁡n))O(n^{2}\cdot(d+\log n)) local computation time, where dd is the dimension of the parameter vector. (In modern machine learning, the dimension dd of the parameter vector may take values in the hundreds of billions .) For simplicity of presentation, we first introduce a version of the Krum function that selects only one vector. Then we discuss how this method can be iterated to leverage the contribution of more than one single correct worker.

Paper Organization.

Section 2 recalls the classical model of distributed SGD. Section 3 proves that linear combinations (solutions used today) are not resilient even to a single Byzantine worker, then introduces the new concept of (α,f)(\alpha,f)-Byzantine resilience. In Section 4, we introduce the Krum function, compute its computational cost and prove its (α,f)(\alpha,f)-Byzantine resilience. In Section 5 we analyze the convergence of a distributed SGD using our Krum function. In Section 6 we discuss how Krum can be iterated to leverage the contribution of more workers. Finally, we discuss related work and open problems in Section 7.

Model

Note that, since the communication is synchronous, if the parameter server does not receive a vector value VbtV_{b}^{t} from a given Byzantine worker bb, then the parameter server acts as if it had received the default value Vbt=0V_{b}^{t}=0 instead.

The parameter server computes a vector F(V1t,…,Vnt)F(V_{1}^{t},\dots,V_{n}^{t}) by applying a deterministic function FF to the vectors received. We refer to FF as the choice function of the parameter server. The parameter server updates the parameter vector using the following SGD equation

The Byzantine workers have full knowledge of the system, including the choice function FF, the vectors proposed by the other workers and can collaborate with each other .

Byzantine Resilience

In most SGD-based learning algorithms used today , the choice function consists in computing the average of the input vectors. Lemma 1 below states that no linear combination of the vectors can tolerate a single Byzantine worker. In particular, averaging is not robust to Byzantine failures.

Consider a choice function FlinF_{lin} of the form

If the Byzantine worker proposes vector Vn=1λn⋅U−∑i=1n−1λiλnViV_{n}=\frac{1}{\lambda_{n}}\cdot U-\sum_{i=1}^{n-1}\frac{\lambda_{i}}{\lambda_{n}}V_{i}, then F=UF=U. Note that the parameter server could cancel the effects of the Byzantine behavior by setting, for example, λn\lambda_{n} to 0, but this requires means to detect which worker is Byzantine. ∎

Condition (ii) is more technical, and states that the moments of FF should be controlled by the moments of the (correct) gradient estimator GG. The bounds on the moments of GG are classically used to control the effects of the discrete nature of the SGD dynamics . Condition (ii) allows to transfer this control to the choice function.

The Krum Function

Our approach to circumvent this issue is to preclude the vectors that are too far away. More precisely, we define our Krum choice function \textscKr(V1,…,Vn)\textsc{Kr}(V_{1},\dots,V_{n}) as follows. For any i≠ji\neq j, we denote by i→ji\rightarrow j the fact that VjV_{j} belongs to the n−f−2n-f-2 closest vectors to ViV_{i}. Then, we define for each worker ii, the score s(i)=∑i→j∥Vi−Vj∥2s(i)=\sum_{i\rightarrow j}\left\lVert V_{i}-V_{j}\right\rVert^{2} where the sum runs over the n−f−2n-f-2 closest vectors to ViV_{i}. Finally, \textscKr(V1,…,Vn)=Vi∗\textsc{Kr}(V_{1},\dots,V_{n})=V_{i_{*}} where i∗i_{*} refers to the worker minimizing the score, s(i∗)≤s(i)s(i_{*})\leq s(i) for all ii.If two or more workers have the minimal score, we choose the vector of the worker with the smallest identifier.

The time complexity of the Krum Function \textscKr(V1,…,Vn)\textsc{Kr}(V_{1},\dots,V_{n}), where V1,…,VnV_{1},\dots,V_{n} are dd-dimensional vectors, is O(n2⋅(d+log⁡n))O(n^{2}\cdot(d+\log n))

For each ViV_{i}, the parameter server computes the nn squared distances ∥Vi−Vj∥2\left\lVert V_{i}-V_{j}\right\rVert^{2} (time O(n⋅d)O(n\cdot d)). Then the parameter server sorts these distances (time O(n⋅log⁡n)O(n\cdot\log n)) and sums the first n−f−1n-f-1 values (time O(n⋅d)O(n\cdot d)). Thus, computing the score of all the ViV_{i}’s takes O(n2⋅(d+log⁡n))O(n^{2}\cdot(d+\log n)). An additional term O(n)O(n) is required to find the minimum score, but is negligible relatively to O(n2⋅(d+log⁡n))O(n^{2}\cdot(d+\log n)). ∎

Proposition 1 below states that, if 2f+2<n2f+2<n and the gradient estimator is accurate enough, (its standard deviation is relatively small compared to the norm of the gradient), then the Krum function is (α,f)(\alpha,f)-Byzantine-resilient, where angle α\alpha depends on the ratio of the deviation over the gradient. When the Krum function selects a correct vector (i.e., a vector proposed by a correct worker), the proof of this fact is relatively easy, since the probability distribution of this correct vector is that of the gradient estimator GG. The core difficulty occurs when the Krum function selects a Byzantine vector (i.e., a vector proposed by a Byzantine worker), because the distribution of this vector is completely arbitrary, and may even depend on the correct vectors. In a very general sense, this part of our proof is reminiscent of the median technique: the median of n>2fn>2f scalar values is always bounded below and above by values proposed by correct workers. Extending this observation to our multi-dimensional is not trivial. To do so, we notice that the chosen Byzantine vector BkB_{k} has a score not greater than any score of a correct worker. This allows us to derive an upper bound on the distance between BkB_{k} and the real gradient. This upper bound involves a sum of distances from correct to correct neighbor vectors, and distances from correct to Byzantine neighbor vectors. As explained above, the first term is relatively easy to control. For the second term, we observe that a correct vector ViV_{i} has n−f−2n-f-2 neighbors (the n−f−2n-f-2 closest vectors to ViV_{i}), and f+1f+1 non-neighbors. In particular, the distance from any (possibly Byzantine) neighbor VjV_{j} to ViV_{i} is bounded above by a correct to correct vector distance. In other words, we manage to control the distance between the chosen Byzantine vector and the real gradient by an upper bound involving only distances between vectors proposed by correct workers.

then the Krum function Kr is (α,f)(\alpha,f)-Byzantine resilient where 0≤α<π/20\leq\alpha<\pi/2 is defined by

The condition on the norm of the gradient, η(n,f)⋅d⋅σ<∥g∥\eta(n,f)\cdot\sqrt{d}\cdot\sigma<\lVert g\rVert, can be satisfied, to a certain extent, by having the (correct) workers computing their gradient estimates on mini-batches . Indeed, averaging the gradient estimates over a mini-batch divides the deviation σ\sigma by the squared root of the size of the mini-batch.

Without loss of generality, we assume that the Byzantine vectors B1,…,BfB_{1},\dots,B_{f} occupy the last ff positions in the list of arguments of Kr, i.e., \textscKr=\textscKr(V1,…,Vn−f,B1,…,Bf)\textsc{Kr}=\textsc{Kr}(V_{1},\dots,V_{n-f},B_{1},\dots,B_{f}). An index is correct if it refers to a vector among V1,…,Vn−fV_{1},\dots,V_{n-f}. An index is Byzantine if it refers to a vector among B1,…,BfB_{1},\dots,B_{f}. For each index (correct or Byzantine) ii, we denote by δc(i)\delta_{c}(i) (resp. δb(i)\delta_{b}(i)) the number of correct (resp. Byzantine) indices jj such that i→ji\rightarrow j. We have

We now examine the case i∗=ki_{*}=k for some Byzantine index kk. The fact that kk minimizes the score implies that for all correct indices ii

We focus on the term D2(i)D^{2}(i). Each correct worker ii has n−f−2n-f-2 neighbors, and f+1f+1 non-neighbors. Thus there exists a correct worker ζ(i)\zeta(i) which is farther from ii than any of the neighbors of ii. In particular, for each Byzantine index ll such that i→li\rightarrow l, ∥Vi−Bl∥2≤∥Vi−Vζ(i)∥2\left\lVert V_{i}-B_{l}\right\rVert^{2}\leq\left\lVert V_{i}-V_{\zeta(i)}\right\rVert^{2}. Whence

Putting everything back together, we obtain

To sum up, condition (i) of the (α,f)(\alpha,f)-Byzantine resilience property holds. We now focus on condition (ii).

Denoting by CC a generic constant, when i∗=ki_{*}=k, we have for all correct indices ii

The second inequality comes from the equivalence of norms in finite dimension. Now

Convergence Analysis

In this section, we analyze the convergence of the SGD using our Krum function defined in Section 4. The SGD equation is expressed as follows

where at least n−fn-f vectors among the VitV^{t}_{i}’s are correct, while the other ones may be Byzantine. For a correct index ii, Vit=G(xt,ξit)V^{t}_{i}=G(x_{t},\xi^{t}_{i}) where GG is the gradient estimator. We define the local standard deviation σ(x)\sigma(x) by

The following proposition considers an (a priori) non-convex cost function. In the context of non-convex optimization, even in the centralized case, it is generally hopeless to aim at proving that the parameter vector xtx_{t} tends to a local minimum. Many criteria may be used instead. We follow , and we prove that the parameter vector xtx_{t} almost surely reaches a “flat” region (where the norm of the gradient is small), in a sense explained below.

(v) finally, beyond a certain horizon, ∥x∥2≥D\lVert x\rVert^{2}\geq D, there exist ϵ>0\epsilon>0 and 0≤β<π/2−α0\leq\beta<\pi/2-\alpha such that

Then the sequence of gradients ∇Q(xt)\nabla Q(x_{t}) converges almost surely to zero.

Conditions (i) to (iv) are the same conditions as in the non-convex convergence analysis in . Condition (v) is a slightly stronger condition than the corresponding one in , and states that, beyond a certain horizon, the cost function QQ is “convex enough”, in the sense that the direction of the gradient is sufficiently close to the direction of the parameter vector xx. Condition (iv), however, states that the gradient estimator used by the correct workers has to be accurate enough, i.e., the local standard deviation should be small relatively to the norm of the gradient. Of course, the norm of the gradient tends to zero near, e.g., extremal and saddle points. Actually, the ratio η(n,f)⋅d⋅σ/∥∇Q∥\eta(n,f)\cdot\sqrt{d}\cdot\sigma/\left\lVert\nabla Q\right\rVert controls the maximum angle between the gradient ∇Q\nabla Q and the vector chosen by the Krum function. In the regions where ∥∇Q∥<η(n,f)⋅d⋅σ\left\lVert\nabla Q\right\rVert<\eta(n,f)\cdot\sqrt{d}\cdot\sigma, the Byzantine workers may take advantage of the noise (measured by σ\sigma) in the gradient estimator GG to bias the choice of the parameter server. Therefore, Proposition 2 is to be interpreted as follows: in the presence of Byzantine workers, the parameter vector xtx_{t} almost surely reaches a basin around points where the gradient is small (∥∇Q∥≤η(n,f)⋅d⋅σ\left\lVert\nabla Q\right\rVert\leq\eta(n,f)\cdot\sqrt{d}\cdot\sigma), i.e., points where the cost landscape is “almost flat”.

Note that the convergence analysis is based only on the fact that function Kr is (α,f)(\alpha,f)-Byzantine resilient. Due to space limitation, the complete proof of Proposition 2 is deferred to the Appendix.

For the sake of simplicity, we write \textscKrt=\textscKr(V1t,…,Vnt)\textsc{Kr}_{t}=\textsc{Kr}(V^{t}_{1},\dots,V^{t}_{n}). Before proving the main claim of the proposition, we first show that the sequence xtx_{t} is almost surely globally confined within the region ∥x∥2≤D\lVert x\rVert^{2}\leq D.

Let ut=ϕ(∥xt∥2)u_{t}=\phi(\lVert x_{t}\rVert^{2}) where

This becomes an equality when a,b≥Da,b\geq D. Applying this inequality to ut+1−utu_{t+1}-u_{t} yields

Let Pt\mathcal{P}_{t} denote the σ\sigma-algebra encoding all the information up to round tt. Taking the conditional expectation with respect to Pt\mathcal{P}_{t} yields

Thanks to condition (ii) of (α,f)(\alpha,f)-Byzantine resilience, and the assumption on the first four moments of GG, there exist positive constants A0,B0A_{0},B_{0} such that

Thus, there exist positive constant A,BA,B such that

When ∥xt∥2<D\lVert x_{t}\rVert^{2}<D, the first term of the right hand side is null because ϕ′(∥xt∥2)=0\phi^{\prime}(\lVert x_{t}\rVert^{2})=0. When ∥xt∥2≥D\lVert x_{t}\rVert^{2}\geq D, this first term is negative because (see Figure 4)

Note that the sequence μt\mu_{t} converges because ∑tγt2<∞\sum_{t}\gamma_{t}^{2}<\infty. Then

Consider the indicator of the positive variations of the left-hand side

The right-hand side of the previous inequality is the summand of a convergent series. By the quasi-martingale convergence theorem , this shows that the sequence ut′u^{\prime}_{t} converges almost surely, which in turn shows that the sequence utu_{t} converges almost surely, ut→u∞≥0u_{t}\rightarrow u_{\infty}\geq 0.

Let us assume that u∞>0u_{\infty}>0. When tt is large enough, this implies that ∥xt∥2\lVert x_{t}\rVert^{2} and ∥xt+1∥2\lVert x_{t+1}\rVert^{2} are greater than DD. Inequality 1 becomes an equality, which implies that the following infinite sum converges almost surely

Note that the sequence ϕ′(∥xt∥2)\phi^{\prime}(\lVert x_{t}\rVert^{2}) converges to a positive value. In the region ∥xt∥2>D\lVert x_{t}\rVert^{2}>D, we have

(Convergence).

We proceed to show that the gradient ∇Q(xt)\nabla Q(x_{t}) converges almost surely to zero. We define

Using a first-order Taylor expansion and bounding the second derivative with K1K_{1}, we obtain

By the properties of (α,f)(\alpha,f)-Byzantine resiliency, this implies

which in turn implies that the positive variations of hth_{t} are also bounded

The right-hand side is the summand of a convergent infinite sum. By the quasi-martingale convergence theorem, the sequence hth_{t} converges almost surely, Q(xt)→Q∞Q(x_{t})\rightarrow Q_{\infty}.

Taking the expectation of Inequality 2, and summing on t=1,…,∞t=1,\dots,\infty, the convergence of Q(xt)Q(x_{t}) implies that

Using a Taylor expansion, as demonstrated for the variations of hth_{t}, we obtain

Taking the conditional expectation, and bounding the second derivatives by K4K_{4},

The positive expected variations of ρt\rho_{t} are bounded

The two terms on the right-hand side are the summands of convergent infinite series. By the quasi-martingale convergence theorem, this shows that ρt\rho_{t} converges almost surely.

This implies that the following infinite series converge almost surely

Since ρt\rho_{t} converges almost surely, and the series ∑t=1∞γt=∞\sum_{t=1}^{\infty}\gamma_{t}=\infty diverges, we conclude that the sequence ∥∇Q(xt)∥\lVert\nabla Q(x_{t})\rVert converges almost surely to zero. ∎

m𝑚m-Krum

So far, for the sake of simplicity, we defined our Krum function so that it selects only one vector among the nn vectors proposed. In fact, the parameter server could avoid wasting the contribution of the other workers by selecting mm vectors instead. This can be achieved, for instance, by selecting one vector using the Krum function, removing it from the list, and iterating this scheme m−1m-1 times, as long as n−m>2f+2n-m>2f+2. We then define accordingly the mm-Krum function

where the Vi∗sV_{i^{s}_{*}}’s are the mm vectors selected as explained above. Note that the 11-Krum function is the Krum function defined in Section 4.

Concluding Remarks

At first glance, the Byzantine-resilient machine problem we address in this paper can be related to multi-dimensional approximate agreement . Yet, results in dd-dimensional approximate agreement cannot be applied in our context for the following reasons: (a) assume that the set of vectors that can be proposed to an instance of the agreement is bounded so that at least f+1f+1 correct workers propose the same vector, which would require a lot of redundant work in our setting; and most importantly, (b) requires a local computation by each worker that is in O(nd)O(n^{d}). While this cost seems reasonable for small dimensions, such as, e.g., mobile robots meeting in a 2D2D or 3D3D space, it becomes a real issue in the context of machine learning, where dd may be as high as 160160 billion (making dd a crucial parameter when considering complexities, either for local computations, or for communication rounds). In our case, the complexity of the Krum function is O(n2⋅(d+log⁡n))O(n^{2}\cdot(d+\log n)).

A closer approach to ours has been recently proposed in . In , the authors assume a bounded gradient, and their work was an important step towards Byzantine-tolerant machine learning. However, their study only deals with parameter vectors of dimension one. In the authors tackle a multi-dimensional situation, using an iterated approximate Byzantine agreement that reaches consensus asymptotically. This is however only achieved on a finite set of possible environmental states and cannot be used in the continuous context of stochastic gradient descent.

The present work offers many possible extensions. First, the question of whether the bound 2f+2<n2f+2<n is tight remains open, so is the question on how to tolerate both asynchrony and Byzantine workers. Second, we have shown that our scheme forces the parameter vector to reach a region where the gradient is small relatively to η⋅d⋅σ\eta\cdot\sqrt{d}\cdot\sigma. The question of whether the factor η(n,f)=O(n)\eta(n,f)=O(n) can be made smaller also remains open. Third, the mm-Krum function iterates the 11-Krum function mm times, multiplying by mm the overall computation complexity. An alternative is to select the first mm vectors after computing the score as in the Krum function. Proving the (α,f)(\alpha,f)-Byzantine-resilience of this alternative remains open.

The authors would like to thank to Lê Nguyen Hoang for fruitful discussion and inputs.

References