Sparse on-chip training hardware accelerator architecture and implementation method thereof
By designing a sparse on-chip training hardware accelerator architecture in the DCNN model, and using singular value decomposition and mixed precision quantization, the high bandwidth and energy consumption problems during dynamic training of the DCNN model on edge devices are solved, and efficient computing and memory access optimization are achieved. Improved training performance and energy efficiency.
Patent Information
- Application Number
- CN202410984295.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-22
- Publication Date
- 2024-10-11
AI Technical Summary
The performance of existing deep convolutional neural network (DCNN) models decreases in actual deployment, especially when dynamic training on edge devices faces the problems of high bandwidth requirements, computing power requirements, storage requirements and energy consumption, and static training models cannot be timely Dealing with time-varying environments, resulting in increased data transfer delays and costs.
A sparse on-chip training hardware accelerator architecture is designed, using algorithm and hardware architecture collaborative design, including off-chip DRAM, on-chip storage system, computing controller, forward propagation and reverse error propagation computing unit array, and weight gradient generation computing unit array , batch normalization layer calculation module, sparse matrix data compression module and activation and pooling calculation module, realize low-rank decomposition and quantization through singular value decomposition and mixed precision data quantization, and optimize forward propagation and reverse error propagation calculation units Array of hardware logic circuits.
It effectively reduces the amount of calculation and memory access required for training, improves the equivalent computing power of the accelerator, reduces the amount of floating point operations and memory access, improves the PE array utilization, and realizes an efficient on-chip training accelerator with throughput, The area efficiency and energy efficiency reach 38.02TOPS, 41.2GOPS/mm2 and 90.63TOPS/W respectively.
Smart Images

