NUQSGD:
P ROVABLY
C OMMUNICATION - EFFICIENT
D ATA - PARALLEL SGD VIA N ONUNIFORM Q UANTIZATION A BSTRACT
As the size and complexity of models and datasets grow, so does the need for communication-efﬁcient variants of stochastic gradient descent that can be deployed on clusters to perform parallel model training.
Alistarh et al.
(2017) describe two variants of data-parallel SGD that quantize and encode gradients to lessen communication costs.
For the ﬁrst variant, QSGD, they provide strong theoretical guarantees.
For the second variant, which we call QSGDinf, they demonstrate impressive empirical gains for distributed training of large neural networks.
Building on their work, we propose an alternative scheme for quantizing gradients and show that it yields stronger theoretical guarantees than exist for QSGD while matching the empirical performance of QSGDinf.
I NTRODUCTION
Deep learning is booming thanks to enormous datasets and very large models, leading to the fact that the largest datasets and models can no longer be trained on a single machine.
One common solution to this problem is to use distributed systems for training.
The most common algorithms underlying deep learning are stochastic gradient descent (SGD) and its variants, which led to a signiﬁcant amount of research on building and understanding distributed versions of SGD.
Implementations of SGD on distributed systems and data-parallel versions of SGD are scalable and take advantage of multi-GPU systems.
Data-parallel SGD, in particular, has received signiﬁcant attention due to its excellent scalability properties (Zinkevich et al., 2010; Bekkerman et al., 2011;
Recht et al., 2011; Dean et al., 2012; Coates et al., 2013; Chilimbi et al., 2014;
Li et al., 2014; Duchi et al., 2015; Xing et al., 2015; Zhang et al., 2015; Alistarh et al., 2017).
In data-parallel SGD, a large dataset is partitioned among K processors.
These processors work together to minimize an objective function.
Each processor has access to the current parameter vector of the model.
At each SGD iteration, each processor computes an updated stochastic gradient using its own local data.
It then shares the gradient update with its peers.
The processors collect and aggregate stochastic gradients to compute the updated parameter vector.
Increasing the number of processing machines reduces the computational costs signiﬁcantly.
However, the communication costs to share and synchronize huge gradient vectors and parameters increases dramatically as the size of the distributed systems grows.
Communication costs may thwart the anticipated beneﬁts of reducing computational costs.
Indeed, in practical scenarios, the communication time required to share stochastic gradients and parameters is the main performance bottleneck (Recht et al., 2011; Li et al., 2014; Seide et al., 2014; Strom, 2015;
Alistarh et al., 2017).
Reducing communication costs in data-parallel SGD is an important problem.
One promising solution to the problem of reducing communication costs of data-parallel SGD is gradient compression, e.g., through gradient quantization (Dean et al., 2012; Seide et al., 2014;
Sa et al., 2015; Gupta et al., 2015; Abadi et al., 2016;
Zhou et al., 2016;
Alistarh et al., 2017; Wen et al., 2017; Bernstein et al., 2018).
(This should not be confused with weight quantization/sparsiﬁcation, as studied by Wen et al.
; Hubara et al.
; Park et al.
Wen et al.
(2017), which we do not discuss here.)
Unlike full-precision data-parallel SGD, where each processor is required to broadcast its local gradient in full-precision, i.e., transmit and receive huge full-precision vectors at each iteration, quantization requires each processor to transmit only a few communication bits per iteration for each component of the stochastic gradient.
One popular such proposal for communication-compression is quantized SGD (QSGD), due to
Alistarh et al.
In QSGD, stochastic gradient vectors are normalized to have unit L 2 norm, and then compressed by quantizing each element to a uniform grid of quantization levels using a randomized method.
While most lossy compression schemes do not provide convergence guarantees,
QSGD’s quantization scheme, is designed to be unbiased, which implies that the quantized stochastic gradient is itself a stochastic gradient, only with higher variance determined by the dimension and number of quantization levels.
As a result, Alistarh et al.
(2017) are able to establish a number of theoretical guarantees for QSGD, including that it converges under standard assumptions.
By changing the number of quantization levels, QSGD allows the user to trade-off communication bandwidth and convergence time.
Despite their theoretical guarantees based on quantizing after L 2 normalization, Alistarh et al.
opt to present empirical results using L ∞ normalization.
We call this variation QSGDinf.
While the empirical performance of QSGDinf is strong, their theoretical guarantees on the number of bits transmitted no longer apply.
Indeed, in our own empirical evaluation of QSGD, we ﬁnd the variance induced by quantization is substantial, and the performance is far from that of SGD and QSGDinf.
Given the popularity of this scheme, it is natural to ask one can obtain guarantees as strong as those of QSGD while matching the practical performance of the QSGDinf heuristic.
In this work, we answer this question in the afﬁrmative by providing a new quantization scheme which ﬁts into
QSGD in a way that allows us to establish stronger theoretical guarantees on the variance, bandwidth, and cost to achieve a prescribed gap.
Instead of QSGD’s uniform quantization scheme, we use an unbiased nonuniform logarithmic scheme, similar to those introduced in telephony systems for audio compression (Cattermole, 1969).
We call the resulting algorithm nonuniformly quantized stochastic gradient descent (NUQSGD).
Like QSGD, NUQSGD is a quantized data-parallel SGD algorithm with strong theoretical guarantees that allows the user to trade off communication costs with convergence speed.
Unlike QSGD, NUQSGD has strong empirical performance on deep models and large datasets, matching that of QSGDinf.
In particular, we provide a new efﬁcient implementation for these schemes using a modern computational framework (Pytorch), and benchmark it on classic large-scale image classiﬁcation tasks.
The intuition behind the nonuniform quantization scheme underlying NUQSGD is that, after L 2 normalization, many elements of the normalized stochastic gradient will be near-zero.
By concentrating quantization levels near zero, we are able to establish stronger bounds on the excess variance.
In the overparametrized regime of interest, these bounds decrease rapidly as the number of quantization levels increases.
Combined with a bound on the expected code-length, we obtain a bound on the total communication costs of achieving an expected suboptimality gap.
The resulting bound is slightly stronger than the one provided by QSGD.
To study how quantization affects convergence on state-of-the-art deep models, we compare
NUQSGD, QSGD, and QSGDinf, focusing on training loss, variance, and test accuracy on standard deep models and large datasets.
Using the same number of bits per iteration, experimental results show that NUQSGD has smaller variance than QSGD, as expected by our theoretical results.
This smaller variance also translates to improved optimization performance, in terms of both training loss and test accuracy.
We also observe that NUQSGD matches the performance of QSGDinf in terms of variance and loss/accuracy.
Further, our distributed implementation shows that the resulting algorithm considerably reduces communication cost of distributed training, without adversely impacting accuracy.
Our empirical results show that NUQSGD can provide faster end-to-end parallel training relative to data-parallel SGD, QSGD, and Error-Feedback SignSGD
(Karimireddy et al., 2019) on the ImageNet dataset.
Summary of Contributions.
• We establish stronger theoretical guarantees for the excess variance and communication costs of our gradient quantization method than those available for QSGD’s uniform quantization method.
• We then establish stronger convergence guarantees for the resulting algorithm, NUQSGD, under standard assumptions.
• We demonstrate that NUQSGD has strong empirical performance on deep models and
large datasets, both in terms of accuracy and scalability.
Thus, NUQSGD closes the gap between the theoretical guarantees of QSGD and the empirical performance of QSGDinf.
1. R ELATED W ORK
Seide et al.
(2014) proposed signSGD, an efﬁcient heuristic scheme to reduce communication costs drastically by quantizing each gradient component to two values.
Bernstein et al.
(2018) later provided convergence guarantees for signSGD.
Note that the quantization employed by signSGD is not unbiased, and so a new analysis was required.
As the number of levels is ﬁxed, SignSGD does not provide any trade-off between communication costs and convergence speed.
Sa et al.
(2015) introduced Buckwild!, a lossy compressed SGD with convergence guarantees.
The authors provided bounds on the error probability of SGD, assuming convexity and gradient sparsity.
Wen et al.
(2017) proposed TernGrad, a stochastic quantization scheme with three levels.
TernGrad also signiﬁcantly reduces communication costs and obtains reasonable accuracy with a small degradation to performance compared to full-precision SGD.
Convergence guarantees for TernGrad rely on a nonstandard gradient norm assumption.
As discussed, Alistarh et al.
(2017) proposed QSGD, a more general stochastic quantization scheme, for which they provide both theoretical guarantees and experimental validation (although for different variants of the same algorithm).
We note that their implementation was only provided in Microsoft CNTK; by contrast, here we provide a more generic implementation in Horovod (Sergeev and Del Balso, 2018), a communication back-end which can support a range of modern frameworks such as Tensorﬂow, Keras, Pytorch, and MXNet.
NUQSGD uses a logarithmic quantization scheme.
Such schemes have long been used in telephony systems for audio compression (Cattermole, 1969).
Logarithmic quantization schemes have appeared in other contexts recently:
Hou and Kwok (2018) studied weight distributions of long short-term memory networks and proposed to use logarithm quantization for network compression.
Zhang et al.
(2017) proposed a gradient compression scheme and introduced an optimal quantization scheme, but for the setting where the points to be quantized are known in advance.
As a result, their scheme is not applicable to the communication setting of quantized data-parallel SGD.
P RELIMINARIES : D ATA - PARALLEL SGD AND C ONVERGENCE
We consider a high-dimensional machine learning model, parametrized by a vector w ∈ R d .
Let Ω ⊆ R
d denote a closed and convex set.
Our objective is to minimize f : Ω → R , which is an unknown, differentiable, convex, and β -smooth function.
The following summary is based on (Alistarh et al., 2017).
Recall that a function f is β -smooth if, for all u , v ∈ Ω , we have (cid:107) ∇ f ( u ) − ∇ f ( v ) (cid:107) ≤ β (cid:107) u − v (cid:107) , where (cid:107) · (cid:107) denotes the Euclidean norm.
Let ( S , Σ , µ ) be a probability space (and let E denote expectation).
Assume we have access to stochastic gradients of f , i.e., we have access to a function g : Ω × S
→ R d such that, if s ∼ µ , then E [ g ( w , s )]
= ∇ f ( w ) for all w ∈ Ω .
In the rest of the paper, we let g ( w ) denote the stochastic gradient for notational simplicity.
The update rule for conventional full-precision projected SGD is w t + 1 = P Ω ( w t − α g ( w t )) , where w t is the current parameter input, α is the learning rate, and P Ω is the Euclidean projection onto Ω .
We say the stochastic gradient has a second-moment upper bound B when E [ (cid:107) g
( w ) (cid:107) 2 ] ≤ B for all w ∈ Ω .
Similarly, the stochastic gradient has a variance upper bound σ
when E [ (cid:107) g
( w ) − ∇ f ( w ) (cid:107) 2 ] ≤ σ 2 for all w ∈ Ω .
Note that a second-moment upper bound implies a variance upper bound, because the stochastic gradient is unbiased.
We have classical convergence guarantees for conventional full-precision SGD given access to stochastic gradients at each iteration:
Theorem 1 (Bubeck 2015, Theorem 6.3) .
Let f : Ω → R denote a convex and β -smooth function and let R 2 (cid:44) sup w ∈ Ω (cid:107) w − w 0 (cid:107) 2 .
Suppose that the projected SGD update is executed for T iterations with α = 1 / ( β + 1 / γ ) where γ = r (cid:112) 2 / T / σ .
Given repeated and independent access to stochastic gradients with a variance upper bound σ 2 , projected SGD satisﬁes
[Equation]
Minibatched (with larger batch sizes) and data-parallel SGD are two common SGD variants used in practice to reduce variance and improve computational efﬁciency of conventional SGD.
Input: local data, local do
Compute gradient t ←
Broadcast t processor
, t
Following (Alistarh et al., 2017), we consider data-parallel SGD, a synchronous distributed framework consisting of K processors that partition a large dataset among themselves.
This framework models real-world systems with multiple GPU resources.
Each processor keeps a local copy of the parameter vector and has access to independent and private stochastic gradients of f .
At each iteration, each processor computes its own stochastic gradient based on its local data and then broadcasts it to all peers.
Each processor receives and aggregates the stochastic gradients from all peers to obtain the updated parameter vector.
In detail, the update rule for full-precision dataparallel SGD is w t + 1 = P Ω ( w t − α K
∑ Kl = 1 g l ( w t )) where g l ( w t ) is the stochastic gradient computed and broadcasted by processor l .
Provided that g l ( w t ) is a stochastic gradient with a variance upper bound σ 2 for all l , then 1 K ∑ Kl = 1 g l ( w t ) is a stochastic gradient with a variance upper bound σ 2 K .
Thus, aggregation improves convergence of SGD by reducing the ﬁrst term of the upper bound in (1).
Assume each processor computes a minibatch gradient of size B .
Then, this update rule is essentially a minibatched update with size BK .
Data-parallel SGD is described in Algorithm 1.
Full-precision data-parallel SGD is a special case of Algorithm 1 with identity encoding and decoding mappings.
Otherwise, the decoded stochastic gradient
ˆ g i ( w t ) is likely to be different from the original local stochastic gradient g i ( w t ) .
By Theorem 1, we have the following convergence guarantees for full-precision data-parallel SGD:
Corollary 1 (Alistarh et al.
2017, Corollary 2.2) .
Let f, R, and γ be as deﬁned in Theoremand let ε > 0 .
Suppose that the projected SGD update is executed for T iterations with α = 1 / ( β + √ K / γ ) on K processors, each with access to independent stochastic gradients of f with a second-moment bound
B.
The smallest T for the full-precision data-parallel SGD that guarantees
E (cid:2) f ( 1 T ∑ Tt = 0 w t ) (cid:3) − min w ∈ Ω f ( w ) ≤ ε is T ε
= O (cid:0) R 2 max ( 2 BK ε 2 , βε ) (cid:1) .
N ONUNIFORMLY Q UANTIZED S TOCHASTIC G RADIENT D ESCENT
Data-parallel SGD reduces computational costs signiﬁcantly.
However, the communication costs of broadcasting stochastic gradients is the main performance bottleneck in large-scale distributed systems.
In order to reduce communication costs and accelerate training, Alistarh et al.
(2017) introduced a compression scheme that produces a compressed and unbiased stochastic gradient, suitable for use in SGD.
At each iteration of QSGD, each processor broadcasts an encoding of its own compressed stochastic gradient, decodes the stochastic gradients received from other processors, and sums all the quantized vectors to produce a stochastic gradient.
In order to compress the gradients, every coordinate (with respect to the standard basis) of the stochastic gradient is normalized by the Euclidean norm of the gradient and then stochastically quantized to one of a small number quantization levels distributed uniformly in the unit interval.
The stochasticity of the quantization is necessary to not introduce bias.
Alistarh et al.
(2017) give a simple argument that provides a lower bound on the number of coordinates that are quantized to zero in expectation.
Encoding these zeros efﬁciently provides communication savings at each iteration.
However, the cost of their scheme is greatly increased variance in the gradient, and thus slower overall convergence.
In order to optimize overall performance, we must balance communication savings with variance.
[Figure] [Figure]
By simple counting arguments, the distribution of the (normalized) coordinates cannot be uniform.
Indeed, this is the basis of the lower bound on the number of zeros.
These arguments make no assumptions on the data distribution, and rely entirely on the fact that the quantities being quantized are the coordinates of a unit-norm vector.
Uniform quantization does not capture the properties of such vectors, leading to substantial gradient variance.
3. N ONUNIFORM Q UANTIZATION
In this paper, we propose and study a new scheme to quantize normalized gradient vectors.
Instead of uniformly distributed quantization levels, as proposed by Alistarh et al.
(2017), we consider quantization levels that are nonuniformly distributed in the unit interval, as depicted in Figure 1.
In order to obtain a quantized gradient that is suitable for SGD, we need the quantized gradient to remain unbiased.
Alistarh et al.
(2017) achieve this via a randomized quantization scheme, which can be easily generalized to the case of nonuniform quantization levels.
Using a carefully parametrized generalization of the unbiased quantization scheme introduced by
Alistarh et al.
, we can control both the cost of communication and the variance of the gradient.
Compared to a uniform quantization scheme, our scheme reduces quantization error and variance by better matching the properties of normalized vectors.
In particular, by increasing the number of quantization levels near zero, we obtain a stronger variance bound.
Empirically, our scheme also better matches the distribution of normalized coordinates observed on real datasets and networks.
We now describe the nonuniform quantization scheme: Let s ∈ { 1 , 2 , ···} be the number of internal quantization levels, and let L
= ( l 0 , l 1 , ··· , l s + 1 ) denote the sequence of quantization levels, where l 0 = 0 < l 1 < ··· < l s + 1 = 1.
For r ∈ [ 0 , 1 ] , let ˜ s ( r ) and p ( r ) satisfy l ˜ s ( r ) ≤ r ≤ l ˜ s ( r )+ 1 and r = (cid:0) 1 − p ( r ) (cid:1) l ˜ s ( r ) + p ( r ) l
˜ s ( r )+ 1 , respectively.
Deﬁne τ ( r ) =
l ˜ s ( r )+ 1 − l ˜ s ( r ) .
Note that ˜ s ( r ) ∈ { 0 , 1 , ··· , s } .
Deﬁnition 1.
The nonuniform quantization of a vector v ∈ R d is
[Equation]
where Q s ( v i )
= (cid:107) v (cid:107)· sign ( v i ) · h i ( v , s ) (2) where, letting r i = | v i | / (cid:107) v (cid:107) , the h i ( v , s ) ’s are independent random variables
such that h i ( v , s ) =
l ˜ s ( r i ) with probability 1 − p ( r i ) and h i ( v , s )
=
l ˜ s ( r i )+
1 otherwise.
We note that the distribution of h i ( v , s ) satisﬁes E [ h i ( v , s )]
= r i and achieves the minimum variance over all distributions that satisfy E [ h i ( v , s )]
= r i with support L .
In the following, we focus on a special case of nonuniform quantization with ˆ L = ( 0 , 1 / 2 s , ··· , 2 s − 1 / 2 s , 1 ) as the quantization levels.
The intuition behind this quantization scheme is that it is very unlikely to observe large values of r i in the stochastic gradient vectors of machine learning models.
Stochastic gradients are observed to be dense vectors (Bernstein et al., 2018).
Hence, it is natural to use ﬁne intervals for small r i values to reduce quantization error and control the variance.
After quantizing the stochastic gradient with a small number of discrete levels, each processor must encode its local gradient into a binary string for broadcasting.
We describe this encoding in
Appendix A.
T HEORETICAL G UARANTEES
In this section, we provide theoretical guarantees for NUQSGD, giving variance and code-length bounds, and using these in turn to compare NUQSGD and QSGD.
Please note that the proofs of
Theorems 2, 3, 4, and 5 are provided in Appendices B, C, D, and E respectively.
Theorem 2 (Variance bound) .
Let v ∈ R d .
The nonuniform quantization of v satisﬁes E [ Q s ( v )]
= v .
Furthermore, provided that s ≤ log ( d ) / 2 , we have
[Equation]
where ε Q = min { min { 2 − 2 s ( d − 2 2 s ) , 2 − s √ d − 2 2 s } + O ( s ) , d / 3 (
[Equation]
− 2 s + 1 + 1 ) } .
The result in Theorem 2 implies that if g ( w ) is a stochastic gradient with a second-moment bound η , then Q s ( g ( w )) is a stochastic gradient with a variance upper bound ε Q η .
In the range of interest where d is sufﬁciently large, i.e., s =
o ( log ( d )) , the variance upper bound decreases with the number of quantization levels.
To obtain this data-independent bound, we establish upper bounds on the number of coordinates of v falling into intervals deﬁned by ˆ L .
Theorem 3 (Code-length bound) .
Let v ∈ R d .
Provided d is large enough to ensure 2 2 s + √ d 2 s ≤ d / e, the expectation E [ | ENCODE ( v ) | ] of the number of communication bits needed to transmit Q s ( v ) is bounded above by
[Equation] [Equation]
where
C = b − ( 1 + o ( 1 )) and n s , d = 2 2 s + 2 s √ d.
Theorem 3 provides a bound on the expected number of communication bits to encode the quantized stochastic gradient.
Note that 2 2 s + √ d 2 s ≤ d / e is a mild assumption in practice.
As one would expect, the bound, (4), increases monotonically in d and s .
In the sparse case, if we choose s =
o ( log d ) levels, then the upper bound on the expected code-length is O (cid:0) 2 s √ d log (cid:0) √ d 2 s (cid:1)(cid:1) .
Combining the upper bounds above on the variance and code-length, Corollary 1 implies the following guarantees for NUQSGD:
Theorem 4 (NUQSGD for smooth convex optimization) .
Let f and R be deﬁned as in Theorem 1, let ε Q be deﬁned as in Theorem 2, let ε > 0 ,
ˆ B =
( 1 + ε Q ) B, and let γ > 0 be given by γ 2 = 2 R 2 / ( ˆ BT ) .
With ENCODE and DECODE deﬁned as in Appendix A, suppose that Algorithm 1 is executed for T iterations with a learning rate α = 1 / ( β + √ K / γ ) on K processors, each with access to independent stochastic gradients of f with a second-moment bound B. Then T ε
= O (cid:0) max (cid:0)
ˆ BK ε 2 , βε (cid:1) R 2 (cid:1) iterations sufﬁce to guarantee E (cid:2)
f (cid:0) 1 T ∑ Tt = 0 w t (cid:1)(cid:3) − min w ∈ Ω f ( w ) ≤ ε .
In addition, NUQSGD requires at most
N Q communication bits per iteration in expectation.
On nonconvex problems, (weaker) convergence guarantees can be established along the lines of, e.g., (Ghadimi and Lan, 2013, Theorem 2.1).
NUQSGD vs QSGD.
How do QSGD and NUQSGD compare in terms of bounds on the expected number of communication bits required to achieve a given suboptimality gap ε ?
The quantity that controls our guarantee on the convergence speed in both algorithms is the variance upper bound, which in turn is controlled by the quantization schemes.
Note that the number of quantization levels, s , is usually a small number in practice.
On the other hand, the dimension, d , can be very large, especially in overparameterized networks.
In Figure 2, we show that the quantization scheme underlying NUQSGD results in substantially smaller variance upper bounds for plausible ranges of s and d .
Note that these bounds do not make any assumptions on the dataset or the structure of the network.
For any (nonrandom) number of iterations T , an upper bound, N A , holding uniformly over iterations k ≤ T on the expected number of bits used by an algorithm A to communicate the gradient on iteration k , yields an upper bound TN A , on the expected number of bits communicated over T iterations by algorithm A .
Taking T = T A , ε to be the (minimum) number of iterations needed to guarantee an expected suboptimality gap of ε based on the properties of A , we obtain an upper bound, ζ A , ε = T A , ε N A , on the expected number of bits of communicated on a run expected to achieve a suboptimality gap of at most ε .
[Figure] [Figure]
e a n N
[Figure]
r
[Figure]
li z
[Figure]
i
[Figure]
n
[Figure]
Theorem 5 (Expected number of communication bits) .
Provided that s =
o ( log ( d )) and 2 ˆ BK ε 2 > βε , ζ NUQSGD , ε = O (cid:0)
ε 2 (cid:112) d ( d − 2 2 s ) log (cid:0) √
d 2 s (cid:1)(cid:1) and ζ QSGD , ε = O ( 1 ε 2 d log √ d ) .
Focusing on the dominant terms in the expressions of overall number of communication bits required to guarantee a suboptimality gap of ε , we observe that NUQSGD provides slightly stronger guarantees.
Note that our stronger guarantees come without any assumption about the data.
E XPERIMENTAL E VALUATION
In this section, we examine the practical performance of NUQSGD in terms of both convergence (accuracy) and speedup.
The goal is to empirically show that NUQSGD can provide the same performance and accuracy compared to the QSGDInf heuristic, which has no theoretical compression guarantees.
For this, we implement and test these three methods (NUQSGD, QSGD, and QSGDInf), together with the distributed full-precision SGD baseline, which we call SuperSGD.
We split our study across two axes: ﬁrst, we examine the convergence of the methods and their induced variance.
Second, we provide an efﬁcient implementation of all four methods in Pytorch using the Horovod communication back-end (Sergeev and Del Balso, 2018), adapted to efﬁciently support quantization, and examine speedup relative to the full-precision baseline.
We investigate the impact of quantization on training performance by measuring loss, variance, accuracy, and speedup for ResNet models (He et al., 2016) applied to ImageNet (Deng et al., 2009) and CIFAR10 (Krizhevsky).
We evaluate these methods on two image classiﬁcation datasets: ImageNet and CIFAR10.
We train
ResNet110 on CIFAR10 and ResNet18 on ImageNet with mini-batch size 128 and base learning rate 0 .
In all experiments, momentum and weight decay are set to 0 .
9 and 10 − 4 , respectively.
The bucket size and the number of quantization bits are set to 8192 and 4, respectively.
We observe similar results in experiments with various bucket sizes and number of bits.
We simulate a scenario with k
GPUs for all three quantization methods by estimating the gradient from k independent mini-batches and aggregating them after quantization and dequantization.
In Figure 3 (left and middle), we show the training loss with 8 GPUs.
We observe that NUQSGD and QSGDinf improve training loss compared to QSGD on ImageNet.
We observe signiﬁcant gap in training loss on CIFAR10 where the gap grows as training proceeds.
We also observe similar performance gaps in test accuracy (provided in Appendix F).
In particular, unlike NUQSGD, QSGD does not achieve test accuracy of full-precision SGD.
Figure 3 (right) shows the mean normalized variance of the gradient (deﬁned in Appendix F) versus training iteration on the trajectory of singleGPU SGD on CIFAR10.
These observations validate our theoretical results that NUQSGD has smaller variance for large models with small number of quantization bits.
Efﬁcient Implementation and Speedup.
To examine speedup behavior, we implemented all quantization methods in Horovod (Sergeev and Del Balso, 2018), a communication back-end supporting
Pytorch, Tensorﬂow and MXNet.
Doing so efﬁciently requires non-trivial refactoring of this framework, since it does not support communication compression—our framework will be open-sourced upon publication.
Our implementation diverges slightly from the theoretical analysis.
First, Horovod applies “tensor fusion” to multiple layers, by merging the resulting gradient tensors for more efﬁcient transmission.
This causes the gradients for different layers to be quantized together, which can lead to loss of accuracy (due to e.g. different normalization factors across the layers).
We addressed this by tuning the way in which tensor fusion is applied to the layers such that it minimizes the accuracy loss.
Second, we noticed that quantizing the gradients corresponding to the biases has a signiﬁcant adverse effect on accuracy; since the communication impact of biases is negligible, we transmit them at full precision.
We apply this for all methods considered.
Finally, for efﬁciency reasons, we directly pack the quantized values into 32-bit numbers, without additional encoding.
We implemented compression and de-compression via efﬁcient CUDA kernels.
Our baselines are full-precision SGD (SuperSGD), Error-Feedback SignSGD
(Karimireddy et al., 2019), and the QSGDinf heuristic, which we compare against the 4-bit and 8-bit NUQSGD variants executing the same pattern.
The implementation of the QSGDinf heuristic provides almost identical convergence numbers, and is sometimes omitted for visibility.
(QSGD yields inferior convergence on this dataset and is therefore omitted.)
All variants are implemented using a standard all-to-all reduction pattern.
Figures 4 (left), (middle) show the execution time per epoch for ResNet34 and
ResNet50 models on ImageNet, on a cluster machine with 8 NVIDIA
Ti GPUs, for the hyperparameter values quoted above.
The results conﬁrm the efﬁciency and scalability of the compressed variant, mainly due to the reduced communication volume.
We note that the overhead of compression and decompression is less than 1% of the batch computation time for NUQSGD.
Figure 4 (right) presents end-to-end speedup numbers (time versus accuracy) for ResNet50/ImageNet, executed on 4 GPUs, under the same hyperparameter settings as the full-precision baseline, with bucket size 512.
First, notice that NUQSGD variants match the target accuracy of the 32-bit model, with non-trivial speedup over the standard data-parallel variant, directly proportional to the perepoch speedup.
The QSGDinf heuristic yields similar accuracy and performance, and is therefore omitted.
Second, we found that unfortunately EF-SignSGD does not converge under these standard hyperparameter settings.
To address this issue, we performed a non-trivial amount of hyperparameter tuning for this algorithm: in particular, we found that the scaling factors and the bucket size must be carefully adjusted for convergence on ImageNet.
We were able to recover full accuracy with
EF-SignSGD on ResNet50, but that the cost of quantizing into buckets of size 64.
Unfortunately, in this setting the algorithm transmits a non-trivial amount of scaling data, and the GPU implementation becomes less efﬁcient due to error computation and reduced parallelism.
The end-to-end speedup of this tuned variant is inferior to NUQSGD-4bit, and only slightly superior to that of NUQSGD-8bit.
Please see Figure 9 in the Appendix and the accompanying text for details.
C ONCLUSIONS
We study data-parallel and communication-efﬁcient version of stochastic gradient descent.
Building on QSGD (Alistarh et al., 2017), we study a nonuniform quantization scheme.
We establish upper bounds on the variance of nonuniform quantization and the expected code-length.
In the overparametrized regime of interest, the former decreases as the number of quantization levels increases, while the latter increases with the number of quantization levels.
Thus, this scheme provides a trade-off between the communication efﬁciency and the convergence speed.
We compare
NUQSGD and QSGD in terms of their variance bounds and the expected number of communication bits required to meet a certain convergence error, and show that NUQSGD provides stronger guarantees.
Experimental results are consistent with our theoretical results and conﬁrm that NUQSGD matches the performance of QSGDinf when applied to practical deep models and datasets including
ImageNet.
Thus, NUQSGD closes the gap between the theoretical guarantees of QSGD and empirical performance of QSGDinf.
One limitation of our study which we aim to address in future work is that we focus on all-to-all reduction patterns, which interact easily with communication compression.
In particular, we aim to examine the interaction between more complex reduction patterns, such as ring-based reductions (Hannun et al., 2014), which may yield superior performance in bandwidthbottlenecked settings, but which interact with communication-compression in non-trivial ways, since they may lead a gradient to be quantized at each reduction step.
A E NCODING
Encoding: 1 Place a 0 at the end of the string; 2 if N == 1 then
Stop; 4 else
Prepend binary ( N ) to the beginning;
Let N (cid:48) denote # bits prepended minus 1;
Encode N (cid:48) recursively;
Decoding: 8 Start with N = 1; 9 if the next bit == 0 then
Stop and return N ; 11 else
Read that bit plus N following bits;
Update N ;
Algorithm 2: Elias recursive coding produces a bit string encoding of positive integers.
By inspection, the quantized gradient Q s ( v ) is determined by the tuple ( (cid:107) v (cid:107) , ρρρ , h ) , where (cid:107) v (cid:107) is the norm of the gradient, ρρρ (cid:44) [ sign ( v 1 ) , ··· , sign ( v d )] T is the vector of signs of the coordinates v i ’s, and h (cid:44) [ h 1 ( v , s ) , ··· , h d ( v , s )]
T are the quantizations of the normalized coordinates.
We can describe the ENCODE function (for Algorithm 1) in terms of the tuple ( (cid:107) v (cid:107) , ρρρ , h ) and an encoding/decoding scheme ERC : { 1 , 2 , ···} → { 0 , 1 } ∗ and ERC − 1 : { 0 , 1 } ∗ → { 1 , 2 , ···} for encoding/decoding positive integers.
The encoding, ENCODE ( v ) , of a stochastic gradient is as follows:
We ﬁrst encode the norm (cid:107) v (cid:107) using b bits where, in practice, we use standard 32-bit ﬂoating point encoding.
We then proceed in rounds, r = 0 , 1 , ··· .
On round r , having transmitted all nonzero coordinates up to and including t r , we transmit ERC ( i r ) where t r + 1 = t r + i r is either (i) the index of the ﬁrst nonzero coordinate of h after t r (with t 0 = 0) or (ii) the index of the last nonzero coordinate.
In the former case, we then transmit one bit encoding the sign ρ t r + 1 , transmit ERC ( log ( 2 s + 1 h t r + 1 )) , and proceed to the next round.
In the latter case, the encoding is complete after transmitting ρ t r + 1 and ERC ( log ( 2 s + 1 h t r + 1 )) .
The DECODE function (for Algorithm 1) simply reads b bits to reconstruct (cid:107) v (cid:107) .
Using ERC − 1 , it decodes the index of the ﬁrst nonzero coordinate, reads the bit indicating the sign, and then uses
ERC − 1 again to determines the quantization level of this ﬁrst nonzero coordinate.
The process proceeds in rounds, mimicking the encoding process, ﬁnishing when all coordinates have been decoded.
Like Alistarh et al.
, we use Elias recursive coding (Elias, 1975, ERC) to encode positive integers.
ERC is simple and has several desirable properties, including the property that the coding scheme assigns shorter codes to smaller values, which makes sense in our scheme as they are more likely to occur.
Elias coding is a universal lossless integer coding scheme with a recursive encoding and decoding structure.
The Elias recursive coding scheme is summarized in Algorithm 2.
For any positive integer N , the following results are known for ERC (Alistarh et al., 2017):
| ERC ( N ) | ≤ (cid:0) 1 + o ( 1 ) (cid:1) log N + 1; 2.
ERC ( N ) can be encoded and decoded in time
O
( | ERC ( N ) | ) ;
Decoding can be done without knowledge of an upper bound on N .
B P ROOF OF T HEOREM 2 (V ARIANCE B OUND )
We ﬁrst ﬁnd a simple expression of the variance of Q s ( v ) for every arbitrary quantization scheme in the following lemma:
Lemma 1.
Let v ∈ R d , L =
( l 0 , l 1 , ··· , l s + 1 ) , and ﬁx s ≥ 1 .
The variance of Q s ( v ) for general sequence of quantization levels is given by
[Equation]
where r i = | v i | / (cid:107) v (cid:107) and p ( r ) , ˜ s ( r ) , τ ( r ) are deﬁned in Section 3.1.
Proof.
Noting the random quantization is i.i.d over elements of a stochastic gradient, we can decompose E [ (cid:107) Q s ( v ) − v (cid:107) 2 ] as:
[Equation]
where σ 2 ( r i )
=
E [( h i ( v , s ) − r i ) 2 ] .
Computing the variance of h i ( v , s ) , we can show that σ 2 ( r i ) =
τ 2 ( r i ) p ( r i ) (cid:0) 1 − p ( r i ) (cid:1) .
In the following, we consider NUQSGD algorithm with ˆ L = ( 0 , 1 / 2 s , ··· , 2 s − 1 / 2 s , 1 ) as the quantization levels.
Then, h i ( v , s ) ’s are deﬁned in two cases based on which quantization interval r i falls into:
1) If r i ∈ [ 0 , 2 − s ] , then
[Equation]
where p 1 (cid:0) r , s (cid:1)
=
2 s r .
2) If r i ∈ [ 2 j − s , 2 j + 1 − s ] for j = 0 , ··· , s − 1, then
[Equation]
with probability
[Equation]
where p 2 (cid:0) r , s (cid:1)
= 2 s − j r − 1 .
Note that Q s ( 0 ) = 0 .
Let S j denote the coordinates of vector v whose elements fall into the ( j + 1 ) -th bin, i.e., S 0 (cid:44) { i : r i ∈ [ 0 , 2 − s ] } and S j + 1 (cid:44) { i : r i ∈ [ 2 j − s , 2 j + 1 − s ] } for j = 0 , ··· , s − 1.
Let d j (cid:44) | S j | .
Applying the result of Lemma 1, we have
[Equation]
where τ j (cid:44) l j + 1 − l j for j ∈ { 0 , ··· , s } .
Substituting τ 0 = 2 − s and τ j = 2 j − 1 − s for j ∈ { 1 , ··· , s } into (9), we have
[Equation]
We ﬁrst note that ∑ i ∈ S 0 p 1 ( r i , s ) ≤ d and ∑ i ∈ S
j + 1 p
( r i , s ) ≤ d for all j , i.e., an upper bound on the variance of Q s ( v ) is given by E [ (cid:107) Q s (
[Equation]
d
[Equation]
s + 1 + 1 ) .
Furthermore, we have
[Equation]
11) since ∑ i ∈ S 0 | v i | (cid:107) v
[Equation]
≤ √ d 0 .
Similarly, we have
[Equation]
Substituting the upper bounds in (11) and (12) into (10), an upper bound on the variance of Q s ( v ) is given by
E [
[Equation]
The upper bound in (13) cannot be used directly as it depends on { d 0 , ··· , d s } .
Note that d
j
’s depend on quantization intervals.
In the following, we obtain an upper bound on E [ (cid:107) Q s ( v ) − v (cid:107) 2 ] , which depends only on d and s .
To do so, we need to use this lemma inspired by (Alistarh et al., 2017,
Lemma A.5): Let (cid:107)·(cid:107)
count the number of nonzero components.
Lemma 2.
Let v ∈ R d .
The expected number of nonzeros in Q s ( v ) is bounded above by
[Equation]
Proof.
Note that d − d 0 ≤ 2 2 s since
[Equation]
For each i ∈ S 0 , Q s ( v i ) becomes zero with probability 1 − 2 s r i , which results in
[Equation]
Using a similar argument as in the proof of Lemma 2, we have
[Equation]
16) for j = 0 , 1 , ··· , s − 1.
Deﬁne b j (cid:44) d − 2 2 ( s − j ) for j = 0 , ··· , s − 1.
Then
[Equation] [Equation]
Note that d s = d − d 0 −···− d s − 1 .
We deﬁne
[Equation] [Equation]
Note that ˜ d 0 ≤ d 0 , ˜ d 1 + ˜ d 0 ≤ d 1 + d 0 , ··· , ˜ d s − 1 + ··· + ˜ d 0 ≤ d s − 1 + ··· + d 0 , and ˜ d s + ··· + ˜ d
=
d s + ··· + d 0 .
Noting that the coefﬁcients of the additive terms in the upper bound in (13) are monotonically increasing with j , we can ﬁnd an upper bound on E [ (cid:107) Q s ( v ) − v (cid:107) 2 ] by replacing ( d 0 , ··· , d s ) with ( ˜ d 0 , ··· , ˜ d s ) in (13), which gives (3) and completes the proof.
C P ROOF OF T HEOREM 3 (C ODE - LENGTH B OUND )
Let | · | denote the length of a binary string.
In this section, we ﬁnd an upper bound on E [ | ENCODE ( v )] , i.e., the expected number of communication bits per iteration.
Recall from
Appendix A that the quantized gradient Q s ( v ) is determined by the tuple ( (cid:107) v (cid:107) , ρρρ , h ) .
Write i 1 < i 2 < ··· < i (cid:107) h (cid:107) 0 for the indices of the (cid:107) h (cid:107) 0 nonzero entries of h .
Let i
= 0.
The encoding produced by ENCODE ( v ) can be partitioned into two parts, R and E , such that
, for j = 1 ,..., (cid:107) h (cid:107) 0 , • R contains the codewords ERC ( i j − i j − 1 ) encoding the runs of zeros; and • E contains the sign bits and codewords ERC ( log { 2 s + 1 h i j } ) encoding the normalized quantized coordinates.
Note that (cid:107) [ i 1 , i 2 − i 1 , ··· , i (cid:107) h (cid:107) 0 − i (cid:107) h (cid:107) 0 − 1 ] (cid:107) 1 ≤ d .
Thus, by (Alistarh et al., 2017, Lemma A.3), the properties of Elias encoding imply that
[Equation] [Equation]
We now turn to bounding | E | .
The following result in inspired by (Alistarh et al., 2017, Lemma A.3).
Lemma 3.
Fix a vector q such that (cid:107) q (cid:107) pp ≤ P , let i 1 <
i 2 < ...
i (cid:107) q (cid:107) 0 be the indices of its (cid:107) q (cid:107) 0 nonzero entries, and assume each nonzero entry is of form of 2 k , for some positive integer k.
Then
[Equation]
q
[Equation]
Proof.
Applying property (1) for ERC (end of Appendix A), we have
[Equation]
where the last bound is obtained by Jensen’s inequality.
Taking q = 2 s + 1 h , we note that (cid:107) q (cid:107) 2 = 2
s
+ 2 (cid:107) h (cid:107) 2 and
[Equation]
=
[Equation]
By Lemma 3 applied to q and the upper bound (20),
[Equation]
Combining (19) and (21), we obtain an upper bound on the expected code-length:
[Equation]
where
[Equation]
It is not difﬁcult to show that, for all k > 0, g 1 ( x ) (cid:44) x log (cid:0) kx (cid:1) is concave.
Note that g 1 is an increasing function up to x = k / e .
Deﬁning g 2 ( x ) (cid:44) x loglog (cid:0) Cx (cid:1) and taking the second derivative, we have
[Equation]
Hence g 2 is also concave on x < C .
Furthermore, g 2 is increasing up to some C / 5 < x ∗ < C / 4.
We note that E [ (cid:107) h (cid:107) 0 ] ≤ 2 2 s + √ d 2 s following Lemma 2.
By assumption 2 2 s + √ d 2 s ≤ d / e , and so,
Jensen’s inequality and (22) lead us to (4).
D P ROOF OF T HEOREM 4 (NUQSGD FOR S MOOTH C ONVEX O PTIMIZATION )
Let g ( w ) and ˆ g ( w ) denote the full-precision and decoded stochastic gradients, respectively.
Then
[Equation]
By Theorem 2, E [ (cid:107) ˆ g ( w ) − g ( w ) (cid:107) 2 ] ≤ ε Q E [ (cid:107) g ( w ) (cid:107) 2 ] .
By assumption, E [ (cid:107) g ( w ) (cid:107) 2 ] ≤ B .
Noting g ( w ) is unbiased, E [ (cid:107) ˆ g ( w ) − ∇ f ( w ) (cid:107) 2 ] ≤ ( 1 + ε Q ) B .
The result follows by Corollary 1.
[Figure]
E P ROOF OF T HEOREM 5 (E XPECTED N UMBER OF C OMMUNICATION B ITS )
Assuming 2 ˆ BK ε 2 > βε , then T ε =
O (cid:0)
ˆ BK ε 2 R 2 (cid:1) .
Ignoring all but terms depending on d and s , we have
T ε =
O ( ˆ B / ε 2 ) .
Following Theorems 2 and 3 for NUQSGD, ζ NUQSGD , ε
= O ( N Q ε Q B / ε 2 ) .
For QSGD, following the results of Alistarh et al.
(2017), ζ QSGD , ε
= O ( ˜ N Q ˜ ε Q B / ε 2 ) where ˜ N Q =
( s 2 + s √ d )+ ( 3 2 + o ( 1 ))
( s 2 + s √ d ) log (cid:16) 2 ( s 2 + d ) s 2 + √ d (cid:17)
+ b and ˜ ε Q = min (cid:0) ds 2 , √ ds (cid:1) .
In overparameterized networks, where d ≥ 2 2 s + 1 , we have ε Q = 2 − s √ d − 2 2 s + O ( s ) and ˜
ε Q = √ d / s .
Furthermore, for sufﬁciently large d , N Q and ˜ N Q are given by O (cid:0) 2 s √ d log (cid:0) √ d 2 s (cid:1)(cid:1) and
O (cid:0) s √ d log ( √ d ) (cid:1) , respectively.
F A DDITIONAL E XPERIMENTS
[Figure]
In this section, we present further experimental results in a similar setting to Section 5.
In Figure 6, we show the test accuracy for training ResNet110 on CIFAR10 and validation accuracy for training ResNet34 on ImageNet from random initialization until convergence (discussed in Section 5).
Similar to the training loss performance, we observe that NUQSGD and QSGDinf outperform QSGD in terms of test accuracy in both experiments.
In both experiments, unlike NUQSGD, QSGD does not recover the test accuracy of SGD.
The gap between NUQSGD and QSGD on ImageNet is signiﬁcant.
We argue that this is achieved because NUQSGD and QSGDinf have lower variance relative to QSGD.
It turns out both training loss and generalization error can beneﬁt from the reduced variance.
[Figure] [Figure]
[Figure] [Figure]
[Figure] [Figure]
M e a n
N o r m a li
z e d
V a r i a n c e
SGD QSGD
QSGDinf NUQSGD
SuperSGD      6 Training Iteration 1e 0.
M e a n
N o r m a li
z e d
V a r i a n c e
We also measure the variance and normalized variance at ﬁxed snapshots during training by evaluating multiple gradient estimates using each quantization method.
All methods are evaluated on the same trajectory traversed by the single-GPU SGD.
These plots answer this speciﬁc question: What would the variance of the ﬁrst gradient estimate be if one were to train using SGD for any number of iterations then continue the optimization using another method?
The entire future trajectory may change by taking a single good or bad step.
We can study the variance along any trajectory.
However, the trajectory of SGD is particularly interesting because it covers a subset of points in the parameter space that is likely to be traversed by any ﬁrst-order optimizer.
For multi-dimensional parameter space, we average the variance of each dimension.
Figure 5 (left), shows the variance of the gradient estimates on the trajectory of single-GPU SGD on
CIFAR10.
We observe that QSGD has particularly high variance, while QSGDinf and NUQSGD have lower variance than single-GPU SGD.
We also propose another measure of stochasticity, normalized variance, that is the variance normalized by the norm of the gradient.
The mean normalized variance can be expressed as
[Equation]
where l ( w ; z ) denotes the loss of the model parametrized by w on sample z and subscript A refers to randomness in the algorithm, e.g., randomness in sampling and quantization.
Normalized variance can be interpreted as the inverse of Signal to Noise Ratio (SNR) for each dimension.
We argue that the noise in optimization is more troubling when it is signiﬁcantly larger than the gradient.
For sources of noise such as quantization that stay constant during training, their negative impact might only be observed when the norm of the gradient becomes small.
Figure 5 (right) shows the mean normalized variance of the gradient versus training iteration.
Observe that the normalized variance for QSGD stays relatively constant while the unnormalized variance of
QSGD drops after the learning rate drops.
It shows that the quantization noise of QSGD can cause slower convergence at the end of the training than at the beginning.
In Figure 7, we show the mean normalized variance of the gradient versus training iteration on
CIFAR10 and ImageNet.
For different methods, the variance is measured on their own trajectories.
Since the variance depends on the optimization trajectory, these curves are not directly comparable.
Rather the general trend should be studied.
ResNet152 Weak Scaling.
In Figure 8, we present the weak scaling results for ResNet152/ImageNet.
Each of the GPUs receives a batch of size 8, and we therefore scale up the global batch size by the number of nodes.
The results exhibit the same superior scaling behavior for NUQSGD relative to the uncompressed baseline.
EF-SignSGD Convergence.
In Figure 9, we present a performance comparison for NUQSGD variants (bucket size 64) and a convergent variant of EF-SignSGD with signiﬁcant levels of parameter tuning for convergence.
We believe this to be the ﬁrst experiment to show convergence of the latter method at ImageNet scale, as the original paper only considers the CIFAR dataset.
For convergence, we have tuned the choice of scaling factor and the granularity at which quantization is applied (bucket size).
We have also considered learning rate tuning, but that did not appear to prevent divergence in the early stages of training for this model.
We did not attempt warm start, since that would signiﬁcantly decrease the practicality of the algorithm.
We have found that bucket size 64 is the highest at which the algorithm will still converge on this model and dataset, and found 1-bit SGD scaling (Seide et al., 2014), which consists of taking sums over positives and over negatives for each bucket, to yield good results.
The experiments are executed on a machine with 8 NVIDIA Titan X
GPUs, and batch size 256, and can be found in Figure 9.
Under these hyperparameter values the
EF-SignSGD algorithm sends 128 bits per each bucket of 64 values (32 for each scaling factor, and 64 for the signs), doubling its baseline communication cost.
Moreover, the GPU implementation is not as efﬁcient, as error feedback must be computed and updated at every step, and there is less parallelism to leverage inside each bucket.
This explains the fact that the end-to-end performance is in fact close to that of the 8-bit NUQSGD variant, and inferior to 4-bit NUQSGD.
G V ARIANCE L OWER B OUND
In the following theorem, we show that for any given set of levels, there exists a distribution of points with dimension d such that the variance is in Ω ( √ d ) , and so our bound is tight in d .
Theorem 6 (Lower bound) .
Let d ∈ Z > 0 and let ( 0 , l 1 , ··· , l s , 1 ) denote an arbitrary sequence of quantization levels.
Provided d ≥ ( 2 / l 1 ) 2 , there exists a vector v ∈ R d such that the variance of unbiased quantization of v is lower bounded by (cid:107) v (cid:107) 2 l 1 √ d / 2 , i.e., the variance is in Ω ( √ d ) .
Proof.
The variance of Q s ( v ) for general sequence of quantization levels is given by
[Equation]
If r ∈ [ l ˜ s ( r ) , l ˜ s ( r )+ 1 ] , the variance σ 2 ( r ) can be expressed as
[Equation]
We consider v 0 =
[ r , r , ··· , r ] T for r (cid:54) = 0.
The normalized coordinates is ˆ v 0 =
[ 1 / √ d , ··· , 1 / √ d ] T .
Using (26) and noting 1 / √ d < l 1 , we have
[Equation]
[Equation]
Summing variance of all coordinates and applying (27), the variance of Q s ( v 0 ) is lower bounded by
[Equation]
[Equation]
H W ORST - CASE V ARIANCE A NALYSIS
In this section, we ﬁrst derive the optimal worst-case variance upper bound by optimizing over the distribution of normalized coordinates for an arbitrary sequence of levels, expressed as a solution to an integer program with quadratic constraints.
We then relax the program to obtain a quadratically constrained quadratic program (QCQP).
A coarser analysis yields an upper bound expressed as a solution to a linear program (LP), which is more amenable to analysis.
We solve this LP analytically for the special case of s = 1 and show the optimal level is at 1 / 2.
Then, for an exponentially spaced collection of levels of the form ( 0 , p s , ··· , p 2 , p , 1 ) for p ∈ [ 0 , 1 ] and an integer number of levels, s , we write the expression of QCQP and solve it efﬁciently using standard solvers.
We have a numerical method for ﬁnding the optimal value of p that minimizes the worst-case variance, for any given s and d .
Through the worst-case analysis, we gain insight into the behaviour of the variance upper bound.
We show that our current scheme is nearly optimal (in the worst-case sense) in some cases.
Using these techniques we can obtain slightly tighter bounds numerically.
H. G ENERALLY S PACED L EVELS
Let L =
( l 0 , l 1 , ··· , l s , l s + 1 ) denote an arbitrary sequence of quantization levels where l 0 = 0 <
l 1 < ··· < l s + 1 = 1.
Recall that, for r ∈ [ 0 , 1 ] , we deﬁne ˜ s ( r ) and p ( r ) such that they satisfy l ˜ s ( r ) ≤ r ≤ l ˜ s ( r )+ 1 and r = (cid:0) 1 − p ( r ) (cid:1) l ˜ s ( r ) + p ( r ) l ˜ s ( r )+ 1 , respectively.
Deﬁne τ ( r ) =
l ˜ s ( r )+ 1 − l ˜ s ( r ) .
Note that
˜ s ( r ) ∈ { 0 , 1 , ··· , s } .
Then, h i ( v , s ) ’s are deﬁned in two cases based on which quantization interval r i falls into:
1) If r i ∈ [ 0 , l 1 ] , then
h i ( v , s
[Equation]
=
[Equation]
with probability 1 − p
[Equation]
r
[Equation]
L
[Equation] [Equation]
where
p 1 (cid:0) r , L (cid:1) =
r / l 1 .
2) If r i ∈ [ l j − 1 , l j ] for j = 1 , ··· , s + 1, then
[Equation]
with probability 1 − p
[Equation]
r
[Equation]
L
[Equation]
otherwise
[Equation] [Equation]
where p 2 (cid:0) r , L (cid:1) =
( r − l j − 1 ) / τ j − 1 .
Let S j denote the coordinates of vector v whose elements fall into the ( j + 1 ) -th bin, i.e., S j (cid:44) { i :
r i ∈
[ l j , l j + 1 ] } for j = 0 , ··· , s .
Let d j (cid:44) | S j | .
Following Lemma 1 and steps in Theorem 2, we can show that
[Equation]
Theorem 7 (QCQP bound) .
Let v ∈ R d .
An upper bound on the nonuniform quantization of v is given by ε QP (cid:107) v (cid:107) 2 where ε QP is the optimal value of the following QCQP:
[Equation]
subject to d − d 0 −···− d
[Equation]
Proof.
Following Lemma 2, we have
[Equation]
for j = 0 , ··· , s − 1.
The problem of optimizing ( d 0 , ··· , d s ) to maximize the variance upper bound (31) subject to (32) is given by
[Equation]
Let z j (cid:44) min { τ 2 j d j , τ j (cid:112)
d j } denote an auxiliary variable for j = 0 , ··· , s .
Problem R 1 can be rewritten as
[Equation] [Equation]
(32) , (33) , and (34) .
The variance optimization problem R 2 is an integer nonconvex problem.
We can obtain an upper bound on the optimal objective of problem R 2 by relaxing the integer constraint as follows.
The resulting QSQP is shown as follows:
[Equation]
subject to d
[Equation]
≥
[Equation]
=
[Equation]
36) (32) , (33) , and (35) .
Note that problem Q 1 can be solved efﬁciently using standard standard interior point-based solvers, e.g., CVX (Boyd and Vandenberghe, 2004).
In the following, we develop a coarser analysis that yields an upper bound expressed as the optimal value to an LP.
Theorem 8 (LP bound) .
Let v ∈ R d .
An upper bound on the nonuniform quantization of v is given by ε LP (cid:107) v (cid:107) 2 where ε LP is the optimal value of the following LP:
[Equation]
subject to d − d 0 −···− d j ≤ ( 1 / l j + 1 ) 2 , j = 0 , ··· , s − 1 , s
[Equation]
d j ≤ d
[Equation]
d
[Equation]
s .
Proof.
The proof follows the steps in the proof of Theorem 7 for the problem of optimizing ( d 0 , ··· , d s ) to maximize the following upper bound
[Equation]
Corollary 2 (Optimal level) .
For the special case with s = 1 , the optimal level to minimize the worst-case bound obtained from problem P 1 is given by l ∗ 1 = 1 / 2 .
Proof.
For s = 1, problem P 1 is given by
[Equation]
subject to d − d 0 ≤ ( 1 / l 1 )
[Equation]
Note that the objective of P 0 is monotonically increasing in ( d 0 , d 1 ) .
It is not difﬁcult to verify that the optimal ( d ∗ 0 , d ∗ 1 ) is a corner point on the boundary line of the feasibility region of P 0 .
Geometrical representation shows that that candidates for an optimal solution are ( d − ( 1 / l 1 ) 2 , ( 1 / l 1 ) 2 ) and ( d , 0 ) .
Substituting into the objective of P 0 , the optimal value of P 0 is given by
[Equation]
[Equation]
Finally, note that τ 0 = τ 1 = 1 / 2 minimizes the optimal value of P 0 (38).
0.9 p
Q C Q P
O p t i m a l
V
a l u e d = 1 e 6, s =
d = 1 e 6, s = d = 1 e 6, s =
d = 1 e 6, s =0.
0.9 p
Q C Q P
O p t i m a l
V a l u e d = 1 e 4, s =d = 1 e 5, s =
d = 1 e 6, s =d = 1 e 7, s =
H. E XPONENTIALLY S PACED L EVELS
In this section, we focus on the special case of exponentially spaced collection of levels of the form L p = ( 0 , p s , ··· , p 2 , p , 1 ) for p ∈ [ 0 , 1 ] and an integer number of levels, s .
In this case, we have τ 0 =
p s and τ j = ( 1 − p ) p s − j for j = 1 , ··· , s .
For any given s and d , we can solve the corresponding quadratic and linear programs efﬁciently to ﬁnd the worst-case variance bound.
As a bonus, we can ﬁnd the optimal value of p that minimizes the worst-case variance bound.
In Figure 10, we show the numerical results obtained by solving QCQP Q 1 with L p versus p using CVX (Boyd and Vandenberghe, 2004).
In Figure 10 (left), we ﬁx d and vary s , while in Figure 10 (right), we ﬁx s and vary d .
As expected, we note that the variance upper bound increases as d increases and the variance upper bound decreases as s increases.
We observe that our current scheme is nearly optimal (in the worst-case sense) in some cases.
Further, the optimal value of p shifts to the right as d increases and shifts to the left as s increases.
I N ONCONVEX OPTIMIZATION
We can obtain convergence guarantees to various learning problems where we have convergence guarantees for SGD under standard assumptions.
On nonconvex problems, (weaker) convergence guarantees can be established along the lines of, e.g., (Ghadimi and Lan, 2013, Theorem 2.1).
In particular, NUQSGD is guaranteed to converge to a local minima for smooth general loss functions.
Theorem 9 (NUQSGD for smooth nonconvex optimization) .
Let f : Ω → R denote a possibly nonconvex and β -smooth function.
Let w 0 ∈ Ω denote an initial point, ε Q be deﬁned as in Theorem 2,
T ∈ Z > 0 , and f ∗ = inf w ∈ Ω
f ( w ) .
Suppose that Algorithm 1 is executed for T iterations with a learning rate
α = O ( 1 / β ) on K processors, each with access to independent stochastic gradients of f with a second-moment bound B.
Then there exists a random stopping time R ∈ { 0 , ··· , T } such that NUQSGD guarantees E
[ (cid:107) ∇ f ( w R ) (cid:107) 2 ] ≤ ε where ε
= O (cid:0) β ( f ( w 0 ) − f ∗ ) / T +( 1 + ε Q ) B (cid:1) .