Year: 2021

Abstract:
Large-batch training has become a commonly used technique when training neural networks with a large number of GPU/TPU processors. As batch size increases, stochastic optimizers tend to converge to sharp local minima, leading to degraded test performance. Current methods usually use extensive data augmentation to increase the batch size, but we found the performance gain with data augmentation decreases as batch size increases, and data augmentation will become insufficient after certain point. In this paper, we propose to use adversarial learning to increase the batch size in large-batch training. Despite being a natural choice for smoothing the decision surface and biasing towards a flat region, adversarial learning has not been successfully applied in large-batch training since it requires at least two sequential gradient computations at each step, which will at least double the running time compared with vanilla training even with a large number of processors. To overcome this issue, we propose a novel Concurrent Adversarial Learning (ConAdv) method that decouple the sequential gradient computations in adversarial learning by utilizing staled parameters. Experimental results demonstrate that ConAdv can successfully increase the batch size on ResNet-50 training on ImageNet while maintaining high accuracy. In particular, we show ConAdv along can achieve 75.3% top-1 accuracy on ImageNet ResNet-50 training with 96K batch size, and the accuracy can be further improved to 76.2% when combining ConAdv with data augmentation. This is the first work successfully scales ResNet-50 training batch size to 96K.

heading: 1 INTRODUCTION
text: With larger datasets and bigger models proposed, training neural networks has become quite timeconsuming. For instance, training BERT (Devlin et al., 2019) takes 3 days on 16 v3 TPUs. GPT-2 (Radford et al., 2019) contains 1,542M parameters and requires 168 hours of training on 16 v3 TPU chips. This also leads to the developments of high performance computing clusters. For example, Google and NVIDIA build high performance clusters with thousands of TPU or GPU chips. How to fully utilize those computing resources for machine learning training thus becomes an important problem.
Data parallelism is a commonly used technique for distributed neural network training, where each processor computes the gradient of a local batch and the gradients across processors are aggregated at each iteration for a parameter update. Training with hundreds or thousands of processors with data parallelism is thus equivalent to running a stochastic gradient optimizer (e.g., SGD or Adam) with a very large batch size, also known as large batch training. For example, Google and NVIDIA showed that by increasing the batch size to 64k on ImageNet, they can finish 90-epoch ResNet training within one minute (Kumar et al., 2021; Mattson et al., 2019).
But why can’t we infinitely increase the batch size as long as more computing resources are available? Large batch training often faces two challenges. First, under a fixed number of training epochs, increasing the batch size implies reducing number of training iterations. Even worse, it has been observed that large-batch training often converges to solutions with bad generalization performance (also known as sharp local minima), possibly due to the lack of inherent noise in each stochastic gradient update. Although this problem can be partially mitigated by using different optimizers such as LARS (You et al., 2017) and LAMB (You et al., 2019), the limit of batch size still exists.
For instance, Google utilizes several techniques, such as distributed batch normalization and Mixedprecision training, to further scale the traing of ResNet-50 on 4096 v3 TPU chips. However, it can just expand the batch size to 64k(Kumar et al., 2021; Ying et al., 2018).
Data augmentation has become an indispensable component of large-batch training pipeline. For instance, researchers at Facebook use augmentation to scale the training of ResNet-50 to 256 NVIDIA P100 GPUs with a batch size of 8k on ImageNet (Goyal et al., 2017). You et al. also use data augmentation to expand the batch size to 32k on 2048 KNL nodes (You et al., 2018). However, in this paper we find that when batch size is large enough (i.e., larger than 32k), the increased diversity in augmented data will also increase the difficulty of training and even have a negative impact on test accuracy.
This motivates us to study the application of adversarial training in large-batch training. Adversarial training methods find a perturbation within a bounded set around each sample to train the model. Previous work finds the adversarial training would lead to a significant decrease in the curvature of the loss surface and make the network more ”linear” in the small batch size case, which could be used as a way to improve generalization (Xie et al., 2020; Moosavi-Dezfooli et al., 2019). However, adversarial training has not been used in large-batch training since it requires a series of sequential gradient computations within each update to find an adversarial example. Even when conducting only 1 gradient ascent for finding adversarial examples, adversarial training requires 2 sequential gradient computations (one for adversarial example and one for weight update) that cannot be parallelized. Therefore, even with infinite computing resources, adversarial training is at least 2 times slower than standard training and increasing the batch size cannot compensate for that.
To resolve this issue and make adversarial training applicable for large-batch training, we propose a novel Concurrent Adversarial Learning (ConAdv) algorithm for large-batch training. We show that by allowing the computation of adversarial examples using staled weights, the two sequential gradient computations in adversarial training can be decoupled, leading to fully parallelized computations at each step. As a result, extra processors can be fully utilized to achieve the same iteration throughput as original SGD or Adam optimizers. Comprehensive experimental results on large-batch training demonstrate that ConAdv is a better choice than existing augmentations.
Our main contributions are listed below:
• This is the first work showing adversarial learning can significantly increase the batch size limit of large-batch training without using data augmentation.
• The proposed algorithm, ConvAdv, can successfully decouple the two sequential gradient computations in adversarial training and make them parallelizable. This makes adversarial training achieve similar efficiency with standard stochastic optimizers when using sufficient computing resources. Furthermore, we empirically show that ConAdv achieves almost identical performance as the original adversarial training. We also provide a theoretical analysis on ConAdv.
• Comprehensive experimental studies demonstrate that the proposed method can push the limit of large batch training on various tasks. For ResNet-50 training on ImageNet, ConAdv alone achieves 75.3% accuracy when using 96K batch size. Further, the accuracy will rise to 76.2% when combined with data augmentation. This is the first method scaling ResNet-50 batch size to 96K with accuracy matching the MLPerf standard (75.9%), while previous methods fail to scale beyond 64K batch size.

