A T S TABILITY ’ S E DGE : H OW TO ADJUST HYPERPARAMETERS TO PRESERVE MINIMA SELECTION IN A SYNCHRONOUS T RAINING OF N EURAL N ETWORKS ?
A BSTRACT
Background: Recent developments have made it possible to accelerate neural networks training signiﬁcantly using large batch sizes and data parallelism.
Training in an asynchronous fashion, where delay occurs, can make training even more scalable.
However, asynchronous training has its pitfalls, mainly a degradation in generalization, even after convergence of the algorithm.
This gap remains not well understood, as theoretical analysis so far mainly focused on the convergence rate of asynchronous methods.
Contributions: We examine asynchronous training from the perspective of dynamical stability.
We ﬁnd that the degree of delay interacts with the learning rate, to change the set of minima accessible by an asynchronous stochastic gradient descent algorithm.
We derive closed-form rules on how the learning rate could be changed, while keeping the accessible set the same.
Speciﬁcally, for high delay values, we ﬁnd that the learning rate should be kept inversely proportional to the delay.
We then extend this analysis to include momentum.
We ﬁnd momentum should be either turned off, or modiﬁed to improve training stability.
We provide empirical experiments to validate our theoretical ﬁndings.
I NTRODUCTION
Training deep neural networks (DNNs) requires large amounts of computational resources, often using many devices operating over days and weeks.
Furthermore, with ever-increasing model size and available data, the amount of compute used was noted to increase exponentially over the past few years (Amodei & Hernandez, 2018).
Fortunately, the operations made in DNN training are highly suitable for parallelization over many devices.
Most commonly, the parallelization is done by "data-parallelism" in which the data is divided into separate batches which are distributed between different devices during training.
By using many devices, with each device highly utilized, one could train on a large number of samples without paying in run-time.
However, this training is done synchronously, with synchronization between the different devices done on every iteration (S-SGD).
With the growth in the number of devices participating in the training, the synchronization becomes a prominent bottleneck.
To overcome the synchronization bottleneck, asynchronous training (A-SGD) has been proposed (Dean et al., 2012; Recht et al., 2011).
The basic idea behind such training is that when a device ﬁnishes calculating its batch gradients, an update to the DNN parameters is immediately performed, without waiting for other devices.
This approach is known as asynchronous centralized training with a parameter server (PS) that updates the parameters (Li, 2014).
The main problem in such training is that, since the PS updates the parameters whenever a device communicates with him, the parameters that are being used in other devices calculation are no longer up-to-date.
This phenomena is called gradient staleness or delay as we will refer to it, and it causes a deterioration in generalization performance when using A-SGD.
The generalization deterioration can be seen in Fig.
Unless the learning rate is signiﬁcantly decreased, we can see a generalization gap : a deterioration in the generalization of A-SGD (with delay τ = 32 ) from the baseline (S-SGD, τ = 0 ) value near the steady state — i.e., after we are near full convergence, following many training epochs (2000).
Due to the generalization gap demonstrated in the ﬁgure, A-SGD with a parameter server and large delays is not commonly used — despite it is relatively simple to implement and despite its vast potential to accelerate training.
Therefore, our main goal in this work is to shed some theoretical light on the generalization gap problem and use it to improve A-SGD training.
[Figure]
Previous theoretical analysis of A-SGD (Liu et al., 2018;
Lian et al., 2016; 2015; Dai et al., 2018;
Dutta et al., 2018; Arjevani et al., 2018) focused on analyzing the convergence rate, i.e., the time it takes to reach steady state, and not on the properties of the obtained solution.
In contrast, in our paper we focus on understanding how the delay affects the selection of the solution we converge to, and changes in this selection can impact generalization.
We tackle these questions from the perspective of dynamical stability.
The dynamical stability approach was used in (Nar & Sastry, 2018; Wu et al., 2018), to study which minima are accessible under a speciﬁc choice of optimization algorithm and hyperparameters.
In (Nar & Sastry, 2018), the authors analyzed gradient descent (GD) algorithm as a discrete-time nonlinear dynamical system.
By analyzing the Lyapunov stability of this system for different minima, they showed a relation between the learning rate choice and the accessible minima set, i.e., the subset of the local optima that GD can converge to.
In (Wu et al., 2018), the authors focused on stochastic gradient descent (SGD), deﬁned a criterion to evaluate the stability of a speciﬁc minimum and used this criterion to show how the learning rate and batch-size play a role in SGD minima selection process.
Here, we use dynamical stability to analyze the dynamics of A-SGD.
Using this approach, the main question we try to tackle is:
How do learning rate, delay and momentum interact and affect the minima selection process?
Contributions
We start by modelling A-SGD as a dynamical system with delay.
By analyzing the stability properties of that system, we ﬁnd:
• There exist an inverse linear relation between the delay of A-SGD, and the threshold learning rate i.e., the critical learning rate in which a minimum loses stability.
• This implies that in order to keep a speciﬁc minimum stability as we change the delay, we need to change the learning rate inversely proportional to the delay.
• Momentum has a crucial role in determining stability properties for A-SGD.
Depending on the speciﬁc training algorithm, it can either hurt the stability or improve it.
We show how to modify momentum to stabilize A-SGD training.
With our theoretical ﬁndings, we derive closed form rules when training asynchronously.
We suggest to scale the learning rate inversely to the delay in order to reach a better generalization performance.
In section 3 we provide experiments on popular classiﬁcation tasks to support our theoretical analysis.
It is interesting to contrast this simple linear relation with the more complicated picture observed for the scaling of the learning rate with the batch size.
Speciﬁcally, it has been observed by Shallue et al.
(2018) that the optimal learning rate scales differently with the batch size when changing the models and datasets, i.e., there is no general "rule of thumb" that applies in all cases.
A similar scaling rule for the learning rate was proposed before (Zhang et al., 2015), however, there it lacked a theoretical basis or a demonstration of its effectiveness with large effective batch sizes, i.e., the sum of all the minibatch sizes of all the workers, as we do here.
T HEORETICAL A NALYSIS 2. P RELIMINARIES AND P ROBLEM S ETUP
Consider the problem of minimizing the empirical loss
[Equation]
where N is the number of samples, x ∈ R d and ∀ i
= 1 , ..., N : f i : R d → R is twice continuously differentiable function.
The update rule for minimizing f ( x ) in eq.
1 using asynchronous stochastic gradient descent (A-SGD) is given by
[Equation]
where η is the learning rate, n ( t ) is a random selection process of a sample from { 1 , 2 , . .
. , N } at iteration t , and τ is some delay due the asynchronous nature of our training.
For simplicity, we focus on a ﬁxed delay τ .
The extension to stochastic delay is discussed in section 2.2.1.
Our main goal is understanding how different factors such as the gradient staleness τ and the learning rate
η affect the minima selection process in neural networks.
In other words, we would like to understand how the different hyperparameters interact to divide the minima of the loss to two sets: those we can converge to and those we cannot converge to.
To analyze this we suppose we are in a vicinity of some minimum point x ∗ , which implies ∇ f ( x ∗ )
= 0 .
Given some values of η and τ , we ask whether or not we can converge to x ∗ , using the theory of dynamical stability.
As we shall see, if the learning rate η or delay τ are too high, then this minimum loses stability, i.e., A-SGD cannot converge to x ∗ , in expectation.
Speciﬁcally, we examine the expectation of the linearized dynamics around x ∗ .
We show in appendix
A that, to ensure stability, it is sufﬁcient that the following one-dimensional equation is stable:
[Equation]
where we deﬁned the Hessian H = 1 N N (cid:80) i
{+=1 ∇ 
+}
f i ( x ∗ ) , the sharpness term a = λ max ( H ) as the maximal eigenvalue of the Hessian, and x t is the projection of the expectation of the perturbation x t − x ∗ on the eigenvector which corresponds to the maximal eigenvalue a .
Additionally, we show in appendix A that the characteristic equation of eq.
3 is
[Equation]
2. S TABILITY A NALYSIS
For given ( η, τ ) , we would like to determine if the minimum point x ∗ is asymptotically stable (Oppenheim, 1999) in expectation.
This will enable us to divide the minima into two sets: those we might converge to since they are stable, and those we cannot possibly converge (except for a measure zero set of initialization) since they are unstable.
We use the characteristic equation (eq. 4) to deﬁne the stability criterion:
Deﬁnition 1 (Stability criterion)
For given ( η, τ ) , we say that the dynamics in eq.
3 are stable if all the roots of the corresponding characteristic equation (eq. 4) are inside the unit circle.
This condition is equivalent to x t → 0 for any initialization.
We would like to ﬁnd conditions on when and how can we change the hyperparameters ( η, τ ) to maintain the same stability criterion.
This, for example, will enable us to understand how to compensate for the delay introduced by asynchrony using the learning rate.
In order to analyze stability we examine the characteristic equation in eq.
4 and ask: when does the maximal root of this polynomial have unit magnitude?
2.2. T HE I NTERACTION B ETWEEN L EARNING R ATE AND D ELAY
Recall the characteristic equation
[Equation]
This polynomial has τ + 1 roots.
In order to ensure stability we require that the root with the maximal magnitude, i.e., the maximal root, will be inside the unit circle.
We want to ﬁnd the threshold learning rate, i.e., the learning rate in which the maximal root is exactly on the unit circle, so we are at the threshold of stability.
In appendix B, we show that this requires that
[Equation]
Using Taylor approximation we get
[Equation]
We observe numerically that the error between the exact solution (eq. 6) and the linear approximation (eq. 7) is smaller than 0 .
for τ ≥ 1 .
Additionally, in the appendix Fig.
6 we demonstrate the high accuracy of the analytic approximation of the relation between 1 aη and τ , compared to the numerical evaluation of the value of 1 aη for which the maximal root of eq.
5 is on the unit circle.
Implications: We can see that to maintain stability for a given minimum point (or a given sharpness value) the learning rate should be kept inversely proportional to the delay.
This implies that given some minimum x ∗ for τ = 0 and a corresponding learning rate η 0 for which this minimum is stable, we can evaluate the learning rate which will ensure this minimum remain stable for larger delay values.
To do this, we ﬁrst estimate a using eq. 6: aη 0 = 2 sin (cid:16) π 4 · 0+2 (cid:17)
= 2 ⇒ a = 2 η 0 .
Note that we do not use eq.
7 to evaluate a since we are interested in τ = 0 , while the relation in eq.
7 is only a good approximation for τ ≥ 1 .
Next, given some delay τ , we substitute a into eq.
7 in order to evaluate a learning rate value for which the stability of all minima is maintained as in τ =
[Equation]
Related empirical results : In section 3.1 we show empirically the existence of a stability threshold for different values of delay and compare it with our theoretical threshold.
Stochastic delay: In appendix C we extend our theoretical analysis to derive the characteristic equation for A-SGD with stochastic delay, i.e., when τ is drawn from some discrete distribution.
We analyze two cases:
• Discrete uniform distribution: τ ∼ unif { a, b } .
• Gaussian distribution discrete approximation: ∀ µ, ∀ k
=
1 , ..., 2 µ : Pr( τ = k ) =
Pr( k − 0 .
5 ≤ z ≤ k + 0 . 5) where z ∼ N ( µ, 1) .
In Zhang et al.
, the authors showed empirically a delay distribution that resembles to Gaussian distribution.
For both cases, we show numerically that the inverse relation between the learning rate η and the expected delay E τ still applies.
2.2. T HE EFFECTS OF MOMENTUM ON STABILITY
The optimization step of A-SGD with momentum is deﬁned as follows:
[Equation]
where x t are the weights, v t and ∇ f n ( t ) ( x t ) are the velocity and gradients at time t , respectively, m is the momentum parameter, η is the step size and τ is the delay.
The constant (1 − m ) term which multiplies the gradients is called "dampening".
In appendix D we extend our theoretical analysis to derive the characteristic equation for A-SGD with momentum .
In addition, in section D.2.1 we show numerically that an inverse relation between the learning rate η and the delay τ also applies when using momentum.
Particularly,
We need to keep the learning rate inversely proportional to the delay.
For a given delay, larger momentum values require smaller learning rate for stability.
Therefore, the range of stable learning rates decreases when the momentum parameter (’ m ’) increases which can make tuning the learning rate difﬁcult, especially with large delays.
These results suggest that, to ensure stability when training with large delay, it is recommended to work without momentum.
Relation to previous results: The conclusion that when using A-SGD with high delay values it’s recommended to turn off momentum is consistent with the results of Mitliagkas et al.
; Liu et al.
In Liu et al.
(2018), for streaming PCA, the authors showed it is necessary to reduce momentum in order to ensure convergence and acceleration through asynchrony.
In Mitliagkas et al.
(2017) the authors suggested that asynchrony adds implicit momentum to the training process and therefore it is necessary to reduce momentum when working asynchronously.
Next, we discuss a new method for introducing momentum into asynchronous training.
This method enables asynchronous training where increasing the momentum parameter improves the stability.
Shifted momentum As discussed, training asynchronously is less stable when momentum is used.
We propose to utilize momentum in an alternative method, called shifted momentum, for training asynchronously where the momentum beneﬁts the training process and particularly its stability.
We observe this method tends to improve the convergence stability compared to training without momentum (or with the original momentum), as is demonstrated in appendix Fig.
We suggest that instead of exchanging the gradients terms, as in eq.
9, we exchange the entire velocity term.
This way, each worker calculates the velocity term based in its own gradients and momentum buffer.
The formulation of this method is given in the following equation:
[Equation]
In appendix D we show that the characteristic equation of eq.
10 is
[Equation]
where we use the sharpness term a = λ max ( H ) as before.
We would like to characterize how the learning rate, delay and momentum affect minima stability.
Thus, for each momentum value, we evaluate numerically the value of 1 aτ for which the maximal root of eq.
11 is on the unit circle, i.e., when we are on the threshold of stability.
In Fig.
4 we see that the inverse relation between the learning rate η and the delay τ still applies when using shifted momentum.
Moreover, we can see that in contrast to regular momentum, in shifted momentum, a larger momentum value m enables us to work with larger step-size.
Therefore, increasing the momentum improves the stability.
Relation to previous results: The analysis of delayed gradients and velocity might also shed light on the stability of recent asynchronous training approaches, where the workers communicating through weight averaging (Lian et al., 2017; Assran et al., 2019).
This method is similar to ours in the sense that each worker holds its own momentum buffer.
In parallel to us, (Hakimi et al., 2019) used a variation of shifted momentum with Nesterov momentum (denoted as Multi-ASGD), and demonstrated empirically its generalization beneﬁts, but without a theoretical analysis of this beneﬁt.
[Figure]
E XPERIMENTS
In this section, we provide experiments to support our theoretical ﬁndings.
In the following subsections we: (1) demonstrate the relationship between hyperparameters and minima selection, and (2) show our ﬁndings can help improve asynchronous training.
Details about the experiments and the implementation can be found in appendix E.
3. H OW H YPERPARAMETERS A FFECT M INIMA S ELECTION
In this section, we demonstrate how the delay and learning rate affect the accessible minima set.
We train with a ﬁxed learning rate.
Minima stability.
To demonstrate how delay and learning rate change the stability of a minimum, we start from a model that converged to some minimum and train with different values of delay and learning rate to see if the algorithm leaves that minimum, i.e., the minimum becomes unstable.
We do so by training a VGG-11 on CIFAR10 for 10,000 epochs – until we reach a steady state.
This training is done without delay, momentum and weight decay.
Next, introduce a delay τ , change the learning rate, and continue to train the model.
Fig.
2 shows the number of epochs it takes to leave the steady state for a given delay τ and learning rate η .
We observe that for certain ( τ, η ) pairs, the algorithm stays in the minimum (below the black circle) while for others it leaves that minimum after some number of epochs (above the black circle).
Importantly, we can see in the right panel in Fig.that, as predicted by the theory, the inverse learning rate, 1 /η , where η is the maximal learning rate in which we did not diverge, scales linearly with the delay τ .
Additional details are given in appendix F.
Generalization with delay.
With delay, we need to adjust the hyperparameters in order to maintain the accessible minima set.
However, even if a certain pair of ( τ , η ) changes the accessible set, it is possible that there are still accessible minima that generalize well.
We perform experiments to investigate what type of generalization we can expect from training with different ( τ , η ) pairs.
We examine this by training a VGG-11 on CIFAR10 with different ( τ , η ) pairs until we reach a steady state (around 6,000 epochs).
We use plain SGD without momentum or weight decay.
We compare the generalization performance achieved by each pair of learning rate and delay.
We repeat the experiment for each pair four times and report mean and standard deviation values.
The results are presented in Fig.
We can see a linear scaling between the delay values and the learning rate empirical stability threshold, i.e., the learning rate in which the error diverge.
In addition, we see that the smallest error (with small variance) is obtained at a learning rate which is somewhat smaller then the learning rate at the empirical threshold of stability, as expected (LeCun et al., 2012). [Figure]
Shifted momentum stability.
In subsection 2.2.2 we introduced shifted momentum as a modiﬁcation of the standard momentum update, in which increasing the momentum value (’ m ’) improves stability.
We validate the stability properties of this method by training a fully connected model with MNIST.
The model has 3 layers, 1024 neurons in each layer with ReLU activations.
Again, training is done synchronously with a large batch and no weight decay until it reaches a steady state.
Then, after reaching a minimum, we continued to train the model, each time with a different triplet of ( τ, η, m ) .
We found the maximum learning rate for a given m and τ for which training does not diverge, i.e, this maximum learning rate is at the edge of stability.
Fig.
4 depicts the empirical results.
The value of a = λ max ( H ) is estimated at the minimum point using power iteration.
Two important results emerge from the graph.
First, in order to maintain the stability threshold, the learning rate has to be inversely proportional to the delay, as described in subsection 2.2.
Second, with increased momentum values, training becomes more stable.
Meaning, we can use larger learning rates with larger momentum value.
This stands in contrast to the analysis of the original momentum: as we show numerically in appendix D, increasing the momentum value m in the standard momentum algorithm decreases the stability and hence we need to decrease the learning rate as the momentum value grows larger.
3. I MPROVING A SYNCHRONOUS T RAINING
So far we focused on the steady state behavior of A-SGD, i.e. after many iterations.
However, one of the prominent motivations for training asynchronously is to speed-up training.
In this subsection, we examine whether our ﬁndings are also relevant for improving the accuracy of models trained asynchronously with little to no excess budget of epochs, compared to equivalent large batch regime.
In large batch training, the learning rate is scaled as a function of the ratio between the large batch size and the small one.
As Shallue et al.
(2018) pointed out, we can expect a different learning rate scaling for different models/datasets.
We start with a set of models and datasets that follow a square root scaling of the learning rate with the batch size (Hoffer et al., 2017).
Recall that our inversely linear scaling rule (i.e., η ∝ 1 /τ ) applies to the large batch learning rate.
We demonstrate the validity of our inversely linear learning rate scaling by comparing our method with one that does not account for the delay τ .
The results are presented in Table 1.
We can see that using the small batch regime with delay (ASGD) does not converge at all.
With our inversely linear learning rate scaling (+LR), there is a small gap from the equivalent large batch.
If we also increase the budget of epochs by 30%, our optimization regime (+30%) generalizes better than the large batch (LB).
Because A-SGD has better run-time performance compared to S-SGD (Dutta et al., 2018; Assran et al., 2019), such excess in epochs may still result in improved overall wall clock time (this depends on the hardware details). [Figure] m - 0 m - 0. m - 0.
[Figure]
m
[Figure]
[Table]
ImageNet.
We next experiment with ResNet50 and ImageNet, which is a popular benchmark for large batch and asynchronous training because of its complexity and scale.
Our focus is asynchronous centralized training with high delay.
To the best of our knowledge, the generalization gap is not closed yet in this setting.
This is an important setting because of its simplicity and its scalability potential.
Optimization details can be found in appendix E.
In Fig.
5, we compare three A-SGD optimizations trained with ImageNet.
As can be seen in the ﬁgure, the generalization gap decreases from 4 .
33% to 1 .
69% , just by turning off momentum.
This corresponds with our analysis and previous results about the relation between momentum and delay.
Shifted momentum similarly improves generalization, as can be seen in the right panel.
This validates our analysis on the beneﬁcial role the momentum parameter has, using shifted momentum.
The learning rate is ﬁrst scaled linearly with the total batch size of all the workers, as in Goyal et al.
Our inverse linear scaling with delay cancels this increase, and we get a similar learning rate as in regular small batch training.
In contrast, when we scaled the learning rate with 1 / √ τ , training did not converge at all.
D ISCUSSION
Motivation.
A fundamental problem with asynchronous training is that it seems to cause a degradation in generalization, even after training has converged to a steady state.
Identifying the root of this problem and resolving it is essential in order to scale parallelism.
When approaching this problem, we need to address two issues.
First, what is the origin of this generalization gap?
Second, how can we decrease this generalization gap?
Conclusions.
Our work tackles both questions by studying the behaviour of A-SGD and the relation between the delay and the hyperparameters, e.g., the learning rate and momentum.
We analyze
A-SGD from the theoretical perspective of dynamical stability.
We ﬁnd that a linear connection between the inverse learning rate and delay is necessary in order to keep the set of accessible minima [Figure] the same.
In addition, we ﬁnd how momentum affects the accessible minima set.
Our analysis suggests that, when increasing delay, momentum degrades stability.
Therefore, it should be turned off in order to maintain performance, as was previously observed empirically (Mitliagkas et al., 2017;
Dai et al., 2018; Liu et al., 2018).
However, we observe that momentum can have some beneﬁts in improving convergence stability without delay.
To maintain these beneﬁts, we propose to modify momentum into a method called shifted momentum.
We supply a theoretical analysis of A-SGD with shifted momentum and conclude that, in contrast to regular momentum, this method improves stability when delay is increased.
In addition, we supply empirical evidence to support these ﬁndings.
Lastly, we demonstrate, these ﬁndings can improve the generalization performance of distributed training algorithms and bring us one step closer to closing the generalization gap.
Future Directions.
It is interesting to examine how the dynamical stability analysis holds during training.
Speciﬁcally, what implications can we derive from the analysis, before we reach the steady state (e.g., a minimum of the loss), given a tight epochs budget.
Our empirical ﬁndings in this case (Fig. 13 ) suggest that the optimal learning rate chosen for the steady state may remain optimal during the convergence process.
This might be because the hyperparameters at the stability threshold are closely related to the hyperparameters that achieve the optimal convergence speed to that minimum.
For example, in GD it easy to show that η threshold = 2 η optimal .
Therefore, both stability and convergence rate may be optimally maintained using similar scaling relations in the hyperparameters.
This is an interesting question for future study.
Another interesting question for future study is to understand how the stability conditions change when some synchronization is introduced.
Several practical A-SGD methods use synchronization to some extent, e.g. (Assran et al., 2019; Chen et al., 2016).
For synchronization methods that reduce the delay in expectation, we can intuitively expect an improvement in dynamical stability, from our analysis of stochastic delay (appendix C).
However, further analysis of the stability method for each method is required for an exact answer.
Answering these questions may lead to a more precise understanding of the trade-offs between S-SGD and the various A-SGD methods.
Appendix A S TABILITY A NALYSIS FOR EQ .
In this section, we would like to analyze the stability of eq. 2.
In particular, we would like to examine if a given minimum point x ∗ is stable.
To analyze this we suppose we are in a vicinity of some minimum point x ∗ , which implies ∇ f ( x ∗ )
= 0 , and ask whether or not we can converge to x ∗ using the theory of dynamical stability.
Formally, consider the linearized dynamics around x ∗ :
[Equation]
where we denoted G ( x t ; n t ) =
∇ f n t ( x t ) and changed the notation of the time index in n ( t ) to the subscript, i.e., n t .
Examining the expectation of this equation we obtain
[Equation]
where in (1) we used ∀ k = 1 , ..., N : Pr( n t
= k ) = 1 N , and in (2) we used the fact that x ∗ is a minimum point and thus N (cid:80)
[Equation]
and denoted
[Equation]
Using s t =
E x t − x ∗ variable change we obtain
[Equation]
From the Spectral Factorization Theorem we can write H
= UAU (cid:62) where U is an orthogonal matrix and A = diag( a 1 , ..., a n ) is a diagonal matrix.
Substituting this into eq.
12 we obtain:
[Equation]
Multiplying the last equation with U (cid:62) from the left, denoting ˜ s t
= U (cid:62) s t , and using the fact that U is an orthogonal matrix, i.e., U (cid:62) U
=
I we get:
[Equation]
Recall that A = diag( a 1 , ..., a N ) is a diagonal matrix.
Therefore, analyzing the dynamics of the last equation is equivalent to analyzing the dynamics of the following N one-dimensional equations:
[Equation]
where s t ( i ) denotes the i th component of the vector s t .
In order to ensure stability of the N -dimensional dynamical system, it’s sufﬁcient to require that
[Equation]
where we assume without loss of generality a 1 ≥ a 2 ≥ · · · ≥ a N .
This is true since the dynamics for i = 1 is the ﬁrst one that loses stability.
To simplify notations we deﬁne x t = ˜ s t (1) and the sharpness term a = a 1 = λ max ( H ) , the maximal singular value of H .
Using these notations, we can re-write eq.
13 as:
[Equation]
Since this is a linear time invariant difference equation, of order τ + 1 , its solution is, generically:
[Equation]
where c i are determined by the initial conditions, and z i are the roots of the characteristic equation of eq.
To ﬁnd this characteristic equation, we substitute x t = z t into eq.
14, and obtain
[Equation]
| B F INDING THE CONDITION FOR THE MAXIMAL ROOT OF THE CHARACTERISTIC EQUATION ( EQ . 4) TO BE ON THE UNIT CIRCLE
To simplify the notation, we denote α = aη .
Recall the characteristic eq.
(eq. 5)
[Equation]
+1 −
[Equation]
τ + α = 0 .
Since we are looking for solution on the unit circle we substitute z = e iθ into the equation where i is the unit imaginary number and θ is some angle.
We obtain: e iθ ( τ +1)
− e iθτ + α = 0 .
Using e iθ = cos( θ ) + i sin( θ ) we get cos [Equation] θ
[Equation] τ + 1)) + i sin ( θ ( τ + 1)) − (cos ( θτ )
+ i sin ( θτ ))
+ α =
⇒ (cid:26) cos [Equation] θ ( τ + 1)) −
[Equation]
+
[Equation]
=
[Equation]
=
Using trigonometric product-sum identities we obtain
[Equation]
If sin (cid:0) θ 2 (cid:1) =
then we get from the ﬁrst equation α = 0 .
This is a contradiction since we assume that α > 0 .
Thus, sin (cid:0) θ 2 (cid:1) (cid:54) = 0 .
This implies from the second equation in eq.
that cos
[Equation]
Substituting this result into the ﬁrst equation in eq.
and using α > 0 we obtain that the possible solutions must satisfy
[Equation]
(cid:18) (1 + 4 k ) π 4 τ +(cid:19) , for k = 0 , 1 , ..., τ .
Also, since sin( x ) = sin( π − x ) we can eliminate symmetric solution and get [Equation] (cid:18) [Equation]
+
[Equation]
k [Equation] 4 τ +(cid:19) , for k = 0 , 1 , ..., (cid:98) τ + 1(cid:99) .
Note that for k = 0 , 1 , ..., (cid:98)
τ +12 (cid:99) :
0 < (1+4 k )
π 4 τ +2 <
π 2 and thus sin (cid:16) (1+4 k )
π 4 τ +2 (cid:17) > 0 is monotonically increasing with k .
Since the magnitude of the characteristic equation increases with α and we are interested in the maximal root we are looking for the minimal α value.
This value corresponds to k = 0 .
Thus, the maximal root satisﬁes:
[Equation]
C S TABILITY A NALYSIS FOR EQ . 2 WITH STOCHASTIC DELAY
We assume that τ ( t ) is drawn from some distribution.
In this section, we would like to analyze the stability of eq. 2.
In particular, we would like to examine if a given minimum point x ∗ is stable.
To analyze this we suppose we are in a vicinity of some minimum point x ∗ , which implies ∇ f ( x ∗ )
= 0 , and ask whether or not we can converge to x ∗ using the theory of dynamical stability.
Formally, consider the linearized dynamics around x ∗ :
[Equation]
where we denoted G ( x t ; n t ) =
∇ f n t ( x t ) and changed the notation of the time index in n ( t )
Examining the expectation of this equation we obtain
[Equation]
where in (1) we used ∀ t and ∀ k
= 1 , ..., N : Pr( n t
= k ) = 1 N , and in (2) we used the fact that x ∗ is a minimum point and thus N (cid:80)
i
[Equation]
and denoted H = 1 N N
[Equation]
[Equation]
Using s t =
E x t − x ∗ variable change we obtain
[Equation]
From the Spectral Factorization Theorem we can write H
= UAU (cid:62) where U is an orthogonal matrix and A = diag( a 1 , ..., a n ) is a diagonal matrix.
Substituting this into eq.
16 we obtain:
[Equation]
Multiplying the last equation with U (cid:62) from the left, denoting ˜ s t
= U (cid:62) s t , and using the fact that U is an orthogonal matrix, i.e., U (cid:62) U
=
I we get:
[Equation]
Recall that A = diag( a 1 , ..., a N ) is a diagonal matrix.
Therefore, analyzing the dynamics of the last equation is equivalent to analyzing the dynamics of the following N one-dimensional equations:
[Equation]
where s t ( i ) denotes the i th component of the vector s t .
In order to ensure stability of the N -dimensional dynamical system, it’s sufﬁcient to require that
[Equation]
where we assume without loss of generality a 1 ≥ a 2 ≥ · · · ≥ a N .
This is true since the dynamics for i = 1 is the ﬁrst one that loses stability.
To simplify notations we deﬁne x t = ˜ s t (1) and the sharpness term a = a 1 = λ max ( H ) , the maximal singular value of H .
Using these notations, we can re-write eq.
13 as:
[Equation]
The characteristic equation of eq.
18 is
[Equation]
C. S TABILIY A NALYSIS
We would like to ﬁnd conditions on when and how can we change the hyperparameters ( η, E τ ) to maintain the same stability criterion (deﬁnition 1).
In order to analyze stability we examine the characteristic equation in eq.
18 and ask: when does the maximal root of this polynomial have unit magnitude?
[Equation]
[Figure]
obtained by numerically evaluating the value of 1 aη for which the maximal root of eq.
20 is on the unit circle.
We can see that in order to maintain stability for a given minimum point, as the delay expectation E τ increases we need to decrease the learning rate η to keep η inversely proportional to τ .
Gaussian distribution discrete approximation: ∀ µ, ∀ k
= 1 , ..., 2 µ : Pr( τ = k ) =
Pr( k − 0 .
5 ≤ z ≤ k + 0 . 5) where z ∼ N ( µ, 1) :
[Figure] [Figure]
D T HEORETICAL A NALYSIS WITH M OMENTUM
In this section, we repeat the steps of the analysis in section 2 for A-SGD with momentum .
D. P RELIMINARIES AND P ROBLEM S ETUP
Consider the problem of minimizing the empirical loss
[Equation]
where N is the number of samples, x ∈ R d and ∀ i
= 1 , ..., N : f i : R d → R is twice continuously differentiable function.
The update rule for minimizing f ( x ) in eq.
21 using asynchronous stochastic gradient descent with momentum (A-MSGD) is given by
[Equation]
where m is the momentum, η is the learning rate, G ( x t ; n t ) =
∇ f n t ( x t ) , n t is a random selection process of a sample from { 1 , 2 , . . .
, N } at iteration t , and τ is some delay due the asynchronous nature of our training.
Our main goal is understanding how different factors such as the gradient staleness τ , and hyperparameters such as the momentum m and learning rate
η affect the minima selection process in neural networks.
In other words, we would like to understand how the different hyperparameters interact to divide the global minima of our network to two sets: those we can converge to and those we cannot converge to.
To analyze this we suppose we are in a vicinity of a minimum point x ∗ , which implies ∇ f ( x ∗ )
= 0 , and ask whether or not we can converge to x ∗ using the theory of dynamical stability.
Formally, consider the linearized dynamics around some minimum point x ∗ :
[Equation]
t
[Equation]
t
[Equation]
Examining the ﬁrst moment of this equation we obtain
E
[Equation]
where 1 N N (cid:80) i = [Equation] ( x
[Equation]
; i
[Equation]
= 1 N ∇ f ( x ∗ )
= 0 since x ∗ is a minimum point and H = 1 N N (cid:80)
i =1 ∇ G ( x ∗ ; i ) =
1 N N (cid:80) i =1 ∇
f i ( x ∗ ) .
Using s t =
E x t − x ∗ variable change we obtain
[Equation]
From the Spectral Factorization Theorem we can write H = UDU (cid:62) where U is an orthogonal matrix and A = diag( a 1 , ..., a n ) is a diagonal matrix.
Substituting this into eq.
23 we obtain:
[Equation]
τ [Equation] Multiplying the last equation with U (cid:62) from the left, denoting ˜ s t
= U (cid:62) s t , and using the fact that U is an orthogonal matrix, i.e., U (cid:62) U
=
I we get:
[Equation]
Recall that A = diag( a 1 , ..., a N ) is a diagonal matrix.
Therefore, analyzing the dynamics of the last equation is equivalent to analyzing the dynamics of the following N one-dimensional equations:
[Equation]
where s t ( i ) denotes the i th component of the vector s t .
In order to ensure stability of the N -dimensional dynamical system, it’s sufﬁcient to require that
[Equation]
where we assume without loss of generality a 1 ≥ a 2 ≥ · · · ≥ a N .
This is true since the dynamics for a 1 is the ﬁrst one that loses stability.
To simplify notations we deﬁne x t = ˜ s t (1) and the sharpness term a = a 1 = λ max ( H ) , the maximal singular value of H .
Using these notations, we can re-write eq.
24 as:
[Equation]
[Equation]
The characteristic equation of this difference equation is
[Equation]
S TABILITY A NALYSIS
We would like to ﬁnd conditions on when and how can we change the hyperparameters ( m, η, τ ) to maintain the same stability criterion (deﬁnition 1).
In order to analyze stability we examine the characteristic equation in eq.
26 and ask: when does the maximal root of this polynomial have unit magnitude?
D.2. T HE I NTERACTION B ETWEEN L EARNING R ATE , D ELAY , AND M OMENTUM
For the general case and different values of momentum, we evaluate numerically the value of 1 aτ for which the maximal root of the general characteristic equation (eq. 26) is on the unit circle, i.e., when we are on the threshold of stability.
We show the results in Fig.
We observe that there is still an inverse relation between the learning rate and delay when using momentum.
Speciﬁcally, we observe that:
We need to decrease the learning rate as the delay increases.
The lines becomes more steep for larger values of momentum.
This implies that, for a given delay, maintaining stability for larger values of momentum requires smaller learning rate.
Therefore, it is easier to maintain stability with m = 0 .
D. S HIFTED MOMENTUM
In this section, we repeat the steps of the analysis in section D.1 for A-SGD with shifted momentum.
The update rule for minimizing f ( x ) in eq.
21 using asynchronous stochastic gradient descent with shifted momentum is given by
[Equation]
Following the same steps as in section
D.1 we obtain the following one-dimensional equation:
[Equation]
The last equation characteristic equation is:
[Equation]
m ) z + m = 0 .
[Figure] [Figure]
E E XPERIMENTS DETAILS
We experimented with a set of popular classiﬁcation tasks:
MNIST (Lecun et al., 1998), CIFAR10,
CIFAR100 (Krizhevsky, 2009) and ImageNet (Deng et al., 2009).
In order to incorporate delay in the experiments, we keep replicas of the model parameters and perform SGD step with different replica at a time according to a round robin scheduling.
The implementation is done with PyTorch framework.
Section C in the appendix shows that constant delay, i.e., round robin, acts similarly in terms of stability to several other delay distributions.
In addition, Zhang et al.
(2015) shows empirically with realistic distribution that constant delay distribution is a good model for delay distribution.
Fig.shows empirically that round robin scheduling works in a similar way to discrete Gaussian distribtion.
Although stochastic gradient descent with momentum was originally introduced with the dampening term, many drop the latter when using momentum SGD.
This is true for most DNN frameworks like
Caffe, PyTorch, and TensorFlow where the dampening term is set to zero by default.
As Shallue et al.
(2018); Yan et al.
(2018) pointed out, without dampening, the momentum scales the learning rate so that the effective learning rate η eff is equal to η eff =
η 1 − m after sufﬁciently many iterations T (i.e., when T → ∞ ).
Because we alter the momentum value in our experiments, we use dampening and scale the learning rate accordingly to keep the effective learning rate the same as without dampening.
E. I MAGE N ET O PTIMIZATION D ETAILS
Our baseline is Goyal et al.
(2017) large batch training.
They trained ResNet50 for 90 epochs with a large batch of 8192 samples and reached the same accuracy level of 23.8% as the small batch training.
They used linear scaling with the batch size (scaling the learning rate by the large batch size divided by the baseline batch size) and a warm-up of the learning rate at the ﬁrst 5 epochs.
We use 32 workers, each with a minibatch size of 256.
F M INIMA S TABILITY E XPERIMENTS
In this section, we provide additional details about the minima stability experiment presented in section 3.
As discussed in section 3, we are interested to examine for which pairs of ( τ, η ) the minima stability remains the same.
In Fig.
12 we show the validation error of such ( τ, η ) pairs as a function of epochs.
We note that these graphs are the same experiment as in Fig.
As can be seen, for larger learning rates, it takes less epochs to leave the minimum.
It is interesting to see that after leaving the minimum, the A-SGD algorithm converges again to a minimum with generalization as good as the baseline (at τ = 0 ).
This suggests that the minima selection process of A-SGD is affected by the whole optimization path.
In other words, suppose we start the optimization from a minimum with good generalization (since it was selected using optimization with τ = 0 ), and then it becomes unstable due to a change in the values of ( η, τ ) , as in this experiment.
These results in Fig.
12 suggest we typically converge to a stable minimum with similar generalization properties, possibly nearby the original minimum.
In contrast, if we start to train from scratch using the same ( η, τ ) pair which lost stability in our experiment, we typically get a generalization gap (as observed in our experiments), which suggests the optimization path might have taken a very different path from the start, leading to other regions with worse generalization than the original minimum.
G A DDITIONAL E XPERIMENTS
We examine what generalization performance we can expect during training, before reaching a minimum.
We do so by using the same experiment in Fig.
We sample the validation error of each learning rate at different epochs.
Results are presented in Fig. 13.
Using our suggested learning rate modiﬁcation (dividing the baseline large batch learning rate by the delay) gives the near optimal learning rate that can be seen in the ﬁgure.
[Figure] [Figure]
of learning rate at different epochs.
The optimal learning rate of η = 0 .
01 chosen found in the scan (which matches our proposed learning rate scaling), stays the same throughout the training.
This might suggest why it’s beneﬁcial to use the optimal hyperparameters for the minimum, even when the algorithm hasn’t converged to the steady state yet.
CNN trained with MNIST, same settings as in Fig 1.