{'fraction_non_alphanumeric': 0.034154251545555896, 'fraction_numerical': 0.014670112496199452, 'mean_word_length': 4.590509915014164, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 1, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Gap Aware Mitigation of Gradient Staleness

Cloud computing is becoming increasingly popular as a platform for distributed training of deep neural networks. Synchronous stochastic gradient descent (SSGD) suffers from substantial slowdowns due to stragglers if the environment is non-dedicated, as is common in cloud computing. Asynchronous SGD (ASGD) methods are immune to these slowdowns but are scarcely used due to gradient staleness, which encumbers the convergence process. Recent techniques have had limited success mitigating the gradient staleness when scaling up to many workers (computing nodes). In this paper we define the Gap as a measure of gradient staleness and propose Gap-Aware (GA), a novel asynchronous-distributed method that penalizes stale gradients linearly to the Gap and performs well even when scaling to large numbers of workers. Our evaluation on the CIFAR, ImageNet, and WikiText-103 datasets shows that GA outperforms the currently acceptable gradient penalization method, in final test accuracy. We also provide convergence rate proof for GA. Despite prior beliefs, we show that if GA is applied, momentum becomes beneficial in asynchronous environments, even when the number of workers scales up.


INTRODUCTION
The steady growth of deep neural networks over the years has made it impractical to train them from scratch on a single worker (i.e., computational device). Distributing the computations over several workers can drastically reduce the training time. However, due to the sequential nature of the widely used stochastic gradient descent (SGD) method, distributing the process is not an easy task.
Synchronous SGD (SSGD) is the most common method used to distribute the learning process across multiple workers. Several recent works (Mikami et al., 2018;Ying et al., 2018;Yamazaki et al., 2019;Goyal et al., 2017) have shown that SSGD can achieve large speedups while maintaining high accuracy. The major drawback of SSGD is that its speed is confined to the slowest worker in every iteration. This shortcoming is magnified in non-dedicated 1 environments such as cloud computing. For this reason, all the above mentioned works were forced to use homogeneous workers in a dedicated network, which serves to reduce the variance in the workers' iteration times. Unlike cloud computing, dedicated networks are expensive and therefore not available to most users.
In asynchronous SGD (ASGD), each worker communicates independently of the others, thereby addressing the major drawback of SSGD. ASGD enjoys linear speedup in terms of the number of workers, even on non-dedicated networks. This makes ASGD a potentially better alternative to SSGD when using cloud computing. Unfortunately, ASGD also has a significant weakness known as gradient staleness; the gradients used to update the parameter server's (master) parameters are often based on older parameters and therefore are inaccurate. Prior works have shown that gradient staleness severely hinders the convergence process by reaching reduced final accuracy (Chen et al., 2016;Cui et al., 2016). Mitliagkas et al. (2016) showed that gradient staleness also induces implicit momentum, thus the momentum coefficient γ must be decayed when scaling up the number of workers. Most research works measure the gradient staleness of a worker according to the delay: the number of master updates since the worker began calculating the stochastic gradient g, until g is used to update the master. To overcome gradient staleness, Zhang et al. (2015b) proposed Staleness-Aware (SA), which penalizes the step size of stale gradients linearly to their delay. This method was later embraced by other works (Jiang et al., 2017;Hardy et al., 2017;?) and is currently the common method for penalizing stale gradients. Unfortunately, this method suffers from a degradation of the final accuracy, especially when scaling up the number of workers. In Section 4.1, we show that the main reason for this degradation is the over-penalization and under-penalization caused by SA.
SSGD and ASGD rely on hyperparameter tuning for every different number of workers (Shallue et al., 2018). Tuning is extremely time-consuming, thus avoiding it is beneficial, whenever possible.
Our contribution: To mitigate gradient staleness while minimizing the degradation of final accuracy, we define a measure of gradient staleness we refer to as the Gap. The Gap is based on the difference between the parameters used to calculate the gradient and the parameters on which the gradient is applied. We propose a new method called Gap-Aware (GA) that penalizes the step size of stale gradients linearly to their Gap, while eliminating the over-penalization or under-penalization of SA. No new hyperparameters are introduced using the GA method.
• We show that GA out-performs SA, especially as the number of workers scales up.
• We prove that the convergence rate of the GA-ASGD algorithm with a non-convex loss function is consistent with SGD: O 1 √ BK where K is the total number of steps and B is the batch size.
• We show that penalizing the gradient itself rather than the step-size, eliminates under-penalization.
• Our results suggest that GA can be used without re-tuning the hyperparameters.
• As opposed to conclusions by Mitliagkas et al. (2016), we show that applying momentum in an asynchronous environment is advantageous (using GA), even when multiple workers are used. • We combine GA with Adam (Kingma & Ba, 2015) (Adam-GA), and show that Adam-GA achieves almost two orders of magnitude better perplexity than Adam or Adam-SA (which combines Adam with SA) using several workers on the Transformers-XL model.
Our results establish GA as a superior gradient-penalizing option to SA and suggest that using GA is a preferable alternative to SSGD in non-dedicated networks such as cloud computing, even when scaling to large numbers of workers. To validate our claims, we performed experiments on the CIFAR10, CIFAR100 (Hinton, 2007), ImageNet (Russakovsky et al., 2015), and WikiText-103 (Merity et al., 2016) datasets, using several state-of-the-art architectures. A version of GA has reached 72.18% final test accuracy on the ImageNet dataset using 128 simulated asynchronous workers. As far as we know, this is the largest number of asynchronous workers reported to converge on ImageNet.

RELATED WORK
Eliminating gradient staleness is a challenging task and several papers suggested techniques to reduce its detrimental effects. Zheng et al. (2017) proposed DC-ASGD, which uses a Taylor expansion to mitigate the gradient staleness. EASGD (Zhang et al., 2015a) uses a center force to pull the workers' parameters toward the master's parameters. Both DC-ASGD and EASGD achieve high accuracy on small numbers of workers, but fall short when trained on large clusters. Chan & Lane (2014) proposed penalizing stale gradients by reducing their size and thus limiting their effect on the learning process. They suggest decaying the learning rate exponentially to the delay; this makes the step size arbitrarily small when the amount of workers grows, virtually ceasing the learning process. As part of their convergence analysis, Dutta et al. (2018) suggest a penalizing method that is linear to the norm between the master and worker's parameters. However, their method introduces another hyperparameter, which requires additional time to tune. As opposed to other methods, GA performs well even when the number of workers is large, without introducing new hyperparameters. Gupta et al. (2016) as well as Aji & Heafield (2019) suggest collecting several gradients before updating the master to reduce the effects of gradient staleness. Wen et al. (2017) propose minimizing the size of the gradients to reduce communication times. GA is orthogonal to both of these approaches.

BACKGROUND
The goal of an optimization procedure is to minimize f (θ), where f is a smooth, but not necessarily convex, objective function (a.k.a. loss) and the vector θ ∈ R d is the model's parameters: where ξ ∈ Ξ is a random variable from Ξ, the entire set of training samples Ξ = {1, 2, · · · , M }. F (θ; ξ) is the stochastic loss function with respect to the training sample indexed by ξ. SGD is commonly the workhorse behind the optimization of deep neural networks. Denoting η as the learning rate and k as the step number, SGD's iterative update rule is: We denote X k as the variable X at the k th step, where X is any variable.
Momentum Momentum (Polyak, 1964) is a widely adopted optimization technique due to its accelerated convergence and oscillation reduction (Sutskever et al., 2013). Instead of simply using the gradient, the momentum iterative update rule 2 uses an exponentially-weighted moving average of gradients called the update vector: v k+1 = γv k + ∇f (θ k ). The update rule is: Nesterov's Accelerated Gradient (NAG) (Nesterov, 1983) is a well-used variation of momentum that has been proven to achieve quadratic speedup in convergence rate compared to SGD.

ASYNCHRONOUS SGD (ASGD)
We consider the commonly used ASGD, which operates with a parameter-server (master), used to keep the model's most up-to-date parameters. Each worker maintains a replica of the model's parameters. The workers run in parallel and synchronize with the master independently from each other at the beginning of each batch iteration. We denote τ k as the delay at the k th step. The worker and master algorithms are given by Algorithm 1 and 2, respectively, where B is the batch-size and ξ k,b denotes the b th sample in the batch sampled at the k th iteration. Gradient staleness appears when a gradient g k is computed on parameters θ k−τ k but applied to different parameters θ k .
Algorithm 1 Momentum-ASGD: worker i Compute gradient: Send g i k to the master Algorithm 2 Momentum-ASGD: master For k = 1...K do: Send θ k+1 to worker i

STALENESS-AWARE
Zhang et al. (2015b) proposed a gradient penalization method called Staleness-Aware (SA). SA aims to reduce the effects of gradient staleness by dividing the step size by its corresponding τ (Algorithm 3). The worker algorithm remains unchanged. The two ideas behind SA is that stale gradients should be penalized to reduce their impact and that gradient staleness scales up with τ . SA successfully mitigates the gradient staleness when N is small. Although commonly used, SA can potentially over-penalize as well as under-penalize stale gradients as we show below.
Algorithm 4 Gap-Aware: master For k = 1...K do: Receive gradient g i k from worker i Calculate Gap: Save and send current parameters θ k+1 to worker i Over-Penalizing Let us assume that at some step k, after τ master updates we get θ k = θ k−τ just as the gradient calculated on θ k−τ is applied. This means there is no gradient staleness for the next gradient update since it was computed using the same parameters on which it is applied. Unfortunately, the delay remains τ > 0, thereby causing over-penalization when SA is used.
Additionally, τ scales linearly with N , which dramatically reduces η when N is large. Consequently, on large numbers of workers, the convergence rate of SA is sluggish and its accuracy plummets.

Under-Penalizing
The SA method doesn't take into account that when using momentum, the update step also contains past gradients. To emphasize the importance of this issue, let's examine a fictional example: assume that some gradient g k is very stale (τ k is large). Following the SA technique, the update rule is: This means the stale gradient g k is indeed penalized by being multiplied by η k τ k , which is small; thus g k doesn't change the parameters much. We further assume the next iteration is very fast (τ k+1 is small). The next update will be: The stale gradient g k is multiplied by γ η k+1 τ k+1 , which is large (assuming η k ≈ η k+1 ). Despite the fact that g k was stale, it still has a significant impact on the learning process. In other words, g k is under-penalized.
To eliminate this possibility we penalize the stale gradient itself rather than the learning rate. Using this method, the staleness of each gradient is accounted for within the update vector v.

GAP-AWARE (GA)
In this section we propose a new method called Gap-Aware to mitigate over and under-penalization.

THE GAP AS A MEASURE OF GRADIENT STALENESS
An intuitive method to measure gradient staleness would be: ∇f (θ k )−∇f (θ k−τ k ) . This essentially measures the difference between the stale gradient and the accurate gradient that is computed on the up-to-date parameters. (Of course, ∇f (θ k ) is never calculated in ASGD algorithms.) Commonly used in deep learning is the Lipschitzian gradients assumption: This implies that θ k − θ k−τ k is a valid (and easily calculated) measure of the gradient staleness. This measure also addresses the delay's over-penalization; using the same simple example described in Section 4.1, the term θ k − θ k−τ k will now be zero, correctly measuring the gradient staleness.
The learning rate η, commonly decays as the training progresses. This decay can be viewed as a built-in penalization to reduce variance. Following this notion, we suggest reducing the staleness penalization as η decays. To accommodate all the attributes above, we define the Gap: Definition 1. G k , the Gap at the k th step, is defined as the minimal number of updates required to traverse the current distance between the master's and worker's parameters using the maximal learning rate and assuming all gradients have an average norm. G k ∈ R is defined as: is a constant representing the maximal distance the parameters can travel in a single update, given the gradient's norm is the average gradient norm.
Definition 1 means that dividing η by the Gap produces larger steps than those produced by SA This allows exploring more distant minimas while still mitigating the gradient staleness. Note that E[G k ] = τ k occurs only if all previous τ k updates were in the exact same direction, which rarely happens. Empirically, we found that E[G k ] < τ k (See Appendix C.8).
To mitigate the gradient staleness, while eliminating the over-penalization and under-penalization, we divide the gradients themselves by their respective Gap. We refer to this method as Gap-Aware (GA).

CONVERGENCE ANALYSIS
In this section we provide the outlines of the convergence analysis. The complete proofs are given in Appendix B. The GA-ASGD update rule (without momentum) is: The convergence rate is the speed (or number of steps) at which a convergent sequence approaches its limit. We follow ideas similar to Lian et al. (2015) to show that the upper bound of the convergence rate of GA on a non-convex loss function is similar to that of SGD. Assumption 1. We assume the following, commonly-used assumptions, hold: • Unbiased gradient: The stochastic gradient ∇F (θ; ξ) is unbiased: • Bounded variance: The variance of the stochastic gradient is bounded: • Lipschitzian gradients: See Equation 2.
We have the following ergodic convergence rate for the iteration of GA-ASGD: denotes taking expectation in terms of all random variables.
To simplify the upper bound in Theorem 1, we observed that setting the learning rate η k such that the expression η k G k is a constant value across all k obtains the following convergence rate: Corollary 1. Assume that Assumption 1 holds and that η k are set such that η k G k is constant for any k as follows: If the maximal delay parameter T satisfies: then the output of GA satisfies the following ergodic convergence rate: Corollary 1 claims that if the total iterations K is greater than O(BT 2 ), the convergence rate achieves O(1/ √ BK), which is consistent with the convergence rate of ASGD presented in Lian et al. (2015), and with the convergence rate of SGD.

GAP-AWARE VERSIONS
We explore three ways to measure G k : • Global: G k ∈ R as defined in Definition 1.
• Layer-wise: Every layer is penalized differently and independently. G k ∈ R P where P is the number of layers in the model. We denote 1 S as an S-dimensional vector of ones. We denote any vector X * ,p is the p th layer in the vector X * . Every element in G k is calculated per-layer: • Parameter-wise: Every parameter (element in the parameter vector θ) is penalized differently and independently. G k ∈ R d where d is the number of parameters. We denote | · | on vector X, as the absolute value per element of X. Every element in G k is calculated and applied per-element: We tested these variations on three different frameworks 3 to determine which technique has the best performance. Figure 1 demonstrates that the parameter-wise method (equation 13) resulted in the best test and train error. Since this phenomenon repeats across all frameworks, we henceforth use the parameter-wise method in the Gap-Aware algorithm. We denote as an element-wise multiplication between vectors and describe the final GA algorithm of the master as Algorithm 4. The worker algorithm remains the same as in Algorithm 1.

EXPERIMENTS
We simulated multiple distributed workers 4 to measure the final test error, train error, and convergence speed of different cluster sizes. To validate that penalizing linearly to the Gap is the factor that leads to better performance, we used the same hyperparameters across all the tested algorithms (see Appendix C.4). These hyperparameters are the ones tuned for a single worker, suggested by the authors of the respective papers for each framework. We simulated the workers' execution time using a gamma-distributed model (Ali et al., 2000) (see Appendix C.3), where the execution time for each individual batch was drawn from a gamma distribution. The gamma distribution is a well-accepted model for task execution time, which naturally gives rise to stragglers. The importance of asynchronous over synchronous training is explained in Appendix D.
Combining GA with DANA One way to verify whether it is better to penalize using the Gap or the delay, is to change the Gap while fixing the delay, and examining the results using GA and SA. Momentum generally increases the norm of the update vector; this in turn, increases the effective step size thus increasing the Gap for a given delay. Hakimi et al. (2019) introduced DANA, which uses the momentum to estimate the master's parameters at the time of the gradient update, thus decreasing the Gap. The combination of decreasing the Gap using DANA and penalizing stale gradients using GA or SA is easily integrated since both methods are orthogonal. In our experiments, we also compared between DANA-Gap-Aware (DANA-GA) and DANA-Staleness-Aware (DANA-SA). We note that since DANA decreases the Gap, DANA-GA penalizes much less than DANA-SA (see Appendix C.8).
• Staleness-Aware: SA as described in Algorithm 3, using a NAG optimizer.
Our evaluation was extensive on image classification tasks such as CIFAR10, CIFAR100 (Hinton, 2007), and ImageNet (Russakovsky et al., 2015). It also included a language modeling task using the WikiText-103 corpus (Merity et al., 2016). All datasets and models are detailed in Appendix C.2. Figure 2, NAG-ASGD shows how gradient staleness is exacerbated by momentum. NAG-ASGD yields high accuracy with few workers, but the test error climbs sharply when more than 16 workers are used. On the other hand, ASGD without momentum performs poorly using few workers. When using many workers, ASGD significantly surpasses NAG-ASGD because of the implicit momentum generated in asynchronous training (Mitliagkas et al., 2016). Figure 2 also demonstrates that both staleness penalization methods (GA and SA) outperform the naive NAG-ASGD. GA results in better final test error than SA across all experiments. This empirically proves that GA is the better method for penalizing the gradients. We claim this occurs mainly because SA over-penalizes the gradients, thereby making it impossible to reach any distant, good minima when the number of steps is limited (for more details see Appendix C.8). Figure 2 shows that DANA potentially diverges when N grows as opposed to DANA-GA and DANA-SA. This shows that DANA benefits from staleness penalization. Furthermore, DANA-GA out-performs all other methods and remains close to the baseline's error across all frameworks. The fact that DANA-GA out-performs DANA-SA validates that GA is superior to SA.   Tuned ASGD To validate that the staleness penalization helps overcome the gradient staleness and improve the results, we tuned the momentum and learning rate of ASGD using 32 workers on the 3 frameworks shown in Figure 2. For each framework, we performed a grid search of 70 perturbations (See Appendix C.12). Table 1 shows that GA and DANA-GA, using the same hyperparameters as the baseline, provide similar or better results than tuning both γ and η, which is highly time-consuming.

DANA Versions
According to Mitliagkas et al. (2016), if momentum is used, the asynchronous implicit momentum should impede the convergence as N increases. However, GA and DANA-GA, which use a large momentum, generally perform better than the tuned ASGD even when N is large. This phenomenon repeats across all frameworks, which suggests that GA, and especially DANA-GA, can mitigate the asynchronous implicit momentum problem. Tuning these methods should further improve the results.
The graphs of the train error also show the same concepts discussed here regarding the test error and are presented in Figure 6, Appendix C.10. The convergence rate analysis appears in Appendix C.11.

IMAGENET EXPERIMENTS
We conducted experiments on the ImageNet dataset using the ResNet-50 model (He et al., 2016). Every asynchronous worker is a machine with 8 GPUs, so the 128 workers in our experiments simulate a total of 1024 GPUs. For reference, Goyal et al. (2017) used 256 GPUs synchronously. The hyperparameters we used are those of the tuned single worker (see Appendix C.4). Table 3 shows that GA out-performs SA due to the high number of workers, which exacerbates the over-penalizing of SA. Unlike SA, GA out-performs NAG-ASGD as N increases due to successful staleness mitigation. DANA-GA remains close to the baseline and better than any other method as N increases. DANA-GA reaches 72.18% final test accuracy when using 128 workers, which is the most asynchronous workers shown to converge on ImageNet as far as we know.

NLP EXPERIMENTS
NLP tasks are usually trained using Adam (Kingma & Ba, 2015). To test SA and GA we implemented a version of Adam-SA and Adam-GA given by Algorithm 10 and 11, respectively (Appendix C.1). Transformer-XL (Dai et al., 2019) is a state-of-the-art model for NLP tasks; however, its sensitivity to gradient staleness is catastrophic (Aji & Heafield, 2019). Table 2 shows that GA successfully mitigates the gradient staleness and achieves near-baseline perplexity while SA results in a higher perplexity by almost two orders of magnitude. In this scenario, SA completely fails to mitigate the gradient staleness, proving the superiority of GA. (See hyperparameters in Appendix C.4).

CONCLUSIONS
The goal of this work is to mitigate gradient staleness, one of the main challenges of ASGD. We argue that penalizing stale gradients linearly to the delay, as done in the widely used SA method, flounders due to over and under-penalization. We defined the Gap to measure gradient staleness and proposed GA, a novel asynchronous distributed technique that mitigates the gradient staleness by penalizing stale gradients linearly to the Gap. We showed that GA surpasses SA across all frameworks, especially in NLP problems or when the number of workers is large. This presents GA as a superior alternative for staleness penalizing. We further introduced DANA-GA and demonstrated that DANA-GA mitigates gradient staleness better than any of the other methods we compared. Despite prior belief, DANA-GA's superb performance enables the use of momentum in asynchronous environments with many workers; it presents a desirable alternative for parallel training with multiple workers, especially on non-dedicated environments such as cloud computing. In future work, we plan to examine what makes GA perform so well in NLP tasks.
Taking expectation with respect to ξ k, * on both sides of equation 14, we have where we use the unbiased stochastic gradient assumption (equation 4).
From the fact that: Next we estimate the upper bound of T 1 and T 2 . For T 2 we have where the fifth equality is due to and the last inequality is due to the bounded variance assumption equation 5 and due to: We next turn to T 1 : where the last inequality is from the Lipschitzian gradient assumption (equation 2). It follows that where the last inequality uses the fact that a + b 2 ≤ 2 a 2 + 2 b 2 for any real vectors a and b.
Taking the expectation in terms of {ξ j−τj , * |j ∈ {k − τ k , ..., k − 1}} for T 3 , we have where the second to last equality is due to the last lines in equation 17 and the third equality is due to Taking the expectation in terms of ξ j−τj , * for T 4 , we have where the last inequality uses the fact that a i 2 for any real vectors a i and the bounded age assumption equation 6.

We take full expectation on both sides of equation 19 and substitute E[T 3 ] and E[T 4 ] by their upper bounds, equation 20 and equation 21 respectively:
Summarizing the inequality equation 23 from k = 1 to k = K, meaning until the K-th update of the master, we have where the second to last inequality is due to equation 7 and the last inequality is due to equation 6. Note that θ * is the global optimization point. By doing a few simple algebraic operations on equation 24 we have: This completes the proof.

Proof for Corollary 1
Proof. Combining equation 9 and equation 10, we get If follows from equation 26 that The last inequality holds since naturally T ≥ 0. This implies that condition equation 7 in Theorem 1 is satisfied globally. Then we can safely apply equation 8 in Theorem 1: where the third inequality is due to equation 26 and the second to last equality uses equation 9. This completes the proof.

Proof for equation in Section 4.1
Proof.
C EXPERIMENTAL SETUP C.1 ALGORITHMS Algorithms 5 to 11 only change the master's algorithm; the complementary worker algorithm is the same as ASGD (Algorithm 1). The master's scheme is a simple FIFO. We consider parameter server optimizations beyond the scope of this paper.
The calculation of the C coefficient is described in Appendix C.6.
We note that in Algorithms 8 and 11 the term θ i is identical to θ k−τ k from the definition of τ k in Section 4.
Algorithm 7 DANA-Staleness-Aware: master Initialize an iteration array for the workers: iter = [0] * N For k = 1...K do: Receive gradient g i k from worker i Calculate worker i's current delay Algorithm 8 DANA-Gap-Aware: master Initialize the given weights for each worker: θ i = θ 0 For k = 1...K do: Receive gradient g i k from worker i Calculate Gap: The Adam-based algorithm requires a slightly more intelligent integration to the gradient staleness penalizing methods (such as GA and SA). Penalizing the gradient before calculating the first and second moments doesn't affect the update vector since the first and second moments cancel each other out. Therefore, we suggest applying the penalty only on the first moment, thus decreasing the update step's size by the desired amount. Since DANA's integration into the Adam algorithm is convoluted and not straight forward, we chose not to implement the combination in this paper.

C.2 DATASETS & MODELS
CIFAR The CIFAR-10 (Hinton, 2007) dataset comprises 60K RGB images partitioned into 50K training images and 10K test images. Each image contains 32x32 RGB pixels and belongs to 1 of 10 equal-sized classes. CIFAR-100 is similar but has 100 classes. Link.
ImageNet The ImageNet dataset (Russakovsky et al., 2015), known as ILSVRC2012, consists of RGB images, each labeled as one of 1000 classes. The images are partitioned into 1.28 million training images and 50K validation images; each image is randomly cropped and re-sized to 224x224 (1-crop validation). Link.

WikiText-103
The WikiText language modeling dataset is a collection of over 100 million tokens extracted from the set of verified Good and Featured articles on Wikipedia. Compared to the preprocessed version of Penn Treebank (PTB), WikiText-103 is over 110 times larger. The WikiText dataset also features a far larger vocabulary and retains the original case, punctuation, and numbers (Merity et al., 2016). Link.
Transformer-XL The WikiText-103 dataset is trained on the Transformer-XL model (Dai et al., 2019). The hyperparameters are the ones suggested in the original paper (also see Appendix C.4) and the implementation is taken from their repository. Link.
C.3 GAMMA DISTRIBUTION Ali et al. (2000) suggest a method called CVB to simulate the run-time of a distributive network of computers. The method is based on several definitions: Definition 2. Task execution time variables: • µ task -mean time of tasks • V task -variance of tasks • µ mach -mean computation power of machines • V mach -variance of computation power of machines is a random number generated using a gamma distribution, where α is the shape and β is the scale.
For our case, all tasks are similar and run on a batch size of B. Therefore, the algorithm for deciding the execution-time of every task on a certain machine is reduced to one of the following: Algorithm 12 Task execution time -homogeneous machines Algorithm 13 Task execution time -heterogeneous machines β mach = µ mach α mach for j from 0 to M : where K is the total amount of tasks of all the machines combined (the total number of batch iterations), M is the total number of machines (workers), and curr is the machine currently about to run.
We note that Algorithms 12 and 13 naturally give rise to stragglers. In the homogeneous algorithm, all workers have the same mean execution time but some tasks can still be very slow; this generally means that in every epoch a different machine will be the slowest. In the heterogeneous algorithm, every machine has a different mean execution time throughout the training. We further note that p[j] is the mean execution time of machine j on the average task.
In our experiments, we simulated execution times using the following parameters as suggested by Ali et al. (2000): µ task = µ mach = B · V 2 mach , where B is the batch size, yielding a mean execution time of µ simulated time units, which is proportionate to B. In the homogeneous setting V mach = 0.1, whereas in the heterogeneous setting V mach = 0.6. For both settings, V task = 0.1. Figure 3 illustrates the differences between the homogeneous and heterogeneous gamma-distribution. Both environments have the same mean (128) but the probability of having an iteration that is at The red area represents the probability to have an iteration which takes more than 1.25x longer than the mean iteration time.
least 1.25x longer than the mean (which means 160 or more) is significantly higher in the heterogeneous environment (27.9% in heterogeneous environment as opposed to 1% in the homogeneous environment).

C.4 HYPERPARAMETERS
Since one of our intentions was to verify that penalizing the gradients linearly to the Gap is the factor that leads to a better final test error and convergence rate, we used the same hyperparameters across all algorithms tested. These hyperparameters are the original hyperparameters of the respective neural network architecture, which are tuned for a single worker. Learning Rate Warm-Up In the early stages of training, the network changes rapidly, causing error spikes. For all algorithms, we follow the gradual warm-up approach (Goyal et al., 2017) to overcome this problem: we divide the initial learning rate by the number of workers N and ramp it up linearly until it reaches its original value after 5 epochs. We also use momentum correction (Goyal et al., 2017) in all algorithms to stabilize training when the learning rate changes.

C.5 WEIGHT DECAY
When GA is used with Weight Decay, the gradients contain a weight decay element which also needs to be divided by the Gap as a part of the gradient.

C.6 C COEFFICIENT
In Definition 1, we explained that we use a coefficient C to measure the gap. In Section 5.3, using the parameter-wise method, C is calculated per-parameter. To calculate C per-parameter, we used a weighted-average in a manner similar to the technique used in Adam (Kingma & Ba, 2015). The mechanism is described in Algorithm 14.

C.7 TABLED RESULTS
Each framework was trained on N ∈ [4, 8, 16, 24, 32] asynchronous workers. Figure 5 contains the experiments not shown in Section 5.3 and demonstrates that parameter-wise Gap-Aware usually reaches better or similar final errors. The hyperparameters are the same ones detailed in Appendix C.4.
C.10 CIFAR TRAINING Figure 6 shows that DANA-GA always remains very close to the zero-error region. This means that, unlike other algorithms, DANA-GA is able to converge on the training set despite the gradient staleness. Figure 6 further demonstrates all of the concepts discussed in Section 6.1. Figure 7 shows that the convergence rate of GA is similar to that of SA, despite using a larger step size. This suggests that GA does not require more steps than SA to reach its (better) minima. DANA-GA's convergence rate remains very close to the baseline, which suggests that it doesn't require more steps to converge. This means that DANA-GA reaches a test error similar to the single worker case in the same number of steps, while enjoying asynchronous speedup. Figure 8 demonstrates the same ideas discussed in the last paragraph on ImageNet using 64 asynchronous workers. However, since in this case the number of workers is much larger, both SA and DANA-SA perform very poorly due the the over-penalization of SA. This helps illustrate that GA is a better staleness mitigation method than SA. DANA-GA remains very close to the baseline despite the large number of workers used, demonstrating the superiority of DANA-GA. This shows that the best hyperparameters can vary between frameworks. The best hyperparameters for a specific framework can also vary across different number of workers as all the hyperparameters found in this experiment are different from the best hyperparameters of the single worker. Tuning for the best hyperparameters for every different number of workers for each framework significantly increases the training time and is best avoided if possible.

C.11 CONVERGENCE RATE
DANA-GA surpasses the tuned ASGD in every framework, while DANA performs very poorly using 32 workers. This proves that gradient penalization is very beneficial to overcome gradient staleness and specifically that GA is a very successful gradient penalization method.

C.13 GRADIENT STALENESS NOISE
We notice that in the ImageNet experiments (Table 3) NAG-ASGD remains relatively close to the baseline even when the number of workers is large, as opposed to the CIFAR experiments, in which NAG-ASGD severely deteriorates as N scales up. This phenomenon suggests that there is some /HDUQLQJ5DWH 0RPHQWXP Figure 11: Test Accuracy of ASGD using 32 asynchronous workers on CIFAR10 WideResNet 16-4 using different learning rate and momentum coefficients. The best accuracy achieved is 71.07% (η = 0.3, γ = −0.5). The tuning includes negative values of momentum gradient staleness noise that a framework can "tolerate" and still perform well. Following this intuition, it is reasonable that some gradient staleness should be allowed to go "un-penalized" to avoid limiting the step-size needlessly. This idea explains why SA and GA demonstrated relatively poor results in ImageNet, especially when the number of workers was relatively small. Though we consider this analysis beyond the scope of this work, it is relevant for this paper to note that we think that the tolerable gradient staleness noise depends on the size of the model and dataset, which suggests that GA can be further improved by correctly analysing the tolerable gradient staleness noise and starting the penalization accordingly. We plan to continue our research in this path as well.

D ASYNCHRONOUS SPEEDUP
Cloud computing is becoming increasingly popular as a platform to perform distributed training of deep neural networks. Although synchronous SGD is currently the primary method (Mikami et al., 2018;Ying et al., 2018;Yamazaki et al., 2019;Goyal et al., 2017) used to distribute the learning process, it suffers from substantial slowdowns when run in non-dedicated environments such as the cloud. This shortcoming is magnified in heterogeneous environments and non-dedicated networks. ASGD addresses the SSGD drawback and enjoys linear speedup in terms of the number of workers in both heterogeneous and homogeneous environments even in non-dedicated networks. This makes ASGD a potentially better alternative for cloud computing.
Figure 12(a) shows the theoretically achievable speedup, based on the detailed gamma-distributed model, for asynchronous (GA and other ASGD variants) and synchronous algorithms using homogeneous and heterogeneous workers. The asynchronous algorithms can achieve linear speedup while the synchronous algorithm (SSGD) falls short as we increase the number of workers. This occurs because SSGD must wait in each iteration until all workers complete their batch. Figure 12(b) shows that ASGD-based algorithms (including GA, SA and DANA versions) are up to 21% faster than SSGD in homogeneous environments. In heterogeneous environments, ASGD methods can be 6x faster than SSGD. We note that this speedup is an underestimate, since our simulation includes only batch execution times. It does not model the execution time of barriers, all-gather operations, and other overheads which usually increase communication time, especially in SSGD.

D.1 GAP-AWARE OVERHEAD
The Gap-Aware method requires the master to save the parameters of every worker and adds some simple calculations mentioned in Algorithm 4 and Algorithm 14. These calculations add no communication or computation requirements to the workers and introduce only a lightweight overhead to the parameter server compared to vanilla-ASGD. This lightweight overhead is similar to the overhead introduced by other ASGD-based methods such as ?. The space requirement is not critical since the master is usually implemented in a distributed manner, and the parameters are stored in the CPU-side memory, which is usually substantially larger than the total parameter size.

D.2 HETEROGENEOUS EXPERIMENTS
We tested the performance of GA in reference to other algorithms when the asynchronous workers are heterogeneous. The setting was very similar to the one mentioned in Section 6, except that it this scenario we used the gamma-distribution to model heterogeneous workers (see Appendix C.3). Figure 13 demonstrates that GA and DANA-GA are superior to the other tested algorithms in heterogeneous environments as well. When comparing between Figure 13 and Figure 2 it is noticeable that heterogeneous environments reach a higher accuracy. This is because in heterogeneous environments some workers are very fast compared to the other ones, thus their gradients are more accurate and arrive more frequently than the slow workers' gradients. Since in cloud computing, the workers can be either heterogeneous or homogeneous, we suggest using DANA-GA to maximize the results.