Year: 2019

Abstract:
Deep neural networks are usually huge, which significantly limits the deployment on low-end devices. In recent years, many weight-quantized models have been proposed. They have small storage and fast inference, but training can still be time-consuming. This can be improved with distributed learning. To reduce the high communication cost due to worker-server synchronization, recently gradient quantization has also been proposed to train deep networks with full-precision weights. In this paper, we theoretically study how the combination of both weight and gradient quantization affects convergence. We show that (i) weight-quantized models converge to an error related to the weight quantization resolution and weight dimension; (ii) quantizing gradients slows convergence by a factor related to the gradient quantization resolution and dimension; and (iii) clipping the gradient before quantization renders this factor dimension-free, thus allowing the use of fewer bits for gradient quantization. Empirical experiments confirm the theoretical convergence results, and demonstrate that quantized networks can speed up training and have comparable performance as full-precision networks.

heading: 1 INTRODUCTION
text: Deep neural networks are usually huge. The high demand in time and space can significantly limit deployment on low-end devices. To alleviate this problem, many approaches have been recently proposed to compress deep networks. One direction is network quantization, which represents each network weight with a small number of bits. Besides significantly reducing the model size, it also accelerates network training and inference. Many weight quantization methods aim at approximating the full-precision weights in each iteration (Courbariaux et al., 2015; Lin et al., 2016; Rastegari et al., 2016; Li & Liu, 2016; Lin et al., 2017; Guo et al., 2017). Recently, loss-aware quantization minimizes the loss directly w.r.t. the quantized weights (Hou et al., 2017; Hou & Kwok, 2018; Leng et al., 2018), and often achieves better performance than approximation-based methods.
Distributed learning can further speed up training of weight-quantized networks (Dean et al., 2012). A key challenge is on reducing the expensive communication cost incurred during synchronization of the gradients and model parameters (Li et al., 2014a;b). Recently, algorithms that sparsify (Aji & Heafield, 2017; Wangni et al., 2017) or quantize the gradients (Seide et al., 2014; Wen et al., 2017; Alistarh et al., 2017; Bernstein et al., 2018) have been proposed.
In this paper, we consider quantization of both the weights and gradients in a distributed environment. Quantizing both weights and gradients has been explored in the DoReFa-Net (Zhou et al., 2016), QNN (Hubara et al., 2017), WAGE (Wu et al., 2018) and ZipML (Zhang et al., 2017). We differ from them in two aspects. First, existing methods mainly consider learning on a single machine, and gradient quantization is used to reduce the computations in backpropagation. On the other hand, we consider a distributed environment, and use gradient quantization to reduce communication cost and accelerate distributed learning of weight-quantized networks. Second, while DoReFa-Net, QNN and WAGE show impressive empirical results on the quantized network, theoretical guarantees are not provided. ZipML provides convergence analysis, but is limited to stochastic weight quantization, square loss with the linear model, and requires the stochastic gradients to be unbiased. This can
be restrictive as most state-of-the-art weight quantization methods (Rastegari et al., 2016; Lin et al., 2016; Li & Liu, 2016; Guo et al., 2017; Hou et al., 2017; Hou & Kwok, 2018) are deterministic, and the resultant stochastic gradients are biased.
In this paper, we relax the restrictions on the loss function, and study in an online learning setting how the gradient precision affects convergence of weight-quantized networks in a distributed environment. The main findings are:
1. With either full-precision or quantized gradients, the average regret of loss-aware weight quantization does not converge to zero, but to an error related to the weight quantization resolution ∆w and dimension d. The smaller the ∆w or d, the smaller is the error (Theorems 1 and 2). 2. With either full-precision or quantized gradients, the average regret converges with a O(1/ √ T )
rate to the error, where T is the number of iterations. However, gradient quantization slows convergence (relative to using full-precision gradients) by a factor related to gradient quantization resolution ∆g and d. The larger the ∆g or d, the slower is the convergence (Theorems 1 and 2). This can be problematic when (i) the weight quantized model has a large d (e.g., deep networks); and (ii) the communication cost is a bottleneck in the distributed setting, which favors a small number of bits for the gradients, and thus a large ∆g .
3. For gradients following the normal distribution, gradient clipping renders the speed degradation mentioned above dimension-free. However, an additional error is incurred. The convergence speedup and error are related to how aggressive clipping is performed. More aggressive clipping results in faster convergence, but a larger error (Theorem 3).
4. Empirical results show that quantizing gradients significantly reduce communication cost, and gradient clipping makes speed degradation caused by gradient quantization negligible. With quantized clipped gradients, distributed training of weight-quantized networks is much faster, while comparable accuracy with the use of full-precision gradients is maintained (Section 4).
Notations. For a vector x, √ x is the element-wise square root, x2 is the element-wise square, Diag(x) returns a diagonal matrix with x on the diagonal, and x y is the element-wise multiplication of vectors x and y. For a matrix Q, ‖x‖2Q = x>Qx. For a matrix X, √ X is the element-wise square root, and diag(X) returns a vector extracted from the diagonal elements of X.

heading: 2 PRELIMINARIES

heading: 2.1 ONLINE LEARNING
text: Online learning continually adapts the model with a sequence of observations. It has been commonly used in the analysis of deep learning optimizers (Duchi et al., 2011; Kingma & Ba, 2015; Reddi et al., 2018). At time t, the algorithm picks a model with parameter wt ∈ S, where S is a convex compact set. The algorithm then incurs a loss ft(wt). After T rounds, the performance is usually evaluated by the regret R(T ) = ∑T t=1 ft(wt) − ft(w∗) and average regret R(T )/T , where w∗ =
arg minw∈S ∑T t=1 ft(w) is the best model parameter in hindsight.