heading: 2 BACKGROUND

heading: 2.1 LARGE-BATCH TRAINING
text: Using data parallelism with SGD naturally leads to large-batch training on distributed systems. However, it was shown that extremely large batch is difficult to converge and has a generalization gap (Keskar et al., 2017; Hoffer et al., 2017) . Therefore, related work start to carefully fine-tune the hyper-parameters to bridge the gap, such as learning rate, momentum (You et al., 2018; Goyal et al., 2017; Li, 2017; Shallue et al., 2018) . Goyal et al. try to narrow the generalization gap with the heuristics of learning rate scaling (Goyal et al., 2017). However, there is still big room to increase the batch size. Several recent works try to use adaptive learning rate to reduce the fine-tuning of hyper-parameters and further scaling the batch size to larger value (You et al., 2018; Iandola
et al., 2016; Codreanu et al., 2017; Akiba et al., 2017; Jia et al., 2018; Smith et al., 2017; Martens & Grosse, 2015; Devarakonda et al., 2017; Osawa et al., 2018; You et al., 2019; Yamazaki et al., 2019). You et al. propose Layer-wise Adaptive Rate Scaling (LARS) (You et al., 2017) for better optimization and scaling to the batch size of 32k without performance penalty on ImageNet. Ying et al. use LARS optimizer to train ResNet-50 on TPU Pods in 2.2 minutes. In addition, related work also try to bridge the gap from aspect of augmentation. Goyal et al. use data augmentation to further scale the training of ResNet-50 on ImageNet (Goyal et al., 2017). Yao et al. propose an adaptive batch size method based on Hessian information to gradually increase batch size during training and use vanilla adversarial training to regularize against the sharp minima Yao et al. (2018a). However, the process of adversarial training is time consuming and they just use the batch size of 16k in the second half of training process (the initial batch size is 256). How to further accelerate the training process based on adversarial training and reduce its computational burden is still an open problem.

heading: 2.2 ADVERSARIAL LEARNING
text: Adversarial training has shown great success on improving the model robustness through collecting adversarial examples and injecting them into training data Goodfellow et al. (2015); Papernot et al. (2016); Wang et al. (2019). Madry et al. (2017) formulates it into a min-max optimization framework as follows:
min θ E(xi,yi)∼D[ max||δ||p∈ L(θt, x+ δ, y)], (1)
where D = {(xi, yi)}ni=1 denotes training samples and xi ∈ Rd, yi ∈ {1, ..., Z}, δ is the adversarial perturbation, || · ||p denotes some Lp-norm distance metric, θt is the parameters of time t and Z is the number of classes. Goodfellow et al. proposes FGSM to collect adversarial data Goodfellow et al. (2015), which performs a one-step update along the gradient direction (the sign) of the loss function.
Project Gradient Descent (PGD) algorithm Madry et al. (2017) firstly carries out random initial search in the allowable range (spherical noise region) near the original input, and then iterates FGSM several times to generate adversarial examples. Recently, several papers Shafahi et al. (2019); Wong et al. (2020); Andriushchenko & Flammarion (2020) aim to improve the computation overhead brought by adversarial training. Specifically, FreeAdv Shafahi et al. (2019) tries to update both weight parameter θ and adversarial example x at the same time by exploiting the correlation between the gradient to the input and to the model weights. Similar to Free-adv, Zhang et al. Zhang et al. (2019) further restrict most of the forward and back propagation within the first layer to speedup computation. FastAdv Wong et al. (2020) finds the overhead could be further reduced by using single-step FGSM with random initialization. While these work aim to improve the efficiency of adversarial training, they still require at least two sequential gradient computations for every step. Our concurrent framework could decouple the two sequential gradient computation to further boost the efficiently, which is more suitable for large-batch training. Recently, several works Xie et al. (2020); Cheng et al. (2021); Chen et al. (2021) show that the adversarial example can serve as an augmentation to benefit the clean accuracy in the small batch size setting. However, whether adversarial training can improve the performance of large-batch training is still an open problem.

heading: 2.3 MLPERF
text: MLPerf Mattson et al. (2019) is an industry-standard performance benchmark for machine learning, which aims to fairly evaluate system performance. Currently, it includes several representative tasks from major ML areas, such as vision, language, recommendation. In this paper, we use ResNet-50 He et al. (2016) as our baseline model and the convergence baseline is 75.9% accuracy on ImageNet.

heading: 3 PROPOSED ALGORITHM
text: In this section, we introduce our enlightening findings and the proposed algorithm. We first study the limitation of data augmentation in large-batch training. Then we discuss the bottleneck of adversarial training in distributed system and propose a novel Concurrent Adversarial Learning (ConAdv) method for large-batch training.

