Optimized group-wise quantized matmul on neural network accelerator
By reshaping matrices and optimizing workload management in DNN accelerators through group-wise quantized MatMul, the solution addresses performance issues in large transformer-based models, enhancing efficiency and competitiveness.
Patent Information
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- INTEL CORP
- Filing Date
- 2025-03-27
- Publication Date
- 2026-07-30
AI Technical Summary
DNN accelerators experience suboptimal performance due to significant workload management overhead from channel-wise quantized MatMuls, leading to low hardware utilization and time stalls, especially in large transformer-based models with billions of parameters.
Implement group-wise quantized MatMul by reshaping input and weight matrices, splitting them into sub-groups for optimized computation, and generating workload descriptors to reduce overhead and improve hardware utilization.
Enhances DNN accelerator performance by fully utilizing hardware capabilities and improving the efficiency of large language models, reducing workload overhead and computation time.
Smart Images

Figure CN2025085221_30072026_PF_FP_ABST
Abstract
Description
OPTIMIZED GROUP-WISE QUANTIZED MATMUL ON NEURAL NETWORK ACCELERATORCross-reference to Related Application (s)
[0001] This application claims priority to and / or receives benefit from International Application No. PCT / CN2025 / 074707, filed on 24 January 2025, titled, OPTIMIZED GROUP-WISE QUANTIZED MATMUL ON NEURAL NETWORK ACCELERATOR. The International Application is hereby incorporated by reference in its entirety.Background
[0002] Deep neural networks (DNNs) are used extensively for a variety of artificial intelligence applications ranging from computer vision to speech recognition and natural language processing due to their ability to achieve high accuracy. However, the high accuracy comes at the expense of significant computation cost. DNNs have extremely high computing demands as there can be a large number of operations as well as a large amount of data to read and write.Brief Description of the Drawings
[0003] Embodiments will be readily understood by the following detailed description in conjunction with the accompanying drawings. To facilitate this description, like reference numerals designate like structural elements. Embodiments are illustrated by way of example, and not by way of limitation, in the figures of the accompanying drawings.
[0004] FIG. 1 illustrates a DNN system, according to some embodiments of the disclosure.
[0005] FIG. 2 illustrates a processing engine, according to some embodiments of the disclosure.
[0006] FIG. 3 illustrates a post-processing engine, according to some embodiments of the disclosure.
[0007] FIG. 4 illustrates a DNN module, according to some embodiments of the disclosure.
[0008] FIG. 5 illustrates a matrix multiplication (MatMul) with N as input channel size, according to some embodiments of the disclosure.
[0009] FIG. 6 illustrates unrolled MatMuls with T as the input channel size, according to some embodiments of the disclosure.
[0010] FIG. 7 illustrates a matrix C illustrating relevant data to be calculated, according to some embodiments of the disclosure.
[0011] FIG. 8 illustrates MatMul with sub-group optimization to trade off computation for workload overhead, according to some embodiments of the disclosure.
[0012] FIG. 9 illustrates impact of applying sub-group optimization, according to some embodiments of the disclosure.
[0013] FIG. 10 illustrates reshaping an input matrix and a weight matrix (also referred to as a further input matrix) , according to some embodiments of the disclosure.
[0014] FIG. 11 illustrates applying sub-group optimization, according to some embodiments of the disclosure.
[0015] FIG. 12 illustrates a compiler, according to some embodiments of the disclosure.
[0016] FIG. 13 depicts a flow diagram of a method for performing a group-wise quantized MatMul operation using channel-wise quantized MatMul operation, according to some embodiments of the disclosure.
[0017] FIG. 14 depicts a flow diagram of a method for compiling a group-wise quantized MatMul operation, according to some embodiments of the disclosure.
[0018] FIG. 15 is a block diagram of an exemplary computing device, according to some embodiments of the disclosure.Detailed DescriptionOverview
[0019] DNNs are used in a variety of applications in the domains such as computer vision, speech recognition, image generation, video generation, etc. DNNs can achieve high accuracy, and in some cases, perform at superhuman-level accuracy. DNNs have interconnected neurons (or operations) that process data, and the layered structure of neural networks enable complex machine learning tasks to be performed. Neural network hardware accelerators (referred to herein as DNN accelerators) with specialized circuitry can perform the operations in an efficient manner.
[0020] In some neural network hardware accelerators, multiple data processing units (DPUs) can be provided in the neural network hardware accelerator to enable fast, specialized, and parallel data processing. In a DPU, a data processing pipeline may be implemented to include a processing engine and a post-processing engine (PPE) . The processing engine may be tasked to perform neural network operations such as matrix multiplications (e.g., MatMul) and convolutions, while the PPE following the processing engine may be tasked to apply neural network operations such as scaling, adding a bias, and applying an activation function. A data processing workload can be scheduled and initiated onto the DPU to be executed by the data processing pipeline. To configure the DPU to perform a data processing workload, a configuration descriptor can be used and loaded onto the DPU to cause the DPU to perform one or more neural network operations of the data processing workload. The configuration descriptor can include instructions and / or register configurations that would configure the hardware circuitry, including registers, of the data processing pipeline to perform the one or more neural network operations on input data and produce output data. In some contexts, a configuration descriptor may be referred to as a workload descriptor.
[0021] Prior to deployment of a neural network model onto a neural network hardware accelerator, a compiler can receive a neural network definition that includes neural network operations associated with a neural network model. Based on the neural network definition, the compiler can identify one or more data processing workloads to be executed by the DPUs of the neural network hardware accelerator. The compiler can produce a processing graph having the one or more data processing workloads. Based on the one or more data processing workloads, the compiler can produce workload descriptors or configuration descriptors that can be used to configure the data processing units of the neural network hardware accelerator to carry out the one or more data processing workloads. Data processing units of a neural network hardware accelerator may be configured to perform neural network operations of the neural network model using configuration descriptors generated by the compiler.
[0022] DNNs have grown, in the era of using DNNs such as transformer-based DNNs to implement large language models (LLMs) , from having millions of parameters to billions of parameters. Larger models have caused 1000X growth in computing demand in just a few years, as the community develop larger models for higher accuracy. LLMs are a type of DNN that has been used for processing and generating data to support a variety of artificial intelligence (AI) tasks. LLMs leverage complex neural networks, typically based on transformer architectures, to capture intricate patterns in language, enabling them to perform tasks such as text completion, question answering, translation, and even creative writing. The scale of these models, often comprising billions of parameters, allows them to exhibit remarkable linguistic capabilities and a degree of general knowledge that was previously unattainable in machine learning systems. Transformer architectures can also be used for other modalities including computer vision and audio.
[0023] Group matrix multiplication (MatMul) is used in Multi-Head Attention (MHA) and Grouped Query Attention (GQA) within LLMs such as Llama (by Meta) , Generative Pre-trained Transformer (by OpenAI) , and Phi3 (by Microsoft) . Additionally, Generative Pre-trained Transformer Quantization (GPTQ) can be employed to quantize weights. In particular, group-wise quantization can be used for weight compression, resulting in data quantization on both the output and input channels when converted to convolution on a DNN accelerator. In some implementations, quantization of a floating-point number, XFP16, into an integer number, XINT, can be expressed as:
[0024] A scaling factor, one of the quantization parameters, is denoted as ScalingFactor. A zero-point, one of the quantization parameters, is denoted as ZeroPoint. For symmetric quantization, ZeroPoint=0. For asymmetric quantization, ZeroPoint=min (XFP16) . Group-wise quantization, when used for weight compression, means that different groups have different corresponding quantization parameters. A weight matrix (or a weight tensor) is split in different groups, where weights within a group share the same quantization parameters.
[0025] However, on some DNN accelerators, these group MatMuls may have suboptimal performance. For those DNN accelerators, without modification to the data processing graph or how workload descriptors are generated, a group MatMul is split into many smaller channel-wise quantized MatMuls, which can result in significant overhead from launching and managing these smaller operations or workloads. Unrolling the MatMul into smaller operations with the same input channel scale value (referred to as channel-wise quantization) as the number of groups can lead to significant increase in workload count, while the compute overhead for each workload is small. Consequently, hardware utilization is low, with time stalls occurring due to the extensive workload management overhead.
[0026] One possible solution to this issue is to improve the performance of workload management. With better workload management, the total overhead can be reduced. Another possible solution is to perform dynamic dequantization to avoid grouped calculation, but that solution introduces more memory traffic and is not good for generation phase which is memory bandwidth bound.
[0027] To better address the problem of workload overhead, the group-quantized MatMul can be expanded into a larger MatMul that is compatible with DNN accelerator hardware implementing channel-wise quantization. The MatMul operation is instead performed on a reshaped input matrix and a reshaped weight matrix, and unnecessary outputs are discarded. The result still obtains the correct result for MatMul. To trade off calculation complexity for workload overhead, the solution splits the larger MatMul into smaller ones. As a result, the total workload overhead is reduced, leading to improved performance.
[0028] The compiler is improved to include the ability to identify opportunities to utilize the improved MatMul operation and generate a data processing graph accordingly. The compiler can generate configuration descriptors based on the data processing graph. When the configuration descriptors are used on a DNN accelerator, the execution of group MatMul can be streamlined with reduced workload overhead.
[0029] The compiler may receive a processing graph representing operations of a neural network. In particular, the compiler may identify that the processing graph has a group-wise quantized matrix multiplication operation. The matrix multiplication operation may perform multiplication of an input matrix with a further input matrix (e.g., multiplication of an input activation matrix and a weight matrix) . In some embodiments, the matrix multiplication operation may be a part of a convolution operation.
[0030] The matrix multiplication operation may be group-wise quantized according to a group size and a number of groups. Different groups may be quantized according to different quantization parameters. Values in a group share the same quantization parameters. A group size corresponds to a number of values that a group has. Group-wise quantized matrix multiplication, when applied to achieve weight compression, may apply different quantization parameters to a number of different groups of weight values of a weight matrix, where a group has a particular group size (or a number of weight values) .
[0031] The compiler may generate an instruction or a workload descriptor to cause a data processing unit to operate on reshaped input matrices, such as a reshaped input matrix and a further reshaped input matrix (also referred to as the reshaped weight matrix herein) . The input matrix can be reshaped to the group size and the number of groups. The further input matrix (e.g., the weight matrix) can be reshaped according to the group size and the number of groups. Reshaping rearranges or reorganizes the elements in a matrix to have a different shape. Reshaping can involve a logical operation rather than a physical data movement operation in hardware. Reshaping can involve recalculating memory addresses for reading the matrix to effectively change the shape of the matrix. In some implementations, reshaping involves changing the manner in which values are read from memory and loaded onto operand registers or memory when performing a mathematical operation. Reshaping a matrix involves changing the dimensions while keeping the same number of elements in the matrix. In some cases, the output matrix being produced by the matrix multiplication operation can be reshaped the group size and the number of groups.
[0032] The shape of the input matrix can be 1xN. The shape of the weight matrix can be NxM. The weight matrix can be applied to the input matrix as part of a neural network operation. The input matrix can be multiplied with the weight matrix. The weight matrix can be applied to the input matrix as a convolution filter or kernel. For the purpose of illustration herein and throughout the written description herewith, the weight matrix NxM is also referred to as “the further input matrix” . The shape of the output matrix can be 1xM. Suppose group-wise quantization is applied along the dimension with N elements and divides the N elements into T groups with a group size of S. N=TxS. The shape of the reshaped input matrix can be the number of groups by the group size, e.g., TxS. The shape of the further reshaped input matrix can be the group size by a product of the number of groups and a dimension of the further input matrix or the output matrix of the matrix multiplication operation, e.g., Sx (T*M) . The shape of the reshaped output matrix can be the number of groups by a product of the number of groups and a dimension of the further input matrix or the output matrix, e.g., Tx (T*M) . One or more slices in the reshaped output matrix can be accumulated to obtain the output matrix having shape 1xM.
[0033] To reduce computations, the reshaped input matrix and the reshaped output matrix can be divided / split into a number of sub-groups, and matrix multiplication workload descriptors can be generated according to the sub-groups, while still generating the one or more slices to be accumulated to obtain the output matrix having shape 1xM. In one example, T can be split into P sub-groups where a sub-group size is Q. T=PxQ. For each sub-group, an input matrix Ap can have a shape QxS, the further input matrix Bp can have a shape Sx (Q*S) . The output matrix Cp can have a shape Qx (Q*M) . Matrix multiplication can be performed on the smaller parts of the reshaped input matrix and the smaller parts of the reshaped output matrix.
[0034] For example, the compiler can generate a matrix multiplication workload descriptor configuring the neural network hardware accelerator to compute a product of a part of the reshaped input matrix (Ap) and a part of the further reshaped input matrix (Bp) . The compiler can generate an accumulation workload descriptor to accumulate one or more slices of the product. The compiler can generate a further matrix multiplication workload descriptor configuring the neural network hardware accelerator to compute a further product of a further part of the reshaped input matrix (Ap) and a further part of the further reshaped input matrix (Bp) . The compiler can generate a further accumulation workload descriptor to accumulate one or more slices of the further product.
[0035] To perform group-wise quantized MatMul using channel-wise quantized MatMuls, the DNN accelerator may reshape an input matrix and a further input matrix according to a group size and a number of groups to obtain a reshaped input matrix and a further reshaped input matrix. The group size and the number of groups can correspond to the group-wise quantized MatMul. The reshaped input matrix and the further reshaped input matrix can undergo sub-group optimization so that computations are reduced. The DNN can perform matrix multiplication operation (e.g., a channel-wise quantized MatMul operation) on a part of the reshaped input matrix and a part of the further reshaped input matrix. Slices of the product obtained by the matrix multiplication operation can be accumulated to determine the final result of multiplying the input matrix and the further input matrix. The process of performing matrix multiplication operations can be repeated for additional sub-group (s) . Further slices from the operations are accumulated to form the final result.
[0036] This solution enables the DNN accelerator to fully utilize its hardware computing capability and improves the performance of LLM models, enhancing the performance and competitiveness of the DNN accelerator.Implementing DNNs on processors or neural network hardware accelerators
[0037] The significant improvements in DNN model size and accuracy coupled with the rapid increase in computing power of execution platforms have led to the adoption of DNN applications even within resource constrained mobile and edge devices that have limited power availability. DNN models may be executed, e.g., for training or inference, by DNN accelerators, or referred to herein as neural network hardware accelerators. A DNN accelerator may be or include one or more data processing units, or DPUs. A DPU may also be referred to as a compute block or compute tile. A DPU has highly specialized hardware circuitry to perform neural network operations. A DPU may include one or more processing engines that can carry out neural network operations or compute operations. A processing engine may include one or more processing cells to perform arithmetic operations associated with neural network operations, such as multiplication, and multiplication and accumulate. A DPU may include one or more PPEs that can carry out neural network operations such as scaling, adding a bias, and applying an activation function.
[0038] Herein and as understood by one skilled in the art, a tensor is a mathematical object that includes scalars, vectors, and matrices, and even data structures in higher dimensions. At its most basic level, a tensor can be a single number, known as a scalar. When extended to one dimension, a tensor can be vector, which is an array of numbers. Further extending to two dimensions, a tensor can be a matrix, which is a grid of numbers. Beyond these, tensors can exist in multiple dimensions, representing complex data structures that can be manipulated and transformed in various ways by a DNN accelerator. In the context of neural networks, tensors can be used to store multidimensional data. A neural network involves operations on tensors. Examples of operations may include addition, subtraction, multiplication, convolution, reshaping, transposition, slicing and indexing, broadcasting, etc. The operations manipulate and transform tensors to perform neural network tasks such as training and inference. Various embodiments relating to matrices and MatMul herein can be applied to tensors more generally.
[0039] FIG. 1 illustrates DNN system 100, according to some embodiments of the disclosure. The whole DNN system 100 or a part of DNN system 100 may be implemented in one or more computing devices, such as the computing device 1500 in FIG. 15. DNN system 100 can generate and execute DNNs, such as transformer-based neural networks, convolutional neural networks, and so on. As shown in FIG. 1, DNN system 100 includes DNN module 101 and DNN accelerator 102. In other embodiments, alternative configurations, different or additional components may be included in DNN system 100. For instance, DNN system 100 may include multiple DNN modules or multiple DNN accelerators. Further, functionality attributed to a component of DNN system 100 may be accomplished by a different component included in DNN system 100 or a different system. In some embodiments, DNN module 101 and DNN accelerator 102 may include or be implemented by different types of processing units. In an example, DNN module 101 may be implemented by one or more central processing units (CPUs) . DNN accelerator 102 may also be referred to as a neural network hardware accelerator, a neural processing unit, AI accelerator, or AI processor. DNN module 101 and DNN accelerator 102 may be implemented in the same chip or as separate chips.
[0040] DNN module 101 facilitates generation and deployment of DNNs. In some embodiments, the DNN module 101 may generate and train DNNs. For instance, the DNN module 101 can define the layered architecture of a DNN. The DNN module 101 can also determine the internal parameters of the DNN through a DNN training process. The DNN module 101 may also determine one or more hyperparameters that define how the DNN is trained. An example hyperparameter is a sparsity ratio that defines the sparsity level of one or more deep learning tensors for the DNN.
[0041] DNN module 101 may compress DNNs, e.g., during or after training. In some embodiments, DNN module 101 may prune weights in one or more layers of a DNN by changing nonzero valued weight to zeros. DNN module 101 may prune weights based on a target weight sparsity ratio. A weight sparsity ratio may be the ratio of the number of zero-valued weights to the total number of weights. In an example where the DNN module 101 prunes weight during DNN training, the DNN module 101 may prune weight of a layer to achieve a target sparsity ratio after one or more epochs. DNN module 101 may prevent the pruned weights from changing values during the rest of the training process. Alternatively, DNN module 101 may allow the pruned weights to change values so that a pruned, zero-valued weight may have a nonzero value after further training. DNN module 101 may prune weights of the layer again after one or more additional epochs.
[0042] DNN module 101 may deploy trained, compressed, or validated DNNs for use in deep learning applications. In some embodiments, DNN module 101 may distribute trained, compressed, or validated DNNs to devices or systems which may use the DNNs to perform tasks (e.g., image classification, motion planning, etc. ) for which the DNNs were trained. In other embodiments, DNN module 101 may facilitate deployment of the DNNs using the DNN accelerator 102. For instance, DNN module 101 may receive data from a device or system coupled with DNN system 100 and input the received data (or data generated by DNN module 101, e.g., based on the received data) into a DNN. In some embodiments, DNN module 101 may control execution processes of trained, compressed, or validated DNNs.
[0043] DNN module 101 may compile instructions executable by DNN accelerator 102 to perform operations of a DNN in accordance with a model definition of the DNN. DNN module 101 may generate instructions (e.g., configuration descriptors, low-level machine instructions, etc. ) that control the operation of the DNN accelerator 102 during the DNN execution. The instructions may correspond to one or more data processing workloads sent from DNN module 101 to DNN accelerator 102, where the one or more data processing workloads are to be executed by DNN accelerator 102. DNN module 101 may function as a compiler for DNNs to be deployed onto and executed by DNN accelerator 102. DNN module 101 may perform compilation of DNNs and generate configuration descriptors and / or low-level machine instructions, based on which the DNNs may be executed. The instructions may be used to configure or control processing cells of processing engine 170 to perform one or more deep neural network operations. The instructions may be used to configure or control post-processing engine 180 to perform one or more operations such as applying an activation function. Certain aspects of the DNN module 101 are described and illustrated in FIGS. 4 and 10.
[0044] DNN module 101 may receive an output of the DNN from the DNN accelerator 102. DNN module 101 may transmit the output of the DNN (or a result of processing the output of the DNN by DNN module 101) to the device or system.
[0045] DNN accelerator 102 executes operations of DNNs, based on instructions (configuration descriptors and / or low-level machine instructions) provided by DNN module 101. For instance, DNN accelerator 102 can execute a DNN by running deep learning operations in the DNN. The process of carrying out a deep learning operation is also referred to as a process of executing the deep learning operation or a process of performing the deep learning operation. The execution of the DNN may be for training the DNN or for using the DNN to perform AI and / or inference tasks.
[0046] As shown in FIG. 1, DNN accelerator 102 includes memory 110, direct memory access (DMA) engine 120, and data processing units 130 (individually referred to as “data processing unit 130” ) . In other embodiments, alternative configurations, different or additional components may be included in DNN accelerator 102. For example, DNN accelerator 102 may include more than one memory 110 or DMA engine 120. As another example, DNN accelerator 102 may include a single data processing unit 130. Further, functionality attributed to a component of DNN accelerator 102 may be accomplished by a different component included in DNN accelerator 102 or by a different system. A component of DNN accelerator 102 may be implemented in hardware, software, firmware, or some combination thereof.
[0047] Memory 110 stores data associated with deep learning operations performed by DNN accelerator 102. Example deep learning operations include convolutions (also referred to as “convolutional operations” ) , layer normalization operations, SoftMax operations, matrix multiplication operations, pooling operations, elementwise operations, activation functions, other types of deep learning operations, or some combination thereof.
[0048] In some embodiments, memory 110 may store data to be used by the data processing units 130 for DNN execution. memory 110 may store weights, such as weights of convolutional layers, which are determined by training DNNs. Memory 110 may further store inputs to DNN layers and / or outputs of DNN layers, such as data generated by the data processing units 130 from performing deep learning operations in DNNs.
[0049] Memory 110 may store instructions (e.g., configuration descriptors, low-level machine instructions, etc. ) executable by DNN accelerator 102, such as instructions executable by data processing unit 130. Memory 110 may be a main memory of DNN accelerator 102. In some embodiments, memory 110 includes one or more dynamic random access memories (DRAMs) . In some embodiments, cache 112 may serve as a cache for memory 110. Cache 112 may include one or more SRAMs. Cache 112 may offer faster data / memory accesses than memory 110. Cache 112 may store data that is frequently accessed. Capacity of cache 112 is smaller than the capacity of memory 110.
[0050] DMA engine 120 facilitates data transfer between memory 110 and local memories 140 of the data processing units 130. For example, DMA engine 120 can read data from memory 110 and write data into local memory 140 of data processing unit 130. As another example, DMA engine 120 can read data from local memory 140 of data processing unit 130 and write data into memory 110. DMA engine 120 provides a DMA feature that allows data processing unit 130 to initiate data transfer between memory 110 and local memories 140 of the data processing units 130 and to perform other operations while the data transfer is being conducted. In some embodiments, DMA engine 120 may read tensors from memory 110, modify the tensors in a way that is optimized for data processing unit 130 before it writes the tensors into local memories 140 of data processing units 130.
[0051] Data processing units 130 perform deep learning operations in DNNs. For instance, data processing unit 130 may execute a DNN layer by running one or more deep learning operations in the DNN layer. Data processing unit 130 may execute a layer, or a portion of a layer, at a time. In some embodiments, the operations of the DNN layers may be run by multiple data processing units 130 in parallel. For instance, multiple data processing units 130 may each perform a data processing workload, or a portion of a data processing workload for a deep learning operation. Data may be shared between data processing units 130. Data processing unit 130 may also be referred to as a compute block, or a compute tile.
[0052] Data processing units 130 may be capable of running various types of deep learning operations, such as convolution, layer normalization, SoftMax operation, pooling, elementwise operation, linear operation, non-linear operation, MatMul, and so on. Deep learning operations performed by the data processing units 130 include tensor operations, i.e., operations whose inputs are tensors or operations whose outputs are tensors. In an example, data processing unit 130 receives an input tensor and one or more convolutional kernels and performs a convolution with the input tensor and convolutional kernels. The result of the convolution may be an output tensor, which can be further computed, e.g., by data processing unit 130 or another data processing unit 130.
[0053] In the embodiments of FIG. 1, each data processing unit 130 includes local memory 140, load module 160, processing engine 170, post-processing engine 180, and output module 190. Data processing unit 130 may include a data processing pipeline that includes load module 160, processing engine 170, post-processing engine 180, and output module 190. Some or all the components of the data processing unit 130 can be implemented on the same chip. In other embodiments, alternative configurations, different or additional components may be included in the data processing unit 130. Further, functionality attributed to a component of data processing unit 130 may be accomplished by a different component included in the data processing unit 130, a different data processing unit 130, another component of the DNN accelerator 102, or a different system. A component of the data processing unit 130 may be implemented in hardware, software, firmware, or some combination thereof.
[0054] Local memory 140 is local to the corresponding data processing unit 130. In the embodiments of FIG. 1, local memory 140 is inside the data processing unit 130. In other embodiments, local memory 140 may be outside the data processing unit 130. Local memory 140 may include one or more SRAMs. The capacity of local memory 140 (e.g., 1.5-2 Megabytes) may be far smaller than the capacity of memory 110. Data in local memory 140 may be transferred to or from memory 110, or cache 112, e.g., through DMA engine 120. In some embodiments, data in local memory 140 may be transferred to or from local memory 140 of another data processing unit 130. Local memory 140 may store data received, used, or generated by load module 160, processing engine 170, post-processing engine 180, or output module 190. Examples of the data may include input activations, weights, output activations, low-level machine instructions, configuration descriptors, and so on.
[0055] In some embodiments, local memory 140 may store tensors to be processed by the processing engine 170 or the post-processing engine 180. The tensors may be input tensors of deep learning operations. Local memory 140 may also store tensors generated by processing engine 170 or post-processing engine 180. The tensors may be output tensors of deep learning operations. The layout of data points of a tensor in local memory 140 may depend on the format in which the tensor is stored. In some embodiments, local memory 140 may store tensors in various formats, including Z-major format, X-major format, and Y-major format. For a tensor with Z-major format, the local memory 140 may store data points having the same (x, y) coordinate contiguously. For instance, the data points having the same (x, y) coordinate may be stored at a sequence of memory addresses the local memory 140. For a tensor with the ZXY format or ZYX format, local memory 140 may store data points having the same (x, y) coordinate contiguously. For instance, the data points having the same (x, y) coordinate may be stored at a sequence of memory addresses in local memory 140. For a tensor with X-major format, local memory 140 may store data points having the same (y, z) coordinate contiguously. For a tensor with Y-major format, local memory 140 may store data points having the same (x, z) coordinate contiguously.
[0056] In some embodiments, local memory 140 may store dense tensors (e.g., dense activation tensors, dense weight tensors, etc. ) , sparse tensors (e.g., sparse activation tensors, sparse weight tensors, etc. ) , and so on. A dense tensor may be a tensor from which zero-valued elements (if any) are not removed. A dense tensor may be converted to a sparse tensor by removing one or more zero-valued elements in the dense tensor. A sparse tensor may also be referred to as a compressed tensor or packed tensor. The process of converting a dense tensor to a sparse tensor may be referred to as sparsity encoding. Sparsity encoding may also generate a sparsity tensor. Each element in the sparsity tensor may correspond to a different element in the dense tensor and indicate whether the element in the dense tensor is zero or not. The sparsity tensor may indicate positions of elements of the sparse tensor in the dense tensor. The sparsity tensor may include a sparsity bitmap, each element of which is a bit. A sparse tensor may be converted to a dense tensor through a densifying process, in which one or more zeros may be added to the sparse tensor based on the sparsity tensor.
[0057] In some embodiments, local memory 140 includes one or more SRAMs. Local memory 140 may be byte-addressable, and each memory address identifies a single byte (eight bits) of storage. In some embodiments, local memory 140 may include memory banks. The number of data banks in the local memory 140 may be 16, 64, 128, 356, 512, 1024, 2048, or other numbers. A memory bank may include a plurality of storage units. In an example, a data bank may include 8, 16, 64, or a different number of storage units. A memory bank or a storage unit in a memory bank may have a memory address. In an example, a storage unit may store a single byte, and data larger than a single byte may be stored in storage units with consecutive memory addresses, i.e., adjacent storage units. For instance, a storage unit can store an integer number in the INT8 format, versus two storage units may be needed to store a number in the FP16 or BF16 format, which has 16 bits. In some embodiments, 16 bits can be transferred from local memory 140 in a single read cycle. In other embodiments, 16 bits can be transferred from local memory 140 in multiple read cycles, such as two cycles.
[0058] Load module 160 loads data from local memory 140 to the processing engine 170 or to post-processing engine 180. Load module 160 may load data from local memory 140 to one or more data buffers of the processing engine 170. Load module 160 may read tensors from the local memory 140. The tensors may include sparse activation tensors, sparse weight tensors, activation sparsity tensors, weight sparsity tensors, and so on. In some embodiments, load module 160 may load data based on a sparsity mode. Load module 160 may select different data to transmit to the processing engine 170 in different sparsity modes.
[0059] Processing engine 170 performs neural network operations of DNNs. An exemplary processing engine 170 is described and illustrated in FIG. 2.
[0060] Post-processing engine 180 processes outputs of processing engine 170. The post-processing engine 180 may include one or more post-processing elements. In some embodiments, the post-processing elements in the post-processing engine 180 may be arranged in an arrangement (e.g., in an array arrangement) that has rows and columns. In some embodiments, post-processing engine 180 computes activation functions. Post-processing engine 180 may receive outputs of processing engine 170 as inputs to the activation functions. In addition or alternative to activation functions, post-processing engine 180 may perform other types of post-processing on outputs of processing engine 170. For instance, post-processing engine 180 may apply a bias on an output of processing engine 170. For instance, post-processing engine 180 may perform scaling on an output of processing engine 170. In some embodiments, post-processing engine 180 may be bypassed for certain neural network operations.
[0061] Output module 190 drains data from processing engine 170 and / or from post-processing engine 180. Output module 190 may write the data to local memory 140. The drained data may be tensors, such as output tensors of neural network operations. In some embodiments, output module 190 may drain data on a cell level of processing engine 170. For each processing cell, output module 190 may drain outputs of processing elements in the processing cell based on a row index or column index of each processing element. For instance, output module 190 may use a sequence of cycles to drain data from a processing cell. Output module 190 may drain the output of some of the processing elements in each cycle. The sequence of the cycles may be configured based on a configuration parameter indicating the operation mode of load module 160. The drained data, e.g., tensors, may be further loaded to memory 110, e.g., through the DMA engine 120. Additionally or alternatively, the drained data may be loaded by the load module 160 to the processing engine 170 for further computation, e.g., for performing a deep learning operation in the next layer.
[0062] FIG. 2 illustrates processing engine 170, according to some embodiments of the disclosure. Processing engine 170 may be included as part of a data processing unit, such as data processing unit 130 of FIG. 1. Processing engine 170 may include one or more processing cells 202. In some embodiments, processing cells 202 may be arranged in one or more rows and / or one or more columns in the processing engine 170. In some embodiments, processing cells 202 may be arranged as one or more sets or arrays of processing cells 202 performing different operations. Processing engine 170 may have one or more arrays of multiply and accumulate circuity (e.g., processing cells 202) optimized to perform compute operations such as MatMul and convolution.
[0063] Each processing cell (e.g., processing cell 202) may include one or more processing elements. In some cases, a processing cell includes a single processing element. In some cases, a processing cell includes a plurality of processing elements. The processing elements may be arranged as an array. The processing elements may be arranged in rows and / or columns. In some cases, a processing cell may include processing element (s) that perform the same operation. In some cases, a processing cell may include processing element (s) that perform different operations. In some cases, at least some of the processing element (s) in a processing cell may be arranged to perform operations in parallel. In some cases, at least some of the processing element (s) in a processing cell may be arranged to perform operations serially.
[0064] A processing element may perform an arithmetic operation associated with neural network operations or DNN operations. In some cases, the one or more processing elements that may be arranged in an array that includes rows and columns. Examples of processing elements may include a multiply unit, a division unit, a scaling unit, an adding unit, an accumulator unit a subtractor unit, a logarithmic unit, an exponentiation unit, a multiply-accumulate (MAC) unit, a bit shift unit, a square root unit, etc. The processing elements in processing cells may be arranged to perform an arithmetic operation on a vector of inputs to generate a vector of outputs (in parallel) , sometimes referred to as vector processing. The processing elements in processing cells may perform scalar operations.
[0065] Processing engine 170 may include controller 204, which may configure circuitry of one or more processing cells 202 to perform the arithmetic operations. In some cases, controller 204 may configure one or more processing cells 202 (or individual processing elements in a processing cell 202) to perform operations in a particular sequence or manner. In some cases, controller 204 may configure one or more processing cells 202 (or individual processing elements in a processing cell 202) according to instructions (e.g., configuration descriptors, and / or low-level machine instructions) loaded in instruction buffer 206. Controller 204 may include a program counter to determine the instructions loaded in instruction buffer 206 to be executed by one or more processing cells 202 (or individual processing elements in a processing cell 202) .
[0066] The instructions (e.g., configuration descriptors, and / or low-level machine instructions) loaded in instruction buffer 206 may signal which processing cells 202 (or individual processing elements in a processing cell 202) is to execute or carry out one or more operations. Instruction buffer 206 may include one or more register files, or one or more arrays of memory cells.
[0067] Data may be loaded in data buffers 208 by controller 204 and / or load module 160 of FIG. 1. The data may be used by processing cells 202. Data produced by processing cells 202 may be drained from data buffers 208 by output module 190 to local memory 140 of FIG. 1. Data buffers 208 may include one or more register files, or one or more arrays of memory cells.
[0068] Data buffers 208 may include one or more of: one or more input data buffers, and one or more output data buffers. Data buffers 208 may include one or more weights / parameters buffers. Data buffers 208 may store operands for one or more processing elements of processing cell 202. Data buffers 208 may store generated outputs of one or more processing elements of processing cell 202.
[0069] The instructions (e.g., configuration descriptors, and / or low-level machine instructions) loaded in instruction buffer 206 may signal which data stored in data buffers 208 is to be processed by processing cells 202 (or individual processing elements in a processing cell 202) . In some cases, the processing cells 202 (or individual processing elements in a processing cell 202) may read data from data buffers 208 at a default location for the processing cell 202 or an individual processing element in the processing cell 202.
[0070] The instructions (e.g., configuration descriptors, and / or low-level machine instructions) loaded in instruction buffer 206 may signal where to store output data in data buffers 208 after processing cells 202 produces the output data. In some cases, the processing cells 202 (or individual processing elements in a processing cell 202) may write data to data buffers 208 at a default location for the processing cell 202 or an individual processing element in the processing cell 202.
[0071] Load module 160 of FIG. 1 may load data to certain locations in data buffers 208. Output module 190 of FIG. 1 may drain data from data buffers 208 to be stored in local memory 140 and / or memory 110 of FIG. 1.
[0072] FIG. 3 illustrates post-processing engine 180, according to some embodiments of the disclosure. As discussed previously with FIG. 1, post-processing engine 180 may process the output (e.g., a tensor) produced by processing engine 170. Some exemplary components in post-processing engine 180 are depicted. In some embodiments, post-processing engine 180 may include bias 302 to add a bias to the output produced by processing engine 170. In some embodiments, post-processing engine 180 may include scale 304 to scale (e.g., multiply by a number) the output produced by processing engine 170. In some embodiments, post-processing engine 180 may include output conversion 360, which may convert the data to different precisions such as integer precision, floating-point precision, etc. Output conversion 360 may convert data between precisions such as INT8, FP16, FP32, etc. Output conversion 360 may perform quantization according to a quantization specified in a configuration descriptor.
[0073] In some embodiments, post-processing engine 180 may include a software programmable look up table (LUT) 388. LUT 388 may be loaded with look up table values provided in a configuration descriptor (e.g., from local memory 140 and / or memory 110) , making LUT 388 software configurable. The look up table values include parameters for approximating a function, such as an activation function.
[0074] In some embodiments, post-processing engine 180 may apply an approximated version (e.g., using linear approximation) of an activation function to the output produced by processing engine 170 using LUT 388. Post-processing engine 180 may include address logic 306, LUT 388, and computation unit 310, to apply the approximated version of the activation function. Specifically, LUT 388 may store one or more look up table values provided in a configuration descriptor that configures post-processing engine 180. The look up table values may approximate a function, such as an activation function or another suitable function. Specifically, the look up table values include parameters for linear segments that approximate the activation function. The linear segments may correspond to different portions of the input range. In some cases, the look up table values may include parameters for other types of segments, such as saturation segments or fixed segments. At different addresses of LUT 388, LUT 388 may store one or more look up table values that specify the segments corresponding to a particular portion of the input range. Parameters for a linear segment can include a slope of a line and an intercept of the line corresponding to the linear segment.
[0075] When post-processing engine 180 receives an input data element, address logic 306 may identify the segment to which the input data element belongs, and therefore the location (e.g., address of LUT 388) where parameters for the segments would be stored. Address logic 306 may determine the address of LUT 388 that is storing one or more look up table values that can be used to calculate an approximation of the function being applied to the input data element (e.g., one or more parameters that specify the segment) . The one or more look up table values may be retrieved from LUT 388 and provided to computation unit 310. Computation unit 310 may compute an output of a linear function corresponding to the linear segment using the one or more look up table values, e.g., the one or more parameters that specify the linear segment. Computation unit 310 may perform multiplication and adding to determine the output of the linear function. Specifically, computation unit 310 may multiply the input data element by a slope of the linear function and add the result of the multiplication by an intercept of the linear function (where both the slope and the intercept may be stored in LUT 388 at the address determined by address logic 306. The output of the linear function calculated by computation unit 310 serves as the approximated output of the function being approximated by LUT 388. In another example where the input data element corresponds to a saturation segment, computation unit 310 may be bypassed. A saturation value may be retrieved from LUT 388 and used as the approximated output of the function being approximated by LUT 388.
[0076] One or more outputs produced by post-processing engine 180 may be provided to local memory 140 of data processing unit 130 via output module 190 of FIG. 1.
[0077] FIG. 4 illustrates DNN module 101, according to some embodiments of the disclosure. DNN module 101 includes interface module 410, training module 420, validating module 440, compiler 450, and datastore 460. In other embodiments, alternative configurations, different or additional components may be included in the DNN module 101. Further, functionality attributed to a component of DNN module 101 may be accomplished by a different component included in DNN module 101 or a different module or system.
[0078] Interface module 410 facilitates communications of DNN module 101 with other modules or systems. For example, interface module 410 establishes communications between DNN module 101 with an external datastore to receive data that can be used to train DNNs or input into DNNs to perform tasks. As another example, interface module 410 supports DNN module 101 to distribute DNNs to other systems, e.g., computing devices configured to apply DNNs to perform tasks.
[0079] Training module 420 trains DNNs by using a training dataset. Training module 420 forms the training dataset. In an example where training module 420 trains an DNN to recognize objects in images, the training dataset includes training images and training labels. The training labels describe ground-truth classifications of objects in the training images. In some embodiments, each label in the training dataset corresponds to an object in a training image. In an example where training module 420 trains a transformer-based neural network to predict the next token, the training data set may include a large library of sequences of tokens. In some embodiments, a part of the training dataset may be used to initially train the DNN, and the rest of the training dataset may be held back as a validation subset used by validating module 440 to validate performance of a trained DNN. The portion of the training dataset not including the tuning subset and the validation subset may be used to train the DNN.
[0080] Training module 420 also determines hyperparameters for training the DNN. Hyperparameters are variables specifying the DNN training process. Hyperparameters are different from parameters inside the DNN (e.g., weights of filters) . In some embodiments, hyperparameters include variables determining the architecture of the DNN, such as number of hidden layers, etc. Hyperparameters also include variables which determine how the DNN is trained, such as batch size, number of epochs, etc. A batch size defines the number of training samples to work through before updating the parameters of the DNN. The batch size is the same as or smaller than the number of samples in the training dataset. The training dataset can be divided into one or more batches. The number of epochs defines how many times the entire training dataset is passed forward and backwards through the entire network. The number of epochs defines the number of times that the deep learning algorithm works through the entire training dataset. One epoch means that each training sample in the training dataset has had an opportunity to update the parameters inside the DNN. An epoch may include one or more batches. The number of epochs may be 1, 5, 10, 50, 100, 500, 1000, or even larger.
[0081] Training module 420 can define the architecture of the DNN, e.g., based on some of the hyperparameters. In some cases, training module 420 may receive a model definition that defines or specifies the architecture of the DNN. The architecture of the DNN can include a plurality of layers. Examples of layers may include convolutional layers, pooling layers, fully connected layers, normalization layers, SoftMax or logit layers, and so on. After training module 420 defines the architecture of the DNN, training module 420 inputs a training dataset into the DNN. The training dataset includes a plurality of training samples. The training module 420 modifies the parameters inside the DNN ( “internal parameters of the DNN” ) to minimize the error between labels of the training objects that are generated by the DNN and the ground-truth labels of the objects. The internal parameters include weights used in layers of the DNN. In some embodiments, the training module 420 uses a cost function to minimize the error.
[0082] Training module 420 may train the DNN for a pre-determined number of epochs. The number of epochs is a hyperparameter that defines the number of times that the deep learning algorithm will work through the entire training dataset. One epoch means that each sample in the training dataset has had an opportunity to update internal parameters of the DNN. After training module 420 finishes the pre-determined number of epochs, training module 420 may stop updating the parameters in the DNN. The DNN having the updated parameters is referred to as a trained DNN.
[0083] Validating module 440 verifies accuracy of trained DNNs. In some embodiments, validating module 440 inputs samples in a validation dataset into a trained DNN and uses the outputs of the DNN to determine the model accuracy. In some embodiments, a validation dataset may be formed of some or all the samples in the training dataset. Additionally or alternatively, the validation dataset includes additional samples, other than those in the training sets. In some embodiments, validating module 440 may determine an accuracy score measuring the precision, recall, or a combination of precision and recall of the DNN. The validating module 440 may use the following metrics to determine the accuracy score: Precision = TP / (TP + FP) and Recall = TP / (TP + FN) , where precision may be how many the DNN correctly predicted (TP or true positives) out of the total it predicted (TP + FP or false positives) , and recall may be how many the DNN correctly predicted (TP) out of the total number of objects that did have the property in question (TP +FN or false negatives) . The F-score (F-score = 2 *PR / (P + R) ) unifies precision and recall into a single measure.
[0084] Validating module 440 may compare the accuracy score with a threshold score. In an example where validating module 440 determines that the accuracy score of the DNN is less than the threshold score, validating module 440 instructs th training module 420 to re-train the DNN. In one embodiment, training module 420 may iteratively re-train the DNN until the occurrence of a stopping condition, such as the accuracy measurement indication that the DNN may be sufficiently accurate, or a number of training rounds having taken place.
[0085] Compiler 450 compiles information associated with DNNs which can be used to cause DNN accelerator 102 of FIG. 1 to carry out neural network operations for DNNs. The information may include one or more of: the model definition, one or more processing graphs, one or more data processing workloads produced from the one or more processing graphs, and executable instructions (e.g., configuration descriptors and / or low-level machine instructions) that can be executed by DNN accelerator 102. The model definition may include one or more neural network operations to be performed by the DNN. In some embodiments, compiler 450 may generate a processing graph representing a DNN. The graph may include nodes and edges. A node may represent a specific neural network operation in the DNN. An edge may connect two nodes and represent a connection between the two corresponding neural network operations. In an example, an edge may encode a tensor that flows from one of the neural network operations to the other neural network operation. The tensor may be an output tensor of the first neural network operation and an input tensor of the second neural network operation. The edge may encode one or more attributes of the tensor, such as size, shape, storage format, quantization parameter, and so on.
[0086] Compiler 450 may pre-process and / or modify the processing graph to identify opportunities to streamline the processing graph to reduce overhead of the compiled configuration descriptors. Due to the specific nature of the data processing pipeline in a DPU, compiler 450 may follow a set of rules or patterns when producing one or more configuration descriptors for one or more nodes of the processing graph. Compiler 450 may traverse through the processing graph to produce configuration descriptors according to the set of rules or patterns. The configuration descriptors can be used and executed by components of the DNN accelerator 102 (e.g., processing engine 170 and post-processing engine 180 of FIG. 1) to execute the DNN. Exemplary compiler 450 is described and illustrated in FIG. 12.
[0087] Datastore 460 stores data received, generated, used, or otherwise associated with the DNN module 101. For example, datastore 460 stores the datasets used by training module 420 and validating module 440. Datastore 460 may also store data generated by training module 420 and validating module 440, such as the hyperparameters for training DNNs, internal parameters of trained DNNs (e.g., weights, etc. ) , data for sparsity acceleration (e.g., sparsity bitmap, etc. ) , and so on. Datastore 460 may store configuration parameters, configuration descriptors, instructions generated by compiler 450, etc. The datastore 460 may include one or more memories. In the embodiment of FIG. 4, datastore 460 is a component of DNN module 101. In other embodiments, datastore 460 may be external to DNN module 101 and communicate with the DNN module 101 through a network.
[0088] Referring back to FIGS. 1-4, DNN system 100 illustrates one implementation of a processor designed to accelerate execution of DNNs. The architecture design of a processor can vary depending on the application requirements of the processor. The architecture design can vary based on the number of DPUs, the number of processing engines, the number of processing cells, the number of post-processing engines, structure of the data processing pipeline in a DPU, support for vector processing, support for sparsity modes, the types or collection of processing elements, amount of memory and buffer size, etc.Workload descriptor or configuration descriptor overhead
[0089] DPUs of a neural network hardware accelerator have highly specialized hardware that can execute data processing workloads for a neural network very efficiently. In some implementations, such as DNN system 100 illustrated in FIGS. 1-4, a DPU’s data processing pipeline can execute a data processing workload involving a compute operation followed by a post-processing operation such as applying an activation function. To initiate the DPU’s data processing pipeline, a configuration descriptor having configuration information for the processing engine to perform the compute operation and configuration information for the PPE to apply the activation function can be loaded onto the DPU. To execute the data processing workload, the data processing pipeline of the DPU can cause input data of the data processing workload to be passed to the processing engine, and the processing engine can generate output data by performing the specified compute operation. The output data generated by the processing engine is then passed to the PPE (the next operation in the data processing pipeline) , and the PPE can generate output data by applying the specified activation function. The output data generated by the PPE is passed onwards as the output data of the data processing workload. The data processing pipeline of a DPU that can execute data processing workloads is described in FIGS. 1-3.
[0090] A configuration descriptor may include register configurations in the configuration descriptor, such as memory addresses and offsets for retrieving and / or writing data (e.g., activation tensor, weight tensor, and output tensors) , configurations for the processing engine, and configurations for the post-processing engine of a DPU. A configuration descriptor may include one or more fields for the register configurations. Different fields may be dedicated for specifying different configurations of various neural network operations. Register configurations may configure a DPU (e.g., the processing engine and / or the post-processing engine) to perform one or more operations and specify configurations for the one or more operations. Register configurations may configure a DPU to fetch data from one or more memory locations and / or fetch data in a certain manner. Register configurations may configure a DPU to write data to one or more memory locations and / or write data in a certain manner. Register configurations may include look up table values for a software programmable look up table in a post-processing engine of a DPU.
[0091] Configuration descriptors can be used to trigger DPUs to perform neural network operations and contribute to how quickly the DNN accelerator can ultimately execute a DNN. Too many configuration descriptors, or inefficient use of configuration descriptors not only means that it would take much longer to execute a DNN, but the size of configuration descriptors can also increase storage and memory demands. As neural network models grow in size, the number and size of compiled configuration descriptors also increases. This leads to longer compile times and greater storage overhead. Consequently, the ever-expanding model sizes pose technical challenges for model compilation and deployment. For instance, a 7-billion parameter large language model might generate around 200,000 data processing workloads, resulting in compiled configuration descriptors that occupy 96 megabytes (MB) of storage. However, the on-chip fast working memory of a DPU such as static random access memory (SRAM) , typically has a capacity of only about 1.5-2 MB. This means that 96 MB of compiled configuration descriptors is 48 times the capacity of the on-chip memory, which is primarily meant for storing activation and weight data for matrix multiplications and convolutions performed by the processing engine. Therefore, if the workload overhead, including the number and total size of the compiled configuration descriptors, is not properly managed, it can consume valuable on-chip memory capacity and / or increase memory access overhead, potentially leading to slower execution of data processing workloads on the DPUs.Executing matrix multiplications on DPUs
[0092] MatMul refers to matrix multiplication. Matrix multiplication is one component in the architecture of LLMs, particularly within the attention mechanisms and feed-forward neural networks of transformer-based models. In these models, information is represented as matrices and vectors, and MatMul operations are used to transform and combine this information throughout the network. Specifically, in the attention mechanism, MatMul is used to compute attention scores by multiplying query matrices with key matrices. These scores determine how much focus or "attention" should be given to different parts of the input sequence. Another MatMul operation then combines these attention scores with value matrices to produce context-aware representations. In the feed-forward network layers, MatMul operations project the input into a higher-dimensional space and then back to the original dimensionality, allowing the model to capture complex relationships in the data. The efficiency of MatMul operations on modern processors enables the training and deployment of large-scale language models. However, as model sizes grow, optimizing these operations becomes increasingly important to manage computational complexity and resource requirements.
[0093] To fit into the memory of each DPU, a compiler may split / unroll the MatMul further into smaller pieces (e.g., smaller data processing workloads) . This can lead to many more configuration descriptors being generated as a result. For example, given a multi-billion parameter LLM, a compiler can generate several thousands of configuration descriptors.
[0094] Group-wise quantization can be used for weight compression. Group-wise quantization can result in data quantization on both the output and input channels when converted to convolution on the DNN accelerator, such as the DNN accelerator illustrated in FIGS. 1-3. Group-wise quantization can reduce the computational and memory requirements of neural networks by applying different quantization parameter (s) to groups of weights within a weight matrix. Matrix multiplication in neural networks can involve multiplying an input matrix A (with dimensions 1xN) with further input matrix B (with dimensions NxM) to produce an output matrix C (with dimensions 1xM) . The further input matrix B can be a weight matrix / tensor. Matrix multiplication is computationally expensive when executed on a DNN accelerator, especially for large models with large weight matrices. Group-wise quantization divides the weight matrix into multiple groups along a particular dimension and applies quantization independently to each group (e.g., apply different quantization parameter (s) to each group) . The further input matrix B can be divided into T number of groups according to a group size S. Each group can be quantized differently with corresponding scaling factors and zero-points, e.g., each group may have one or more corresponding quantization parameters. For example, if the further input matrix B is a 1024×1024 weight matrix and the group size S is 128, there are then T=8 number of groups. Each group would have one or more corresponding quantization parameters (e.g., scaling factor and zero-point) , allowing for more precise representation of the weights within each group. Group-wise quantization can be particularly useful in transformer architectures where different attention heads can have significantly different weight distributions, making uniform quantization suboptimal.
[0095] A data processing unit executing a MatMul operation may not be able to readily support group-wise quantization where different quantization parameters are applied to different groups of the weights in the weight matrix. Since the DNN accelerator illustrated in FIGS. 1-3 does not readily support group-wise quantization within a data processing unit, the compiler in a DNN module can unroll the group-wise MatMul operation in the processing graph into smaller operations to be executed by one or more data processing units supporting channel-wise quantization. The smaller operations would implement channel-wise quantization, where different quantization parameters can be applied to individual channels, allowing each unrolled MatMul operation to become a channel-wise quantized operation to be performed by and executed directly on a data processing unit that supports channel-wise quantization.
[0096] FIG. 5 illustrates a MatMul operation with N as input channel size, according to some embodiments of the disclosure. If group-wise quantization is applied to weights along the dimension N, where for which every S in N share same quantization parameters (e.g., quantization scaling factors and zero-points) , and there are total T groups to which different quantization parameters may be applied, the MatMul operation can be unrolled into S smaller channel-wise quantized MatMul operations where a channel-wise quantization MatMul operation can have T as the input channel size. Mathematically speaking, N=SxT.
[0097] FIG. 6 illustrates S number of unrolled MatMul operations with T as the input channel size, according to some embodiments of the disclosure. As a result of the unrolling of the group-wise quantized MatMul, the group-wise quantized MatMul is split into S tiny MatMuls where each tiny MatMul can perform channel-wise quantization. As seen in FIG. 6, the group-wise quantized MatMul can result with many tiny channel-wise quantized MatMuls (shown as MATMUL-1, …MATMUL-S) , which means that the total workload count (e.g., the number of configuration descriptors to execute the many tiny channel-wise quantized MatMuls) increases significantly. However, the actual compute overhead for each tiny MatMul is too small to effectively compensate the workload overhead. In the example shown, group-wise quantized MatMul turns into S number of channel-wise quantized MatMuls, causing at least S workload descriptors for performing channel-wise quantized MatMuls to be generated for one group-wise MatMul operation with S number of groups.Rethinking MatMul execution on DPUs
[0098] One solution to reduce workload overhead is to reconsider how to perform MatMul and optimize the operations in a way that would trade off computation for workload overhead. If input matrix A is a 1×N matrix and a further input matrix B (e.g., a weight matrix) is an N×M matrix, the output matrix C will be a 1×M matrix. Further input matrix B is being group-wise quantized the dimension with N elements where group size is S and number of groups is T (for every S elements in N in share the same quantization parameters) . Suppose the input matrix A and the further input matrix B (the weight matrix) are reshaped. Input matrix A is reshaped from 1×N to TxS, and the further input matrix B (e.g., a weight matrix) is reshaped from N×M to S× (T*M) . The output matrix C would be reshaped as well. The output matrix C is reshaped from 1×M to T× (T*M) . The content of output matrix C can be represented as a 2D array in range [1, T] , as depicted in FIG. 7, where each element in the 2D array has M values. The reshaping of matrices (e.g., the input matrix and the further input matrix) is illustrated in FIG. 10.
[0099] Upon inspection of the 2D array, the results of the tiny unrolled MatMuls illustrated in FIG. 5 can be obtained from this new output matrix C. Specifically, relevant data (shaded in black) , or C [i] [i] along the diagonal in the 2D array, correspond to the results of the tiny unrolled MatMuls illustrated in FIG. 5. FIG. 7 reveals an insight that MatMul can benefit from sub-group optimization, because the new output matrix C has many results which are not needed (shaded in a dotted pattern) . In particular, the insight means that it is possible to slice the reshaped input matrices into smaller sub-groups so that smaller MatMuls can be performed while still producing the relevant data. Slicing the reshaped input matrices into sub-groups can reduce computation and / or avoid unnecessary computations.
[0100] Suppose T is split into P sub-group (s) , where the sub-group size is Q (or size of each sub-group is Q) . Mathematically speaking, T = PxQ. For each sub-group p, input matrix Ap has shape Q×S, further input matrix matrix Bp (the weight matrix) has shape S× (Q*M) , and output matrix Cp has shape Qx (Q*M) . Specifically, FIG. 8 illustrates MatMul with sub-group optimization to trade off computation for workload overhead, according to some embodiments of the disclosure. The graph reflects the P sub-groups of MatMuls (shown as MATMUL-1, …MATMUL-P) being performed instead. The resulting output matrices Cp after undergoing sub-group optimization / conversion are shown in FIG. 9 as triple lined boxes. Specifically, FIG. 9 illustrates the impact of applying sub-group optimization, according to some embodiments of the disclosure. With the sub-group optimization, the unnecessary computations could be reduced (much of the reshaped matrix C is no longer calculated, as illustrated in FIG. 9) , while the results of the tiny MatMuls of FIG. 5 can still be obtained from the results.
[0101] For a specific LLM model, the value of sub-group size Q as discussed with FIG. 8 can be adjusted and chosen for a best tradeoff between computation and workload overhead.
[0102] FIG. 11 illustrates applying sub-group optimization, according to some embodiments of the disclosure. In the example illustrated, an input matrix, a further input matrix, and an output matrix have been reshaped as reshaped input matrix A, further reshaped input matrix B, and reshaped output matrix C, according to the technique illustrated in FIGS. 8-10. In particular, T is split into P=3 sub-groups with sub-group size Q. The reshaped input matrix A can be split into P=3 sub-groups, shown as A1, A2, and A3. The further reshaped input matrix B can be split into P=3 sub-groups, shown as B1, B2, and B3. The shape of Ap is QxS. The shape of Bp is Sx (Q*M) . Matrix multiplication operations can be performed on Ap x Bp, to obtain Cp. For example, when P=3, three sub-group matrix multiplication workload descriptors are generated to perform: A1 x B1, A2 x B2, and A3 x B3, and to obtain products: C1, C2, and C3 respectively. The shape of Cp is Qx (Q*M) .
[0103] Performing sub-group optimization allows generation of relevant data along the diagonal of the reshaped output matrix C (as seen in FIGS. 7 and 9) , while performing fewer computations overall. One or more slices (e.g., Q slices) having shape 1xM or M values can be obtained from a product produced by a sub-group matrix multiplication. As illustrated in FIG. 8, Q slices that have shape 1xM can be obtained from the product C1. Q slices that have shape 1xM can be obtained from the product C2. Q slices that have shape 1xM can be obtained from the product C3. The P*Q slices from the products can be accumulated to obtain the output matrix having shape 1xM.
[0104] FIG. 12 illustrates compiler 450, according to some embodiments of the disclosure. To take advantage of sub-group optimization of MatMul as discussed herein, compiler 450 may implement operations to identify opportunities to convert MatMul with group-wise quantization into the graph depicted in FIG. 8. Compiler 450 includes neural network analyzer 1202, identify group-wise quantized MatMul 1204, configuration descriptors generator 1208, and scheduler 1210. One or more components of compiler 450 may implement one or more operations described herein, such as one or more operations of method 1300.
[0105] Neural network analyzer 1202 may analyze a DNN and determine how a neural network hardware accelerator can implement the DNN utilizing the DPUs of the accelerator. Neural network analyzer 1202 may receive the neural network model definition of the DNN. A neural network model definition may specify one or more layers of a neural network. For example, a neural network model definition may specify layers of the neural network and how the data should flow through the layers. A layer can be specified by the neural network operation that the layer performs. Examples of layers can include fully connected (linear) layer, convolutional layer, recurrent layer, long short-term memory network, gated recurrent unit layer, max pooling layer, average pooling layer, batch normalization layer, normalization layer, dropout layer, activation layer, embedding layer, etc. The layer can be specified by one or more of: input size, hidden size, output size, etc. The layer can be specified by one or more parameters of the neural network operation (e.g., for a convolutional layer, one or more parameters may include kernel size, padding, stride, etc. ) .
[0106] In some cases, neural network analyzer 1202 may determine a processing graph based on the neural network model definition. A processing graph may include connected nodes. The connected nodes can represent neural network operations to be executed by one or more data processing units and an order of execution of the neural network operations. The edges connecting the nodes can represent the flow of data between the neural network operations. Examples of neural network operations can include: a compute operation, convolution, filtering, pooling, matrix multiplication, applying an activation function (clamping function, exponential function, sigmoid function, power function, square root function, etc. ) , etc. An edge connecting a node and a further node that follows the node may represent that an output generated by the node is to be provided as an input to the further node. The processing graph may include one or more neural network operations to be executed by one or more DPUs (of the neural network hardware accelerator) .
[0107] Neural network analyzer 1202 may determine one or more data processing workloads to be carried out by the DPUs (of the neural network hardware accelerator) based on the processing graph and / or the neural network model definition. The one or more data processing workloads may correspond to and / or include one or more neural network operations of the processing graph. For example, a data processing workload may include one or more neural network operations to be executed according to one or more configurations. The data processing workload may be executed by a data processing pipeline of a data processing unit, such as a processing engine of a data processing unit, or a post-processing engine of a data processing unit. In some cases, a neural network operation may translate to a data processing workload. In some cases, a neural network operation may translate to multiple data processing workloads. In some cases, one or more neural network operations may translate to one or more data processing workloads. The neural network operations can be executed by a data processing pipeline of a data processing unit, such as a processing engine of a data processing unit, or a post-processing engine of a data processing unit. The neural network operations can be executed by one or more data processing units or one or more parts of a data processing unit, according to the order of execution represented by the processing graph. A neural network operation of a data processing workload may be executed by a data processing unit according to one or more configurations for the neural network operation. In some cases, the neural network model definition includes the processing graph.
[0108] As illustrated by FIGS. 7-11 and discussed in the overview, there are opportunities for rethinking MatMul (through reshaping the input matrices and sub-group optimization) to allow for group-wise quantized MatMul to be executed efficiently on DPUs supporting channel-wise quantization with low workload overhead. Identify group-wise quantized 1004 may determine whether the processing graph has a group-wise quantized MatMul operation. Identify group-wise quantized MatMul 1204 may traverse through the processing graph determined by neural network analyzer 1202 to find a group-wise quantized MatMul operation. Identify group-wise quantized MatMul 1204 may transform the group-wise quantized MatMul operation to have a processing graph illustrated in FIG. 8 (and not use the unrolled version illustrated in FIG. 6) .
[0109] Configuration descriptors generator 1208 may generate one or more configuration descriptors based on the data processing graph illustrated in FIG. 8.
[0110] Scheduler 1210 may coordinate when and which DPUs should have the configuration descriptors generated by configuration descriptors generator 1208 loaded to execute the data processing workloads. The data processing workloads may be allocated by scheduler 1210 to the DPUs (in a neural network hardware accelerator) , and scheduler 1210 may coordinate to have the corresponding configuration descriptors (or one or more parts of a configuration descriptor) provided to the DPUs. In some cases, scheduler 1210 may determine a plan that can load balance execution of the data processing workloads. Scheduler 1210 may determine a plan that ensures the data processing workloads are being executed according to the processing graph. Scheduler 1210 may determine a plan to cause a configuration descriptor or a portion of a configuration descriptor to be loaded onto a DPU at an appropriate time. In some cases, scheduler 1210 may be a part of compiler 450. In some cases, scheduler 1210 may be a part of DNN module 101 of FIGS. 1 and 4.Method for executing group-wise quantized MatMul using channel-wise quantized MatMuls
[0111] FIG. 13 depicts a flow diagram of method 1300 for performing a group-wise quantized MatMul operation using channel-wise quantized MatMul operation, according to some embodiments of the disclosure. Method 1300 can be implemented by a DNN accelerator as described herein.
[0112] In 1302, an input matrix can be reshaped according to a group size and a number of groups to generate a reshaped input matrix. The group size and the number of groups may correspond to a group-wise quantized matrix multiplication operation.
[0113] In 1304, a weight matrix can be reshaped according to the group size and the number of groups to generate a reshaped weight matrix.
[0114] In 1306, a matrix multiplication operation is performed on a part of the reshaped input matrix and a part of the reshaped weight matrix. In some embodiments, the matrix the matrix multiplication operation is channel-wise quantized matrix multiplication operation.
[0115] In some embodiments, a shape of the reshaped input matrix is the number of groups by the group size. A shape of the reshaped weight matrix is the group size by a product of the number of groups and a dimension of the further input matrix or a dimension of an output matrix.
[0116] In some embodiments, performing the matrix multiplication operation comprises computing a product of the part of the reshaped input matrix and the part of the reshaped weight matrix. Method 1300 may further include accumulating one or more slices of the product.
[0117] In some embodiments, method 1300 further includes performing a further matrix multiplication operation on a further part of the reshaped input matrix and a further part of the reshaped weight matrix to compute a further product, accumulate one or more further slices of the further product.
[0118] In some embodiments, method 1300 further includes splitting the reshaped input matrix and the reshaped weight matrix according to a number of sub-groups to obtain the part of the reshaped input matrix and the part of the reshaped weight matrix.Method for compiling a data processing graph
[0119] FIG. 14 depicts a flow diagram of method 1400 for compiling a group-wise quantized MatMul operation, according to some embodiments of the disclosure. Method 1400 can be implemented by compiler 450 of the FIGS.
[0120] In 1402, a processing graph corresponding to a neural network is received. The processing graph has a matrix multiplication operation to multiply an input matrix with a further input matrix to compute an output matrix. The matrix multiplication operation is group-wise quantized according to a group size and a number of groups.
[0121] In 1404, one or more matrix multiplication workload descriptors to be executed by a neural network hardware accelerator are generated based on a reshaped input matrix and a reshaped weight matrix. The reshaped input matrix is determined / generated by reshaping the input matrix according to the group size and the number of groups. The reshaped weight matrix is determined / generated by reshaping the weight matrix according to the group size and the number of groups.
[0122] In some embodiments, a shape of the reshaped input matrix is the number of groups by the group size. In some embodiments, a shape of the reshaped weight matrix is the group size by a product of the number of groups and a dimension of the output matrix.
[0123] In some embodiments, the one or more matrix multiplication workload descriptors comprise a matrix multiplication workload descriptor configuring the neural network hardware accelerator to compute a product of a part of the reshaped input matrix and a part of the reshaped weight matrix. Method 1400 may further include generating an accumulation workload descriptor to accumulate one or more slices of the product.
[0124] In some embodiments, the one or more matrix multiplication workload descriptors comprise a further matrix multiplication workload descriptor configuring the neural network hardware accelerator to compute a further product of a further part of the reshaped input matrix with a further part of the reshaped weight matrix. Method 1400 may further include generating a further accumulation workload descriptor to accumulate one or more further slices of the further product.
[0125] In some embodiments, generating the matrix multiplication one or more workload descriptors comprises determining a number of sub-groups for splitting the reshaped input matrix and the reshaped weight matrix, and generating the one or more matrix multiplication workload descriptors according to the number of sub-groups.Test case results
[0126] In one experiment where group-wise quantization MatMul layer of an LLM is executed with sub-group optimization discussed herein, the performance (e.g., execution duration) is optimized from 266us to 188us from hardware profiling, which is about 29%improvement. The whole LLM’s performance achieved a 22%speed up.Exemplary computing device
[0127] FIG. 15 is a block diagram of an apparatus or a system, e.g., an exemplary computing device 1500, according to some embodiments of the disclosure. One or more computing devices 1500 may be used to implement the functionalities described with the FIGS. and herein. A number of components illustrated in FIG. 15 can be included in the computing device 1500, but any one or more of these components may be omitted or duplicated, as suitable for the application. In some embodiments, some or all of the components included in the computing device 1500 may be attached to one or more motherboards. In some embodiments, some or all of these components are fabricated onto a single system on a chip (SoC) die. Additionally, in various embodiments, the computing device 1500 may not include one or more of the components illustrated in FIG. 15, and the computing device 1500 may include interface circuitry for coupling to the one or more components. For example, the computing device 1500 may not include a display device 1506, and may include display device interface circuitry (e.g., a connector and driver circuitry) to which a display device 1506 may be coupled. In another set of examples, the computing device 1500 may not include an audio input device 1518 or an audio output device 1508 and may include audio input or output device interface circuitry (e.g., connectors and supporting circuitry) to which an audio input device 1518 or audio output device 1508 may be coupled.
[0128] The computing device 1500 may include a processing device 1502 (e.g., one or more processing devices, one or more of the same types of processing device, one or more of different types of processing device) . The processing device 1502 may include electronic circuitry that process electronic data from data storage elements (e.g., registers, memory, resistors, capacitors, quantum bit cells) to transform that electronic data into other electronic data that may be stored in registers and / or memory. Examples of processing device 1502 may include a CPU, a graphical processing unit (GPU) , a quantum processor, a machine learning processor, an artificial intelligence processor, a neural network processor, an artificial intelligence accelerator, an application-specific integrated circuit (ASIC) , an analog signal processor, an analog computer, a microprocessor, a digital signal processor, a field programmable gate array (FPGA) , a tensor processing unit (TPU) , a neural network hardware accelerator, a DNN accelerator (e.g., DNN accelerator 102 as illustrated in FIG. 1-3) , etc.
[0129] The computing device 1500 may include a memory 1504, which may itself include one or more memory devices such as volatile memory (e.g., DRAM) , nonvolatile memory (e.g., read-only memory (ROM) ) , high bandwidth memory (HBM) , flash memory, solid state memory, and / or a hard drive. Memory 1504 includes one or more non-transitory computer-readable storage media. In some embodiments, memory 1504 may include memory that shares a die with the processing device 1502.
[0130] In some embodiments, memory 1504 includes one or more non-transitory computer-readable media storing instructions executable to perform operations described with the FIGS. and herein. Exemplary parts, e.g., DNN module 101 and compiler 450, that may be encoded as instructions and stored in memory 1504 are depicted. Memory 1504 may store instructions that encode one or more exemplary parts, such as DNN module 101, one or more parts of DNN module 101, compiler 450, and / or one or more parts of compiler 450. Memory 1504 may store instructions that encode one or more operations of method 1300 of FIG. 13. Memory 1504 may store instructions that encode one or more operations of method 1400 of FIG. 14. The instructions stored in the one or more non-transitory computer-readable media may be executed by processing device 1502.
[0131] In some embodiments, memory 1504 may store data, e.g., data structures, binary data, bits, metadata, files, blobs, etc., as described with the FIGS. and herein. Memory 1504 may store compiled configuration descriptors described herein, e.g., constant configuration descriptors and variable configuration descriptors. Memory 1504 may store a neural network definition. Memory 1504 may store a processing graph. Memory 1504 may store data processing workloads that can implement the processing graph. Memory 1504 may store the dictionary that groups data processing workloads that share a common operation.
[0132] In some embodiments, memory 1504 may store one or more DNNs (and or parts thereof) . Memory 1504 may store training data for training (trained) a DNN. Memory 1504 may store instructions that perform operations associated with training a DNN. Memory 1504 may store input data, output data, intermediate outputs, intermediate inputs of one or more DNNs. Memory 1504 may store one or more parameters used by the one or more DNNs. Memory 1504 may store information that encodes how nodes of the one or more DNNs are connected with each other. Memory 1504 may store instructions to perform one or more operations of the one or more DNNs. Memory 1504 may store a model definition that specifies one or more operations of a DNN. Memory 1504 may store instructions, such as configuration descriptors, that are generated by a compiler based on the model definition.
[0133] In some embodiments, the computing device 1500 may include a communication device 1512 (e.g., one or more communication devices) . For example, the communication device 1512 may be configured for managing wired and / or wireless communications for the transfer of data to and from the computing device 1500. The term "wireless" and its derivatives may be used to describe circuits, devices, systems, methods, techniques, communications channels, etc., that may communicate data through the use of modulated electromagnetic radiation through a nonsolid medium. The term does not imply that the associated devices do not contain any wires, although in some embodiments they might not. The communication device 1512 may implement any of a number of wireless standards or protocols, including but not limited to Institute for Electrical and Electronic Engineers (IEEE) standards including Wi-Fi (IEEE 802.10 family) , IEEE 802.16 standards (e.g., IEEE 802.16-2005 Amendment) , Long-Term Evolution (LTE) project along with any amendments, updates, and / or revisions (e.g., advanced LTE project, ultramobile broadband (UMB) project (also referred to as "3GPP2" ) , etc. ) . IEEE 802.16 compatible Broadband Wireless Access (BWA) networks are generally referred to as WiMAX networks, an acronym that stands for worldwide interoperability for microwave access, which is a certification mark for products that pass conformity and interoperability tests for the IEEE 802.16 standards. The communication device 1512 may operate in accordance with a Global System for Mobile Communication (GSM) , General Packet Radio Service (GPRS) , Universal Mobile Telecommunications System (UMTS) , High Speed Packet Access (HSPA) , Evolved HSPA (E-HSPA) , or LTE network. The communication device 1512 may operate in accordance with Enhanced Data for GSM Evolution (EDGE) , GSM EDGE Radio Access Network (GERAN) , Universal Terrestrial Radio Access Network (UTRAN) , or Evolved UTRAN (E-UTRAN) . The communication device 1512 may operate in accordance with Code-division Multiple Access (CDMA) , Time Division Multiple Access (TDMA) , Digital Enhanced Cordless Telecommunications (DECT) , Evolution-Data Optimized (EV-DO) , and derivatives thereof, as well as any other wireless protocols that are designated as 3G, 4G, 5G, and beyond. The communication device 1512 may operate in accordance with other wireless protocols in other embodiments. The computing device 1500 may include an antenna 1522 to facilitate wireless communications and / or to receive other wireless communications (such as radio frequency transmissions) . The computing device 1500 may include receiver circuits and / or transmitter circuits. In some embodiments, the communication device 1512 may manage wired communications, such as electrical, optical, or any other suitable communication protocols (e.g., the Ethernet) . As noted above, the communication device 1512 may include multiple communication chips. For instance, a first communication device 1512 may be dedicated to shorter-range wireless communications such as Wi-Fi or Bluetooth, and a second communication device 1512 may be dedicated to longer-range wireless communications such as global positioning system (GPS) , EDGE, GPRS, CDMA, WiMAX, LTE, EV-DO, or others. In some embodiments, a first communication device 1512 may be dedicated to wireless communications, and a second communication device 1512 may be dedicated to wired communications.
[0134] The computing device 1500 may include power source / power circuitry 1514. The power source / power circuitry 1514 may include one or more energy storage devices (e.g., batteries or capacitors) and / or circuitry for coupling components of the computing device 1500 to an energy source separate from the computing device 1500 (e.g., DC power, AC power, etc. ) .
[0135] The computing device 1500 may include a display device 1506 (or corresponding interface circuitry, as discussed above) . The display device 1506 may include any visual indicators, such as a heads-up display, a computer monitor, a projector, a touchscreen display, a liquid crystal display (LCD) , a light-emitting diode display, or a flat panel display, for example.
[0136] The computing device 1500 may include an audio output device 1508 (or corresponding interface circuitry, as discussed above) . The audio output device 1508 may include any device that generates an audible indicator, such as speakers, headsets, or earbuds, for example.
[0137] The computing device 1500 may include an audio input device 1518 (or corresponding interface circuitry, as discussed above) . The audio input device 1518 may include any device that generates a signal representative of a sound, such as microphones, microphone arrays, or digital instruments (e.g., instruments having a musical instrument digital interface (MIDI) output) .
[0138] The computing device 1500 may include a GPS device 1516 (or corresponding interface circuitry, as discussed above) . The GPS device 1516 may be in communication with a satellite-based system and may receive a location of the computing device 1500, as known in the art.
[0139] The computing device 1500 may include a sensor 1530 (or one or more sensors) . The computing device 1500 may include corresponding interface circuitry, as discussed above) . Sensor 1530 may sense physical phenomenon and translate the physical phenomenon into electrical signals that can be processed by, e.g., processing device 1502. Examples of sensor 1530 may include: capacitive sensor, inductive sensor, resistive sensor, electromagnetic field sensor, light sensor, camera, imager, microphone, pressure sensor, temperature sensor, vibrational sensor, accelerometer, gyroscope, strain sensor, moisture sensor, humidity sensor, distance sensor, range sensor, time-of-flight sensor, pH sensor, particle sensor, air quality sensor, chemical sensor, gas sensor, biosensor, ultrasound sensor, a scanner, etc.
[0140] The computing device 1500 may include another output device 1510 (or corresponding interface circuitry, as discussed above) . Examples of the other output device 1510 may include an audio codec, a video codec, a printer, a wired or wireless transmitter for providing information to other devices, haptic output device, gas output device, vibrational output device, lighting output device, home automation controller, or an additional storage device.
[0141] The computing device 1500 may include another input device 1520 (or corresponding interface circuitry, as discussed above) . Examples of the other input device 1520 may include an accelerometer, a gyroscope, a compass, an image capture device, a keyboard, a cursor control device such as a mouse, a stylus, a touchpad, a bar code reader, a Quick Response (QR) code reader, any sensor, or a radio frequency identification (RFID) reader.
[0142] The computing device 1500 may have any desired form factor, such as a handheld or mobile computer system (e.g., a cell phone, a smart phone, a mobile internet device, a music player, a tablet computer, a laptop computer, a netbook computer, a personal digital assistant (PDA) , a personal computer, a remote control, wearable device, headgear, eyewear, footwear, electronic clothing, etc. ) , a desktop computer system, a server or other networked computing component, a printer, a scanner, a monitor, a set-top box, an entertainment control unit, a vehicle control unit, a digital camera, a digital video recorder, an Internet-of-Things device, or a wearable computer system. In some embodiments, the computing device 1500 may be any other electronic device that processes data.Select examples
[0143] Example 1 provides an apparatus, including one or more data processing units; and one or more non-transitory computer-readable memories to store instructions, where the instructions, when executed by the one or more data processing units, cause the one or more data processing units to: reshape an input matrix according to a group size and a number of groups to generate a reshaped input matrix; reshape a weight matrix according to the group size and the number of groups to generate a reshaped weight matrix, the group size and the number of groups corresponding to a group-wise quantized matrix multiplication operation on the input matrix and the weight matrix; and perform matrix multiplication operation on a part of the reshaped input matrix and a part of the reshaped weight matrix.
[0144] Example 2 provides the apparatus of example 1, where: a shape of the reshaped input matrix is the number of groups by the group size.
[0145] Example 3 provides the apparatus of example 1 or 2, where: a shape of the reshaped weight matrix is the group size by a product of the number of groups and a dimension of an output matrix of the group-wise quantized matrix multiplication operation.
[0146] Example 4 provides the apparatus of any one of examples 1-3, where: performing the matrix multiplication operation includes computing a product of the part of the reshaped input matrix and the part of the reshaped weight matrix; and the instructions further cause the one or more data processing units to accumulate one or more slices of the product.
[0147] Example 5 provides the apparatus of any one of examples 1-4, where the instructions further cause the one or more data processing units to: perform a further matrix multiplication operation on a further part of the reshaped input matrix and a further part of the reshaped weight matrix to compute a further product; and accumulate one or more further slices of the further product.
[0148] Example 6 provides the apparatus of any one of examples 1-5, where the instructions further cause the one or more data processing units to: split the reshaped input matrix and the reshaped weight matrix according to a number of sub-groups to obtain the part of the reshaped input matrix and the part of the reshaped weight matrix.
[0149] Example 7 provides the apparatus of any one of examples 1-6, where the matrix multiplication operation is a channel-wise quantized matrix multiplication operation.
[0150] Example 8 provides one or more non-transitory computer-readable media storing instructions that, when executed by one or more data processing units, cause the one or more data processing units to: reshape an input matrix according to a group size and a number of groups to generate a reshaped input matrix; reshape a weight matrix according to the group size and the number of groups to generate a reshaped weight matrix, the group size and the number of groups corresponding to a group-wise quantized matrix multiplication operation on the input matrix and the weight matrix; and perform matrix multiplication operation on a part of the reshaped input matrix and a part of the reshaped weight matrix.
[0151] Example 9 provides the one or more non-transitory computer-readable media of example 8, where: a shape of the reshaped input matrix is the number of groups by the group size.
[0152] Example 10 provides the one or more non-transitory computer-readable media of example 8 or 9, where: a shape of the reshaped weight matrix is the group size by a product of the number of groups and a dimension of an output matrix of the group-wise quantized matrix multiplication operation.
[0153] Example 11 provides the one or more non-transitory computer-readable media of any one of examples 8-10, where: performing the matrix multiplication operation includes computing a product of the part of the reshaped input matrix and the part of the reshaped weight matrix; and the instructions further cause the one or more data processing units to accumulate one or more slices of the product.
[0154] Example 12 provides the one or more non-transitory computer-readable media of any one of examples 8-11, where the instructions further cause the one or more data processing units to: perform a further matrix multiplication operation on a further part of the reshaped input matrix and a further part of the reshaped weight matrix to compute a further product; and accumulate one or more further slices of the further product.
[0155] Example 13 provides the one or more non-transitory computer-readable media of any one of examples 8-12, where the instructions further cause the one or more data processing units to: split the reshaped input matrix and the reshaped weight matrix according to a number of sub-groups to obtain the part of the reshaped input matrix and the part of the reshaped weight matrix.
[0156] Example 14 provides the one or more non-transitory computer-readable media of any one of examples 8-13, where the matrix multiplication operation is channel-wise quantized matrix multiplication operation.
[0157] Example 15 provides a method, including reshaping an input matrix according to a group size and a number of groups to generate a reshaped input matrix; reshaping a weight matrix according to the group size and the number of groups to generate a reshaped weight matrix, the group size and the number of groups corresponding to a group-wise quantized matrix multiplication operation on the input matrix and the weight matrix; and performing matrix multiplication operation on a part of the reshaped input matrix and a part of the reshaped weight matrix.
[0158] Example 16 provides the method of example 15, where: a shape of the reshaped input matrix is the number of groups by the group size.
[0159] Example 17 provides the method of example 15 or 16, where: a shape of the reshaped weight matrix is the group size by a product of the number of groups and a dimension of an output matrix of the group-wise quantized matrix multiplication operation.
[0160] Example 18 provides the method of any one of examples 15-17, where: performing the matrix multiplication operation includes computing a product of the part of the reshaped input matrix and the part of the reshaped weight matrix; and the method further includes accumulating one or more slices of the product.
[0161] Example 19 provides the method of any one of examples 15-18, further including performing a further matrix multiplication operation on a further part of the reshaped input matrix and a further part of the reshaped weight matrix to compute a further product; and accumulating one or more further slices of the further product.
[0162] Example 20 provides the method of any one of examples 15-19, further including splitting the reshaped input matrix and the reshaped weight matrix according to a number of sub-groups to obtain the part of the reshaped input matrix and the part of the reshaped weight matrix.
[0163] Example 21 provides the method of any one of examples 15-20, where the matrix multiplication operation is channel-wise quantized matrix multiplication operation.
[0164] Example A is an apparatus comprising means for carrying out any one of the methods described herein and a method of any one of examples 15-21.
[0165] Example B is a computer program product comprising instructions that cause one or more processors to perform any one of the methods described herein and a method of any one of examples 15-21.
[0166] Example C includes a DNN module as described and illustrated herein.
[0167] Example D includes a compiler as described and illustrated herein.
[0168] Example E includes a DNN system comprising a DNN module according to example C and a DNN accelerator as described herein.
[0169] Example F includes a DNN accelerator to perform any one of the methods described herein and a method of any one of examples 15-21.Variations and other notes
[0170] Although the operations of the example method shown in and described with reference to the FIGS. are illustrated as occurring once each and in a particular order, it will be recognized that the operations may be performed in any suitable order and repeated as desired. Additionally, one or more operations may be performed in parallel. Furthermore, the operations illustrated in the FIGS. may be combined or may include more or fewer details than described.
[0171] The various implementations described herein may refer to artificial intelligence, machine learning, and deep learning. Deep learning may be a subset of machine learning. Machine learning may be a subset of artificial intelligence. In cases where a deep learning model is mentioned, if suitable for a particular application, a machine learning model may be used instead. In cases where a deep learning model is mentioned, if suitable for a particular application, a digital signal processing system may be used instead.
[0172] The above description of illustrated implementations of the disclosure, including what is described in the Abstract, is not intended to be exhaustive or to limit the disclosure to the precise forms disclosed. While specific implementations of, and examples for, the disclosure are described herein for illustrative purposes, various equivalent modifications are possible within the scope of the disclosure, as those skilled in the relevant art will recognize. These modifications may be made to the disclosure in light of the above detailed description.
[0173] For purposes of explanation, specific numbers, materials and configurations are set forth in order to provide a thorough understanding of the illustrative implementations. However, it will be apparent to one skilled in the art that the present disclosure may be practiced without the specific details and / or that the present disclosure may be practiced with only some of the described aspects. In other instances, well known features are omitted or simplified in order not to obscure the illustrative implementations.
[0174] Further, references are made to the accompanying drawings that form a part hereof, and in which are shown, by way of illustration, embodiments that may be practiced. It is to be understood that other embodiments may be utilized, and structural or logical changes may be made without departing from the scope of the present disclosure. Therefore, the following detailed description is not to be taken in a limiting sense.
[0175] Various operations may be described as multiple discrete actions or operations in turn, in a manner that is most helpful in understanding the disclosed subject matter. However, the order of description should not be construed as to imply that these operations are necessarily order dependent. In particular, these operations may not be performed in the order of presentation. Operations described may be performed in a different order from the described embodiment. Various additional operations may be performed or described operations may be omitted in additional embodiments.
[0176] For the purposes of the present disclosure, the phrase “A or B” or the phrase "A and / or B" means (A) , (B) , or (A and B) . For the purposes of the present disclosure, the phrase “A, B, or C” or the phrase "A, B, and / or C" means (A) , (B) , (C) , (A and B) , (A and C) , (B and C) , or (A, B, and C) . The term "between, " when used with reference to measurement ranges, is inclusive of the ends of the measurement ranges.
[0177] The description uses the phrases "in an embodiment" or "in embodiments, " which may each refer to one or more of the same or different embodiments. The terms "comprising, " "including, " "having, " and the like, as used with respect to embodiments of the present disclosure, are synonymous. The disclosure may use perspective-based descriptions such as "above, " "below, " "top, " "bottom, " and "side" to explain various features of the drawings, but these terms are simply for ease of discussion, and do not imply a desired or required orientation. The accompanying drawings are not necessarily drawn to scale. Unless otherwise specified, the use of the ordinal adjectives “first, ” “second, ” and “third, ” etc., to describe a common object, merely indicates that different instances of like objects are being referred to and are not intended to imply that the objects so described must be in a given sequence, either temporally, spatially, in ranking or in any other manner.
[0178] In the following detailed description, various aspects of the illustrative implementations will be described using terms commonly employed by those skilled in the art to convey the substance of their work to others skilled in the art.
[0179] The terms “substantially, ” “close, ” “approximately, ” “near, ” and “about, ” generally refer to being within + / -20%of a target value as described herein or as known in the art. Similarly, terms indicating orientation of various elements, e.g., “coplanar, ” “perpendicular, ” “orthogonal, ” “parallel, ” or any other angle between the elements, generally refer to being within + / -5-20%of a target value as described herein or as known in the art.
[0180] In addition, the terms “comprise, ” “comprising, ” “include, ” “including, ” “have, ” “having” or any other variation thereof, are intended to cover a non-exclusive inclusion. For example, a method, process, or device, that comprises a list of elements is not necessarily limited to only those elements but may include other elements not expressly listed or inherent to such method, process, or device. Also, the term “or” refers to an inclusive “or” and not to an exclusive “or. ”
[0181] The systems, methods and devices of this disclosure each have several innovative aspects, no single one of which is solely responsible for all desirable attributes disclosed herein. Details of one or more implementations of the subject matter described in this specification are set forth in the description and the accompanying drawings.
Claims
1.An apparatus, comprising:one or more data processing units; andone or more non-transitory computer-readable memories to store instructions, wherein the instructions, when executed by the one or more data processing units, cause the one or more data processing units to:reshape an input matrix according to a group size and a number of groups to generate a reshaped input matrix;reshape a weight matrix according to the group size and the number of groups to generate a reshaped weight matrix, the group size and the number of groups corresponding to a group-wise quantized matrix multiplication operation on the input matrix and the weight matrix; andperform matrix multiplication operation on a part of the reshaped input matrix and a part of the reshaped weight matrix.2.The apparatus of claim 1, wherein:a shape of the reshaped input matrix is the number of groups by the group size.3.The apparatus of claim 1 or 2, wherein:a shape of the reshaped weight matrix is the group size by a product of the number of groups and a dimension of an output matrix of the group-wise quantized matrix multiplication operation.4.The apparatus of any one of claims 1-3, wherein:performing the matrix multiplication operation comprises computing a product of the part of the reshaped input matrix and the part of the reshaped weight matrix; andthe instructions further cause the one or more data processing units to accumulate one or more slices of the product.5.The apparatus of any one of claims 1-4, wherein the instructions further cause the one or more data processing units to:perform a further matrix multiplication operation on a further part of the reshaped input matrix and a further part of the reshaped weight matrix to compute a further product; andaccumulate one or more further slices of the further product.6.The apparatus of any one of claims 1-5, wherein the instructions further cause the one or more data processing units to:split the reshaped input matrix and the reshaped weight matrix according to a number of sub-groups to obtain the part of the reshaped input matrix and the part of the reshaped weight matrix.7.The apparatus of any one of claims 1-6, wherein the matrix multiplication operation is a channel-wise quantized matrix multiplication operation.8.One or more non-transitory computer-readable media storing instructions that, when executed by one or more data processing units, cause the one or more data processing units to:reshape an input matrix according to a group size and a number of groups to generate a reshaped input matrix;reshape a weight matrix according to the group size and the number of groups to generate a reshaped weight matrix, the group size and the number of groups corresponding to a group-wise quantized matrix multiplication operation on the input matrix and the weight matrix; andperform matrix multiplication operation on a part of the reshaped input matrix and a part of the reshaped weight matrix.9.The one or more non-transitory computer-readable media of claim 8, wherein:a shape of the reshaped input matrix is the number of groups by the group size.10.The one or more non-transitory computer-readable media of claim 8 or 9, wherein:a shape of the reshaped weight matrix is the group size by a product of the number of groups and a dimension of an output matrix of the group-wise quantized matrix multiplication operation.11.The one or more non-transitory computer-readable media of any one of claims 8-10, wherein:performing the matrix multiplication operation comprises computing a product of the part of the reshaped input matrix and the part of the reshaped weight matrix; andthe instructions further cause the one or more data processing units to accumulate one or more slices of the product.12.The one or more non-transitory computer-readable media of any one of claims 8-11, wherein the instructions further cause the one or more data processing units to:perform a further matrix multiplication operation on a further part of the reshaped input matrix and a further part of the reshaped weight matrix to compute a further product; andaccumulate one or more further slices of the further product.13.The one or more non-transitory computer-readable media of any one of claims 8-12, wherein the instructions further cause the one or more data processing units to:split the reshaped input matrix and the reshaped weight matrix according to a number of sub-groups to obtain the part of the reshaped input matrix and the part of the reshaped weight matrix.14.The one or more non-transitory computer-readable media of any one of claims 8-13, wherein the matrix multiplication operation is channel-wise quantized matrix multiplication operation.15.A method, comprising:reshaping an input matrix according to a group size and a number of groups to generate a reshaped input matrix;reshaping a weight matrix according to the group size and the number of groups to generate a reshaped weight matrix, the group size and the number of groups corresponding to a group-wise quantized matrix multiplication operation on the input matrix and the weight matrix; andperforming matrix multiplication operation on a part of the reshaped input matrix and a part of the reshaped weight matrix.16.The method of claim 15, wherein:a shape of the reshaped input matrix is the number of groups by the group size.17.The method of claim 15 or 16, wherein:a shape of the reshaped weight matrix is the group size by a product of the number of groups and a dimension of an output matrix of the group-wise quantized matrix multiplication operation.18.The method of any one of claims 15-17, wherein:performing the matrix multiplication operation comprises computing a product of the part of the reshaped input matrix and the part of the reshaped weight matrix; andthe method further comprises accumulating one or more slices of the product.19.The method of any one of claims 15-18, further comprising:performing a further matrix multiplication operation on a further part of the reshaped input matrix and a further part of the reshaped weight matrix to compute a further product; andaccumulating one or more further slices of the further product.20.The method of any one of claims 15-19, further comprising:splitting the reshaped input matrix and the reshaped weight matrix according to a number of sub-groups to obtain the part of the reshaped input matrix and the part of the reshaped weight matrix.21.The method of any one of claims 15-20, wherein the matrix multiplication operation is channel-wise quantized matrix multiplication operation.