Figure CN118760651A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of on-chip self-learning accelerated computing of artificial intelligence chips, and specifically relates to a sparse on-chip training hardware accelerator architecture and an implementation method thereof. Background Art
[0002] In recent years, with the explosive growth of various algorithms and data sets, deep convolutional neural networks (DCNN) have gradually played an increasingly important role in our real life. Unlike traditional algorithms, deep neural networks can complete tasks that require high abstraction, such as computer vision and natural language processing. Although these deep neural network algorithms have excellent performance, as the application scenarios become more complex, the scale of the network also increases, and the amount of computation increases sharply. In order to meet the performance requirements of accuracy and speed when applying DCNN, scholars at home and abroad have proposed a variety of accelerator architectures for deep neural network inference to balance algorithm accuracy and hardware efficiency, such as Eyeriss, TPU, etc. However, it should be noted that the data of real application scenarios and the data of DCNN offline training often do not meet the independent and identically distributed assumption. This inherent problem will inevitably lead to a serious reduction in the performance of the DCNN model in actual deployment. In addition, privacy issues and large amounts of data communication overhead also require edge devices to have online learning capabilities. On the one hand, although users hope that applications can be more personalized during use, in order to protect personal privacy, users always prefer to adjust DCNN models on local devices rather than transferring local data to the cloud to help DCNN models continue training; on the other hand, in many application scenarios that require real-time multi-task execution and are dynamic (such as self-driving cars), static training models cannot handle time-varying environments in a timely and effective manner. However, uploading a large amount of newly collected environmental data to the cloud for incremental model training causes high data transmission delays, and the resulting cost increase is usually unacceptable. Therefore, enabling DCNN models that have been deployed on edge devices to have online learning capabilities is very necessary to solve the above problems, and this has become a key research trend.
[0003] The key to online learning lies in more efficient on-chip training optimization techniques and the design of corresponding neural network hardware. Neural network hardware is a multidisciplinary and cross-disciplinary research field that uses specially designed hardware circuits to map and process neural network algorithms. However, due to strict hardware resource constraints, dynamic training of DCNN models on edge devices is extremely challenging. Compared with inference tasks, training tasks face severe problems such as higher bandwidth requirements, higher computing power requirements, higher storage requirements, and higher energy consumption. In response to these problems, researchers have proposed various DCNN on-chip training accelerator designs in order to achieve a better trade-off between algorithm accuracy and hardware efficiency. These on-chip training accelerators can be divided into two categories. The first type of accelerators aims to accelerate the training stages that were originally based on intensive calculations, while the second type further improves the performance of hardware accelerators by developing and utilizing the data sparsity of DCNN models. However, there is still a huge gap between the performance achieved by the accelerator designs proposed in previous work and the actual application requirements, and there are still many problems that need to be explored. Summary of the invention
[0004] In order to ensure the training quality of the DCNN model when it runs on an on-chip training accelerator, while effectively reducing the hardware consumption of the system and improving energy efficiency, the present invention provides a sparse on-chip training hardware accelerator architecture and an implementation method thereof, and adopts a method of collaborative design of algorithms and hardware architecture to improve the computational efficiency and hardware efficiency of DCNN on-chip training.
[0005] In order to achieve the above object, the present invention adopts the following technical solution:
[0006] A sparse on-chip training hardware accelerator architecture includes: an off-chip DRAM, an on-chip storage system, a computing controller FSM Ctrl, a forward propagation and reverse error propagation computing unit array FP / EP PE, a weight gradient generation computing unit array WG PE, a batch normalization layer computing module ACBN, a sparse matrix data compression module flag-CSR, and an activation and pooling computing module; wherein,
[0007] Off-chip DRAM, used to store input data, network initial weights, and intermediate calculation results, which is connected to the on-chip storage system;
[0008] The on-chip storage system is used to temporarily store the weights, input and output neurons, and feature gradient data required for the current calculation. It is connected to the off-chip DRAM, the weight gradient generation calculation unit array WG PE, the batch normalization layer calculation module ACBN, and the sparse matrix data compression module flag-CSR for data transmission and exchange;
[0009] The computing controller FSM Ctrl is used to control the computing process of each computing module in the accelerator and the read and write status of the storage system according to the current state and some counter values, and is connected to the control part of all modules in the accelerator;
[0010] The forward propagation and reverse error propagation calculation unit array FP / EP PE is used to calculate the forward reasoning and reverse error propagation process of the deep neural network. It reads data from the on-chip storage system and sends the data to the batch normalization layer calculation module ACBN after the calculation is completed;
[0011] The weight gradient generation calculation unit array WG PE is used to calculate the weight gradient generation and update process of the deep neural network. It is connected to the on-chip storage system to obtain data and write calculation results;
[0012] The batch normalization layer calculation module ACBN is used to complete the calculation of the batch normalization layer in the deep neural network. It reads data from the forward propagation and reverse error propagation calculation unit array FP / EP PE or the on-chip storage system for calculation, and sends the result to the sparse matrix data compression module flag-CSR;
[0013] The sparse matrix data compression module flag-CSR is used to compress the output neurons into the final sparse matrix compression format. It obtains data from the batch normalization layer calculation module ACBN for compression and sends the compressed data to the on-chip storage system;
[0014] The activation and pooling calculation module is used to complete the calculation of the activation layer and the pooling layer in the deep neural network. It is connected to the batch normalization layer calculation module ACBN for data exchange.
[0015] A further improvement of the present invention is that the forward propagation and reverse error propagation calculation unit array FP / EP PE is a three-dimensional structure composed of a data sorting module DR, a U array, a V array and an addition tree AT array; wherein the data sorting module DR adopts a bitonic sorting method, and is responsible for sorting the input data in ascending order according to the column index and then transmitting it to the U array or the V array for subsequent calculation; the U array is composed of a shifter, and the V array is composed of a multiplier VM and an adder VA; in the DCNN forward propagation process, the forward propagation and reverse error propagation calculation unit array FP / EP PE is configured as a "DR-U-AT-VM-VA" pipeline calculation mode, and in the reverse error propagation stage it is configured as a "DR-VM-U-AT-VA" pipeline calculation mode.
[0016] A further improvement of the present invention is that the forward propagation and reverse error propagation calculation unit arrays FP / EP PE simultaneously support dynamic gating of sub-vectors in the standard convolutional layer matrix U and the matrix V according to model configuration information, omitting related calculations of some sub-vectors.
[0017] A further improvement of the present invention is that the weight gradient generation calculation unit array WG PE is a two-dimensional structure composed of multipliers, shifters and adders; different PE rows correspond to parallel calculations of different input feature gradient maps, and PEs with the same number in different PE rows correspond to the same input feature map.
[0018] A further improvement of the present invention is that the weight gradient generation calculation unit array WG PE is a six-stage pipeline calculation structure; in the WG calculation stage, for each PE row, the sparsely coded input feature gradient row dX is first decoded and stored in a local register; then, the sparsely coded input feature value X is input to the weight gradient generation calculation unit array WGPE, and a multiplication-accumulation operation is performed with the corresponding dX to obtain the partial sum of dW; next, the partial sum of dW is shifted-added using the U subvector to obtain the partial sum of dV; finally, after all input feature maps are calculated, the partial sum of dV is transmitted to the adder for accumulation between different input channels.
[0019] A further improvement of the present invention is that the sparse matrix data compression module flag-CSR is composed of a detector and a counter, which is responsible for compressing the output neuron into the final sparse matrix compression format and finally transmitting it to the storage system; the output eigenvalue X or feature gradient dX is calculated from the batch normalization layer calculation module ACBN and the activation and pooling calculation module, and is transmitted one by one to the sparse matrix data compression module flag-CSR; wherein the detector is used to detect whether the input is zero, and if the input is equal to zero, the counter is increased by 1; once a non-zero value is detected, the value of the counter is the column index of the current non-zero value; when the count value of the counter is equal to the row size, the highest flag bit of the last encoded non-zero value will be set to 1; after the compression is completed, the encoded value will be stored in the corresponding first-in-first-out memory.
[0020] A method for implementing a sparse on-chip training hardware accelerator, characterized in that the method is based on the sparse on-chip training hardware accelerator, comprising:
[0021] The singular value decomposition (SVD) is used to decompose the weight matrix in the deep convolutional neural network (DCNN) model into a low-rank matrix. nA mixed-precision data quantization scheme is proposed that combines quantization with retaining high-bit-width precision, and the hardware logic circuits of the forward propagation and reverse error propagation calculation unit arrays FP / EP PE and the weight gradient generation calculation unit array WG PE are designed. Finally, the peripheral control and storage circuits are designed and combined to obtain a sparse on-chip training hardware accelerator.
[0022] A further improvement of the present invention is that the specific implementation steps of the method are:
[0023] 1) The DCNN model is pre-trained offline on the cloud or server using a public dataset until convergence to obtain a pre-trained model;
[0024] 2) Decompose the original weight tensor of each layer in the pre-trained model through SVD calculation to obtain an orthogonal matrix U, a diagonal matrix Σ and another orthogonal matrix V′;
[0025] 3) Quantize the decomposed matrix U to 2 n , and multiply the singular values in the matrix Σ with the corresponding subvectors in the matrix V′ to obtain a new matrix V;
[0026] 4) According to the computational characteristics of the low-rank decomposition of the pre-trained model weights, the forward propagation and reverse error propagation calculation unit arrays FP / EP PE and the weight gradient generation calculation unit array WG PE hardware logic circuits are designed using Verilog and SystemVerilog hardware description languages;
[0027] 5) Based on the two computing unit array circuits obtained in 4), the peripheral control, storage and auxiliary computing module circuits are designed using Verilog and SystemVerilog hardware description languages to obtain a neural network accelerator functional component that supports the low-rank decomposition and quantization;
[0028] 6) According to the architectural hierarchy of each layer in the pre-trained deep neural network model, the accelerator functional components and the deep neural network accelerator general components are combined to build a sparse on-chip training hardware accelerator;
[0029] 7) Load the quantized matrices U and V onto the off-chip DRAM of the accelerator, and configure the accelerator to only fine-tune the sub-vector weight parameters in the matrix V during training, while the basis vector weight parameters in the matrix U remain unchanged.
[0030] Compared with the prior art, the present invention has at least the following beneficial technical effects:
[0031] The present invention provides a sparse on-chip training hardware accelerator architecture and its implementation method. Among them, low-rank decomposition and quantization operations reduce the amount of weight data and the bit width of each data, which can effectively reduce the amount of calculation and memory access required for training. The experimental results show that the amount of calculation required for on-chip training is reduced by about 30%, and the amount of off-chip memory access is reduced by about 20%; the data sparsity design of weights and activations can enable the accelerator to skip some invalid calculations and improve the equivalent computing power of the accelerator. The experimental results show that the floating-point operation of the training network is reduced to about 60% of the original; the data compression and sparse coding module can skip invalid data in the memory access process and reduce the memory access. The experimental results show that it reduces the memory access by 35% to 40% during the network training process; the sparse calculation alignment strategy can balance the computing load between PEs, improve the PE array utilization and actual computing power, and the experimental results show that it increases the PE array utilization by about 30% during the network training process. The throughput, area efficiency and energy efficiency of the on-chip training accelerator designed by the present invention reach 38.02TOPS and 41.2GOPS / mm respectively. 2 and 90.63TOPS / W. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 This is the flowchart of the online fine-tuning based on model lightweighting proposed in the present invention.
[0033] Figure 2 Schematic diagram of applying SVQ-DQ technology in standard convolutional layers.
[0034] Figure 3 Schematic diagram of applying SVQ-DQ technology in the fully connected layer.
[0035] Figure 4 This is the overall architecture diagram of the DQ-STP proposed in the present invention.
[0036] Figure 5 This is a diagram of the optimized data flow design of the on-chip training accelerator DQ-STP proposed in the present invention.
[0037] Figure 6 Schematic diagram of different calculation modes of PE skipping input zero value calculation in the three stages of DCNN training proposed by the present invention, where Figure 6 (a) Describe the computational model of the FP / EP stage, Figure 6 (b) Describes the calculation mode of the WG stage.
[0038] Figure 7 This is a schematic diagram of the sparse computing alignment strategy based on continuous calculation of IFM within a group proposed by the present invention.
[0039] Figure 8 The detailed architecture diagram and calculation process of the FP / EP PE array proposed in the present invention are shown in FIG. Figure 8 (a) describes the architecture of the FP / EP PE array. Figure 8 (b) describes the flow chart of the FP stage pipeline calculation, Figure 8 (c) Flowchart describing the pipeline computation of the EP stage.
[0040] Fig. 9 FIG. 1 is a detailed architecture diagram of the WG PE array proposed in the present invention.
[0041] Fig.10 This is a detailed architecture diagram of the flag-CSR encoder proposed in the present invention. DETAILED DESCRIPTION
[0042] In the following, only some exemplary embodiments are briefly described. As those skilled in the art will appreciate, the described embodiments may be modified in various ways without departing from the spirit or scope of the present invention. Therefore, the drawings and descriptions are considered to be exemplary and non-restrictive in nature.
[0043] In the description of the present invention, it should be understood that the terms "center", "longitudinal", "lateral", "length", "width", "thickness", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", "clockwise", "counterclockwise", "axial", "radial", "circumferential" and the like indicate orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the referred device or element must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as limiting the present invention.
[0044] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the present invention, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0045] In the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", "connected", "fixed" and the like should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection, an electrical connection, or a communication; it can be a direct connection, or an indirect connection through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between two elements. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0046] In the present invention, unless otherwise clearly specified and limited, a first feature being "above" or "below" a second feature may include that the first and second features are in direct contact, or may include that the first and second features are not in direct contact but are in contact through another feature between them. Moreover, a first feature being "above", "above" and "above" a second feature includes that the first feature is directly above and obliquely above the second feature, or simply indicates that the first feature is higher in level than the second feature. A first feature being "below", "below" and "below" a second feature includes that the first feature is directly above and obliquely above the second feature, or simply indicates that the first feature is lower in level than the second feature.
[0047] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.
[0048] It should also be understood that the terms used in the present specification are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the present specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0049] It should be further understood that the term "and / or" used in the present description and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0050] Various structural schematic diagrams of the embodiments disclosed in the present invention are shown in the accompanying drawings. These figures are not drawn to scale, and some details are magnified and some details may be omitted for the purpose of clear expression. The shapes of various regions and layers shown in the figures and the relative sizes and positional relationships therebetween are only exemplary, and may deviate in practice due to manufacturing tolerances or technical limitations, and those skilled in the art may additionally design regions / layers with different shapes, sizes, and relative positions according to actual needs.
[0051] The embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0052] The weight matrix in the DCNN model is decomposed into low rank using singular value decomposition SVD. On this basis, the present invention selects 2 n A mixed precision data quantization scheme that combines quantization with high bit width precision retention. The present invention refers to this technical solution at the algorithm level as the SVD-DQ model lightweight training strategy.
[0053] At the hardware level, the present invention considers the co-design of software and hardware and designs a more efficient DCNN on-chip training accelerator based on the algorithm improvement proposed above. The present invention calls this hardware-level design DQ-STP, and its overall architecture includes:
[0054] The computing controller (FSM Ctrl) based on the finite state machine (FSM) is a finite state machine with multiple computing states. It controls the computing process of each computing module in DQ-STP and the read and write status of the storage system according to the current state and some counters.
[0055] The FP / EP PE array is a three-dimensional structure consisting of a data sorting module, a U array, a V array, and an adder tree (AT) array. Specifically, since the subvectors in the matrix U are quantized to 2 n , so the U array is mainly composed of shifters, while the V array is composed of multipliers and adders.
[0056] The WG PE array is a two-dimensional structure consisting of multipliers, shifters, and adders.
[0057] The ACBN module is used to independently calculate the FP, EP, and WG stages of the batch normalization (BN) layer during training, and collaborates with the FP / EP PE array to implement pipeline calculations.
[0058] The flag-CSR encoder is responsible for compressing the output neuron or feature gradient value into the sparse matrix compression format required for storage and finally transmitting it to the storage system.
[0059] The memory system is used to temporarily store the weights U and V, input and output neurons X, input and output feature gradients dX, and output weight gradients dV required for the current calculation.
[0060] Other computing modules, mainly including ReLU modules and pooling modules, are used to calculate the FP and EP stages of the activation function layer and pooling layer in the DCNN model.
[0061] Preferably, the EP and WG stages in the back propagation process are designed for parallel computing. Most previous works use a unified PE array to sequentially execute the FP, EP, and WG stages in the time dimension, resulting in repeated external memory accesses in the EP and WG computing stages. In contrast, in order to improve the computing efficiency of the EP and WG stages, the DQ-STP designed by the present invention uses two independent PE arrays to parallelly compute the EP and WG stages in the back propagation process.n Quantization,The computational units in the PE array designed for the EP stage are mainly shifters, so they do not consume a lot of logic resources. Therefore, the parallel design can greatly reduce the off-chip memory access cost of the EP and WG stages, while improving the accelerator computing speed.
[0062] Preferably, taking advantage of data sparsity, the sparse activation values and feature gradient values are encoded based on the proposed flag-CSR sparse data compression storage format, further improving the calculation speed of DQ-STP while reducing the off-chip memory access cost and on-chip storage consumption.
[0063] Preferably, a sparse computing alignment strategy based on continuous IFM computing within a group is proposed to further improve the utilization of the computing unit array.
[0064] like Figure 1 As shown, the processing flow of the SVD-DQ online fine-tuning technology based on model lightweight proposed in the present invention can be divided into four steps. In the first step, the DCNN model is pre-trained offline in the cloud or server using a public data set until convergence. In the second step, the original weight tensor W of each layer in the pre-trained model is decomposed into the product of an orthogonal matrix U, a diagonal matrix Σ and another orthogonal matrix V′ through SVD calculation. The main idea of SVD matrix low-rank decomposition can be expressed by the following formula:
[0065] W=U∑V'
[0066] Where Σ is a diagonal matrix, also called a singular value matrix, because except for the main diagonal elements which are the singular values of the matrix W, the elements in other positions are all 0, and the number of singular values on the diagonal is the rank of W. In the third step, in order to further reduce the computational complexity and the off-chip memory access cost, the present invention proposes to quantize the decomposed matrix U into 2 n , and multiply the singular values in the matrix Σ with the corresponding subvectors in the matrix V′ to obtain a new matrix V. Specifically, each value in the matrix U is replaced by its closest 2 n Since all values greater than or equal to 0 in U fall within the interval [0,1], the present invention selects -7 as the minimum value of n, and replaces any value less than 2 -7 The values of are replaced with 0. Obviously, this operation introduces weight sparsity to the matrix U. The quantization process of negative values is similar. The above steps are all processed offline outside the device and will not increase the computational complexity of the online fine-tuning process on the device. The last step is to convert the low-rank decomposition and 2 nThe quantized new pre-trained model is loaded onto the local device. The sub-vectors in the matrix U mentioned above are used as basis vectors to retain the pre-trained features of the model, and the training of the weight parameters in these basis vectors is "frozen" during the fine-tuning phase. The DCNN model will fine-tune the sub-vector weight parameters in the matrix V according to the user's personal data, while the basis vector weight parameters in the matrix U remain unchanged.
[0067] like Figure 2 As shown in FIG. 1 , the present invention provides an example for applying SVD-DQ in a standard convolutional layer. Taking a 3×3 convolution kernel as an example, the present invention first merges the convolution kernels calculated for all input feature maps (IFM) corresponding to an output feature map (OFM) into a 3m×3 matrix W, where m is the number of all input feature maps. Then, we apply the SVD-based matrix decomposition to the matrix W and transform the 2 n Quantization is applied to the matrix U. Since the maximum rank of the matrix W is 3, the decomposed matrices U and V′ have only three subvectors. Based on this, the computational complexity of an output neuron changes from 9m "multiply-accumulate" operations to 9m "shift-add" operations and 9 "multiply-accumulate" operations. In addition, since 2 n Quantization, so for each data only log 2 n bits are used for storage, which greatly saves the access cost of the off-chip memory. It should be noted that the present invention sets a threshold t to control the size of the matrix W. When m is greater than t, in order to avoid too large a number of rows in the matrix W, all input feature maps will be divided into groups of t input feature maps, and SVD-based decomposition will be performed in each group.
[0068] like Figure 3 As shown in FIG. 1 , the present invention provides an example for applying SVD-DQ in a fully connected layer. First, the weights of all input neurons (IN) corresponding to an output neuron (ON) are combined into a p / 3×3 matrix W, where p is the number of all input neurons. Then, the present invention applies SVD-based matrix decomposition to the matrix W and converts 2 n Quantization is applied to the matrix U. Similar to the convolutional layer calculation, the computational cost of an output neuron changes from p "multiplication-accumulation" operations to p "shift-addition" operations and 9 "multiplication-accumulation" operations. Similarly, the present invention also sets a threshold t for the fully connected layer to control the size of the matrix W. When p is greater than t, in order to avoid the number of rows of the matrix W being too large, all input neurons will be divided into groups of t input neurons, and SVD-based decomposition will be performed within each group.
[0069] like Figure 4As shown, the overall architecture of the DQ-STP proposed in the present invention includes a computation controller (FSM Ctrl) based on a finite state machine (FSM), a FP / EPPE array supporting forward propagation / backward error propagation, a WG PE array for weight gradient generation, an efficient batch normalization layer computation module ACBN, a sparse matrix data compression / decompression flag-CSR encoder, a memory system (Memory System) and other computation modules. Among them, the computation controller is a finite state machine with multiple computation states, which can control the operation process of each computation module in the DQ-STP and the read and write state of the memory system according to the current state and some counters. The FP / EP PE array is a three-dimensional structure composed of a data sorting module (DR), a U array, a V array and an adder tree (AT) array. Specifically, since the subvectors in the matrix U are quantized to 2 n , so the U array is mainly composed of shifters, while the V array is composed of multipliers and adders. The WG PE array is a two-dimensional structure composed of multipliers, shifters and adders. The ACBN module is used to independently calculate the FP, EP and WG stages of the BN layer during training, and cooperate with the FP / EP PE array to realize pipeline calculation. The output neuron is obtained by the sequential calculation of "convolution-BN-ReLU-pooling" (FP stage) or "convolution-pooling-ReLU-BN" (EP stage). After that, the output neuron or feature gradient value will be compressed into the final sparse matrix compression storage format through the flag-CSR encoder, and finally transmitted to the storage system. The storage system is used to temporarily store the weights U and V, input and output neurons X, input and output feature gradients dX, and output weight gradients dV required for the current calculation. In addition, there are ReLU modules and pooling modules for calculating the FP and EP stages of the activation function layer and pooling layer in the DCNN model.
[0070] like Figure 5 As shown in the figure, the optimized data flow design of the DQ-STP proposed in the present invention is introduced in detail, which includes three main designs. First, the present invention adopts ACBN to optimize the calculation of the BN layer, which significantly reduces the computational complexity and off-chip memory access cost of the BN layer, thereby reducing the calculation time. Then, the present invention designs parallel calculations for the EP and WG stages in the back-propagation process. Most previous works use a unified PE array to sequentially execute the FP, EP, and WG stages in the time dimension, resulting in repeated external memory accesses in the EP and WG calculation stages. In contrast, in order to improve the computational efficiency of the EP and WG stages, the DQ-STP designed by the present invention uses two independent PE arrays to parallelly calculate the EP and WG stages. Due to the 2 nQuantization, the computing units in the PE array designed for the EP stage are mainly shifters, so they do not consume a lot of logic resources. Parallel design can greatly reduce the off-chip memory access cost of the EP and WG stages, while improving the accelerator calculation speed. Based on this solution, the present invention continues to take advantage of data sparsity and uses the flag-CSR sparse data compression storage format to encode sparse activation values and feature gradient values, further improving the calculation speed of DQ-STP while reducing off-chip memory access costs and on-chip storage consumption.
[0071] like Figure 6 As shown in Figure 1, it describes different computation modes of PE skipping input zero value computation in the three stages of DCNN training. After ACBN optimization, the FP and EP stages have unified input data sparsity (Unified inputActivation Sparsity, UIAS), so in the hardware circuit design, the FP and EP computing units also have a unified zero skipping PE mode, as shown in Figure 1. Figure 6 As shown in (a). First, when a weight is input into PE, it is necessary to determine whether it is 0. If it is equal to 0, PE will skip all calculations of the current row. The present invention names this zero-skip PE mode as "weight zero-skip mode". Secondly, if the weight is not equal to 0, the sparse coded data in the current row are input into PE one by one, and a "multiplication-accumulation" operation is performed with the corresponding weight. After the partial sum is obtained, it is stored in the local register file (RegisterFile, RF) of PE according to the column index. The present invention names this zero-skip PE mode as "intra-row zero-skip mode". Then, if the highest flag of the first sparse coded data of the row received by PE is 1, and the non-zero value is actually 0, it means that the input values of this row are all 0, then PE will skip the convolution calculation of this row. The present invention names this zero-skip PE mode as "inter-row zero-skip mode". Finally, according to the column index, the corresponding partial sum is read from the local RF of PE, and added to the partial sums of different rows to obtain the final output of PE. The zero-skip PE mode of the WG calculation unit is shown in FIG. Figure 6 As shown in (b), it is similar to the FP and EP computing units, except that during the calculation process, the sparsely coded gradient needs to be decoded and stored in the PE local RF first so that data can be reused in subsequent calculations.
[0072] like Figure 7 As shown, it is well known that the problem of IAS imbalance will lead to a decrease in PE utilization, which is also one of the main bottlenecks faced by sparse computing hardware design. In order to solve this problem, the present invention proposes a sparse computing alignment strategy based on continuous calculation of IFM within a group to utilize the random data sparsity in different IFM rows.
[0073] like Figure 8As shown, Figure 8 (a) The computing architecture of the FP / EP PE array designed by the present invention is introduced in detail, which includes three main computing modules, namely, the U array, the V array and the adder tree array. The U array is a three-dimensional structure, n U_PElines correspond to the parallel computing of n different IFMs, n U PE tiles correspond to the parallel computing of n different OFMs, and the computing of different weights in the subvectors of the matrix U is carried out in a serial manner. When the FP / EP PE array executes the FP and EP stages of the training process respectively, the data rearrangement module, the U array, the V array and the AT array are dynamically reconfigured into different five-stage pipeline forms, such as Figure 8 (b) and Figure 8 As shown in (c), it includes the data rearrangement module (DR), U_PE array (U), addition tree array (AT), multiplication calculation (VM) and addition calculation (VA) of the V_PE array. Specifically, the data rearrangement module adopts the bitonic sorting method, which is responsible for sorting the input data in ascending order according to the column index and then transmitting it to the PE array for subsequent calculation. The unified FP / EP PE array will be configured as the pipeline calculation mode of "DR-U-AT-VM-VA" in the FP stage, and will be configured as the pipeline calculation mode of "DR-VM-U-AT-VA" in the EP stage. It is worth noting that the sub-vectors of the standard convolutional layer matrix U and matrix V can be dynamically gated according to the model configuration information, omitting the relevant calculations of some sub-vectors to achieve a better trade-off between accuracy and hardware efficiency.
[0074] In the FP calculation phase of the DCNN training process, the same sparsely coded input feature value X is first broadcast to the three U_PEs in the same PE line, and these three U_PEs correspond to different weights in the same U sub-vector. Then, U_PE calculates the shift sum of three consecutive rows in IFM through the sparse calculation mode, and transmits the result to the AT array to calculate the accumulation of partial sums between multiple input channels. Next, the result U[i]_result of the AT array is sent to the V array and performs a "multiplication-accumulation" operation with the corresponding V sub-vector. Finally, after the partial sum accumulation of all V sub-vectors is completed, the output result sum_result of the FP phase is calculated. In the EP calculation phase, the sparsely coded input feature gradient dX is first sent to the V array for multiplication. Then, the result V[i]_result of the V array is sent to the U array and the AT array to obtain the result U[i]_result of the AT array. Finally, the output result sum_result of the EP phase is obtained by accumulating the partial sums of different sub-vectors in V_PE. Obviously, the FP / EP PE array can use a unified data flow to calculate the FP and EP stages, effectively reducing the complexity of hardware circuit design. In addition, since the weight vectors U and V are both one-dimensional vectors, it is easy to input the reordered weight tensor for the unified FP / EP PE array by simply reading the weights in reverse from each sub-vector.
[0075] like Fig. 9 As shown, in order to improve the throughput of the accelerator in the EP and WG calculation stages, in addition to Figure 8 In addition to the unified FP / EP PE array mentioned in the previous section, the present invention also designs a WG PE array to support parallel computing of the EP and WG stages. The details of the WG PE array are as follows: Fig. 9 As shown, it is a two-dimensional structure. The n WG_PE lines correspond to the parallel calculation of n different input feature gradient maps. The n WG_PEs with the same number in different WG_PE lines correspond to the same IFM, and WG_PE is a six-stage pipeline calculation structure. In the WG calculation stage, for each WG_PE line, the sparsely coded input feature gradient row dX is first decoded and stored in the local RF. Then, the n sparsely coded input feature values X are input to WG_PE, and a "multiplication-accumulation" operation is performed with the corresponding dX to obtain the partial sum of dW. Next, the U subvector is used to perform a "shift-add" operation on the partial sum of dW to obtain the partial sum of dV. Finally, after all IFM calculations are completed, the partial sum of dV is transmitted to AT for accumulation between different input channels. Compared with the original WG calculation stage, the design of the present invention only adds some low-cost shift operations.
[0076] like Fig.10 As shown, it details the computational architecture of the flag-CSR encoder proposed in the present invention, which consists of a detector and a counter. The output eigenvalue X or feature gradient dX is calculated from the "ACBN-ReLU-pooling" block and transmitted to the flag-CSR encoder one by one. The detector is used to detect whether the input is zero. If the input is equal to zero, the counter is increased by 1. Once a non-zero value is detected, the value of the counter is the column index of the current non-zero value. When the count value of the counter is equal to the row size, the highest flag bit of the last encoded non-zero value will be set to 1. After compression is completed, the encoded value will be stored in the corresponding first-in-first-out (FIFO) memory. Obviously, the sparse matrix compression storage format based on flag-CSR proposed in the present invention greatly saves the hardware resource consumption brought by the encoder.
[0077] The above shows and describes the basic principles and main features of the present invention and the advantages of the present invention. It is obvious to those skilled in the art that the present invention is not limited to the details of the above exemplary embodiments, and the present invention can be implemented in other specific forms without departing from the spirit or basic features of the present invention. Therefore, no matter from which point of view, the embodiments should be regarded as exemplary and non-restrictive. The scope of the present invention is defined by the attached claims rather than the above description, and it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present invention. Any figure mark in the claims should not be regarded as limiting the claims involved.
[0078] In addition, it should be understood that although this specification is described in accordance with the implementation modes, not every implementation mode contains only one independent technical solution. This description of the specification is only for the sake of clarity. Those skilled in the art should regard the specification as a whole. The technical solutions in each embodiment can also be appropriately combined to form other implementation modes that can be understood by those skilled in the art. The above content is only to illustrate the technical idea of the present invention, and cannot be used to limit the protection scope of the present invention. Any changes made on the basis of the technical solution according to the technical idea proposed by the present invention shall fall within the protection scope of the claims of the present invention.
Claims
1. A sparse on-chip training hardware accelerator architecture, characterized in that: include: Off-chip DRAM, on-chip storage system, computing controller FSM Ctrl, forward propagation and reverse error propagation computing unit array FP / EP PE, weight gradient generation computing unit array WG PE, batch normalization layer computing module ACBN, sparse matrix data compression module flag-CSR and activation and pooling computing module; among them, Off-chip DRAM, used to store input data, network initial weights, and intermediate calculation results, which is connected to the on-chip storage system; The on-chip storage system is used to temporarily store the weights, input and output neurons, and feature gradient data required for the current calculation. It is connected to the off-chip DRAM, the weight gradient generation calculation unit array WG PE, the batch normalization layer calculation module ACBN, and the sparse matrix data compression module flag-CSR for data transmission and exchange; The computing controller FSM Ctrl is used to control the computing process of each computing module in the accelerator and the read and write status of the storage system according to the current state and some counter values, and is connected to the control part of all modules in the accelerator; The forward propagation and reverse error propagation calculation unit array FP / EP PE is used to calculate the forward reasoning and reverse error propagation process of the deep neural network. It reads data from the on-chip storage system and sends the data to the batch normalization layer calculation module ACBN after the calculation is completed; The weight gradient generation calculation unit array WG PE is used to calculate the weight gradient generation and update process of the deep neural network. It is connected to the on-chip storage system to obtain data and write calculation results; The batch normalization layer calculation module ACBN is used to complete the calculation of the batch normalization layer in the deep neural network. It reads data from the forward propagation and reverse error propagation calculation unit array FP / EP PE or the on-chip storage system for calculation, and sends the result to the sparse matrix data compression module flag-CSR; The sparse matrix data compression module flag-CSR is used to compress the output neurons into the final sparse matrix compression format. It obtains data from the batch normalization layer calculation module ACBN for compression and sends the compressed data to the on-chip storage system; The activation and pooling calculation module is used to complete the calculation of the activation layer and the pooling layer in the deep neural network. It is connected to the batch normalization layer calculation module ACBN for data exchange.
2. A sparse on-chip training hardware accelerator architecture according to claim 1, characterized in that: The forward propagation and reverse error propagation calculation unit array FP / EP PE is a three-dimensional structure composed of a data sorting module DR, a U array, a V array and an addition tree AT array; the data sorting module DR adopts a bitonic sorting method, which is responsible for sorting the input data in ascending order according to the column index and then transmitting it to the U array or the V array for subsequent calculation; the U array is composed of shifters, and the V array is composed of multipliers VM and adders VA; in the DCNN forward propagation process, the forward propagation and reverse error propagation calculation unit array FP / EP PE is configured as a pipeline calculation mode of "DR-U-AT-VM-VA", and in the reverse error propagation stage it is configured as a pipeline calculation mode of "DR-VM-U-AT-VA".
3. The sparse on-chip training hardware accelerator architecture according to claim 1, characterized in that: The forward propagation and reverse error propagation calculation unit arrays FP / EP PE simultaneously support dynamic gating of sub-vectors in the standard convolutional layer matrix U and matrix V according to the model configuration information, omitting the related calculations of some sub-vectors.
4. The sparse on-chip training hardware accelerator architecture according to claim 1, characterized in that: The weight gradient generation calculation unit array WG PE is a two-dimensional structure composed of multipliers, shifters and adders; different PE rows correspond to the parallel calculation of different input feature gradient maps, and PEs with the same number in different PE rows correspond to the same input feature map.
5. The sparse on-chip training hardware accelerator architecture according to claim 1, characterized in that: The weight gradient generation calculation unit array WG PE is a six-stage pipeline calculation structure; in the WG calculation stage, for each PE row, the sparsely coded input feature gradient row dX is first decoded and stored in the local register; Then, the sparsely coded input feature value X is input to the weight gradient generation calculation unit array WG PE, and a multiplication-accumulation operation is performed with the corresponding dX to obtain the partial sum of dW; next, the partial sum of dW is shifted-added using the U subvector to obtain the partial sum of dV; finally, after all input feature maps are calculated, the partial sum of dV is transmitted to the adder for accumulation between different input channels.
6. The sparse on-chip training hardware accelerator according to claim 1, characterized in that: The sparse matrix data compression module flag-CSR consists of a detector and a counter, which is responsible for compressing the output neurons into the final sparse matrix compression format and finally transmitting it to the storage system; The output eigenvalue X or feature gradient dX is calculated from the batch normalization layer calculation module ACBN and the activation and pooling calculation module, and transmitted one by one to the sparse matrix data compression module flag-CSR; wherein, the detector is used to detect whether the input is zero. If the input is equal to zero, the counter is increased by 1; once a non-zero value is detected, the value of the counter is the column index of the current non-zero value; when the count value of the counter is equal to the row size, the highest flag bit of the last encoded non-zero value will be set to 1; after compression is completed, the encoded value will be stored in the corresponding first-in-first-out memory.
7. A method for implementing a sparse on-chip training hardware accelerator, characterized in that: The method is based on a sparse on-chip training hardware accelerator according to any one of claims 1 to 6, comprising: The singular value decomposition (SVD) is used to decompose the weight matrix in the deep convolutional neural network (DCNN) model into a low-rank matrix. n A mixed-precision data quantization scheme is proposed that combines quantization with retaining high-bit-width precision, and the hardware logic circuits of the forward propagation and reverse error propagation calculation unit arrays FP / EP PE and the weight gradient generation calculation unit array WG PE are designed. Finally, the peripheral control and storage circuits are designed and combined to obtain a sparse on-chip training hardware accelerator.
8. The method for implementing a sparse on-chip training hardware accelerator according to claim 7, characterized in that: The specific implementation steps of this method are: 1) The DCNN model is pre-trained offline on the cloud or server using a public dataset until convergence to obtain a pre-trained model; 2) Decompose the original weight tensor of each layer in the pre-trained model through SVD calculation to obtain an orthogonal matrix U, a diagonal matrix Σ and another orthogonal matrix V′; 3) Quantize the decomposed matrix U to 2 n , and multiply the singular values in the matrix Σ with the corresponding subvectors in the matrix V′ to obtain a new matrix V; 4) According to the computational characteristics of the low-rank decomposition of the pre-trained model weights, the forward propagation and reverse error propagation calculation unit arrays FP / EP PE and the weight gradient generation calculation unit array WG PE hardware logic circuits are designed using Verilog and SystemVerilog hardware description languages; 5) Based on the two computing unit array circuits obtained in 4), the peripheral control, storage and auxiliary computing module circuits are designed using Verilog and SystemVerilog hardware description languages to obtain a neural network accelerator functional component that supports the low-rank decomposition and quantization; 6) According to the architectural hierarchy of each layer in the pre-trained deep neural network model, the accelerator functional components and the deep neural network accelerator general components are combined to build a sparse on-chip training hardware accelerator; 7) Load the quantized matrices U and V onto the off-chip DRAM of the accelerator, and configure the accelerator to only fine-tune the sub-vector weight parameters in the matrix V during training, while the basis vector weight parameters in the matrix U remain unchanged.
Citation Information
Patent Citations
A sparse convolutional neural network accelerator and an implementation method
CN109635944A
Deep learning training hardware accelerator utilizing sparsity
CN111368988A
Cited By
Neural network accelerator and acceleration method
CN119378619A
Quaternary pulse-based pulse neural network accelerator and calculation method thereof
CN119558360A
Joint search method and device for neural network and hardware
CN120163196A
Weight matrix acceleration system and method
CN120318478A
A weight matrix acceleration system and method
CN120318478B