heading: 3.1 DOES DATA AUGMENTATION IMPROVE THE PERFORMANCE OF LARGE-BATCH TRAINING?
text: Data augmentation can usually improve generalization of models and is a commonly used technique to improve the batch size limit in large-batch training. To formally study the effect of data augmentation in large-batch training, we train ResNet-50 using ImageNet Deng et al. (2009) by AutoAug (AA) Cubuk et al. (2019). The results shown in Figure 2 reveal that although AA helps improve generalization under batch size ≤ 64K, the performance gain decreases as batch size increases. Further, it could lead to negative effect when the batch size is large enough (e.g., 128K or 256K). For instance, the top-1 accuracy increase from 76.9% to 77.5% when using AA on 1k batch size. However, it decreases from 73.2% to 72.9% under data augmentation when the batch size is 128k and drops from 64.7% to 62.5% when the batch size is 256k. The main reason is that the augmented data increases the diversity of training data, which leads to slower convergence when using fewer training iterations. Recent work try to concat the original data and augmented data to jointly train the model and improve their accuracy (Berman et al., 2019). However, we find that concating them will hurt the accuracy when batch size is large. Therefore, we just use the augmented data to train the model. The above experimental results motivate us to explore a new method for large batch training.

heading: 3.2 ADVERSARIAL LEARNING IN THE DISTRIBUTED SETTING
text: Adversarial learning can be viewed as a way to automatically conduct data augmentation. Instead of defining fixed rules to augment data, adversarial learning conducts gradient-based adversarial attacks to find adversarial examples. As a result, adversarial learning leads to smoother decision boundary Karimi et al. (2019); Madry et al. (2017), which often comes with flatter local minima Yao et al. (2018b). Instead of solving the original empirical risk minimization problem, adversarial learning aims to solve a min-max objective that minimizes the loss under the worst case perturbation of samples within a small radius. In this paper, since our main goal is to improve clean accuracy instead of robustness, we consider the following training objective that includes loss on both natural samples and adversarial samples:
min θ E(xi,yi)∼D[L(θt;xi, yi) + max‖δ‖p∈ L(θt;xi + δ, yi)], (2)
whereL is the loss function and represents the value of perturbation. Although many previous work in adversarial training focus on improving the trade-off between accuracy and robustness Shafahi et al. (2019); Wong et al. (2020), recently Xie et al. show that using split BatchNorm for adversarial and clean data can improve the test performance on clean data Xie et al. (2020). Therefore, we also adopt this split BatchNorm approach.
Update
Update
Sequence 1 Concurrent 1
Sequence 2
Concurrent 2
Concurrent Training (Independet)
First Gradient
Second Gradient
Figure 3: Vanilla Training and Concurrent Training
Algorithm 1 ConAdv for t = 1, · · · , T do
for xi ∈ Bkc,t do Compute Loss: L(θt;xi, yi) using main BN, Lka(θt; x̂i(θt−τ ), yi) using adv BN, LB(θt) = EBkc,tL(θt;xi, yi)+
EBka,t(x̂i(θt−τ ), yi) Minimize the LB(θt) and obtain gkt (θt)
end for for xi ∈ Bkc,t+τ do
Calculate adv gradient gka(θt)on Bkc,t+τ Obtain adv examples (x̂i(θt), yi)
end for end for Aggregate: ĝt(θt) = 1K ∑K k=1 ĝ k t (θt) Update weight θt+1 on parameter sever
For Distributed Adversarial Learning (DisAdv), training data D is partitioned into N local dataset Dk, and D = ∪k=Kk=1 Dk. For worker k, we firstly sample a mini-batch data (clean data) Bkt,c from the local dataset Dk at each step t. After that, each worker downloads the weights θt from parameter sever and then uses θt to obtain the adversarial gradients gka(θt) = ∇xL(θt;xi, yi) on input example xi ∈ Bkt,c. Noted that we just use the local loss E(xi,yi)∼DkL(θt;xi, yi) to calculate the adversarial gradient gka(θt) rather than the global loss E(xi,yi)∼DL(θt;xi, yi), since we aim to reduce the communication cost between workers. In addition, we use 1-step Project Gradient Descent (PGD) to calculate x̂∗i (θt) = xi + α · ∇xL(θt;xi, yi) to approximate the optimal adversarial example x∗i . Therefore, we can collect the adversarial mini-batch Bka,t = {(x̂∗i (θt), yi)} and use both the clean example (xi, yi) ∈ Bkc,t and adversarial example (x̂∗i (θt), yi) ∈ Bka,t to update the weights θt. More specially, we use main BatchNorm to calculate the statics of clean data and auxiliary BatchNorm to obtain the statics of adversarial data.
We show the workflow of adversarial learning on distributed systems (DisAdv) as Figure 1, and more importantly, we notice that it requires two sequential gradient computations at each step which is time-consuming and, thus, not suitable for large-batch training. Specifically, we firstly need to compute the gradient gka(θt) to collect adversarial example x̂
∗. After that, we use these examples to update the weights θt, which computes the second gradient. In addition, the process of collecting adversarial example x̂∗i and use x̂ ∗ i to update the model are tightly coupled, which means that each worker cannot calculate local loss E(xi,yi)∼DkL(θt;xi, yi) and E(xi,yi)∼DkL(θt; x̂∗i , yi) to update the weights θt, until the total adversarial examples x̂∗i are obtained.