heading: 2.2 WEIGHT QUANTIZATION
text: In BinaryConnect (Courbariaux et al., 2015), each weight is binarized using the sign function either deterministically or stochastically. In ternary-connect (Lin et al., 2016), each weight is stochastically quantized to {−1, 0, 1}. Stochastic weight quantization often suffers severe accuracy degradation, while deterministic weight quantization (as in the binary-weight-network (BWN) (Rastegari et al., 2016) and ternary weight network (TWN) (Li & Liu, 2016)) achieves much better performance.
In this paper, we will focus on loss-aware weight quantization, which further improves performance by considering the effect of weight quantization on the loss. Examples include loss-aware binarization (LAB) (Hou et al., 2017) and loss-aware quantization (LAQ) (Hou & Kwok, 2018). Let the full-precision weights from all L layers in the deep network be w. The corresponding quantized weight is denoted Qw(w) = ŵ, where Qw(·) is the weight quantization function. At the (t + 1)th iteration, the second-order Taylor expansion of ft(ŵ), i.e., ft(ŵt) +∇ft(ŵt)>(ŵ− ŵt) + 12 (ŵ− ŵt) >Ht(ŵ − ŵt) is minimized w.r.t. ŵ, where Ht is the Hessian at ŵt. A direct computation of
Ht is expensive. In practice, this is approximated by Diag( √ v̂t), where v̂t is the moving average:
v̂t = βv̂t−1 + (1− β)ĝ2t = ∑t
j=1 (1− β)βt−j ĝ2j , (1)
with gt the stochastic gradient, β ' 1, and is readily available in popular deep network optimizers such as RMSProp and Adam. Diag( √ v̂t) is also an estimate of Diag( √ diag(H2t )) (Dauphin et al., 2015). Computationally, the quantized weight is obtained by first performing a preconditioned gradient descent wt+1 = wt − ηtDiag( √ v̂t) −1ĝt, followed by quantization via solving the following problem:
ŵt+1 = Qw(wt+1) = arg min ŵ ‖wt+1 − ŵ‖2Diag(√v̂t) s.t. ŵ = αb, α > 0, b ∈ (Sw) d. (2)
For simplicity of notations, we assume that the same scaling parameter α is used for all layers. Extension to layer-wise scaling is straightforward. For binarization, Sw = {−1,+1}, the weight quantization resolution is ∆w = 1, and a simple closed-form solution is obtained in (Hou et al., 2017). For m-bit linear quantization, Sw = {−Mk, . . . ,−M1,M0,M1, . . . ,Mk}, where k = 2m−1 − 1, 0 = M0< · · ·<Mk are uniformly spaced, with weight quantization resolution ∆w = Mr+1 −Mr. An efficient approximate solution of (2) is obtained in (Hou & Kwok, 2018).

heading: 2.3 GRADIENT QUANTIZATION
text: In a distributed learning environment with data parallelism, the main bottleneck is often on the communication cost due to gradient synchronization. By quantizing the gradients before synchronization (Seide et al., 2014; Wen et al., 2017; Alistarh et al., 2017), this cost can be significantly reduced. For example, assuming that the full-precision gradient is 32-bit, the communication cost can be reduced 32/m times when gradients are quantized to m bits.
Most recent gradient quantization methods (Wen et al., 2017; Alistarh et al., 2017; Zhang et al., 2017) require the quantized gradient to be unbiased, and thus use stochastically quantized gradients. On the other hand, deterministic gradient quantization makes the quantized gradient biased, and the resultant analysis more complex. In this paper, we consider the more general m-bit stochastic linear quantization (Alistarh et al., 2017):
Qg(gt) = st · sign(gt) qt, (3)
where st = ‖gt‖∞, qt ∈ (Sg)d, and Sg = {−Bk, . . . ,−B1, B0, B1, . . . , Bk}, with k = 2m−1− 1, 0 = B0 < B1 < · · · < Bk are uniformly spaced. The gradient quantization resolution is defined as ∆g = Br+1 − Br. The ith element qt,i in qt is equal to Br+1 with probability (|gt,i|/st −Br) /(Br+1 − Br), and Br otherwise. Here, r is an index satisfying Br ≤ |gt,i|/st < Br+1. Note that Qg(gt) is an unbiased estimator of gt.

heading: 3 PROPERTIES OF A QUANTIZED MODEL
text: In this section, we consider quantization of both weights and gradients in a distributed environment with N workers using data parallelism. For easy illustration, we use the parameter server model (Li et al., 2014b) in Figure 1, though it also holds for other configurations such as the AllReduce model (Rabenseifner, 2004). At the tth iteration, worker n ∈ {1, 2, . . . , N} computes the full-precision gradient ĝ(n)t w.r.t. the quantized weight and quantizes ĝ (n) t to g̃ (n) t = Qg(ĝ (n) t ). The quantized gradients are then synchronized and averaged at the parameter server as: g̃t = 1 N ∑N n=1 g̃ (n) t . The server updates the second moment ṽt based on g̃t, and also the full-precision
weight as wt+1 = wt − ηtDiag( √ ṽt) −1g̃t. The weight is quantized using loss-aware weight quantization to produce ŵt+1 = Qw(wt+1), which is then sent back to all the workers.

heading: 3.1 ASSUMPTIONS
text: Analysis on quantized deep networks has only been performed on models with (i) full-precision gradients and weights quantized by stochastic weight quantization (Li et al., 2017; De Sa et al., 2018), or simple deterministic weight quantization using the sign (Li et al., 2017); (ii) full-precision weights and quantized gradients (Alistarh et al., 2017; Wen et al., 2017; Bernstein et al., 2018);
(iii) quantized weights and quantized gradients (Zhang et al., 2017), but limited to stochastic weight quantization, square loss on linear model (i.e., ft(wt) = (x>t wt−yt)2) in Section 2.1), and unbiased gradient.
In this paper, we study the more advanced loss-aware weight quantization, with both full-precision and quantized gradients. As it is deterministic and has biased gradients, the above analysis do not apply here. Moreover, we do not assume a linear model, and relax the assumptions on ft as:
(A1) ft is convex; (A2) ft is twice differentiable with Lipschitz-continuous gradient; and (A3) ft has bounded gradient, i.e., ‖∇ft(w)‖ ≤ G and ‖∇ft(w)‖∞ ≤ G∞ for all w ∈ S.
These assumptions have been commonly used in convex online learning (Hazan, 2016; Duchi et al., 2011; Kingma & Ba, 2015) and quantized networks (Alistarh et al., 2017; Li et al., 2017). Obviously, the convexity assumption A1 does not hold for deep networks. However, this facilitates analysis of deep learning models, and has been used in (Kingma & Ba, 2015; Reddi et al., 2018; Li et al., 2017; De Sa et al., 2018). Moreover, as will be seen, it helps to explain the empirical behavior in Section 4.
As in (Duchi et al., 2011; Kingma & Ba, 2015; Li et al., 2017), we assume that ‖wm −wn‖ ≤ D and ‖wm − wn‖∞ ≤ D∞ for all wm,wn ∈ S. Moreover, the learning rate ηt decays as η/ √ t, where η is a constant (Hazan, 2016; Duchi et al., 2011; Kingma & Ba, 2015; Li et al., 2017).
For simplicity of notations, we denote the full-precision gradient ∇ft(wt) w.r.t. the full-precision weight by gt, and the full-precision gradient ∇ft(Qw(wt)) w.r.t. the quantized weight by ĝt. As ft is twice differentiable (Assumption A2), using the mean value theorem, there exists p ∈ (0, 1) such that gt − ĝt = ∇ft(wt) − ∇ft(ŵt) = ∇2ft (ŵt + p(wt − ŵt)) (wt − ŵt). Let H′t = ∇2ft(ŵt+p(wt− ŵt)) be the Hessian at ŵt+p(wt− ŵt). Moreover, let α = max{α1, . . . , αT }, where αt is the scaling parameter in (2) at the tth iteration.

