The original article is in Chinese. The English version is automatically translated by AI.

0x00 Preface

This article focuses on convergence analysis in distributed machine learning. As the fourth part, it mainly covers convergence proofs in distributed learning, again primarily referencing 1. At the same time, we extend the assumptions to the distributed setting.

Gradient Unbiased Estimate Assumption

$$ \mathbb{E}[g(w;\xi)] = \nabla f(w) $$

Gradient Bounded Variance Assumption

$$ \mathrm {Var}(\nabla f(w;\xi)) \leq \sigma^2 $$

Since $\frac{1}{m} \sum_{i=1}^{m} g\left(w, \xi_{i}\right)$ estimates $\nabla f(w)$, we obtain

$$ \mathrm {Var}\left(\frac{1}{m} \sum_{i=1}^{m} g\left(w, \xi_{i}\right)\right) = \mathbb{E}\left[\left\|\frac{1}{m} \sum_{i=1}^{m} g\left(w, \xi_{i}\right)\right\|^{2}\right] - \left\|\mathbb{E}\left[\frac{1}{m} \sum_{i=1}^{m} g\left(w, \xi_{i}\right)\right]\right\|^{2} \leq \frac{\sigma^{2}}{bm} $$

That is,

$$ \mathbb{E}_{\xi}\left[\left\|\frac{1}{m} \sum_{i=1}^{m} g(w, \xi_{i})\right\|^2\right] \leq ||\nabla f(w)||^{2} + \frac{\sigma^2}{bm} $$

0x01 Distributed Synchronous Stochastic Gradient Descent

Let’s first introduce several distributed optimization methods. The first is synchronous distributed SGD, which is simply an extension of SGD. Suppose we have $m$ worker nodes; in the Parameter Server framework this is called synchronous SGD. The iteration is:

$$ \begin{aligned} w_{t+1} &=w_{t}-\frac{\eta}{m} \sum_{i=1}^{m} g(w_{t}, \xi_{i}) \\ &=w_{t}-\frac{\eta}{m} \sum_{i=1}^{m} \frac{1}{b} \sum_{j=1}^{b} \nabla f\left(w_{t}, \xi_{i, j}\right) \end{aligned} $$

For synchronous SGD, we have the following theorem:

defination

Suppose the objective $f$ is $\mu$-strongly convex and $L$-smooth on $R^{d}$, and satisfies the unbiased gradient estimate and bounded gradient variance assumptions. When the step size satisfies $\eta \leq \frac{1}{L}$ and the starting point is $w_0$, after $t$ steps of Distributed Synchronous mini-batch SGD, $\mathbb{E}[f(w_{t})]$ is bounded as:
$$ \mathbb{E}[f(w_{t})] - f(w^{*}) - \frac{\eta L \sigma^{2}}{2\mu bm} \leq (1- \eta \mu)^{t}\left (\mathbb{E}[f(w_{0})] - f(w^{*}) - \frac{\eta L \sigma^{2}}{2\mu bm} \right ) $$

As can be seen from the assumptions above, this basically just adds a factor of $m$ to the SGD result by replacing $b$ with $bm$, so I’ll skip the proof here and leave it to the reader.

In addition, there are K-Synchronous SGD and K-batch-Synchronous SGD; the proofs are essentially the same, replacing $m$ with $K$.

0x02 Distributed Asynchronous Stochastic Gradient Descent

In the synchronous case, by the weakest-link (cannikin) principle we always have to wait for the slowest worker, and if one worker node fails, the entire system blocks. Although $K-Sync$ and $K-batch-sync$ mitigate this to some extent, they still waste compute (since the remaining tasks have to be canceled, throwing away a lot of resources). Going asynchronous avoids this issue, but at the cost of stale gradients (not canceling other tasks means gradients are no longer computed from the same parameters—the cost of gradient staleness).