heading: 3.3 CONCURRENT ADVERSARIAL LEARNING FOR LARGE-BATCH TRAINING
text: As mentioned in the previous section, the vanilla DisAdv requires two sequential gradient computations at each step, where the first gradient computation is to obtain x̂∗i based on L(θt, xi, yi) and then compute the gradient of L(θt, x̂∗i , yi) to update θt. Due to the sequential update nature, this overhead cannot be reduced even when increasing number of processors — with infinite number of processors the speed of two sequential computations will be twice of one parallel update. This makes adversarial learning unsuitable for large-batch training. In the following, we propose a simple but novel method to resolve this issue, and provide theoretical analysis on the proposed method.
Concurrent Adversarial Learning (ConAdv) As shown in Figure 3, our main finding is that if we use staled weights (θt−τ ) for generating adversarial examples, then two sequential computations can be de-coupled and the parameter update step run concurrently with the future adversarial example generation step.
Now we formally define the ConAdv procedure. Assume xi is sampled at iteration t, instead of the current weights θt, we use staled weights θt−τ (where τ is the delay) to calculate the gradient and further obtain an approximate adversarial example x̂i(θt−τ ):
ga(θt−τ ) = ∇xL(θt−τ ;xi, yi), x̂i(θt−τ ) = xi + α · ga(θt−τ ). (3)
In this way, we can obtain the adversarial sample x̂i(θt−τ ) through stale weights before updating the model at each step t. Therefore, the training efficiency can be improved. The structure of ConAdv as shown in Figure 1: At each step t, each worker k can directly concatenate the clean mini-batch data and adversarial mini-batch data to calculate the gradient ĝkt (θt) and update the model. That is because we have obtain the approximate adversarial example x̂i based on the stale weights θt−τ before iteration t.
In practice, we set τ = 1 so the adversarial examples x̂i is computed at iteration t − 1. Therefore, each iteration will compute the current weight update and the adversarial examples for the next batch:
θt+1 = θt + η
2 ∇θ(E(xi,yi)∼Bt,cL(θt;xi, yi) + Ex̂i,yi∼Bt,aL(θt, x̂i(θt−1), yi)), (4)
x̂i(θt) = xi + α · ∇xL(θt;xi, yi), where (xi, yi) ∈ Bc,t+1, (5)
where Bc,t = ∪k=Kk=1 Bkc,t denotes clean mini-batch of all workers and Ba,t = ∪k=Kk=1 Bka,t represents adversarial mini-batch of all workers. These two computations can be parallelized so there is no longer 2 sequential computations at each step. In the large-batch setting when the number of workers reach the limit that each batch size can use, ConAdv is similarly fast as standard optimizers such as SGD or Adam. The pseudo code of proposed ConAdv is shown in Algorithm 1.