heading: 3.2 WEIGHT QUANTIZATION WITH FULL-PRECISION GRADIENT
text: When only weights are quantized, the update for loss-aware weight quantization is wt+1 = wt − ηtDiag( √ v̂t) −1ĝt,
where v̂t is the moving average of the (squared) gradients ĝ2t in (1). Theorem 1. For loss-aware weight quantization with full-precision gradients and ηt = η/ √ t,
R(T ) ≤ D 2 ∞ √ dT
2η √∑T t=1 (1− β)βT−t‖ĝt‖2 + ηG∞ √ d√ 1− β √∑T t=1 ‖ĝt‖2
+ √ LD ∑T t=1 √ ‖wt − ŵt‖2H′t , (4)
R(T )
T ≤ O ( d√ T ) + LD √ D2 + dα2∆2w 4 . (5)
For standard online gradient descent with the same learning rate scheme, R(T )/T converges to zero at the rate of O(1/ √ T ) (Hazan, 2016). From Theorem 1, the average regret converges at the same
rate, but only to a nonzero error LD √ D2 +
dα2∆2w 4 related to the weight quantization resolution
∆w and dimension d.

heading: 3.3 WEIGHT QUANTIZATION WITH QUANTIZED GRADIENT
text: When both weights and gradients are quantized, the update for loss-aware weight quantization is wt+1 = wt − ηtDiag( √ ṽt) −1g̃t,
where g̃t is the stochastically quantized gradient Qg(∇ft(Qw(wt))). The second moment ṽt is the moving average of the (squared) quantized gradients g̃2t . The following Proposition shows that gradient quantization significantly blows up the norm of the quantized gradient relative to its fullprecision counterparts. Moreover, the difference increases with the gradient quantization resolution ∆g and dimension d. Proposition 1. E(‖g̃t‖2) ≤ ( 1+ √ 2d−1 2 ∆g + 1)‖ĝt‖ 2. Theorem 2. For loss-aware weight quantization with quantized gradients and ηt = η/ √ t,
E(R(T )) ≤ D 2 ∞ √ dT
2η √∑T t=1 (1− β)βT−tE(‖g̃t‖2) + ηG∞ √ d√ 1− β √∑T t=1 E(‖g̃t‖2)
+ √ LD ∑T t=1 E( √ ‖wt − ŵt‖2H′t), (6)
E
( R(T )
T
) ≤ O √1 +√2d− 1 2 ∆g + 1 · d√ T + LD√D2 + dα2∆2w 4 . (7)
The regrets in (4) and (6) are of the same form and differ only in the gradient used. Similarly, for the average regrets in (5) and (7), quantizing gradients slows convergence by a factor of √ 1+ √
2d−1 2 ∆g + 1, which is a direct consequence of the blowup in Proposition 1. These obser-
vations can be problematic as (i) deep networks typically have a large d; and (ii) distributed learning prefers using a small number of bits for the gradients, and thus a large ∆g .