This section is the main focus of this post. The assumptions remain $L-smooth$ and $\mu$-strongly convex, together with unbiased gradient estimates and bounded gradient variance. However, the definitions of unbiased gradient estimates and bounded gradient variance here differ slightly from before:

defination

Unbiased Stochastic Gradients: the stochastic gradient is an unbiased estimate of the true gradient $$ \mathbb{E}_{\xi_{j}|w_{k}}[g(w_{k};\xi_{j})] = \nabla f(w_{k}), \forall k \leq j $$

Compared to the earlier definition $\mathbb{E}{\xi{j}}[g(w;\xi_{j})] = \nabla f(w)$, this is stricter because when $k<j$ they are not i.i.d.; they are only independent once the current iteration reaches $j$, or once $\xi_{j}$ is accessed.

defination

Bounded Gradient Variance: bounded gradient variance $$ \mathbb{E}_{\xi_{j}|w_{k}}[||g(w_{k};\xi_{j})-\nabla f(w_{k})||^2] \leq \frac{\sigma^2}{b}, \forall k \leq j $$

Beyond that, we also need a staleness assumption:

defination

Bounded Staleness Assumption: we assume $\gamma \leq 1$ $$ \mathbb{E}[||\nabla f(w_{j})-\nabla f(w_{\tau(j)})||^2] \leq \gamma \mathbb{E}[||\nabla f(w_{j})||^2] $$

where $\tau(j)$ is the index of the model version received by the worker, with $\tau(j)\leq j$, which is a random variable. Also, $\tau(j)$ is governed by a parameter $p_{0}$, a lower bound on the probability of receiving a fresh gradient during iteration.

defination

Suppose $p_{0}^{(j)}$ is the conditional probability that $\tau(j)=j$ given all past delays and parameters, with $p_{0}\leq p_{0}^{(j)}$; then $$ \mathbb{E}[||\nabla f(w_{\tau(j)})||^2] \geq p_{0} \mathbb{E}[||\nabla f(w_{j})||^2] $$

Proof:

$$ \begin{align} \mathbb{E}[||\nabla f(w_{\tau(j)})||^2] &= p_{0}^{(j)} \mathbb{E}[||\nabla f(w_{\tau(j)})||^2|\tau(j)=j] + (1-p_{0}^{(j)}) \mathbb{E}[||\nabla f(w_{\tau(j)})||^2|\tau(j)\neq j] \\ &\geq p_{0} \mathbb{E}[||\nabla f(w_{j})||^2] \end{align} $$

If each worker’s gradient computation time follows an exponential distribution, then $j-\tau(j)$ is geometrically distributed and $p_{0}=\frac{1}{m}$. That’s because under exponential service times, the number of gradients the PS receives within a time window follows a Poisson distribution.

From the definitions and assumptions above, we have

defination