heading: 3.4 CONVERGENCE ANALYSIS
text: In this section, we will show that despite using staled gradient, ConAdv still enjoys nice convergence properties. For simplicity, we will use L(θ, xi) as a shorthand for L(θ;xi, yi) and ‖ · ‖ indicates the `2 norm. Let optimal adversarial example x∗i = arg maxx∗i∈Xi L(θt, x ∗ i ). In order to present our main theorem, we will need the following assumptions.
Assumption 1. The function L(θ, x) satisfies the Lipschitzian conditions:
‖∇xL(θ1;x)−∇xL(θ2;x)‖ ≤ Lxθ‖θ1 − θ2‖, ‖∇θL(θ1;x)−∇θL(θ2;x)‖ ≤ Lθθ‖θ1 − θ2‖, ‖∇θL(θ;x1)−∇θL(θ;x2)‖ ≤ Lθx‖x1 − x2‖, ‖∇xL(θ;x1)−∇xL(θ;x2)‖ ≤ Lxx‖x1 − x2‖.
(6)
Assumption 2. L(θ, x) is locally µ-strongly concave in Xi = {x∗ : ||x∗ − xi||∞ ≤ } for all i ∈ [n], i.e., for any x1, x2 ∈ Xi,
L(θ, x1) ≤ L(θ, x2) + 〈∇xL(θ, x2), x1 − x2〉 − µ
2 ‖x1 − x2‖, (7)
Assumption 2 can be verified based on the relation between robust optimization and distributional robust optimization in Sinha et al. (2017); Lee & Raginsky (2017).
Assumption 3. The concurrent stochastic gradient ĝ(θt) = 12|B| ∑|B| i=1(∇θL(θt;xi)+∇θL(θt, x̂i)) is bounded by the constant M : ‖ĝ(θt)‖ ≤M. (8)
Assumption 4. Suppose LD(θt) = 12n ∑n i=1(L(θt, x∗i ) + L(θt, xi)), g(θt) =
1 2|B| ∑|B| i=1(∇θL(xi) + ∇θL(θt, x∗i )) and E[g(θt)] = ∇LD(θt), where |B| represents batch size . The variance of g(θt) is bounded by σ2:
E[‖g(θt)−∇LD(θt)‖2] ≤ σ2. (9)
Based on the above assumptions, we can obtain the upper bound between original adversarial example x∗i (θt) and concurrent adversarial example x ∗ i (θt−τ ), where τ is the delay time.
Lemma 1. Under Assumptions 1 and 2, we have
‖x∗i (θt)− x∗i (θt−τ )|| ≤ L
µ ||θt − θt−τ‖ ≤ Lxθ µ ητM. (10)
Lemma 1 illustrates the relation between x∗i (θt) and x ∗ i (θt−τ ), which is bounded by the delay τ . When the delay is small enough, x∗i (θt−τ ) can be regarded as an approximator of x ∗ i (θt). We now establish the convergence rate as the following theorem. Theorem 1. Suppose Assumptions 1, 2, 3 and 4 hold. Let loss function LD(θt) = 1 2n ∑n i=1(L(θt;x∗i , yi) + L(θt;xi, yi)) and x̂i(θt−τ ) be the λ-solution of x∗i (θt−τ ): 〈x∗i (θt−τ ) − x̂i(θt−τ ),∇xL(θt−τ ; x̂i(θt−τ ), yi)〉 ≤ λ. Under Assumptions 1 and 2, for the concurrent stochastic gradient ĝ(θ). If the step size of outer minimization is set to ηt = η = min(1/L, √ ∆/Lσ2T ). Then the output of Algorithm 1 satisfies:
1
T T−1∑ t=0 E[||∇LD(θt)||22] ≤ 2σ √ L∆ T + L2θx 2 ( τMLxθ Lµ + √ λ µ )2 (11)
where L = Lθθ + Lxθ2µ Lθx
Our result provides a formal convergence rate of ConAdv and it can converge to a first-order stationary point at a sublinear rate up to a precision of L 2 θx
2 ( τMLxθ Lµ + √ λ µ )
2, which is related to τ . In practice we use the smallest delay τ = 1 as discussed in the previous subsection.

heading: 4 EXPERIMENTAL RESULTS

heading: 4.1 EXPERIMENTAL SETUP
text: Architectures and Datasets. We select ResNet as our default architectures. More specially, we use the mid-weight version (ResNet-50) to evaluate the performance of our proposed algorithm. The dataset we used in this paper is ImageNet-1k, which consists of 1.28 million images for training and 50k images for testing. The convergence baseline of ResNet-50 in MLPerf is 75.9% top-1 accuracy in 90 epochs (i.e. ResNet-50 version 1.5 Goyal et al. (2017)).
Implementation Details. We use TPU-v3 for all our experiments and the same setting as the baseline. We consider 90-epoch training for ResNet-50. For data augmentation, we mainly consider AutoAug (AA). In addition, we use LARS You et al. (2017) to train all the models. Finally, for adversarial training, we always use 1-step PGD attack with random initialization.

heading: 4.2 IMAGENET TRAINING WITH RESNET
text: We train ResNet-50 with ConAdv and compare it with vanilla training and DisAdv. The experimental results of scaling up batch size in Table 1 illustrates that ConAdv can obtain the similar
accuracy compared with DisAdv and meanwhile speeding up the training process. More specially, we can find that the top-1 accuracy of all methods are stable when the batch size is increased from 4k to 32k. After that, the performance starts to drop, which illustrates the bottleneck of large-batch training. However, ConAdv can improve the top-1 accuracy and the improved performance is stable as DisAdv does when the batch size reaches the bottleneck (such as 32k, 64k, 96k), but AutoAug gradually reaches its limitations. For instance, the top-1 accuracy increases from 74.3 to 75.3 when using ConAdv with a batch size of 96k and improved accuracy is 0.7%, 0.9% and 1.0% for 32k, 64k and 96k. However, AutoAug cannot further improve the top-1 accuracy when batch size is 96k. The above results illustrate that adversarial learning can successfully maintain a good test performance in the large-batch training setting and can outperform data augmentation.
In addition, Figure 4(a) presents the throughput (images/ms) on scaling up batch size. We can observe that ConAdv can further increase throughput and accelerate the training process. To obtain accurate statistics of BatchNorm, we need to make sure each worker has at least 64 examples to calculate them (Normal Setting). Thus, the number of cores is [Batch Size / 64]. For example, we use TPU v3-256 to train DisAdv when batch size is 32k, which has 512 cores (32k/64=512). As shown in Figure 4(a), the throughput of DisAdv increases from 10.3 on 4k to 81.7 on 32k and CondAdv achieve about 1.5x speedup compared with DisAdv, which verifies our proposed ConAdv can maintain the accuracy of large-batch training and meanwhile accelerate the training process.
To simulate the speedup when the number of workers reach the limit that each Batch Size can use, we use a large enough distributed system to train the model with the batch size of 512, 1k and 2k on TPU v3-128, TPU v3-256 and TPU v3-512 , respectively. The result is shown in Figure 4(b), we can obtain that ConAdv can achieve about 2x speedup compared with DisAdv. Furthermore, in this scenario we can observe ConAdv can achieve the similar throughput as Baseline (vanilla ResNet-50 training). For example, compared with DisAdv, the throughput increases from 36.1 to 71.3 when using ConAdv with a batch size of 2k. In addition, the throughput is 75.7, which illustrates that ConAdv can achieve a similar speed as baseline. However, ConAdv can expand to larger batch size than baseline. Therefore, ConAdv can further accelerate the training of deep neural network.

heading: 4.3 IMAGENET TRAINING WITH DATA AUGMENTATION
text: To explore the limit of our method and evaluate whether adversarial learning can be combined with data augmentation for large-batch training, we further apply data augmentation into proposed adversarial learning algorithm and the results are shown in Table 2. We can find that ConAdv can further improve the performance of large-batch training on ImageNet when combined with Autoaug (AA). Under this setting, we can expand the batch size to more than 96k, which can improve the algorithm efficiency and meanwhile benefit for the machine utilization. For instance, for ResNet, the top-1 accuracy increases from 74.3 to 76.2 under 96k when using ConAdv and AutoAug.

heading: 4.4 TRAINING TIME
text: The wall clock training times for ResNet-50 are shown in Table 3. We can find that the training time gradually decreases with batch size increasing. For example, the training time of ConAdv decreases
from 1277s to 227s when scale the batch size from 16k to 64k. In addition, we can find that DisAdv need about 1.5x training time compared with vanilla ResNet-50 but ConAdv can efficiently reduce the training of DisAdv to a level similar to vanilla ResNet. For instance, the training time of DisAdv is reduced from 1191s to 677s when using ConAdv. Noted that we don’t
report the clock time for vanilla ResNet-50 at 64k since the top-1 accuracy is below the MLPerf standard 75.9%. The number of machines required to measure the maximum speed at 96K exceeds our current resources. The comparison on 32k and 64k also can evaluate the runtime improvement.

heading: 4.5 GENERALIZATION GAP
text: To the best of our knowledge, theoretical analysis of generalization errors in large-batch setting is still an open problem. However, we empirically found that our method can successfully reduce the generalization gap in large-batch training. The experimental results in Table 4 indicate that ConAdv can narrow the generalization gap. For example, the generalization gap is 4.6 for vanilla ResNet-50 at 96k and ConAdv narrows the gap to 2.7. In addition, combining ConAdv with AutoAug, the training accuracy and test accuracy can further increase and meanwhile maintain the similar generalization gap.

heading: 4.6 ANALYSIS OF ADVERSARIAL PERTURBATION
text: Adversarial learning calculate an adversarial perturbation on input data to smooth the decision boundary and help the model converge to the flat minima. In this section, we analyze the effects of different perturbation values for the performance of large-batch training on ImageNet. The analysis results are illustrated in Table 5. It presents that we should increase the attack intensity as the batch size increasing. For example, the best attack perturbation value increases from 3 (32k) to 7 (96k) for ResNet-50 and from 8 (16k) to 12 (64k). In addition, we should increase the perturbation value when using data augmentation. For example, the perturbation value should be 3 for original ResNet-50 but be 5 when data augmentation is applied.

heading: 5 CONCLUSIONS
text: We firstly analyze the effect of data augmentation for large-batch training and propose a novel distributed adversarial learning algorithm to scale to larger batch size. To reduce the overhead of adversarial learning, we further propose a novel concurrent adversarial learning to decouple the two sequential gradient computations in adversarial learning. We evaluate our proposed method on ResNet. The experimental results show that our proposed method is beneficial for large-batch training.

heading: 6 ETHICS STATEMENT
text: We do not have any potential ethics issues in this paper. We hope to propose a novel distributed adversarial learning algorithm to accelerate large-batch training.

heading: 7 REPRODUCIBILITY STATEMENT
text: We provide our code in Appendix A.4. In addition, we also list our main hyperparameters for largebatch training in Appendix A.4 (Table 6). For experimental details, we introduce our experiment settings in section 4, such as the dataset, model architecture, data augmentation, optimizer and so on.

heading: A APPENDIX
text: A.1 THE PROOF OF LEMMA 1:
Under Assumptions 1 and 2, we have
‖x∗i (θt)− x∗i (θt−τ )‖ ≤ Lxθ µ ‖θt − θt−τ‖ ≤ Lxθ µ ητM (12)
where x∗i (θt) and x ∗ i (θt−τ ) denote the adversarial example of xi calculated by θt and stale weight θt−τ , respectively.
Proof:
According to Assumption 2, we have
L(θt, x∗i (θt−τ )) ≤ L(θt, x∗i (θt)) + 〈∇xL(θt, x∗i (θt)), x∗i (θt−τ )− x∗i (θt)〉− µ
2 ‖x∗i (θt−τ )− x∗i (θt)‖2, ≤ L(θt, x∗i (θt))− µ
2 ‖x∗i (θt−τ )− x∗i (θt)‖2
(13)
In addition, we have
L(θt, x∗i (θt)) ≤ L(θt, x∗i (θt−τ )) + 〈∇xL(θt, x∗i (θt−τ )), x∗i (θt)− x∗i (θt−τ )〉− µ
2 ‖x∗i (θt−τ )− x∗i (θt)‖2
(14)
Combining (13) and (14), we can obtain:
µ‖x∗i (θt−τ )− x∗i (θt)‖2 ≤ 〈∇xL(θt, x∗i (θt)), x∗i (θt)− x∗i (θt−τ )〉 ≤ 〈∇xL(θt, x∗i (θt−τ ))−∇xL(θt−τ , x∗i (θt−τ )), x∗i (θt)− x∗i (θt−τ )〉 ≤ ‖∇xL(θt, x∗i (θt−τ ))−∇xL(θt−τ , x∗i (θt−τ ))‖‖x∗i (θt)− x∗i (θt−τ )‖ ≤ Lxθ‖θt − θt−τ‖‖x∗i (θt)− x∗i (θt−τ )‖
(15)
where the second inequality is due to 〈∇xL(θt−τ , x∗i (θt−τ )), x∗i (θt) − x∗i (θt−τ )〉 ≤ 0, the third inequality holds because CauchySchwarz inequality and the last inequality follows from Assumption 1. Therefore,
‖x∗i (θt)− x∗i (θt−τ )‖ ≤ Lxθ µ ‖θt − θt−τ‖
≤ Lxθ µ ‖ ∑ j∈[1,τ ] (θt−j+1 − θt−j)‖
≤ Lxθ µ ‖ ∑ j∈[1,τ ] ηĝt−j(xi))‖
≤ Lxθ µ ητM
(16)
where the second inequality follows the calculation of delayed weight, the third inequality holds because the difference of weights is calculated with gradient ĝt−j(j ∈ [1, τ ]) and the last inequality holds follows Assumption 3.
Thus,
‖x∗i (θt)− x∗i (θt−τ )‖ ≤ Lxθ µ ητM (17)
This completes the proof.
A.2
Lemma 2. Under Assumptions 1 and 2, we have LD(θ) is L-smooth where L = Lθθ + Lxθ2µ Lθx, i.e., for any θ1 and θ2, we can say
‖∇θLD(θt)−∇θLD(θt−τ )‖ ≤ L‖θt − θt−τ‖ (18)
LD(θt) = LD(θt−τ ) + 〈LD(θt−τ ), θt − θt−τ 〉+ L
t− τ ‖θt − θt−τ‖ (19)
Proof:
Based on Lemma 1, we can obtain:
‖x∗i (θt)− x∗i (θt−τ )‖ ≤ Lxθ µ ‖θt − θt−τ‖ (20)
We can obtain for i ∈ [n]:
‖∇θL(θt, x∗i (θt))−∇θL(θt−τ , x∗i (θt−τ ))‖ ≤‖∇θL(θt, x∗i (θt))−∇θL(θt, x∗i (θt−τ ))‖
+ ‖∇θL(θt, x∗i (θt−τ ))−∇θL(θt−τ , x∗i (θt−τ ))‖ ≤Lθθ‖θt − θt−τ‖+ Lθx‖x∗i (θt)− x∗i (θt−τ )‖
≤Lθθ‖θt − θt−τ‖+ Lθx Lxθ µ ‖θt − θt−τ‖
=(Lθθ + Lθx Lxθ µ )‖θt − θt−τ‖
(21)
where the second inequality holds because Assumption 1, the third inequality holds follows Lemma 1.
Therefore,
‖∇LD(θt)−∇LD(θt−τ )‖2 ≤ ‖ 1
2n n∑ i=1 (∇θL(θt, xi) +∇θL(θt, x∗i (θt)))
− 1 2n n∑ i=1 (∇θL(θt−τ , xi) +∇θL(θt−τ , x∗i (θt−τ )))‖
≤ 1 2n n∑ i=1 ‖∇θL(θt, xi)−∇θL(θt−τ , xi)‖
+ 1
2n n∑ i=1 ‖∇θL(θt, x∗i (θt))−∇θL(θt−τ , x∗i (θt−τ ))‖
≤ 1 2 Lθθ‖θt − θt−τ‖+ 1 2 (Lθθ + Lθx Lxθ µ )‖θt − θt−τ‖
= (Lθθ + Lxθ 2µ Lθx)‖θt − θt−τ‖
(22)
This completes the proof.
A.3
Lemma 3. Let x̂i(θt) be the λ-solution of x∗i (θt): 〈x∗i (θt)− x̂i(θt),∇xL(θt, x̂i(θt))〉 ≤ λ. Under Assumptions 1 and 2, for the concurrent stochastic gradient ĝ(θ), we have
‖g(θt)− ĝ(θt−τ )‖ ≤ Lθx 2
√ λ
µ . (23)
Proof:
‖g(θt)− ĝ(θt−τ )‖ = ‖ 1 2|B| ∑ i∈|B| (∇θL(θt, xi) +∇θL(θt, x∗i (θt))
− (∇θL(θt, xi) +∇θL(θt, x̂i(θt−τ )))‖
= ‖ 1 2|B| ∑ i∈|B| (∇θL(θt, x∗i (θt))−∇θL(θt, x̂i(θt−τ )))‖
≤ 1 2|B| ∑ i∈|B| ‖∇θL(θt, x∗i (θt))−∇θL(θt, x̂i(θt−τ ))‖
≤ 1 2|B| ∑ i∈|B| Lθx‖x∗i (θt)− x̂i(θt−τ )‖
= 1 2|B| ∑ i∈|B| Lθx‖x∗i (θt)− x∗i (θt−τ ) + x∗i (θt−τ )− x̂i(θt−τ )‖
≤ 1 2|B| ∑ i∈|B| (Lθx‖x∗i (θt)− x∗i (θt−τ )‖+ Lθx‖x∗i (θt−τ )− x̂i(θt−τ )‖)
= 1 2|B| ∑ i∈|B| (Lθx‖x∗i (θt)− x∗i (θt−τ )‖+ Lθx‖x∗i (θt−τ )− x̂i(θt−τ )‖)
≤ 1 2|B| ∑ i∈|B| (LθxητM Lxθ µ + Lθx‖x∗i (θt−τ )− x̂i(θt−τ )‖)
(24)
Let x̂i(θt−τ ) be the λ-approximate of x∗i (θt−τ ), we can obtain:
〈x∗i (θt−τ )− x̂i(θt−τ ),∇θL(θt−τ ; x̂i(θt−τ ))〉 ≤ δ (25)
In addition, we can obtain:
〈x̂i(θt−τ )− x∗i (θt−τ ),∇xL(θt−τ , x∗i (θt−τ )) ≤ 0 (26)
Combining 25 and 26, we have:
〈x∗i (θt−τ )− x̂i(θt−τ ),∇θL(θt−τ ; x̂i(θt−τ ))−∇xL(θt−τ , x∗i (θt−τ ))〉 ≤ λ (27)
Based on Assumption 2, we have
µ‖x∗i (θt−τ )− x̂i(θt−τ )‖2 ≤ 〈∇xL(θt−τ , x∗i (θt−τ ))−∇xL(θt−τ , x̂i(θt−τ ), x̂i−x∗i (θt−τ ))〉 (28)
Combining 28 with 27, we can obtain:
µ‖x∗i (θt−τ )− x̂(θt−τ )‖2 ≤ λ (29)
Therefore, we have
‖x∗i (θt−τ )− x̂(θt−τ )‖ ≤
√ λ
µ . (30)
Thus, we can obtain
‖g(θt)− ĝ(θt−τ )‖ ≤ Lθx 2 (ητM Lxθ µ +
√ λ
µ ) (31)
This completes the proof.
A.3 THE PROOF OF THEOREM 1:
Suppose Assumptions 1, 2, 3 and 4 hold. Let ∆ = LD(θ0) − minθ LD(θ), ∇LD(θt) = 1 2n ∑n i=1(∇L(θt, xi, yi) + ∇L(θt, x∗i , yi)). If the step size of outer minimization is set to ηt =
η = min(1/L, √
∆/Lσ2T ), where L = Lθθ + Lxθ2µ Lθx. Then the output of Algorithm 1 satisfies:
1
T T−1∑ t=0 E[‖∇LD(θt)‖2] ≤ 2σ √ L∆ T + L2θx 2 ( τMLxθ Lµ + √ λ µ )2 (32)
where L = (MLθxLxθ/ µ+ Lθθ).
Proof:
LD(θt+1) ≤ LD(θt) + 〈∇LD(θt), θt+1 − θt〉+ L
2 ‖θt+1 − θt‖2
= LD(θt)− η‖∇LD(θt)‖2 + Lη2
2 ||ĝ(θt)‖22 + η〈∇LD(θt),∇LD(θt)− ĝ(θt)〉
= LD(θt)− η(1− Lη
2 )‖∇LD(θt)‖2 + η(1− Lη)〈∇LD(θt),∇LD(θt)− ĝ(θt)〉
+ Lη2
2 ‖ĝ(θt)−∇LD(θt)‖2
= LD(θt)− η(1− Lη
2 )‖∇LD(θt)‖2 + η(1− Lη)〈∇LD(θt), g(θt)− ĝ(θt)〉
+ η(1− Lη)〈∇LD(θt),∇LD(θt)− g(θt)〉+ Lη2
2 ‖ĝ(θt)− g(θt) + g(θt)−∇LD(θt)‖2
≤ LD(θt)− η
2 ‖∇LD(θt)‖22 +
η 2 (1− Lη)‖ĝ(θt)− g(θt)‖2
+ η(1− Lη)〈∇LD(θt),∇LD(θt)− g(θt)〉+ Lη2(‖ĝ(θt)− g(θ)‖22 + ‖g(θt)−∇LD(θt)‖2)
= LD(θt)− η
2 ||∇LD(θt)‖22 +
η 2 (1 + Lη)‖ĝ(θt)− g(θt)‖2
+ η(1− Lη)〈∇LD(θt),∇LD(θt)− g(θt)〉+ Lη2‖g(θt)−∇LD(θt)‖22) (33)
Taking expectation on both sides of the above inequality conditioned on θt, we can obtain:
E[LD(θt+1)− LD(θt)|θt] ≤ − η
2 ||∇LD(θt)‖2 +
η 2 (1 + Lη)( Lθx 2 (ητM Lxθ µ +
√ λ
µ ))2 + Lη2σ2
= −η 2 ‖∇LD(θt)‖2 + η 8 (1 + Lη)(Lθx(ητM Lxθ µ +
√ λ
µ ))2 + Lη2σ2
= −η 2 ‖∇LD(θt)‖2 + ηL2θx 8 (1 + Lη)(ητM Lxθ µ +
√ λ
µ )2 + Lη2σ2
(34)
where we used the fact that E[g(θt)] = ∇LD(θt), Assumption 2, Lemma 2 and Lemma 3. Taking the sum of (34) over t = 0, ..., T − 1, we obtain that:
T−1∑ t=0 η 2 E[‖∇LD(θt)‖2] ≤ E[LD(θ0)−LD(θT )]+ T−1∑ t=0 ηL2θx 8 (1+Lη)(ητM Lxθ µ +
√ λ
µ )2+L T−1∑ t=0 η2σ2
(35) Choose η = min(1/L, √
∆ TLσ2 ) where ∆ = LD(θ0) − LD(θT ) and L = Lθθ + Lxθ 2µ Lθx, we can
show that:
1
T T−1∑ t=0 E[‖∇LD(θt)‖2] ≤ 2σ √ L∆ T + L2θx 2 ( τMLxθ Lµ + √ λ µ )2 (36)
This completes the proof.
A.4 CODE AND HYPERPARAMETERS
CODE:
Our code can be found in this link: https://github.com/conadv/ConAdv
HYPERPARAMETERS:
More specially, our main hyperparameters are shown in Table 6.

Review summaries:
This paper presents a simple algorithm named ConAdv to incorporate adversarial training into the large-batch training setting such that one can further increase the batch size without harming too much accuracy while maintaining the high utilization of the hardware. The core idea is to use adversarial training to improve the accuracy for large batch training and at the same time use stale weights to allow parallel computation of the adversarial example and the normal gradient updates. With his simple yet novel approach, the paper has demonstrated good performance on ImageNet with batch size as large as 96k while maintaining the accuracy above MLPerf's 75.9.

This manuscript empirically show that adversarial training in large-batch training scenario has better performance than traditional data augmentation. And furthermore, the authors proposed a simple method to conduct adversarial example generation and gradient computation w.r.t. to weights concurrently to accelerate the adversarial training in distributed setting. The key strategy is to use staled weights to generate adversarial examples, and then decoupled the bi-level optimization.