heading: 3.4 WEIGHT QUANTIZATION WITH QUANTIZED CLIPPED GRADIENTS
text: To reduce convergence speed degradation caused by gradient quantization, gradient clipping has been proposed as an empirical solution (Wen et al., 2017). The gradient ĝt is clipped to Clip(ĝt), where
Clip(ĝt,i) = { ĝt,i |ĝt,i| ≤ cσ, sign(ĝt,i) · cσ otherwise.
Here, c is a constant clipping factor, and σ is the standard deviation of elements in ĝt. The update then becomes
wt+1 = wt − ηtDiag( √ v̌t) −1ǧt,
where ǧt ≡ Qg(Clip(ĝt)) ≡ Qg(Clip(∇ft(Qw(wt)))) is the quantized clipped gradient. The second moment v̌t is computed using the (squared) quantized clipped gradient ǧ2t .
As shown in Figure 2(a) of (Wen et al., 2017), the distribution of gradients before quantization is close to the normal distribution. Recall from Section 3.3 that the difference between E(‖g̃t‖2) of the quantized gradient g̃t and the full-precision gradient ‖ĝt‖2 is related to the dimension d. The following Proposition shows that E(‖ǧt‖2)/E(‖ĝt‖2) becomes independent of d if ĝt follows the normal distribution and clipping is used.
Proposition 2. Assume that ĝt followsN (0, σ2I), we have E(‖ǧt‖2) ≤ ((2/π) 1 2 c∆g+1)E(‖ĝt‖2).
However, the quantized clipped gradient may now be biased (i.e., E(ǧt) = Clip(ĝt) 6= ĝt). The following Proposition shows that the bias is related to the clipping factor c. A larger c (i.e., less severe gradient clipping) leads to smaller bias.
Proposition 3. Assume that ĝt follows N (0, σ2I), we have E(‖Clip(ĝt) − ĝt‖2) ≤ dσ2(2/π) 1 2F (c), where F (c) = −ce− c 2 2 + √
π 2 (1 + c 2)(1− erf( c√ 2 )), and erf(z) = 2√ π ∫ z 0 e−t 2 dt
is the error function.
Theorem 3. Assume that ĝt followsN (0, σ2I). For loss-aware weight quantization with quantized clipped gradients and ηt = η/ √ t,
E(R(T )) ≤ D 2 ∞ √ dT
2η √∑T t=1 (1− β)βT−tE(‖ǧt‖2) + ηG∞ √ d√ 1− β √∑T t=1 E(‖ǧt‖2)
+ √ LD ∑T t=1 E( √ ‖wt − ŵt‖2H′t) +D ∑T t=1 E( √ ‖Clip(ĝt)− ĝt‖2), (8)
E
( R(T )
T
) ≤ O (√ (2/π) 1 2 c∆g + 1
d√ T
) + LD √ D2 +
dα2∆2w 4
+ √ dDσ(2/π) 1 4 √ F (c). (9)
Note that terms involving g̃t in Theorem 2 are replaced by ǧt. Moreover, the regret has an additional term D ∑T t=1 E( √ ‖Clip(ĝt)− ĝt‖2) over that in Theorem 2. Comparing the average regrets in Theorems 1 and 3, gradient clipping before quantization slows convergence by a factor
of √ (2/π) 1 2 c∆g + 1, as compared to using full-precision gradients. This is independent of d as
the increase in E(‖ǧt‖2) is independent of d (Proposition 2). Hence, a ∆g larger than the one in Theorem 2 can be used, and this reduces the communication cost in distributed learning.
A larger c (i.e., less severe gradient clipping) makes F (c) smaller (Figure 2). Compared with (6) in Theorem 2, the extra error √ dDσ(2/π) 1 4 √ F (c) in (9) is thus smaller, but convergence is also slower. Hence, there is a trade-off between the two. Remark 1. There are two scaling schemes in distributed training with data parallelism: strong scaling and weak scaling (Snavely et al., 2002). In this work, we consider weak scaling, which is more popular in deep network training. In weak scaling, the same data set size is used for each worker. The gradients are averaged over the N workers as1 gt = 1N ∑N n=1 g (n) t . If the gradients before averaging are independent random variables with zero mean, and ‖g(n)t ‖2 is bounded byG2, then E(‖gt‖2) = E(‖ 1N ∑N n=1 g (n) t ‖2) = 1N2E( ∑N n=1 ‖g (n) t ‖2) ≤ G2/N . From Theorems 1-3, the convergence speed with one worker is determined by D 2 ∞ √ dT
2η √∑T t=1(1− β)βT−tE(‖gt‖2) +
ηG∞ √ d√
1−β
√∑T t=1 E(‖gt‖2) ≤ D2∞ √ d 2η √ TG2 + ηG∞ √ d√ 1−β √ TG2 ≤ (D 2 ∞ √ d 2η + ηG∞ √ d√ 1−β ) √ TG2 , while
with N workers by (D 2 ∞ √ d
2η + ηG∞
√ d√ 1−β ) √ TG2/N = ( D2∞ √ d 2η + ηG∞ √ d√ 1−β ) √
(T/N)G2. Thus, with N workers, the number of iterations for convergence is subsequently reduced by a factor of 1/N as compared to using a single worker.

heading: 4 EXPERIMENTS

heading: 4.1 SYNTHETIC DATA
text: In this section, we first study the effect of dimension d on the convergence speed and final error of a simple linear model with square loss as in (Zhang et al., 2017). Each entry of the model parameter
1With a slight abuse of notation, gt here can be the full-precision gradient or quantized gradient with/without clipping.
is generated by uniform sampling from [−0.5, 0.5]. Samples xi’s are generated such that each entry of xi is drawn uniformly from [−0.5, 0.5], and the corresponding output yi fromN (x>i w∗, (0.2)2). At the tth iteration, a mini-batch of B = 64 samples are drawn to form Xt = [x1, . . . ,xB ] and yt = [y1, . . . , yB ]
>. The corresponding loss is ft(wt) = ‖X>t wt − yt‖2/2B. The weights are quantized to 1 bit using LAB. The gradients are either full-precision (denoted FP) or stochastically quantized to 2 bits (denoted SQ2). The optimizer is RMSProp, and the learning rate is ηt = η/ √ t, where η = 0.03. Training is terminated when the average training loss does not decrease for 5000 iterations.
Figure 3(a) shows2 convergence of the average training loss ∑T t=1 ft(wt)/T , which differs from the average regret only by only a constant. As can be seen, for both full-precision and quantized gradients, a larger d leads to a larger loss upon convergence. Moreover, convergence is slower for larger d, particularly when the gradients are quantized. These agree with the results in Theorems 1 and 2.

heading: 4.2 CIFAR-10
text: In this experiment, we follow (Wen et al., 2017) and use the same train/test split, data preprocessing, augmentation and distributed Tensorflow setup.
4.2.1 VARYING d
We first study the effect of d on deep networks. Experiments are performed on two neural network models. The first one is a multi-layer perceptron with one layer of d hidden units (Reddi et al., 2016). The weights are quantized to 3 bits using LAQ3. The gradients are either full-precision (denoted FP) or stochastically quantized to 3 bits (denoted SQ3). The optimizer is RMSProp, and the learning rate is ηt = η/ √ t, where η = 0.1. The second network is the Cifarnet (Wen et al., 2017). We set d to be the number of filters in each convolutional layer. The gradients are either full-precision or stochastically quantized to 2 bits (denoted SQ2). Adam is used as the optimizer. The learning rate is decayed from 0.0002 by a factor of 0.1 every 200 epochs as in (Wen et al., 2017).
Figures 3(b) and 3(c) show convergence of the average training loss for both networks. As can be seen, similar to that in Section 4.1, a larger d leads to larger convergence degradation of the quantized gradients as compared to using full-precision gradients. However, unlike the linear model, a larger d does not necessarily lead to a larger loss upon convergence.
4.2.2 WEIGHT QUANTIZATION RESOLUTION ∆w
We use the same Cifarnet model as in (Wen et al., 2017), with d = 64. Weights are quantized to 1 bit (LAB), 2 bits (LAQ2), or m bits (LAQm). The gradients are full-precision (FP) or stochastically quantized to m = {2, 3, 4} bits (SQm) without gradient clipping. Adam is used as the optimizer. The learning rate is decayed from 0.0002 by a factor of 0.1 every 200 epochs. Two workers are used in this experiment. Figure 4 shows convergence of the average training loss with different numbers of bits for the quantized weight. With full-precision or quantized gradients, weight-quantized networks have larger training losses than full-precision networks upon convergence. The more bits are used, the smaller is the final loss. This agrees with the results in Theorems 1 and 2. Table 1 shows the test
2Legend “W(LAB)-G(FP)” means that weights are quantized using LAB and gradients are full-precision.
set accuracies. Weight-quantized networks are less accurate than their full-precision counterparts, but the degradation is small when 3 or 4 bits are used.
4.2.3 GRADIENT QUANTIZATION RESOLUTION ∆g
We use the same Cifarnet model as in (Wen et al., 2017). Adam is used as the optimizer. The learning rate is decayed from 0.0002 by a factor of 0.1 every 200 epochs. Figure 5 shows convergence of the average training loss with different numbers of bits for the quantized gradients, again without gradient clipping. Using fewer bits yields a larger final error, and using 2- or 3-bit gradients yields larger training loss and worse accuracy than full-precision gradients (Figure 5 and Table 1). The fewer bits for the gradients, the larger the gap. The degradation is negligible when 4 bits are used. Indeed, 4-bit gradient sometimes has even better accuracy than full-precision gradient, as its inherent randomness encourages escape from poor sharp minima (Wen et al., 2017). Moreover, using a larger m results in faster convergence, which agrees with Theorem 2.

heading: 4.2.4 GRADIENT CLIPPING
text: In this section, we perform experiments on gradient clipping, with clipping factor c in {1, 2, 3}, using the Cifarnet (Wen et al., 2017). LAQ2 is used for weight quantization and SQ2 for gradient quantization. Adam is used as the optimizer. The learning rate is decayed from 0.0002 by a factor of 0.1 every 200 epochs. Figure 6(a) shows histograms of the full-precision gradients before clipping. As can be seen, the gradients at each layer before clipping roughly follow the normal distribution, which verifies the assumption in Section 3.4. Figure 6(b) shows the average ‖g̃t‖2/‖ĝt‖2 (for nonclipped gradients) and ‖ǧt‖2/‖ĝt‖2 (for clipped gradients) over all iterations. The dimensionalities (d) of the various Cifarnet layers are “conv1”: 1600, “conv2”: 1600, “fc3”: 884736, “fc4”: 73728,
“softmax”: 1920. Layers with large d have large ‖g̃t‖2/‖ĝt‖2 values, which agrees with Proposition 1. With clipped gradients, ‖ǧt‖2/‖ĝt‖2 is much smaller and does not depend on d, agreeing with Proposition 3. Figure 6(c) shows convergence of the average training loss. Using a smaller c (more aggressive clipping) leads to faster training (at the early stage of training) but larger final training loss, agreeing with Theorem 3.
Figure 7 shows convergence of the average training loss with different numbers of bits for the quantized clipped gradient, with c = 3. By comparing3 with Figure 5, gradient clipping achieves faster convergence, especially when the number of gradient bits is small. For example, 2-bit clipped gradient has comparable speed (Figure 7) and accuracy (Table 1) as full-precision gradient.

heading: 4.2.5 VARYING THE NUMBER OF WORKERS
text: In Remark 1, we showed that using multiple workers can reduce the number of training iterations required. In this section, we vary the number of workers in a distributed learning setting with weak scaling, using the Cifarnet (Wen et al., 2017). We fix the mini-batch size for each worker to 64, and set a smaller number of iterations when more workers are used.
We use 3-bit quantized weight (LAQ3), and gradients are full-precision or stochastically quantized to m = {2, 3, 4} bits (SQm). Table 2 shows the testing accuracies with varying number of workers N . Observations are similar to those in Section 4.2.4. 2-bit quantized clipped gradient has comparable performance as full-precision gradient, while the non-clipped counterpart requires 3 to 4 bits for comparable performance.

heading: FP FP 83.28 83.38 83.76

heading: 4.3 IMAGENET
text: In this section, we train the AlexNet on ImageNet. We follow (Wen et al., 2017) and use the same data preprocessing, augmentation, learning rate, and mini-batch size. Quantization is not performed in the first and last layers, as is common in the literature (Zhou et al., 2016; Zhu et al., 2017; Polino et al., 2018; Wen et al., 2017). We use Adam as the optimizer. We experiment with 4-bit loss-aware weight quantization (LAQ4), and the gradients are either full-precision or quantized to 3 bits (SQ3).
Table 3 shows the accuracies with different numbers of workers. Weight-quantized networks have slightly worse accuracies than full-precision networks. Quantized clipped gradient outperforms the non-clipped counterpart, and achieves comparable accuracy as full-precision gradient.
Figure 8 shows the speedup in distributed training of a weight-quantized network with quantized/full-precision gradient compared to training with one worker using full-precision gradient. We use the performance model in (Wen et al., 2017), which combines lightweight profiling on a single node with analytical communication modeling. We use the AllReduce communication model (Rabenseifner, 2004), in which each GPU communicates with its neighbor until all gradients are accumulated to a single GPU. We do not include the server’s computation effort on weight quantization and the worker’s effort on gradient clipping, which are negligible compared to the forward and backward propagations in the worker. As can be seen from the Figure, even though the number of bits used for gradients increases by one at every aggregation step in the AllReduce model, the proposed method still significantly reduces network communication and speeds up training. When the bandwidth is small (Figure 8(a)), communication is the bottleneck, and using quantizing gradients is significantly faster than the use of full-precision gradients. With a larger bandwidth (Figure 8(b)), the difference in speedups is smaller. Moreover, note that on the 1Gbps Ethernet with quantized gradients, its speedup is similar to those on the 10Gbps Ethernet with full-precision gradients.

heading: 5 CONCLUSION
text: In this paper, we studied loss-aware weight-quantized networks with quantized gradient for efficient communication in a distributed environment. Convergence analysis is provided for weight-quantized models with full-precision, quantized and quantized clipped gradients. Empirical experiments confirm the theoretical results, and demonstrate that quantized networks can speed up training and have comparable performance as full-precision networks.

heading: ACKNOWLEDGMENTS
text: We thank NVIDIA for the gift of GPU card.

heading: A PROOFS
text: A.1 PROOF OF THEOREM 1
First, we introduce the following two lemmas. Lemma 1. Let vt = ∑t j=1(1 − β)βt−jg2j , where β ∈ [0, 1). Assume that ‖gj‖∞ < G∞ for j ∈ {1, 2 . . . , t}. Then,
vt,i ≥ (1− β)g2t,i, (10)√ vt,i ≤ G∞, (11)
‖ √ vt‖ = √√√√ t∑ j=1 (1− β)βt−j‖gj‖2. (12)
Proof. vt,i = ∑t j=1(1− β)βt−jg2j,i ≥ (1− β)g2t,i. Moreover,
√ vt,i = √√√√ t∑ j=1 (1− β)βt−jg2j,i ≤ √√√√ t∑ j=1 (1− β)βt−jG2∞ ≤ G∞,
and
‖ √ vt‖ = √√√√ d∑ i=1 vt,i = √√√√ d∑ i=1 t∑ j=1 (1− β)βt−jg2j,i = √√√√ t∑ j=1 (1− β)βt−j‖gj‖2.
Lemma 2. [Lemma 10.3 in (Kingma & Ba, 2015)] Let g1:T,i = [g1,i, g2,i, . . . , gT,i]> be the vector containing the ith element of the gradients for all iterations up to T , and gt be bounded as in Assumption A3. Then,
T∑ t=1 √ g2t,i t ≤ 2G∞‖g1:T,i‖.
Proof. (of Theorem 1) When only weights are quantized, the update for loss-aware weight quantization is wt+1 = wt − ηtDiag( √ v̂t) −1ĝt. (13)
The update for the ith entry of wt is wt+1,i = wt,i − ηt ĝt,i√ v̂t,i . This implies
(wt+1,i − w∗i )2 = (wt,i − w∗i )2 − 2ηt(wt,i − w∗i ) gt,i√ v̂t,i
+2ηt(wt,i − w∗i ) (gt,i − ĝt,i)√
v̂t,i + η2t ( ĝt,i√ v̂t,i )2.
After rearranging, gt,i(wt,i − w∗i ) = √ v̂t,i
2ηt ((wt,i − w∗i )2 − (wt+1,i − w∗i )2)
+(wt,i − w∗i )(gt,i − ĝt,i) + ηt 2 ( ĝ2t,i√ v̂t,i ). (14)
Since ft is convex, we have
ft(wt)− ft(w∗) ≤ g>t (wt −w∗) = d∑ i=1 gt,i(wt,i − w∗i ). (15)
As ft is convex (Assumption A1) and twice differentiable (Assumption A2),∇2ft LI, where I is the identity matrix. Combining with the assumption in Section 3.1 that ‖wm −wn‖ ≤ D, we have
‖wt −w∗‖2H′t ≤ L‖wt −w ∗‖2 ≤ LD2, ‖wt − ŵt‖2H′t ≤ L‖wt − ŵt‖ 2 ≤ LD2. (16)
Let 〈x,y〉 = x>y be the dot product between two vectors x and y. Combining (14) and (15), sum over all the dimensions i ∈ {1, 2 . . . , d} and over all iterations t ∈ {1, 2, . . . , T}, we have
R(T ) = ∑T
t=1 ft(wt)− ft(w∗)
≤ d∑ i=1
√ v̂1,i
2η1 (w1,i − w∗i )2 + d∑ i=1 T∑ t=2
(√ v̂t,i 2ηt − √ v̂t−1,i 2ηt−1 ) (wt,i − w∗i )2
+ T∑ t=1 〈wt −w∗,gt − ĝt〉+ d∑ i=1 T∑ t=1 ηt 2  ĝ2t,i√ (1− β)ĝ2t,i  ≤ D 2 ∞
2η d∑ i=1 √ T v̂T,i + T∑ t=1 〈H ′ 1 2 t (wt −w∗),H ′− 12 t (gt − ĝt)〉+ ηG∞√ 1− β d∑ i=1 ‖ĝ1:T,i‖
≤ D 2 ∞
2η d∑ i=1 √ T v̂T,i + T∑ t=1 √ ‖wt −w∗‖2H′t √ ‖wt − ŵt‖2H′t + ηG∞√ 1− β d∑ i=1 ‖ĝ1:T,i‖
≤ D 2 ∞
2η d∑ i=1 √ T v̂T,i + ηG∞√ 1− β d∑ i=1 ‖ĝ1:T,i‖+ √ LD T∑ t=1 √ ‖wt − ŵt‖2H′t
≤ D 2 ∞
2η
√ dT √√√√ T∑ t=1 (1− β)βT−t‖ĝt‖2 + ηG∞√ 1− β √ d √√√√ T∑ t=1 ‖ĝt‖2
+ √ LD T∑ t=1 √ ‖wt − ŵt‖2H′t . (17)
The first inequality comes from (10) in Lemma 1. In the second inequality, the first term comes from∑d i=1 √ v̂1,i 2η1 (w1,i −w∗i )2 + ∑d i=1 ∑T t=2
(√ v̂t,i
2ηt − √ v̂t−1,i 2ηt−1 ) (wt,i −w∗i )2 = ∑d i=1 √ v̂T,i 2ηT (wT,i −
w∗i ) 2 and the domain bound assumption in Section 3.1 (i.e., (wT,i −w∗i ) ≤ ‖wT −w∗‖∞ ≤ D∞). The second term comes from the definition of H′t (i.e., H ′− 12 t (gt − ĝt) = H ′ 1 2 t (wt − ŵt)), and Lemma 2. The third inequality comes from Cauchy’s inequality. The fourth inequality comes from (16). The last inequality comes from (12) in Lemma 1.
For m-bit (m > 1) loss-aware weight quantization in (13), as
ŵt = arg minw ‖ŵ −wt‖2Diag(√v̂t−1) = d∑ i=1 √ v̂t−1,i(ŵi − wt,i)2
s.t. ŵ = αtbt, α > 0, b ∈ (Sw)d. If −αtMk ≤ wt,i ≤ αtMk, as √ v̂t−1,i > 0, the optimal ŵt,i satisfies ŵt,i ∈ {αtMr,i, αtMr+1,i}, where r is the index that satisfies αtMr,i ≤ wt,i ≤ αtMr+1,i. Since α = max{α1, . . . , αT }, we have
(ŵt,i − wt,i)2 = min{(αtMr+1,i − |wt,i|)2, (αtMr,i − |wt,i|)2} ≤ ( αtMr+1,i − αtMr,i
2
)2 ≤ α
2∆2w 4 . (18)
Otherwise (i.e., wt,i is exterior of the representable range), the optimal ŵt,i is just the nearest representable value of wt,i. Thus,
(ŵt,i − wt,i)2 = (|wt,i| − αtMk)2 ≤ w2t,i. (19)
From (18) and (19), and sum over all the dimensions, we have
‖ŵt −wt‖2 ≤ dα2∆2w
4 + ‖wt‖2 ≤ dα2∆2w 4 +D2. (20)
From (16) and (20),
‖ŵt −wt‖2H′t ≤ L ( D2 + dα2∆2w 4 ) . (21)
From (21) and Assumption A3, we have from (17)
R(T ) ≤ D 2 ∞dG∞
√ T
2η + ηdG2∞
√ T√
1− β + LD
√ D2 +
dα2∆2w 4 T.
Thus, the average regret is R(T )/T ≤ ( D2∞G∞
2η + ηG2∞√ 1− β ) d√ T + LD √ D2 + dα2∆2w 4 . (22)
A.2 PROOF OF PROPOSITION 1
Lemma 3. For stochastic gradient quantization in (3), E(g̃t) = ĝt, and E(‖g̃t − ĝt‖2) ≤ ∆g‖ĝt‖∞‖ĝt‖1.
Proof. Denote the ith element of the quantized gradient g̃t by g̃t,i. For two adjacent quantized values Br,i, Br+1,i with Br,i ≤ |gt,i|/st < Br+1,i,
E(g̃t,i) = E(st · sign(ĝt,i) · qt,i) = st · sign(ĝt,i) ·E(qt,i) = st · sign(ĝt,i) · (pBr+1,i + (1− p)Br,i) = st · sign(ĝt,i) · (p(Br+1,i −Br,i) +Br,i)
= st · sign(ĝt,i) · |ĝt,i| st = ĝt,i.
Thus, E(g̃t) = ĝt, and the variance of the quantized gradients satisfy
E(‖g̃t − ĝt‖2) = d∑ i=1 (stBr+1,i − |ĝt,i|)(|ĝt,i| − stBr,i)
= s2t d∑ i=1 (Br+1,i − |ĝt,i| st )( |ĝt,i| st −Br,i)
≤ s2t d∑ i=1 (Br+1,i −Br,i) |ĝt,i| st
= ∆g‖ĝt‖∞‖ĝt‖1.
Proof. From Lemma 3,
E(‖g̃t‖2) = E(‖g̃t − ĝt‖2) + ‖ĝt‖2 ≤ ∆g‖ĝt‖∞‖ĝt‖1 + ‖ĝt‖2. Denote {x1, x2, . . . , xd} as the absolute values of the elements in ĝt sorted in ascending order. From Cauchy’s inequality, we have
‖ĝt‖∞‖ĝ‖1 = xd d∑ i=1 xi = d∑ i=1 xdxi ≤ d−1∑ i=1 ( 1 + √ 2d− 1 2 x2i + 1 1 + √ 2d− 1 x2d) + x 2 d
= 1 + √
2d− 1 2 d∑ i=1 x2i = 1 + √ 2d− 1 2 ‖ĝt‖2.
The equality holds iff x1 = x2 = · · · = √
2 1+ √ 2d−1xd. Thus, we have
E(‖g̃t‖2) ≤ ( 1 + √
2d− 1 2 ∆g + 1)‖ĝt‖2.
A.3 PROOF OF THEOREM 2
Proof. When both weights and gradients are quantized, the update is wt+1 = wt − ηtDiag( √ ṽt) −1g̃t. (23)
Similar to the proof of Theorem 1, and using that E(g̃t) = ĝt (Lemma 3), we have
E(R(T )) ≤ d∑ i=1 E(
√ ṽ1,i
2η1 (w1,i − w∗i )2) + d∑ i=1 T∑ t=2 E
( ( √ ṽt,i 2ηt − √ ṽt−1,i 2ηt−1 )(wt,i − w∗i )2 )
+ T∑ t=1 E(〈wt −w∗,gt − g̃t〉) + d∑ i=1 T∑ t=1 ηt 2 E(  g̃2t,i√ (1− β)g̃2t,i )  ≤ D 2 ∞
2η d∑ i=1 E( √ T ṽT,i) + T∑ t=1 E〈H ′ 1 2 t (wt −w∗),H ′− 12 t (gt − ĝt)〉
+ ηG∞√ 1− β d∑ i=1 E(‖g̃1:T,i‖)
≤ D 2 ∞
2η d∑ i=1 E( √ T ṽT,i) + T∑ t=1 E( √ ‖wt −w∗‖2H′t √ ‖wt − ŵt‖2H′t)
+ ηG∞√ 1− β d∑ i=1 E(‖g̃1:T,i‖)
≤ D 2 ∞
2η
√ dTE(‖ √ ṽT ‖) +
ηG∞√ 1− β d∑ i=1 E(‖g̃1:T,i‖)
+ √ LD T∑ t=1 E( √ ‖wt − ŵt‖2H′t)
≤ D 2 ∞
2η
√ dT √√√√ T∑ t=1 (1− β)βT−tE(‖g̃t‖2) + ηG∞√ 1− β √ d √√√√ T∑ t=1 E(‖g̃t‖2)
+ √ LD T∑ t=1 E( √ ‖wt − ŵt‖2H′t).
As (21) in the proof of Theorem 1 still holds, using Proposition 1 and Assumption A3, we have
E(R(T )) ≤ D2∞ 2η √ dT √√√√ T∑ t=1 (1− β)βT−t‖ĝt‖2 + ηG∞√ 1− β √ d √√√√ T∑ t=1 ‖ĝt‖2  · √ 1 + √
2d− 1 2 ∆g + 1 + LD
√ D2 +
dα2∆2w 4
≤ ( D2∞G∞
2η + ηG2∞√ 1− β
) d √ T √ 1 + √
2d− 1 2 ∆g + 1 + LD
√ D2 +
dα2∆2w 4 .
E(R(T )/T ) ≤ ( D2∞G∞
2η + ηG2∞√ 1− β
)√ 1 + √
2d− 1 2 ∆g + 1 d√ T + LD
√ D2 +
dα2∆2w 4 .
A.4 PROOF OF PROPOSITION 2
Proof. From Lemma 3, E(Qg(Clip(ĝt))) = Clip(ĝt),
and E(‖Qg(Clip(ĝt))‖2) ≤ E(∆g‖Clip(ĝt)‖∞‖Clip(ĝt)‖1 + ‖Clip(ĝt)‖2).
As [ĝt]i ∼ N (0, σ2), its pdf is f(x) = 1√2πσ2 e − x2 2σ2 . Thus, E(‖Clip(ĝt)‖1) ≤ E(‖ĝt‖1) = d∑ i=1 E(|[ĝt]i|) = d ∫ +∞ −∞ |x|f(x)dx = 2d ∫ +∞ 0 xf(x)dx
= d ∫ +∞ 0 1√ 2πσ2 e− x2 2σ2 dx2 = d −2σ2√ 2πσ2 e− u 2σ2 ∣∣∣+∞ 0 = (2/π) 1 2 dσ.
As E(‖Clip(ĝt)‖2) ≤ E(‖ĝt‖2), and that E(‖ĝt‖2) = dσ2, we have
E(‖Qg(Clip(ĝt))‖2) ≤ E(∆g‖Clip(ĝt)‖∞‖Clip(ĝt)‖1 + ‖Clip(ĝt)‖2) ≤ ∆gcσ(2/π) 1 2 dσ + E(‖Clip(ĝt)‖2)
≤ ((2/π) 12 c∆g + 1)E(‖ĝt‖2).
A.5 PROOF OF PROPOSITION 3
Proof. E(‖Clip(ĝt)− ĝt‖2) = d( ∫ +∞ cσ (x− cσ)2f(x)dx+ ∫ −cσ −∞ (−x− cσ)2f(x)dx)
≤ 2d ∫ +∞ cσ (x− cσ)2f(x)dx
= 2d√ 2πσ2 σ3(−ce− c 2 2 +
√ π
2 (1 + c2)(1− erf( c√ 2 )))
= (2/π) 1 2 dσ2F (c).
A.6 PROOF OF THEOREM 3
Proof. When both weights and gradients are quantized, and gradient clipping is applied before gradient quantization, the update then becomes
wt+1 = wt − ηtDiag( √ v̌t) −1ǧt. (24)
Similar to the proof of Theorem 1, and using that E(Qg(Clip(ĝt))) = Clip(ĝt), we have E(R(T )) ≤ d∑ i=1 E( √ v̌1,i 2η1 (w1,i − w∗i )2) + d∑ i=1 T∑ t=2 E ( ( √ v̌t,i 2ηt − √ v̌t−1,i 2ηt−1 )(wt,i − w∗i )2 )
+ T∑ t=1 E(〈wt −w∗,gt − ǧt〉) + d∑ i=1 T∑ t=1 ηt 2 E  ǧ2t,i√ (1− β)ǧ2t,i 
≤ D 2 ∞
2η d∑ i=1 E( √ T v̌T,i) + T∑ t=1 E〈wt −w∗,gt − ĝt〉+ T∑ t=1 E〈wt −w∗, ĝt − Clip(ĝt)〉
+ ηG∞√ 1− β d∑ i=1 E(‖ǧ1:T,i‖)
≤ D 2 ∞
2η d∑ i=1 E( √ T v̌T,i) + T∑ t=1 E〈H ′ 1 2 t (wt −w∗),H ′− 12 t (gt − ĝt)〉
+ T∑ t=1 E〈wt −w∗, ĝt − Clip(ĝt)〉+ ηG∞√ 1− β d∑ i=1 E(‖ǧ1:T,i‖)
≤ D 2 ∞ √ dT
2η E(‖ √ v̌T ‖) + ηG∞√ 1− β d∑ i=1 E(‖ǧ1:T,i‖)
+ √ LD T∑ t=1 E( √ ‖wt − ŵt‖2H′t) + T∑ t=1 E( √ ‖wt −w∗‖2 √ ‖(ĝt − Clip(ĝt))‖2)
≤ D 2 ∞ √ dT
2η
√√√√ T∑ t=1 (1− β)βT−tE(‖ǧt‖2) + ηG∞ √ d√ 1− β √√√√ T∑ t=1 E(‖ǧt‖2)
+ √ LD T∑ t=1 E( √ ‖wt − ŵt‖2H′t) +D T∑ t=1 E( √ ‖ĝt − Clip(ĝt)‖2).
(21) in the proof of Theorem 1 still holds. Similar to the proof of Theorem 2, using the domain bound assumption in Section 3.1 (i.e., ‖wm − wn‖ ≤ D and ‖wm − wn‖∞ ≤ D∞ for any wm,wn ∈ S), and Proposition 3, we have
E(R(T )/T ) ≤ ( D2∞G∞
2η + ηG2∞√ 1− β
)√ (2/π) 1 2 c∆g + 1
d√ T
+LD √ D2 +
dα2∆2w 4 + √ dDσ(2/π) 1 4
√ F (c).

Review summaries:
This paper studies the convergence properties of loss-aware weight quantization with different gradient precisions in the distributed environment, in which servers keeps the full-precision weights and workers keeps quantized weights. The authors provided convergence analysis for weight quantization with full-precision, quantized and quantized clipped gradients. Specifically, they find that: 1) the regret of loss-aware weight quantization with full-precision gradient converge to an error related to the weight quantization resolution and dimension d. 2) gradient quantization slows the convergence by a factor related to gradient quantization resolution and dimension d. 3) gradient clipping renders the speed degradation dimension-free.