Suppose the objective $f$ is $\mu$-strongly convex and $L$-smooth on $R^{d}$, and satisfies the unbiased gradient estimate, bounded gradient variance, and staleness assumptions. When the step size satisfies $\eta \leq \frac{1}{2L}$ and the starting point is $w_0$, after $t$ steps of Distributed Asynchronous mini-batch SGD, $\mathbb{E}[f(w_{t})]$ is bounded as:
$$ \mathbb{E}[f(w_{t})] - f(w^{*}) - \frac{\eta L \sigma^{2}}{2\mu b{\gamma}'} \leq (1- \eta \mu{\gamma}')^{t}\left (\mathbb{E}[f(w_{0})] - f(w^{*}) - \frac{\eta L \sigma^{2}}{2\mu b{\gamma}'} \right ) $$
where ${\gamma}' = 1-\gamma+\frac{p_{0}}{2}$

Proof:

By $L$-smoothness,

$$ \begin{align} f(w_{j+1}) &\leq f(w_{j}) + (w_{j+1}-w_{j})^{\top}\nabla f(w_{j}) + \frac{L}{2}||w_{j+1}-w_{j}||^2 \\ &= f(w_{j}) - \eta g(w_{\tau(j)})^{\top}\nabla f(w_{j}) + \frac{L\eta^2}{2}||g(w_{\tau(j)})||^2 \\ &= f(w_{j}) - \frac{\eta}{2} ||\nabla f(w_{j})||^2 - \frac{\eta}{2} ||g(w_{\tau(j)})||^2 + \frac{\eta}{2} ||\nabla f(w_{j})-g(w_{\tau(j)})||^2 + \frac{L\eta^2}{2}||g(w_{\tau(j)})||^2 \end{align} $$

The last line uses $2a^{\top}b = ||a||^2 + ||b||^2 - ||a-b||^2$. Since $g(w_{\tau(j)})$ is an unbiased estimate, taking expectations on both sides gives

$$ \begin{align} \mathbb{E}[f(w_{j+1})] - \mathbb{E}[f(w_{j})] &\leq - \frac{\eta}{2} \mathbb{E}[||\nabla f(w_{j})||^2] - \frac{\eta}{2} \mathbb{E}[||g(w_{\tau(j)})||^2] + \frac{\eta}{2} \mathbb{E}[||\nabla f(w_{j})-g(w_{\tau(j)})||^2] + \frac{L\eta^2}{2}\mathbb{E}[||g(w_{\tau(j)})||^2] \\ &= - \frac{\eta}{2} \mathbb{E}[||\nabla f(w_{j})||^2] - \frac{\eta}{2} \mathbb{E}[||g(w_{\tau(j)})||^2] + \frac{\eta}{2} \mathbb{E}[||\nabla f(w_{j})-\nabla f(w_{\tau(j)}) +\nabla f(w_{\tau(j)}) - g(w_{\tau(j)})||^2] + \frac{L\eta^2}{2}\mathbb{E}[||g(w_{\tau(j)})||^2] \\ &= - \frac{\eta}{2} \mathbb{E}[||\nabla f(w_{j})||^2] - \frac{\eta}{2} \mathbb{E}[||g(w_{\tau(j)})||^2] + \frac{L\eta^2}{2}\mathbb{E}[||g(w_{\tau(j)})||^2] + \frac{\eta}{2} \mathbb{E}[||\nabla f(w_{j})-\nabla f(w_{\tau(j)})||^2] + \frac{\eta}{2} \mathbb{E}[||\nabla f(w_{\tau(j)}) - g(w_{\tau(j)})||^2] \\ &= - \frac{\eta}{2} \mathbb{E}[||\nabla f(w_{j})||^2] - \frac{\eta}{2} \mathbb{E}[||g(w_{\tau(j)})||^2] + \frac{L\eta^2}{2}\mathbb{E}[||g(w_{\tau(j)})||^2] + \frac{\eta}{2} \mathbb{E}[||\nabla f(w_{j})-\nabla f(w_{\tau(j)})||^2] + \frac{\eta}{2} (\mathbb{E}[||\nabla f(w_{\tau(j)})||^2] - 2\mathbb{E}[\nabla f(w_{\tau(j)})^{\top}g(w_{\tau(j)})] + \mathbb{E}[||g(w_{\tau(j)})||^2]) \\ &= - \frac{\eta}{2} \mathbb{E}[||\nabla f(w_{j})||^2] - \frac{\eta}{2} \mathbb{E}[||g(w_{\tau(j)})||^2] + \frac{L\eta^2}{2}\mathbb{E}[||g(w_{\tau(j)})||^2] + \frac{\eta}{2} \mathbb{E}[||\nabla f(w_{j})-\nabla f(w_{\tau(j)})||^2] + \frac{\eta}{2} \mathbb{E}[||g(w_{\tau(j)})||^2] - \frac{\eta}{2} \mathbb{E}[||\nabla f(w_{\tau(j)})||^2] \\ &= - \frac{\eta}{2} \mathbb{E}[||\nabla f(w_{j})||^2] - \frac{\eta}{2} \mathbb{E}[||\nabla f(w_{\tau(j)})||^2] + \frac{L\eta^2}{2}\mathbb{E}[||g(w_{\tau(j)})||^2] + \frac{\eta}{2} \mathbb{E}[||\nabla f(w_{j})-\nabla f(w_{\tau(j)})||^2] \\ &\leq - \frac{\eta}{2} \mathbb{E}[||\nabla f(w_{j})||^2] - \frac{\eta}{2} \mathbb{E}[||\nabla f(w_{\tau(j)})||^2] + (\frac{L\eta^2\sigma^{2}}{2b} + \frac{L\eta^2}{2}\mathbb{E}[||\nabla f(w_{\tau(j)})||^2]) + \frac{\eta \gamma}{2} \mathbb{E}[||\nabla f(w_{j})||^2] \\ &= -\frac{\eta}{2}(1-\gamma) \mathbb{E}[||\nabla f(w_{j})||^2] + \frac{L\eta^2\sigma^{2}}{2b} - \frac{\eta}{2}(1-\eta L) \mathbb{E}[||\nabla f(w_{\tau(j)})||^2] \\ &\leq -\frac{\eta}{2}(1-\gamma) \mathbb{E}[||\nabla f(w_{j})||^2] + \frac{L\eta^2\sigma^{2}}{2b} - \frac{\eta}{4}p_{0}\mathbb{E}[||\nabla f(w_{j})||^2] \\ &= -\frac{\eta}{2}(1-\gamma+\frac{p_{0}}{2}) \mathbb{E}[||\nabla f(w_{j})||^2] + \frac{L\eta^2\sigma^{2}}{2b} \end{align} $$

Next, using strong convexity,

$$ 2\mu (f(w) - f(w^{*})) \leq ||\nabla f(w)||^2 $$

we have

$$ \mathbb{E}[f(w_{j+1})] - f(w^{*}) \leq \left(1- \eta \mu\left(1-\gamma+\frac{p_{0}}{2}\right)\right)\left(\mathbb{E}[f(w_{j})] - f(w^{*})\right) + \frac{L\eta^{2} \sigma^{2}}{2b} $$

Setting ${\gamma}’ = 1-\gamma+\frac{p_{0}}{2}$, balancing terms (?), and unrolling gives the result:

$$ \mathbb{E}[f(w_{t})] - f(w^{*}) - \frac{\eta L \sigma^{2}}{2\mu b{\gamma}'} \leq (1- \eta \mu{\gamma}')^{t}\left (\mathbb{E}[f(w_{0})] - f(w^{*}) - \frac{\eta L \sigma^{2}}{2\mu b{\gamma}'} \right ) $$

0x03 K-Async SGD

In this case,

$$w_{j+1}=w_{j}-\frac{\eta}{K} \sum_{k=1}^{K} g(w_{\tau(k,j)};\xi_{k,j})$$

where $k=1,2,\cdots,K$ denotes the index of the workers contributing in the current round, $\xi_{k,j}$ denotes the samples of the $k$-th worker in iteration $j$, and $\tau(k,j)$ denotes the model version index of the $k$-th worker in iteration $j$, with $\tau(k,j)\leq j$ being a random variable. Also, $g(w_{\tau(k,j)};\xi_{k,j}) = \frac{1}{b} \sum_{\xi \in \xi_{k,j}} \nabla f(w_{\tau(k,j)};\xi)$.

The conclusion changes slightly as well, with ${\gamma}’ = 1-\gamma+\frac{p_{0}}{2}$:

$$ \mathbb{E}[f(w_{t})] - f(w^{*}) - \frac{\eta L \sigma^{2}}{2\mu b{\gamma}'K} \leq (1- \eta \mu{\gamma}')^{t}\left (\mathbb{E}[f(w_{0})] - f(w^{*}) - \frac{\eta L \sigma^{2}}{2\mu b{\gamma}'K} \right ) $$

Reference