<?xml-model href='http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng' schematypens='http://relaxng.org/ns/structure/1.0'?><TEI xmlns="http://www.tei-c.org/ns/1.0">
	<teiHeader>
		<fileDesc>
			<titleStmt><title level='a'>You Already Have It: A Generator-Free Low-Precision DNN Training Framework Using Stochastic Rounding</title></titleStmt>
			<publicationStmt>
				<publisher>Springer</publisher>
				<date>10/23/2022</date>
			</publicationStmt>
			<sourceDesc>
				<bibl> 
					<idno type="par_id">10483558</idno>
					<idno type="doi"></idno>
					<title level='j'>European Conference on Computer Vision (ECCV)</title>
<idno></idno>
<biblScope unit="volume"></biblScope>
<biblScope unit="issue"></biblScope>					

					<author>Geng Yuan</author><author>Sung-En Chang</author><author>Qing Jin</author><author>Alec Lu</author><author>Yanyu Li</author><author>Yushu Wu</author><author>Zhenglun Kong</author><author>Yanyue Xie</author><author>Peiyan Dong</author><author>Minghai Qin</author><author>Xiaolong Ma</author><author>Xulong Tang</author><author>Zhenman Fang</author><author>Yanzhi Wang</author>
				</bibl>
			</sourceDesc>
		</fileDesc>
		<profileDesc>
			<abstract><ab><![CDATA[Stochastic rounding is a critical technique used in low-precision deep neural networks (DNNs) training to ensure good model accuracy. However, it requires a large number of random numbers generated on the fly. This is not a trivial task on the hardware platforms such as FPGA and ASIC. The widely used solution is to introduce random number generators with extra hardware costs. In this paper, we innovatively propose to employ the stochastic property of DNN training process itself and directly extract random numbers from DNNs in a self-sufficient manner. We propose different methods to obtain random numbers from different sources in neural networks and a generator-free framework is proposed for low-precision DNN training on a variety of deep learning tasks. Moreover, we evaluate the quality of the extracted random numbers and find that high-quality random numbers widely exist in DNNs, while their quality can even pass the NIST test suite.]]></ab></abstract>
		</profileDesc>
	</teiHeader>
	<text><body xmlns="http://www.tei-c.org/ns/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink">
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="1">Introduction</head><p>To fully unleash the full power of the deep neural networks (DNNs) on various resource-constrained edge computing devices, DNN model compression <ref type="bibr">[5,</ref><ref type="bibr">39,</ref><ref type="bibr">40]</ref> [ <ref type="bibr">34,</ref><ref type="bibr">26,</ref><ref type="bibr">17,</ref><ref type="bibr">29,</ref><ref type="bibr">28,</ref><ref type="bibr">50,</ref><ref type="bibr">31,</ref><ref type="bibr">22,</ref><ref type="bibr">18]</ref> has become the fundamental element and core enabler to bridge the gap between algorithm innovation and hardware implementation <ref type="bibr">[30,</ref><ref type="bibr">11,</ref><ref type="bibr">35,</ref><ref type="bibr">25,</ref><ref type="bibr">27,</ref><ref type="bibr">48,</ref><ref type="bibr">47,</ref><ref type="bibr">6,</ref><ref type="bibr">49,</ref><ref type="bibr">21,</ref><ref type="bibr">12,</ref><ref type="bibr">13]</ref>. Recently, a surge of research efforts has been devoted to low-precision DNN training to better satisfy the limitation of the computation and storage resources on edge devices <ref type="bibr">[52,</ref><ref type="bibr">53]</ref>. However, the commonly used rounding schemes, such as round-up (ceiling), round-down (floor), or rounding-to-nearest, usually lead to severe accuracy degradation in low-precision training scenarios <ref type="bibr">[14]</ref>. The reason is that the small gradients below the minimum representation precision are always rounded to zero, hence an information loss for weight updates <ref type="bibr">[16]</ref>. Therefore, prior works propose the stochastic rounding scheme to help preserve information and enable low-precision training achieving similar accuracy as the full-precision floating-point training <ref type="bibr">[14,</ref><ref type="bibr">32]</ref>.</p><p>Stochastic rounding is to round up or round down a number (e.g., the gradient) in a probabilistic way. And the probability is proportional to the proximity of the number and its nearby low-precision representation level. In specific, for each time of stochastic rounding and each number to be rounded, a random number needs to be generated to indicate the probabilistic rounding decision.</p><p>However, generating a large number of high-quality random numbers in parallel on hardware-based deep learning platforms such as FPGA and ASIC is not a trivial task <ref type="bibr">[2,</ref><ref type="bibr">24]</ref>. The commonly used solution is to incorporate a large number of random number generators (RNGs) <ref type="bibr">[19]</ref> to generate random numbers on the fly <ref type="bibr">[38,</ref><ref type="bibr">32]</ref>. This will inevitably introduce extra hardware costs and complexity. Many prior works just assume the stochastic rounding can be appropriately incorporated in their design by default but barely care about its actual implementation <ref type="bibr">[43,</ref><ref type="bibr">53,</ref><ref type="bibr">52]</ref>. For example, considering a representative FPGA-based DNN training design <ref type="bibr">[23]</ref>, incorporating stochastic rounding will increase 23% hardware costs (i.e., LUTs) <ref type="bibr">[33]</ref> to fulfill its computation parallelism.</p><p>With the trend of stochastic rounding becoming a "must-do" step in lowprecision DNN training <ref type="bibr">[43,</ref><ref type="bibr">46,</ref><ref type="bibr">53,</ref><ref type="bibr">52]</ref>, we may raise the following question. Is there a more efficient way to obtain the random numbers without using extra hardware? Fortunately, the answer is positive. One important thing that is neglected by the prior works is that the neural network training process is based on a certain degree of randomness, for example, the randomness introduced by the mini-batch training with stochastic gradient descent and the randomly shuffled training samples. This indicates that the neural network itself is supposed to be a potential source of random numbers.</p><p>In this paper, we innovatively propose to employ the stochastic property of the neural network training process to directly extract random numbers from neural networks. We consider the dynamically changed trainable parameters, training data, and intermediate results during the training process can be regarded as source data with randomness, and random numbers with arbitrary bits can be extracted from them. We propose two methods of random number extraction. One is to extract the corresponding number of bits directly from a source data, but the random numbers obtained in this way are heavily affected by the distribution of the source data. Therefore, we further propose the method of extracting the least significant bit (LSB) from multiple source data and synthesizing a random number with multiple bits (e.g., 8 bits). This method greatly improves the randomness of the obtained random numbers.</p><p>Based on that, we argue that when a random number is needed during DNN training, it is not necessary to use an additional random number generator to generate one because you already have it. We can directly extract random numbers from the network by leveraging the stochastic property of the DNN training process. Therefore, we propose a generator-free framework as a more flexible and hardware-economic solution for low-precision DNN training. And we utilize the extracted random numbers for stochastic rounding in a self-sufficient manner to achieve high model accuracy.</p><p>We investigate the quality of random numbers extracted from different types of source data (e.g., trainable parameters, intermediate results). And we find that high-quality random numbers can be widely extracted from certain types of source data (e.g., the gradient of weights) without delicate selections. Most impressively, we find that the extracted random numbers can pass the entire NIST test suite SP800-22 <ref type="bibr">[37]</ref>, which is one of the most widely used testing suits for random numbers. Note that even the most widely used linear-feedback shift register (LFSR)-based random number generator fails some of the tests.</p><p>Moreover, besides obtaining random numbers with uniform distribution needed for stochastic rounding, we further propose a method that can obtain random numbers with arbitrary distributions (e.g., Gaussian and Beta distribution) using the pixels of training data. This further enhances the flexibility of our framework, and it is much more difficult to be achieved when using the conventional hardware-based random number generators.</p><p>To validate the effectiveness of our proposed methods, we conduct comprehensive experiments on a variety of deep learning tasks, including image classification task on CIFAR-10/100 dataset using ResNet-20/ResNet-32 and ImageNet dataset using ResNet-18, image super-resolution task on Set-5 and DIV2K using WDSR, and various natural language processing tasks using BERT. Compared to conventional methods that use random number generators, our generator-free methods can achieve similar accuracy with a 9% reduction in hardware costs.</p><p>The contributions of our paper are summarized as follows:</p><p>-Unlike the conventional methods that require many random number generators, we innovatively propose a generator-free framework, which directly extracts random numbers from the neural network by employing the randomness of the training process. -We explore the validity of different sources for random number extraction.</p><p>Then, we propose different random number extraction methods and analyze the quality of the extracted random numbers. -Our methods can widely extract high-quality random numbers that can pass the entire NIST test suite SP800-22, while the widely used LFSR-based random number generator cannot. -Besides successfully extracting the uniformly distributed random numbers for stochastic rounding, we further propose an image pixel-based method that can obtain random numbers with arbitrary distribution, which is hard to achieve using hardware random number generators. -Finally, we validate the effectiveness of our generator-free framework on various tasks, including image classification, image super-resolution, and natural language processing. Our framework successfully achieves the same accuracy as the convention methods while eliminating the hardware costs of random number generators.</p><p>2 Background</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.1">Rounding Schemes</head><p>Rounding technique has been widely used in a range of scientific fields. It usually occurs when compressing the representation precision of a number. The rounding technique can be generally formulated as follows:</p><p>where Round(x) denotes the rounding scheme applied to a given value x. The &#8970;x&#8971; represents to floor the x to the its nearest representation level. And &#1013; is the representation precision. The probability p(x) &#8712; [0, 1] and the different rounding schemes can be distinguished by using different constraints on p(x).</p><p>For example, the round-up (ceiling) or round-down (floor) scheme sets p(x) = 0 or p(x) = 1 consistently. On the other hand, the probability constraint can also relate to x, such as in the round-to-nearest scheme <ref type="bibr">[1]</ref> and the stochastic rounding scheme <ref type="bibr">[16,</ref><ref type="bibr">14]</ref>. In the round-to-nearest scheme, the probability is set to p(x) = 1 for x &#8712; [0, &#1013; 2 ) and p(x) = 0 for x &#8712; [ &#1013; 2 , &#1013;). Instead of the deterministic rounding schemes above, the stochastic rounding scheme lets p(x) = 1 -x-&#8970;x&#8971; &#1013; , making the expected rounding error to be zero, i.e., E(Round(x)) = x. Therefore, stochastic rounding is considered an unbiased rounding scheme <ref type="bibr">[45]</ref>. Due to the challenges of the intensive computation and storage in DNN training, quantization techniques are commonly used to save hardware resources, which is especially critical for resource-limited devices such as FP-GAs and ASICs. In a low-precision DNN training process, data from several sources are mainly to be quantized, including weights, activations, gradients, and errors <ref type="bibr">[44]</ref>. The later works <ref type="bibr">[46,</ref><ref type="bibr">8]</ref> further propose to quantize the batch normalization (BN) and the optimizer. Among those sources, the model accuracy is largely sensitive to gradient quantization.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.2">Stochastic Rounding in Low-Precision DNN Training</head><p>The prior work <ref type="bibr">[14]</ref> shows that the DNN training is hard to converge under 16-bit precision gradients when using the conventional rounding-to-nearest scheme. And the 16-bit precision is not even a considerably low-precision compared to 8-bit, 4-bit, even the binary precision. The reason is that when using the rounding-to-nearest scheme on low-precision gradients the small gradients below the minimum representation precision are always rounded to zero. This will incur the information loss for weight updates <ref type="bibr">[16]</ref>. And by using stochastic rounding scheme, this issue can be mitigated <ref type="bibr">[14]</ref>. With the help of stochastic rounding, recent works further quantize the gradients to 8-bit precision while still maintaining a comparable accuracy as the full-precision (i.e., floating-point 32 bits) training.</p><p>Many literatures that focus on algorithm optimization for low-precision training assume the stochastic rounding can be appropriately incorporated in their design by default <ref type="bibr">[43,</ref><ref type="bibr">53,</ref><ref type="bibr">52]</ref>, and they barely care about the actual implementation of stochastic rounding on hardware. However, implementing stochastic rounding for low-precision DNN training on hardware is not a trivial task. The stochastic rounding units (SRUs) are commonly used in prior designs <ref type="bibr">[38,</ref><ref type="bibr">32]</ref>. Figure <ref type="figure">1</ref> shows the general SRU design on hardware. Assume 8-bit precision is used for DNN training. The 16-bit input data of a SRU is obtained from the convolution result of 8-bit activations and 8-bit errors. A 8-bit random number generator is needed in each SRU to generate random numbers on the fly. The linear-feedback shift register (LFSR) is usually used as the RNG <ref type="bibr">[33]</ref>. The generated random number will concatenate with eight zeros as its higher bits and add to the input data. Then the stochastic rounded 8-bit gradient can be obtained by cropping the lower 8 bits away on the 16-bit output data of the adder.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3">A Generator-free Framework for Low-Precision DNN Training</head></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.1">Framework Overview</head><p>As we mentioned in Section 2.2, in order to mitigate the information loss and achieve high accuracy, the stochastic rounding technique is indispensable in lowprecision DNN training. Since each gradient requires independent stochastic rounding and a RNG can only generate one random number at each time, in the conventional design, the RNG array modules are used to fulfill the computation parallelism, as shown in Figure <ref type="figure">2</ref> (a). In each RNG array module, there are a large number of RNGs needed. This will introduce considerable hardware costs, especially for high throughput designs. And to make RNGs work independently (i.e., generate independent random numbers), each RNG also needs to have its corresponding seed and mask. This also introduces extra storage overhead.</p><p>In this work, we argue that it is unnecessary to use RNGs to generate random numbers during the DNN training process. The reason is that the DNN training process is based on a certain degree of randomness, such as the minibatch training with stochastic gradient descent and the randomly shuffled training samples. We are supposed to find random numbers directly from the neural network. Therefore, we propose a generator-free framework for low-precision DNN training. As shown in Figure <ref type="figure">2</ref> (b), instead of using RNG arrays, we propose to use a random number extractor module to extract random numbers from different sources in the neural network (in Section 3.2). And we propose two methods to extract random numbers from the source data (in Section 3.3). Besides obtaining the uniformly distributed random numbers used for stochastic rounding, we also find a method that can obtain random numbers with arbitrary distribution (in Section 3.4).</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.2">Source of Random Numbers</head><p>We consider the accessible data during the neural network training as the source data. The source that can be potentially used for random number extracting should satisfy certain characteristics. The first characteristic is that the source data should be dynamically changing and have stochasticity over time during the training process. The second characteristic is that the source should have a large amount of source data that can fulfill the computation parallelism.</p><p>By considering the above characteristics, several candidate sources can be potentially used for random number extraction, including the trainable parameters, intermediate computation results, and input data from training samples, as shown in Figure <ref type="figure">2</ref> (b). However, not all the candidate sources are suitable for random number extraction. For example, the intermediate results (activations) after the ReLU layers will contain a large number of zeros, which significantly biased data distribution. Extracting random numbers from such sources cannot obtain high-quality random numbers with uniform distribution, which is desired for stochastic rounding. Therefore, the model accuracy will degrade considerably.</p><p>In this work, we explore the quality of random numbers extracted from different sources and evaluate the performance of low-precision training using the extracted random numbers. We find that the weights and the gradients of weights can generally be used as good sources to extract high-quality random numbers. On the contrary, the sources such as activations and the errors (the gradient of the Conv layers' outputs) are bad sources for random number extraction, and hence a bad low-precision training accuracy. Note that this bad accuracy can be improved using our proposed number-mapping strategy (will be explained in Section 3.3), but it is still lower than the accuracy achieved by using random numbers extracted from good sources. More details and comparison results are presented in Section 4.3.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Source</head></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.3">Methods of Random Number Extraction</head><p>After determining the potential sources for random number extraction, we also need to have an appropriate method to extract the actual random numbers.</p><p>Method #1: direct source bits extraction. The first method is to directly extract random number with certain bits from the source data. As shown in the left-hand side of Figure <ref type="figure">3</ref>, assuming the source data matrix/tensor could be one layer's weights, gradients, activations, errors, or input pixels of training samples, from each source data in the matrix/tensor we can extract a random number.</p><p>The number of bits to extract depends on the required representation precision of the random number. We prefer to use the n lowest bits (e.g., 3 bits) since they are usually the fraction bits that will change frequently. The random numbers obtained in this method do have a certain degree of randomness; however, they are heavily affected by the distribution of the source data. If the distribution of source data is far from uniform, the accuracy of low-precision training will be compromised. This is because non-uniformly distributed random numbers introduce rounding bias during the training process, while the ideal stochastic rounding is unbiased. Method #2: synthesize using multiple source LSBs. To overcome the non-ideal distribution of the source data, we further propose to synthesize a random number using the least significant bit (LSB) extracted from different source data. As shown in the right-hand side of Figure <ref type="figure">3</ref> of source data is the most frequently changed bit and is independent to other source data. Compared to method #1, the synthesized random numbers have much better quality that is closer to the ideal uniform distribution, making them valid for low-precision DNN training. Though synthesizing random numbers consumes more source data than directly extracting random numbers with certain bits, the synthesized random numbers are still enough to fulfill the computation parallelism due to the adequate sources for the extraction. During DNN training, the extracted random numbers will be directly assigned to the corresponding stochastic rounding unit to replace the RNGs. In this way, the hardware costs of RNGs can be eliminated. Another advantage of our proposed methods is that the extracted/synthesized random numbers are free from periodic repetition, which is a common issue for the RNGs <ref type="bibr">[36]</ref>.</p><p>Figure <ref type="figure">4</ref> shows the quality of extracted random numbers obtained using our methods during a real low-precision DNN training process using ResNet-20 on CIFAR-10 dataset. We pick a location from the second last layer's gradients and observed the random numbers extracted from the same source data location (three locations are picked for the synthesizing method). We collect the extracted random numbers over 20 training epochs. From Figure <ref type="figure">4</ref> (a), (b), (c), and (d) we can see that the synthesizing method provides random numbers with higher quality than the directly extracting method in both the early training stage and late training stage. And Figure <ref type="figure">4</ref> (e) and (f) shows the synthesized random numbers obtained in 80 consecutive training iterations. The high randomness can be observed in both the early training stage and the late training stage. Extraction with Number-Mapping Strategy. As we mentioned in Section 3.2, some source data such as activations (has a large number of zeros) are significantly biased. None of the above two extraction methods can obtain highquality random numbers. When using such bad random numbers for stochastic rounding in low-precision training, the network even cannot converge. However, if we extract random numbers (e.g., 3-bits) and use a simple mapping strategy which maps the extracted even numbers to the middle numbers within the range (e.g., {0, 1, 2, 3, 4, 5, 6, 7} &#8594; {3, 1, 2, 7, 4, 6, 5, 0}), then the extracted random numbers will form a bell-like distribution. This can effectively improve the trained model accuracy. Though this method cannot outperform the model accuracy obtained by extracting random numbers from good sources, it still has better accuracy than using nearest rounding. The reason is that the bell-like distribution makes the rounding becomes a hybrid scheme between the ideal stochastic rounding (with uniform random number distribution) and nearest rounding. It mitigates the biases introduced by the bad data distribution while preserving a certain degree of randomness. But we still suggest directly extracting high-quality random numbers from good sources. More details are discussed in Appendix.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.4">Obtaining Random Numbers with Arbitrary Distribution</head><p>In our generator-free framework, besides extracting the uniformly distributed random numbers for stochastic rounding, we further propose a novel imagepixel-based random number extraction method that can extract random numbers with an arbitrary distribution. And this is hard to be achieved in conventional methods using fixed hardware random number generators.</p><p>As shown in Figure <ref type="figure">5</ref>, in DNN training, the training samples in a training dataset will be divided into several mini-batches. If we look at the value of the same pixel location over a training epoch (i.e., n mini-batches), we will find the values of a pixel location scattered within a range following a certain distribution. In each training epoch, every training sample is guaranteed to be used once, but the order of the training samples used is different due to the dataset shuffling for each training epoch. This indicates two facts: &#9312; the value distribution of a pixel location will remain the same over the entire training process; &#9313; the order of values presented in a pixel location is varied between different epochs. These two properties give us a unique opportunity for random number extraction. In our method, we divide the value range of a pixel location into 2 n intervals (e.g., 8 intervals for 3-bit random number, as shown in Figure <ref type="figure">5</ref>) using 2 n -1 threshold levels. Then, depending on the interval in which the pixel value is located, the corresponding random number can be obtained. Since the value distributions of different pixel locations are varied, each pixel requires its own threshold levels. The threshold levels are unique for a certain dataset and can be easily obtained offline. For each training mini-batch, each pixel of input image can create a random number. It is worth noting that the content in the edge pixels of images are often the background. As a result, the values of those edge pixels are more likely to be concentrated in very large or small, making it possible that some intervals are indistinguishable and fail to obtain the well-distributed random numbers. Therefore, we exclude the edge pixels for random number extraction.</p><p>In Figure <ref type="figure">5</ref>, we show a real example that uses our image-pixel-based method obtaining random numbers with the beta distribution (&#945; = 1, &#946; = 2). It can be observed that a high-quality beta distribution is obtained. Besides, we can also obtain other desired distributions by simply modifying the threshold levels. And the threshold arrays can be easily generated offline by going over the training dataset once. More details are shown in Appendix.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4">Results</head></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.1">Experiments Setup</head><p>In this Section, we evaluate our proposed framework and methods on various practical deep learning tasks, including image classification task, image superresolution task , and natural language processing tasks. All of our models including the full-precision (FP) models and the low-precision (LP) models are trained on a GPU server with 4&#215; NVIDIA 2080Ti GPUs. The PyTorch framework is used for model training. For the low-precision training, we quantize all weights, activations, gradients, and errors using fewer bits (detailed numbers are given in corresponding result tables). The "Ours" method in the result tables indicates the results obtained using our generator-free framework, which extracts random numbers from the network as we proposed. To make fair comparisons, in the "LP" method, we adopt the same training hyperparameters as our generatorfree method, but with the random numbers generated from the simulated RNGs. We simulate the behavior of LFSR-based RNGs to generate random numbers for the "LP" method. For all our results, if not specified, they are extracted from the gradients of the model's second layer by synthesizing using multiple source LSBs method (i.e., Method#2) and without using number-mapping strategy. We mainly evaluate four different extraction sources including the activations (i.e., Conv outputs, before BN and ReLU), errors (the gradients of activations), weights, and gradient (of weights).</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.2">Accuracy of Low-precision DNN Training</head><p>Accuracy for Image Classification. We evaluate our framework on CIFAR-10/100 dataset <ref type="bibr">[20]</ref> using ResNet-20/32 <ref type="bibr">[15]</ref>. The results are shown in Table <ref type="table">1</ref>. The 8-bit precision and 6-bit precision are used, respectively. For the 8-bit precision results on CIFAR-10, we compare our method with Zhu et al. <ref type="bibr">[53]</ref>. Both of methods achieve similar accuracy as the FP result, thanks to the superiority of stochastic rounding. However, 16-bit RNGs are required in Zhu et al. <ref type="bibr">[53]</ref>, while we are generator-free. With the 6-bit precision, though both the LP method and our method have around 0.3% accuracy degradation, our method still achieves similar accuracy as the LP method. For the results on CIFAR-100 using ResNet-32, since the CIFAR-100 task is harder than CIFAR-10, all results with 8-bit precision start to have a minor accuracy degradation compared to the FP result. And for both 8-bit precision and 6-bit precision, our generator-free method can achieve similar accuracy as the LP method that requires RNGs.</p><p>Table <ref type="table">2</ref> shows the results on ImageNet dataset <ref type="bibr">[7]</ref> using ResNet-18. Our generator-free method achieve the same accuracy as the floating point training result. We have a clear advantage compared to nearest rounding method. More importantly, our method also outperforms the hardware random number generator-based method (LP stochastic ) with a 0.4% margin. The reason is that our extracted random numbers have higher quality, which has a more critical impact on the harder dataset (ImageNet v.s. CIFAR).</p><p>Accuracy for Other Tasks. Table <ref type="table">3</ref> shows the comparison results for image super-resolution task using WDSR-B network <ref type="bibr">[10]</ref>. The model is trained on DIV2K <ref type="bibr">[41]</ref> dataset and tested on Set-5 <ref type="bibr">[3]</ref> and DIV2K dataset. We evaluate our framework using input size of 640&#215;360 and 320&#215;180 for 2&#215; and 4&#215; resolution up scaling, respectively. And Table <ref type="table">4</ref> shows the evaluation results for natural language processing (NLP) tasks using BERT <ref type="bibr">[9]</ref> on a variety of datasets from the General Language Understanding Evaluation (GLUE) <ref type="bibr">[42]</ref> benchmark. From the results, we can observe that the image super-resolution task is more sensitive to low-precision training compared to classification and NLP tasks. Our generatorfree method consistently achieves similar accuracy as the conventional method, which validates the effectiveness of our proposed methods and framework.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.3">Comparison of Different Extraction Sources</head><p>We first investigate the low-precision training model accuracy using extracted random numbers from different sources including activations, errors, weights, and gradients. And for each type of source, we also cover different layers from the first, middle, and last part of the model. From Table <ref type="table">5</ref> we can find consistent phenomenons on both datasets. The errors are the worst source for random number extraction, and its later layers are relatively better than the front layers. This is because the errors generally contain a dominant number of zeros in low-precision training, which will significantly bias the distribution of random numbers. The weights and gradients are the two of the good sources which can achieve high training accuracy because they generally tend to have a normal distribution which will make the LSB has relatively balanced zeros and ones. However, based on our observations, we found the weights have a much lower flipping rate on their LSB compared to the gradients. We conjecture that this is caused by the low-precision representation in training, which limits the small perturbation on weights to a certain degree compared to the floating-point 32-bit training. This makes the gradient a better source for random number extraction. The evaluation of information entropy will be shown in Section 4.4 and more discussions can be found in Appendix.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.4">Randomness Tests and Hardware Saving</head><p>To quantitatively evaluate the quality of the extracted random numbers, we test the information entropy of the random numbers throughout the training process. The results are shown in Table <ref type="table">6</ref>. We can find that the random numbers extracted from weight and gradient have highest information entropy and they are close to 6-bit. Combining the accuracy results from the Table <ref type="table">5</ref>, we can find a positive relationship between the information entropy and the final low-precision training accuracy. We also test the quality of extracted random numbers using the widely used NIST test suite SP800-22 <ref type="bibr">[37]</ref>. And we surprisingly find that the random numbers extracted from gradients can generally pass the entire tests, which indicates the random numbers has very high quality. Note that even the widely used LFSR-based random number generators can fail the NIST test. More details are discussed in Appendix.</p><p>From the hardware perspective, compared to hardware-based random number generators, our generator-free approach does not require any arithmetic or logical expressions (do no use LUT), and thus is more hardware-friendly and enables resource-efficient design implementations. We estimate the LUT saving using Xilinx Vitis high-level synthesis (HLS) tool and based on the representative FPGA-based DNN training design methodology <ref type="bibr">[23]</ref> with LFSR-based stochastic rounding unit (SRU) design <ref type="bibr">[33]</ref>. We can successfully save 38.5% and 9% LUTs costs of the SRU and the overall design, respectively. Note that the LUTs are considered a tight resource in FPGA-based DNN training design. Generally, a design prefers not to reach a high LUTs utilization rate since it will lead to routing problems on the FPGA that can significantly slow down the working frequency <ref type="bibr">[51]</ref>. Even in the FPGA vendor's (Xilinx) design <ref type="bibr">[4]</ref>, the LUT utilization does not pass 70% on edge FPGA (PYNQ-Z1) or 50% on cloud FPGAs (AWS F1). Therefore, the LUTs reduction achieved by our method is considerable.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.5">Discussion and Future Works</head><p>In this paper, we pave a new way to obtain random numbers for low-precision training. We explore the performance of different types of sources heuristically, and a systematic exploration can be done for future works. By finding a large number of high-quality random numbers that can be easily extracted from DNNs, our work may also inspire more research in the security field. Moreover, besides the random numbers used by stochastic rounding, our image-pixel-based method can also extract random numbers with arbitrary distribution, which can be potentially used for a broader range of tasks and is worth being further investigated.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5">Conclusion</head><p>In this paper, we argue that when random numbers are needed during the DNN training, it is unnecessary to pay extra hardware costs for random number generators because we already have them. Therefore, we explore the validity of different sources and methods for high-quality random number extraction. We propose a generator-free framework to extract and use the random numbers during low-precision DNN training. Moreover, we propose an image-pixel-based method that can extract random numbers with arbitrary distribution, which is hard to achieve using hardware random number generators. Our framework successfully achieves the same accuracy as the convention methods while eliminating the hardware costs of random number generators.</p></div></body>
		</text>
</TEI>
