Data acceleration pipeline synchronization loop
By designing a data acceleration pipeline synchronization ring in the AI accelerator and using the cascaded transmission block structure to achieve high concurrent data transmission, the data reading delay problem caused by the multi-level cache architecture is solved, and the performance and efficiency of the AI accelerator are improved.
Patent Information
- Application Number
- CN202410634534.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-22
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2044-05-22
AI Technical Summary
In AI accelerators, multi-level cache architecture causes data read latency problems, especially in large-model AI calculations. Insufficient cache capacity leads to storage access bottlenecks and limited computing performance.
Design a data acceleration pipeline synchronization ring, which forms a pipeline transfer structure through cascaded forward transmission blocks and backward transmission blocks to achieve high concurrent data input and output, and uses multi-level FIFO cascade and register cascade for data push, reducing Data transfer process, quickly transmit data.
It effectively reduces the multi-layer cache delay between the computing core group and DRAM, improves data transmission efficiency, reduces the control dependence on computing resources, and improves the overall performance of the AI accelerator.
Smart Images

Figure CN118484143B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the database field, and in particular to a data acceleration pipeline synchronization ring. Background Art
[0002] In the current AI acceleration GPU, SOC, and ASIC designs, the relationship between computing cores and storage is centered around Figure 1 The typical architecture implementation shown in the figure. There will be some fine-tuning in the specific design, and the number of cache layers may be different. For example, in the Ampere architecture of the A100 high-end graphics card, the original L0 layer is merged into the L1 layer. The L1 cache in this architecture is at the KB level, and its cache capacity can be as high as hundreds of KB, such as 192KB for the A100 graphics card and 256KB for the H100 graphics card. The L2 cache is at the MB level, and its cache capacity can reach tens of MB, such as 50MB for the A100 graphics card and H100. For DRAM, its cache capacity is usually at the GB level. Due to the speed requirements, there are many solutions using HBM and GDDR, and the capacity ranges from more than ten GB to tens of GB. For example, NVDIA's latest B200 has a capacity of 192GB (HBM).
[0003] In the related art, the weights of AI calculation parameters are usually initialized and stored in DRAM in the computer, and need to be imported into the computing core for calculation. Figure 1 From the architecture disclosed in, it can be seen that the computing core imports parameters through multiple layers of cache, and the access order is to query the nearest level of cache first. If it misses, the next level of cache is queried until it hits and returns the data. When the data is returned, some designs can be returned directly to the computing core, while others need to be synchronized to the next level of cache first, and can only be obtained by the computing core after being synchronized to L0 / L1. Therefore, if the L0 / L1 cache does not hit, the parameter reading delay will be very long. The above are the problems caused by one-time reading of parameters. In large-model AI calculations, it will be executed continuously, resulting in cumulative delays, and insufficient cache capacity will cause the cache to be unable to accommodate, which will lead to repeated reading of higher-level caches and even DRAM, which will amplify the storage access bottleneck problem. Summary of the invention
[0004] The embodiment of the present application provides a data acceleration pipeline synchronization loop to solve the latency problem caused by the computing core group in the accelerator and acceleration system reading data based on multi-level cache.
[0005] The present application discloses a data acceleration pipeline synchronization ring, the pipeline synchronization ring is connected to N computing core groups in an accelerator, and the pipeline synchronization ring includes M cascaded forward transmission blocks and M cascaded backward transmission blocks; the forward transmission block at the head end and the forward transmission block at the tail end are respectively connected to the data receiving module and the data sending module of the accelerator; the output of the forward transmission block at the tail end is cascaded to the backward transmission block at the head end;
[0006] The i-th forward transmission block in the cascaded forward transmission block and the M-i+1-th backward transmission block in the cascaded backward transmission block correspond to each other to form a forward and backward transmission group, and each forward and backward transmission group is commonly connected to at least one computing core group, and the data is sent to the target computing core group in a pipeline form according to the clock cycle for calculation, and the data output by the computing core group is sent to the pipeline synchronization ring.
[0007] Specifically, the backward transmission block includes a backward register and P backward writing units cascaded forward and backward; P is a positive integer;
[0008] The backward register is connected to the output end of the previous cascade transmission block to receive and store intermediate data; one output of the backward register is connected to the first backward write unit, and the data is pushed to the target backward write unit in a pipeline manner through the cascade structure, and the other output is directly connected to the next cascade transmission block to push the intermediate data to the target transmission block in a pipeline manner.
[0009] Specifically, the first write registers in each backward write unit in the same backward transmission block are cascaded front and back, data is input through the backward registers, and the data is pushed to different forward write units in a pipeline manner;
[0010] The backward writing unit includes at least Q write registers cascaded forward and backward, each write register is connected to a computing core group, and pushes data to the target computing core group in the forward writing unit in a pipeline form.
[0011] Specifically, the forward transmission block includes a forward FIFO buffer, a forward register, P groups of forward receiving units and a forward writing unit; P is a positive integer;
[0012] P forward receiving units are cascaded front to back, and P forward writing units are cascaded front to back, and the forward writing units and forward receiving units in the same group are connected to the same computing core group;
[0013] One input end of the forward FIFO buffer is connected to the output of the previous cascade transmission block to receive and store intermediate data, and the other input end is connected to the output of the tail-end forward receiving unit to receive data output from the tail-end forward receiving unit;
[0014] The output of the forward FIFO buffer is connected to the forward register, and the output of the forward register is connected to the first forward write unit, so that the pipeline data is pushed to the target forward write unit through a cascade structure.
[0015] Specifically, the forward writing unit includes at least Q forward and backward cascaded writing registers, each writing register is connected to a computing core group, and the data is pushed to the target computing core group in the forward writing unit in a pipeline manner;
[0016] The forward receiving unit includes at least Q receiving FIFO buffers cascaded forward and backward, each receiving FIFO buffer is connected to a computing core group, caches the intermediate data input by the computing core group, and sends the intermediate data to the pipeline synchronization ring layer by layer in a pipeline form.
[0017] Specifically, the first write registers in each forward write unit in the same forward transmission block are cascaded front and back, data is input through the forward registers, and the data is pushed to different forward write units in a pipeline form;
[0018] The tail end receiving FIFO buffers in each forward receiving unit in the same forward transmission block are cascaded front and back, and the intermediate data input by different computing core groups are sent to the forward FIFO buffer layer by layer in a pipeline manner.
[0019] Specifically, in the i-th forward transmission block and the (M-i+1)-th backward transmission block, the forward writing unit and the backward writing unit located in the same group have the same structure.
[0020] Specifically, in the same group of forward receiving units and forward writing units of the same forward transmission block, the numbers of registers and FIFO buffers are the same.
[0021] Specifically, the forward write unit includes S layers of register circuits, each layer of register circuits includes at least Q write registers cascaded forward and backward, each write register output is connected to the first write register in an independent lower layer register circuit, and all write registers of all register circuits of the Sth layer are respectively connected to a computing core group;
[0022] The forward receiving unit includes S layers of FIFO buffer circuits, each layer of FIFO buffer includes at least Q receiving FIFO buffers cascaded forward and backward, each receiving FIFO buffer output is connected to a tail receiving FIFO buffer in an independent lower layer FIFO buffer circuit, and all receiving FIFO buffers of all FIFO buffer circuits of the Sth layer are respectively connected to a computing core group;
[0023] The backward receiving unit and the forward receiving unit in the same forward and backward transmission group have the same structure.
[0024] Specifically, the data pushed into the pipeline synchronization ring is provided with a bit identifier, and the forward transmission block and the backward transmission block determine the state and flow direction of the data based on the corresponding flag bit of the bit identifier;
[0025] When the flag bit of the bit identifier indicates that the data is exhausted, the data is directly discarded;
[0026] When the flag bit of the bit identifier indicates that the data is not exhausted, the data is sent to the write register layer by layer until it is pushed into the target computing core group.
[0027] The beneficial effects brought about by the technical solution provided in the embodiment of the present application include at least: a pipeline transmission structure is formed by cascading forward transmission blocks and cascaded backward transmission blocks, and the forward transmission block is divided into cascaded forward receiving units and forward writing units according to input and output; each forward receiving unit adopts multi-stage FIFO cascading and access to the computing core group, and each forward writing unit adopts multi-stage register cascading and access to the computing core group to achieve high-concurrency data input and output; adjacent writing units in each transmission block cascade the first register, and adjacent receiving units cascade the tail FIFO, so that the input and output data can be pushed in pipeline between the writing units and the receiving units, as well as the pipeline jump push inside the writing unit and the receiving unit, thereby achieving fast data transmission. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 It is a multi-level cache computing core group storage acceleration architecture disclosed in the related art;
[0029] Figure 2 It is a schematic diagram of hardware deployment based on the flash attention solution in related technologies;
[0030] Figure 3 A schematic diagram of synchronous data flow based on current AI accelerator chips is shown;
[0031] Figure 4 It is a structural diagram of an accelerator architecture for near-IO pipeline computing provided in an embodiment of the present application;
[0032] Figure 5 It is a structural diagram of a water flow synchronization ring;
[0033] Figure 6 It is a schematic diagram of the structure of the backward transmission block in the pipeline synchronization ring;
[0034] Figure 7 It is a schematic diagram of the structure of the forward transmission block in the pipeline synchronization ring;
[0035] Figure 8 It is a structural diagram of the AI acceleration system provided by this application;
[0036] Fig. 9 It is a schematic diagram of the structure of the AI acceleration system for long-sequence linear calculations;
[0037] Fig.10 It is an AI accelerator designed based on the flash attention computing principle. DETAILED DESCRIPTION
[0038] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.
[0039] The term "multiple" as used herein refers to two or more than two. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the related objects are in an "or" relationship.
[0040] Figure 1 It is a computing core group storage acceleration architecture with multi-level cache disclosed in the related art; for the computing core group part in this architecture, different products produced and designed by different companies have different designs, usually containing one computing core or multiple parallel computing cores. The computing core usually supports pipeline computing, and when multiple computing cores are included, the computing functions of different computing cores may be different, such as including computing cores of different precisions at the same time, and including matrix computing cores (often MAC arrays), vector computing cores, etc. Taking the A100 and H100 architectures as an example, one L1 cache corresponds to a streaming multiprocessor SM (streaming multiprocessor), which contains four computing core groups, each computing core group contains multiple streaming processors SP (streaming processors), these SPs include different numbers of FP32 pipeline computing cores, INT32 pipeline computing cores, FP64 pipeline computing cores and NVDIA customized tensor cores (Tensor core), and the Tensor core in A100 is the third generation, and H100 is the fourth generation. With Figure 1 Taking the architecture disclosed in as an example, in some designs, the L0 layer cache is merged into the core group as a shared memory, while the L1 and upper layers are located outside the core group. Several core groups share one L1 cache to perform parameter access, while multiple L1 caches and the upper layer L2 cache perform parameter access. Multiple L2 caches are finally connected to the storage medium for storage models and data parameters, which can be HBM, DDR, LPDDR or GDDR DRAM, etc.
[0041] From the above architecture, it can be seen that when designing current AI computing chips, the needs of convolutional neural networks (CNN) are often taken into account. The parameters are composed of convolution kernels at most. After a convolution kernel is imported, it will slide on the data to be calculated and perform convolution operations. One convolution operation can be understood as a multiplication and addition operation (MAC operation) for one parameter. A convolution kernel in CNN will participate in multiple operations, and the calculation density of unit parameters is relatively high. Taking resnet50 as an example, in the first layer of convolution, a convolution kernel convolves 224*224 input into a size of 112*112, the convolution kernel is 7*7, and the number of convolution calculations is 112*112=12544 times. It can be considered that each parameter has been read 12544 times (MAC calculation) from the time it was read to the current result. After the CNN parameters are read, more calculations will occur. If the next set of parameters is imported during the calculation delay, the delay caused by multiple layers of cache can be hidden, while ensuring that the next calculation starts as soon as possible.
[0042] However, as the success of GPT has led to more and more applications of large models based on the Transformer architecture, computing requirements have changed. For Transformer, the parameters are mainly large matrices, and the calculations that most parameters participate in can be abstracted as vector multiplication by matrix equals vector:
[0043] F(y)=x*w
[0044] Where x is an m-dimensional vector, w is an m*n matrix, and y is an n-dimensional vector, then for the element y of y k (k∈[1,n]) has:
[0045]
[0046] As can be seen from the formula, each parameter data only participates in one multiplication and addition operation, and the computing density is low. The computing core can easily meet this performance requirement. At the same time, the model parameters under the Transformer architecture are large. Taking the current LLaMa2 as an example, the smallest model is 7B, that is, the number of parameters is about 7 billion. The FP32 parameters require a storage capacity of about 28GB, and even if quantized to int8, it still requires 7GB. The above causes the running performance of the Transformer architecture model on the AI accelerator to be directly related to the DRAM capacity and the speed (throughput) and latency (latency) of DRAM parameters directly to the computing core. However, the cache of the current architecture AI accelerator is far from providing sufficient capacity. The computing core obtains parameters equivalent to directly reading DRAM. At this time, the latency caused by the multi-layer cache architecture seriously affects the performance of computing. Although multi-batch computing (multi-task parallelism) has brought a certain improvement in computing resource utilization, the performance loss caused by insufficient physical bandwidth utilization has not been alleviated.
[0047] Insufficient cache capacity will also bring more problems. Take the optimization of softmax in GPU as an example. The pseudo code written to prevent overflow of softmax needs to contain at least 3 loops. The use of loops requires caching intermediate results, which takes up a small amount of cache, especially in long-dimensional models such as Transformer (softmax may reach tens of K levels according to the supported token length, and the minimum is also K level). At the same time, for multi-core parallel computing such as GPU, data synchronization between cores will also increase the delay overhead outside the algorithm. In response to the above defects, many optimization codes in the CNN era are optimized and implemented using the online softmax algorithm. Combined with the calculation formula of the attention layer, the exp splittable feature is also used to form a flash attention scheme to further reduce loops.
[0048] Figure 2 This is a schematic diagram of the hardware deployment based on the flash attention solution in the related technology. Figure 2 The shaded part is the data that needs to be stored in the L0 / L1 cache closest to the computing core group. The additional boxed part of the shaded part indicates valid data (for example, in A, the maximum cache amount generated by the intermediate result is the shaded part, and the final accumulated result is the boxed part). D is the dimension of the head (usually small, such as 128 for LLaMa2), and B corresponds to the parallelism b, which can be set manually. L is the sequence length, which may be very long (such as 16K), but according to the current calculation method, there is no need to put the entire L sequence length matrix in the L0 / L1 cache, only the D*B size needs to be considered. Each tile is pipelined and the cache is small. This method greatly solves the problem of parameter amplification. This calculation method has certain limitations:
[0049] First, we assume that D is relatively small. This method is for better operation. The original attention calculation D, which is equal to L, is divided into the current D (D = L / n_haeds, n_haeds is the number of heads in the multi-head attention) through the multi-head attention calculation method. Moreover, as the model evolves, it is impossible to confirm whether D will continue to grow. This may become a restriction on the direction of algorithm evolution. The controlling factor of parallelism B is the size of the cache, but usually this parameter should consider the parallelism of the computing core. For example, if a hardware is given, the cache size is fixed, and the B*D value is fixed. If D is different in different models, the B that can be set is different. However, the parallelism of the given hardware computing core is fixed. In this case, it will lead to mismatch of parallelism and seriously reduce the utilization of computing resources.
[0050] In the generation stage of Inference, the essence of single batch calculation is vector multiplication by matrix, where Q is a vector. In AI computing core design, systolic arrays are often used to multiply matrices by matrices, and multiple batch operations are performed to improve resource utilization. T As V slides with the sequence, Q needs to be stored completely. In multiple batches, batches of Q need to be stored. At this time, due to the cache size limit, the number of batches is also limited, which further limits the utilization of computing resources. The above two problems lead to serious limitations on the performance of high-density computing cores. At the same time, flash attention only alleviates the amplification of the multi-layer cache access delay problem, but does not improve the problem itself. The above K T As V slides in sequence, it still needs to access DRAM through a multi-layer cache mechanism.
[0051] The AI acceleration device built based on the above architecture also has device latency between multiple devices, because before Transformer, most AI calculations were only performed by multiple devices during training, and inference was mostly run on a single device. In the Transformer model, it is common to use multiple devices to perform inference calculations together. For example, the llama2-70B model requires two or four A100 / H100s to obtain better performance.
[0052] Figure 3 Figure 1 shows a schematic diagram of synchronous data flow based on the current AI accelerator chip. When the computing core groups in the two devices synchronize data, the data in device 1 must first pass through a multi-layer cache mechanism ( Figure 3 In this way, the data in the target device DRAM must pass through a multi-layer cache mechanism to reach the target computing core group. In this way, without considering the inter-chip transmission and DRAM delay, the multi-layer delay between the computing core group and DRAM is usually 100 clock cycles or more, which has a great impact on efficiency. At the same time, if global data exchange is performed inside the device, similar delays will occur and affect computing efficiency.
[0053] Figure 4This is a schematic diagram of the structure of the accelerator architecture for near-IO pipeline computing provided by an embodiment of the present application. The AI accelerator (AI acceleration device) under this architecture is internally provided with a multi-channel direct access module, M computing core groups and a pipeline synchronization ring; the M computing core groups are divided into N core groups containing the same or different numbers of core groups. The design of the core group is mainly to concentrate several computing core groups, which can specifically achieve greater integration and higher-scale acceleration tasks.
[0054] The multi-channel direct access module includes N DRAM controllers, and the N DRAM controllers are connected to the external DRAM one by one. The N DRAM controllers here are set according to actual needs and connected to a certain number of storage devices to realize the data reading and writing operations on the DRAM. In order to speed up the data transmission efficiency and reduce the control dependence on the computing core group, at least K direct access storage DMA controllers can be connected to each DRAM controller, and connected to the corresponding core group through the DMA controller. Thereby, the data in the i-th DRAM is directly read to the i-th computing core group, and the result data output by the i-th computing core group is directly cached to the i-th DRAM.
[0055] Each DRAM controller corresponds to multiple DMA access channels, which are directly connected to the corresponding core group, and can achieve fast and direct access. In addition to eliminating the delay caused by the multi-layer cache mechanism, it can also eliminate delays such as switch arbitration and bus forwarding, and maximize the physical performance of DRAM. Because the call of the ordinary access port needs to continuously call the resources of the computing core group for control, while the application of DMA only needs to occupy the core group resources when it is initiated and ended. The intermediate process is completely controlled autonomously by the DMA controller, which improves the utilization rate of the core group resources.
[0056] It should be noted that the type of controller in the multi-channel direct access module can be determined according to the design of the AI acceleration chip. The current mainstream preferred HBM, but it does not rule out the use of GDDR, DDR, LPDDR and other controllers due to process, available procurement lines, historical technology and other reasons. In addition, in this application, the core group as a whole is directly connected to the DMA channel, and the number and scale of computing core groups in the core group corresponding to different DRAMs can be designed according to different designer design ideas and target scenarios. The relationship between the DMA channel and these computing core groups can be defined as one-to-one, one-to-many, many-to-one, etc. according to demand. In principle, it is not encouraged to support many-to-many, which will reduce access efficiency.
[0057] In a possible implementation, a one-to-one design can be adopted, that is, the number of DMAs is consistent with the number of computing core groups in the core group, and the DMA controller also needs to set the same number of common access ports to connect to all computing core groups, which is mainly for data exchange and acceleration tasks across core groups and across DRAM devices. To this end, the present application also sets a Switch arbitrator in the multi-channel direct access module.
[0058] The switch arbiter is connected to N DRAM controllers and N core groups through common access ports. Its purpose is to cross-read the data in the i-th DRAM to the j-th core group, and cross-cache the result data output by the j-th core group to the i-th DRAM. i and j are different positive integers. Each DRAM controller corresponds to a common access channel. The common channels between controllers are uniformly accessed through a switch, and an access port is provided for each computing core group. This design provides a global access channel for the computing core group. The speed of this channel is slower than that of the DMA channel, but the delay for global data exchange is still better than that of exchange through a multi-layer cache mechanism.
[0059] In addition, in some embodiments, if the accelerator wants to effectively exchange data with other peripheral devices, a data sending module and a data receiving module can also be set up. The data sending module and the data receiving module are respectively connected to the pipeline synchronization ring. After the data calculated by the acceleration computing core is pushed through the pipeline synchronization ring, the result can be sent from the data sending module to the outside of the accelerator. Similarly, the external data can be received by the data receiving module and sent to the pipeline synchronization ring, and then pushed to the target computing core group in the core group group.
[0060] Figure 5 It is a structural diagram of a pipeline synchronization ring. The pipeline synchronization ring is connected to N core groups, and contains M cascaded forward transmission blocks Forward step and M cascaded backward transmission blocks Backward step. The forward transmission block is for forward data transmission, while the backward transmission block is for reverse data transmission. In particular, the forward transmission block at the head end and the forward transmission block at the tail end are respectively connected to the data receiving module Receiver and the data sending module Sender. Of course, the Receiver and Sender can be swapped, or the data sending and receiving modules can be set at the head and tail ends of the cascaded backward transmission blocks, which does not affect the overall structure. The forward and backward transmission blocks are a cascade structure as a whole, that is, the output of the forward transmission block at the tail end is cascaded to the first backward transmission block. As shown Figure 5In the example, Forward step 1 is connected to Receiver, which is then connected to Forward step M in turn, and Forward step M is connected to Sender and output. At the same time, Forward step M is further cascaded to Backward step 1, and then connected to Backward step M in turn. Note that the forward and backward transmission blocks do not completely form a ring. M, N, K, i, j are positive integers.
[0061] The i-th forward transmission block and the M-i+1-th backward transmission block of the pipeline synchronization ring correspond to each other and are connected to at least one computing core group. Figure 5 In the example, Forward step 1 corresponds to Backward step M, and Forward step M corresponds to Backward step 1, and so on. Each Forward step i and Backward step M-i+1 is a group, and they should be connected to the same computing core group. The number of computing core groups connected to each group can be freely set. For example, if N computing core groups are evenly divided into M groups, each group will have N / M.
[0062] The purpose of this design structure is to send data to the target computing core group in a pipeline form for calculation, and to send the data output by the computing core group into the pipeline synchronization ring. Under the action of the forward and backward transmission blocks, the data sent from any computing core group can be pushed to any other computing core group in a pipeline manner through the transmission block, and the special structure of the forward and backward cascade folding reciprocating can realize the step-by-step push of computing core group 1 to computing core group N, and then continue to push back from computing core group N to computing core group 1. Similarly, Receiver and Sender can realize data exchange between accelerators, push calculations after receiving external data, and send out the result data or intermediate data of pipeline calculations, which is also the core embodiment of the "synchronization ring" in this application.
[0063] Figure 6 1 is a schematic diagram of the structure of a backward transmission block in a pipeline synchronization ring, wherein the backward step includes a backward register and P backward write units write steps cascaded forward and backward; wherein P is a positive integer. Figure 6 For the convenience of description, three backward writing units are illustrated.
[0064] The Backward register is connected to the output of the previous cascade transmission block to receive and store intermediate data. One output of the Backward register is connected to the first backward write unit write step 1, and the data is pushed to the target backward write unit in a pipeline through the cascade structure. The other output is directly connected to the next cascade transmission block to push the intermediate data to the target transmission block in a pipeline. Assuming that the intermediate data needs to be sent to the computing core group 4 in write step 2, it needs to be sent to write step 1 first, and then passed to write step 2.
[0065] The first write register in each Backward write in the same Backward step is cascaded forward and backward, and data is input through the Backward register, and the data is pushed to different Backward write steps in a pipeline manner. The Backward write step contains at least Q write registers cascaded forward and backward, each write register is connected to a computing core group, and the data is pushed to the target computing core group in the forward write unit in a pipeline form. The special feature of this structure is that the continuous storage of registers will occupy clock cycles and cause delays, so the first write register 1 in each Backward write step is cascaded. Assuming that the intermediate data is to be pushed to the computing core group 8 in writestep 3, the data is pushed in a pipeline jump manner, that is, Backward register→(Backward write step 1)write register 1→(Backward write step 2)writeregister 1→(Backward write step 3)write register 1, and then writeregister 1→write register 2→computing core group 8 in this layer. It should be noted that the number of registers (computing core groups) cascaded in each write step can be the same or different, and is set according to actual needs.
[0066] Figure 7 It is a structural diagram of a forward transmission block in a pipeline synchronization ring, wherein the Forward step includes a forward FIFO buffer Forward fifo, a forward register Forward register, P groups of forward receiving units Forward receive step and a forward write unit Forward write step; P is a positive integer.
[0067] P Forward receive steps are cascaded back and forth, and P Forward write steps are cascaded back and forth. The Forward write step and Forward receive step in the same group are connected to the same computing core group. Because one is used for sending and the other is used for receiving data, the data flow direction is opposite. For the convenience of description, the pipeline timing is used for numbering description, that is, Forward write step i and Forward receive step P-i+1 are grouped together, corresponding to Figure 7 In the figure, Forward write step 1 and Forward receive step 3 are in the same group, and so on.
[0068] One input end of the forward fifo is connected to the output of the previous cascade transmission block to receive and register intermediate data, and the other input end is connected to the output of the forward receive step P at the tail end to receive data output from the Pth forward receive unit. The output of the forward fifo is connected to the forward register, and the output of the forward register is connected to the first forward write unit, forward write step 1, to push the pipeline data to the target forward write unit through the cascade structure.
[0069] The forward write step contains at least Q write registers cascaded forward and backward. Each write register is connected to a computing core group. The purpose is to push the (intermediate) data to the target computing core group in the forward write unit in a pipeline manner.
[0070] The forward receive step includes at least Q forward and backward cascaded receive FIFO cache Switch fifos. Each Switch fifo is connected to a computing core group, caches the intermediate data input by the computing core group, and sends the intermediate data to the pipeline synchronization ring layer by layer in the form of pipeline.
[0071] In some embodiments, the Forward step and the Backward step may include multiple layers of Backwardwrite step and Forward receive step. For example, the forward write unit includes S layers of register circuits, each layer of register circuits includes at least Q write registers cascaded forward and backward, each write register output is connected to the first write register in an independent lower layer register circuit, and all write registers of all register circuits of the Sth layer are respectively connected to a computing core group. Correspondingly, the forward receive unit includes S layers of FIFO buffer circuits, each layer of FIFO buffer includes at least Q receive FIFO buffers cascaded forward and backward, each receive FIFO buffer output is connected to the tail receive FIFO buffer in an independent lower layer FIFO buffer circuit, and all receive FIFO buffers of all FIFO buffer circuits of the Sth layer are respectively connected to a computing core group. In the same group of forward receive units and forward write units of the same forward transmission block, the number of registers and FIFO buffers is the same, and the details will not be repeated.
[0072] For example, Figure 7 In the figure, write register 1 in Forward write step 1 is not directly connected to computing core group 1, but is connected to Forward write step 11. Then Forward write step 11 continues to include Q write registers, each of which is connected to a computing core group, thus forming a multi-layer nested structure. The last layer is connected to the computing core group, and the same applies to the other parts.
[0073] In the pipeline synchronization loop provided by the present application, the first write register write register 1 in each Forward write step in the same Forward step is cascaded front and back, and data is input through the Forward register, and the data is pushed to different forward write units in a pipeline form. This method can advance forward according to the final destination of the pipeline jump, reduce the data transmission process, quickly push the (intermediate) data to the target forward write unit, and then pass it in sequence inside the unit to the target computing core group.
[0074] Similarly, for the structure of input data, the tail Forward receive step Q in each Forward receive step in the same Forward step is cascaded, and the intermediate data input by different computing core groups is sent to the Forward fifo layer by layer in a pipeline manner. This method allows the data to be pushed forward in a pipeline jump manner, reducing the FIFO cache transmission process.
[0075] In particular, because Backward step i and Forward step M-i+1 are in the same group of transmission blocks and jointly maintain the same computing core group, the forward write unit and the backward write unit in the i-th forward transmission block and the M-i+1-th backward transmission block, which are in the same group, have the same structure. That is, they contain the same number and structure of write registers, and the number of registers and FIFO buffers in the same group of forward receiving units and forward write units in the same forward transmission block is also the same.
[0076] In the above transmission block structure, the forward and backward write units only store one data, so it is a full pipeline situation, and the register can be used to complete the layer-by-layer transmission. However, there is QoS control in the forward receiving unit, and an uncertain number of multiple data may be cached. For this reason, when transmitting write data in each clock cycle, registers + judgment logic are used to implement it. When receiving the data of the computing core group to the main transmission stream in each cycle, the fifo structure is used for buffering, mainly to solve the conflict between the two data sources. In the specific design, it should be noted that the closer to the main stream, the higher the data bandwidth upper limit should be designed. At the same time, for the data sent by the computing core group, multiple receives in the pipeline synchronization ring may arrive at the same time, so fifo is used for caching. In some applications, if the data is expected to have serious data flow conflicts, QoS restrictions can be added where necessary.
[0077] Assume that the pipeline synchronization loop is considered in layers, the top layer is the Forward step 1-Forwardstep M, and the Backward step 1-Backward step M structure. When the Forward step and Backwardstep only have a single-layer register structure (and FIFO cache), the second layer is a single Forward step and Backwardstep structure, and the third layer is the computing core group. Figure 5-7 Taking three layers as an example, when the forward step and the backward step contain multiple layers of register structures, the pipeline level of the overall synchronization loop increases accordingly. Assume that the number of pipeline layers is sync_layers, and the number of pipelines in each layer is sync_steps (i.e., the Q value in the above embodiment, the number in different units can be different, and the attached Figure 6-7 (description with sync_layers=3, sync_steps=3) the maximum number of supported computing core groups is:
[0078] sync_steps sync_layers
[0079] The minimum and maximum delays in the device are:
[0080] latenc_min=sync_layers
[0081] lateny_max=sync_steps*sync_layers
[0082] Taking the A100 graphics card as an example, there are 108 computing core groups SM. At this time, a 3-layer 5-level pipeline is used to support up to 125 computing core groups, with a minimum synchronization delay of 3 cycles and a maximum of 15 cycles. Compared with the multi-level cache mechanism with a minimum synchronization delay of 100 cycles, it is close to the 10 cycles of hitting the L1 cache, or even faster.
[0083] According to the pipeline data push rules of the above-mentioned pipeline synchronization loop, the bit identifier is used to determine whether to send it to the next accelerator device and to determine which computing core group receives it internally during the data push process. Specifically, a bit identifier is set for the data pushed into the pipeline synchronization loop, and the forward transmission block and the backward transmission block determine the state and direction of the data based on the corresponding flag bit of the bit identifier. Before each forward and backward step is pushed, the data direction and whether it is exhausted are determined according to the flag bit of the bit identifier. If exhausted, the data is discarded; if not exhausted, the transmission direction is determined and pushed. Each step is divided into multiple layers of pipelines in order to cope with the large number of computing core groups on some chips, to push data with the shortest delay, and to shorten the length of the bit identifier of the computing core group.
[0084] To summarize, the present application forms a pipeline transmission structure with cascaded forward transmission blocks and cascaded backward transmission blocks. The forward transmission block is divided into cascaded forward receiving units and forward writing units according to input and output; each forward receiving unit adopts multi-stage FIFO cascading and access computing core group, and each forward writing unit adopts multi-stage register cascading and access computing core group to achieve high-concurrency data input and output; adjacent writing units in each transmission block cascade the first register, and adjacent receiving units cascade the tail FIFO, so that the input and output data can be pushed in pipeline between the writing units and the receiving units, as well as the pipeline jump push inside the writing unit and the receiving unit, thereby achieving fast data transmission.
[0085] Inside the accelerator, the computing core groups can directly access the external storage media through multi-channel DMA control, accelerate data extraction and transmission efficiency, read the data in DRAM to the computing core group, or receive the data output by the computing core group and write it back to DRAM; for cross-core group and cross-DRAM data interaction, the switch arbitrator is set to achieve cross-connection of global DRAM and core group data. The accelerator abandons the multi-layer cache design mode, reduces the overall cost, transmits data to the specified computing core with minimal delay, and speeds up the data processing speed of the accelerator.
[0086] Figure 8 It is a structural schematic diagram of the AI acceleration system provided in the present application, which includes at least two accelerators and a data exchange circuit disclosed above, at least two accelerators are respectively connected to a number of DRAMs, and the data sending module and the data receiving module of the accelerator are respectively connected to the data exchange circuit.
[0087] The computing core group in the accelerator is used to perform at least one of matrix operations and vector operations. The sending-end accelerator performs data acceleration tasks and sends matrix data and / or vector data to the data exchange circuit through the data sending module. The receiving-end accelerator receives matrix data and / or vector data through the data receiving module and performs data acceleration tasks.
[0088] Take Transformer (GPT, LLaMa, Gemini, etc. are all transformer architecture models) as an example to illustrate the working principle of the architecture and system. The main calculations of Transformer are concentrated on attention calculations (attention) and linear layer calculations (linear).
[0089] 1. For long sequence linear calculation
[0090] For a sequence calculation O(k)=A(n)W(n,k), there are different parallel computing methods depending on the external topology, the number of AI acceleration devices (hereinafter referred to as devices) in the system, and the size of vectors and matrices.
[0091] It is convenient to perform parallel segmentation according to A. Assuming that the system has 4 devices and each device has a computing core group, we have (linear parallel acceleration 1):
[0092]
[0093]
[0094]
[0095]
[0096] O=(O1,O2,O3,O4)
[0097] In this design, matrix multiplication is generally calculated by the MAC array, that is, the computing core group in the core group performs matrix operations for the MAC array. The four devices extract data through the DMA channel respectively, and then send and receive data after the pipeline operation is performed through the pipeline synchronization ring. The four devices are connected to the external switching circuit or switch at the same time, the purpose is to package and send data. This system is mainly used for multi-device collaborative execution of model acceleration tasks.
[0098] Of course, for pipeline topology or A sequence with a long segmentation, assuming the system has 2 devices, each with two computing core groups, then there is (linear parallel acceleration 2):
[0099]
[0100]
[0101]
[0102]
[0103] O=O1+O2+O3+O4
[0104] The system structure corresponding to this solution is as follows Fig. 9 As shown, because the vector addition operation is completed by the (computing core group) vector computing core, and because there are two devices, the switch or switching circuit can be directly omitted, and the Sender of one device is directly connected to the Receiver of another device to achieve fast data interaction between devices.
[0105] 2. For attention calculation
[0106] For O = softmax(QK T )V, the algorithm can adopt the calculation principle of flash attention. When deployed based on this architecture, further optimization can be made on the data flow. Fig.10 It is an AI accelerator designed based on the flash attention computing principle. The core group is divided into two computing core groups. Each computing core group contains both matrix operations and vector operations. One of the computing core groups contains a MAC array to execute QK T The Vector computing core performs the calculation of m and d, while the other computing core group contains the MAC array to perform the multiplication matrix V calculation, and the Vector computing core performs the calculation of o. Because the execution O = softmax (QK TThe )V algorithm only needs two computing core groups. In order to better simplify the system structure, other structures are omitted. Only the input and output of the two computing core groups are simultaneously connected to the pipeline synchronization ring to implement attention calculation. The main features of this structure are as follows:
[0107] a) Parameters are directly calculated in the MAC array without going through a multi-layer cache mechanism;
[0108] b) Data between computing core groups is transmitted through the pipeline synchronization system (composed of a single device or multiple devices with multiple layers of pipeline synchronization rings, senders, receivers, etc.), and cacheless pipeline transmission can be performed;
[0109] c) It can support larger computing core groups (higher computing density), and the number of computing core groups that need to interact synchronously is reduced overall;
[0110] d) The setting of parallelism is based on the computing core group resources, without considering the cache size, to achieve the best performance.
[0111] In summary, this system architecture has the following beneficial effects in AI model computing scenarios:
[0112] 1) In AI computing scenarios with large model parameters, especially when multiple devices need to collaborate and exchange data globally within the device, it can effectively reduce data synchronization delay and thus improve overall performance;
[0113] 2) This architecture has low cache requirements and can effectively reduce device area while maintaining computing power and DRAM storage capacity, thereby improving yield or increasing computing power density, both of which achieve the goal of cost savings;
[0114] 3) This architecture is scalable and can scale almost linearly with the number of devices in the system. Cluster deployment has a strong cost-effectiveness advantage, especially when the demand for large models becomes more and more widespread, which can reduce the TCO of data centers.
[0115] 4) This architecture has strong adaptability and has fewer restrictions on computing core group design and external connection method design, and can better bring out the existing technical advantages of different designers.
[0116] The preferred embodiments of the present invention are described above; it should be understood that the present invention is not limited to the above-mentioned specific embodiments, and the devices and structures not described in detail should be understood to be implemented in a common manner in the art; any technician familiar with the art can make many possible changes and modifications without departing from the technical solution of the present invention, or modify them into equivalent embodiments with equivalent changes, which does not affect the essential content of the present invention; therefore, any simple modifications, equivalent changes and modifications made to the above embodiments based on the technical essence of the present invention without departing from the content of the technical solution of the present invention are still within the scope of protection of the technical solution of the present invention.
Claims
1. A data acceleration pipeline synchronization loop, characterized in that: The pipeline synchronization ring is connected to N computing core groups in the accelerator, and the pipeline synchronization ring includes M cascaded forward transmission blocks and M cascaded backward transmission blocks; the forward transmission block at the head end and the forward transmission block at the tail end are respectively connected to the data receiving module and the data sending module of the accelerator; The output of the forward transmission block at the tail end is cascaded to the backward transmission block at the head end; The i-th forward transmission block in the cascaded forward transmission block and the M-i+1-th backward transmission block in the cascaded backward transmission block correspond to each other to form a forward and backward transmission group, and each forward and backward transmission group is commonly connected to at least one computing core group; the forward and backward transmission group sends data to the target computing core group in a pipeline form according to the clock cycle for calculation, and sends the data output by the computing core group to the pipeline synchronization ring; The forward transmission block includes a forward register, a forward receiving unit and a forward writing unit, and the backward transmission block includes a backward register and a backward writing receiving unit; the forward receiving unit receives the data input by the computing core group and sends it to the pipeline synchronization ring in a pipeline form, and the forward writing unit and the backward writing unit push the data to the target computing core group in a pipeline form.
2. The data acceleration pipeline synchronization ring according to claim 1, characterized in that: The backward transmission block includes a backward register and P backward writing units cascaded forward and backward; P is a positive integer; The backward register is connected to the output end of the previous cascade transmission block to receive and store intermediate data; One output of the backward register is connected to the first backward write unit, and the data is pushed to the target backward write unit in a pipeline manner through the cascade structure. Another output is directly connected to the next cascade transmission block, and the intermediate data is pushed to the target transmission block in a pipeline manner.
3. The data acceleration pipeline synchronization ring according to claim 2, characterized in that: The first write registers in each backward write unit in the same backward transmission block are cascaded front and back, data is input through the backward registers, and the data is pushed to different forward write units in a pipeline manner; The backward writing unit includes at least Q write registers cascaded forward and backward, each write register is connected to a computing core group, and pushes data to the target computing core group in the forward writing unit in a pipeline form.
4. The data acceleration pipeline synchronization ring according to claim 2, characterized in that: The forward transmission block includes a forward FIFO buffer, a forward register, a P group of forward receiving units and a forward writing unit; P is a positive integer; P forward receiving units are cascaded front to back, and P forward writing units are cascaded front to back, and the forward writing units and forward receiving units in the same group are connected to the same computing core group; One input end of the forward FIFO buffer is connected to the output of the previous cascade transmission block to receive and store intermediate data, and the other input end is connected to the output of the tail-end forward receiving unit to receive data output from the tail-end forward receiving unit; The output of the forward FIFO buffer is connected to the forward register, and the output of the forward register is connected to the first forward write unit, so that the pipeline data is pushed to the target forward write unit through a cascade structure.
5. The data acceleration pipeline synchronization ring according to claim 4, characterized in that: The forward writing unit includes at least Q forward and backward cascaded writing registers, each writing register is connected to a computing core group, and the data is pushed to the target computing core group in the forward writing unit in a pipeline manner; The forward receiving unit includes at least Q receiving FIFO buffers cascaded forward and backward, each receiving FIFO buffer is connected to a computing core group, caches the intermediate data input by the computing core group, and sends the intermediate data to the pipeline synchronization ring layer by layer in a pipeline form.
6. The data acceleration pipeline synchronization ring according to claim 5, characterized in that: The first write registers in each forward write unit in the same forward transmission block are cascaded front and back, data is input through the forward registers, and the data is pushed to different forward write units in a pipeline form; The tail end receiving FIFO buffers in each forward receiving unit in the same forward transmission block are cascaded front and back, and the intermediate data input by different computing core groups are sent to the forward FIFO buffer layer by layer in a pipeline manner.
7. The data acceleration pipeline synchronization ring according to claim 4, characterized in that: In the i-th forward transmission block and the (M-i+1)-th backward transmission block, the forward writing unit and the backward writing unit located in the same group have the same structure.
8. The data acceleration pipeline synchronization ring according to claim 7, characterized in that: In the same group of forward receiving units and forward writing units of the same forward transmission block, the numbers of registers and FIFO buffers are the same.
9. The data acceleration pipeline synchronization ring according to claim 4, characterized in that: The forward write unit includes S layers of register circuits, each layer of register circuits includes at least Q write registers cascaded forward and backward, each write register output is connected to the first write register in an independent lower layer register circuit, and all write registers of all register circuits of the Sth layer are respectively connected to a computing core group; The forward receiving unit includes S layers of FIFO buffer circuits, each layer of FIFO buffer includes at least Q receiving FIFO buffers cascaded forward and backward, each receiving FIFO buffer output is connected to a tail receiving FIFO buffer in an independent lower layer FIFO buffer circuit, and all receiving FIFO buffers of all FIFO buffer circuits of the Sth layer are respectively connected to a computing core group; In the same group of forward receiving units and forward writing units of the same forward transmission block, the numbers of registers and FIFO buffers are the same.
10. The data acceleration pipeline synchronization ring according to claim 5, characterized in that: The data pushed into the pipeline synchronization ring is provided with a bit identifier, and the forward transmission block and the backward transmission block determine the state and flow direction of the data based on the corresponding flag bit of the bit identifier; When the flag bit of the bit identifier indicates that the data is exhausted, the data is directly discarded; When the flag bit of the bit identifier indicates that the data is not exhausted, the data is sent to the write register layer by layer until it is pushed into the target computing core group.
