Post-training calibration for activation sparsity
The post-training calibration for activation sparsity in DNNs addresses the computational and memory challenges of transformer-based models by using a few-shot calibration technique to induce sparsity, enhancing efficiency and adaptability in LLMs without extensive retraining.
Patent Information
- Application Number
- PCT/CN2024/101824
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2024-06-27
- Publication Date
- 2026-01-02
AI Technical Summary
Deep neural networks (DNNs) face high computational and memory demands due to their large number of operations and data requirements, particularly in transformer-based models like large language models (LLMs), which are computationally demanding and memory-intensive, especially during inference.
A post-training calibration method for activation sparsity is implemented, using a few-shot calibration technique to induce sparsity in activation tensors with a small dataset, employing a two-stage greedy grid search to determine calibrated importance threshold values and estimated mode values for mode-centering, allowing for efficient pruning and deployment on hardware without extensive retraining.
This method achieves computational and memory efficiency by strategically inducing sparsity in activation tensors, reducing computational and memory requirements, and enabling faster deployment with minimal data usage, adaptable to various use-cases and LLM architectures, without significant representation loss.
Smart Images

Figure CN2024101824_02012026_PF_FP_ABST
Abstract
Description
POST-TRAINING CALIBRATION FOR ACTIVATION SPARSITYBackground
[0001] 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
[0002] 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.
[0003] FIG. 1 illustrates an exemplary large language model, according to some embodiments of the disclosure.
[0004] FIG. 2 illustrates a serial transformer block, according to some embodiments of the disclosure.
[0005] FIG. 3 illustrates a parallel transformer block, according to some embodiments of the disclosure.
[0006] FIG. 4 illustrates an attention layer of a transformer block, according to some embodiments of the disclosure.
[0007] FIG. 5 illustrates a feed forward network layer of a transformer block, according to some embodiments of the disclosure.
[0008] FIG. 6 illustrates a gated version of a feed forward network layer of a transformer block, according to some embodiments of the disclosure.
[0009] FIG. 7 illustrates a DNN system, according to some embodiments of the disclosure.
[0010] FIG. 8 illustrates a processing engine, according to some embodiments of the disclosure.
[0011] FIG. 9 illustrates a processing element of a processing cell, according to some embodiments of the disclosure.
[0012] FIG. 10 illustrates a DNN module, according to some embodiments of the disclosure.
[0013] FIG. 11 illustrates post-training optimization, according to some embodiments of the disclosure.
[0014] FIG. 12 illustrates one or more pruners added to a neural network, according to some embodiments of the disclosure.
[0015] FIG. 13 illustrates computational and memory access savings when pruners are added to a neural network, according to some embodiments of the disclosure.
[0016] FIG. 14 illustrates one or more pruners added to a neural network, according to some embodiments of the disclosure.
[0017] FIG. 15 illustrates a pruner, according to some embodiments of the disclosure.
[0018] FIG. 16 illustrates pruning and lossless mode-centering, according to some embodiments of the disclosure.
[0019] FIG. 17 illustrates a two-stage greedy grid search, according to some embodiments of the disclosure.
[0020] FIG. 18 illustrates a first stage of the two-stage greedy grid search, according to some embodiments of the disclosure.
[0021] FIG. 19 illustrates a second stage of the two-stage greedy grid search, according to some embodiments of the disclosure.
[0022] FIG. 20 a flowchart illustrating a method for pruning and mode-centering, according to some embodiments of the disclosure.
[0023] FIG. 21 a flowchart illustrating a method for post-training calibration for activation sparsity, according to some embodiments of the disclosure.
[0024] FIG. 22 is a block diagram of an exemplary computing device, according to some embodiments of the disclosure.Detailed Description
[0025] Overview
[0026] The last decade has witnessed a rapid rise in artificial intelligence (AI) based data processing, particularly based on DNNs. DNNs are widely used in the domains of computer vision, speech recognition, image, and video processing mainly due to their ability to achieve beyond human-level accuracy. A DNN typically includes a sequence of layers. A DNN layer may include one or more deep learning operations (also referred to as “neural network operations” ) , such as convolution operation, matrix multiplication operation, layer normalization operation, batch normalization operation, SoftMax operation, pooling operation, element-wise operation, linear operation, non-linear operation, and so on. While DNNs are effective at analyzing and predicting, they come at a cost of immense computational power. DNNs can consume significant power and runtime during training and during inference.
[0027] Transformer-based neural networks or transformer-based models are a type of DNN that can be used to power large language models (LLMs) and computer vision models (referred to in literature as ViTs) . Transformer-based neural networks are used in services and applications such as natural language processing, speech processing, conversational AI assistants, image captioning, object detection, video understanding, recommendation systems, bioinformatics, time-series forecasting, reinforcement learning, and generative models to produce text, image, or music.
[0028] An LLM can have billions of parameters. The first token prediction of an LLM is bottlenecked by compute. Second token predictions onwards are bottlenecked by memory bandwidth. Sparsity is a key technique in the compression of neural networks, complementing methods like quantization, distillation, and neural architecture search.
[0029] The premise of sparsity is to exploit the deterministic arithmetic with zero for computational efficiency, e.g., anything multiplied by 0 equals 0, and anything added to 0 remains unchanged. The main workhorse of neural network, i.e., dot product involves series of sum and multiplication between its inputs, namely weight (e.g., parameters) and activation (e.g., features) . When zero occurs in any of them, associated compute and memory operations can be skipped, resulting in speedup, space, and energy savings.
[0030] Weight sparsity can be implemented by inducing zero into the network parameters during-or post-training. Because of the high redundancy in a network overparameterized for a target dataset, introducing zeros to weights can be easy to implement. Activation, on the other hand, is relatively challenging to prune, owing to its dynamic nature on a per-input basis and indirect controllability through backpropagation. In some deployments, inferences can be made more efficient through activation sparsity.
[0031] Activation sparsity is often observed with the use of rectified linear unit (ReLU) activation. ReLU activation can be found in the output of a multilayer perceptron (MLP) or feedforward neural network (FFN) . MLP or FFN may include fully-connected neurons followed by a non-linear activation function such as the ReLU activation.
[0032] ReLU function can be represented as follows: ReLU (x) =max (0, x) (eq. 1)
[0033] The output of the ReLU activation, acting as a rectifier, may naturally include many zero’s, hence activation sparsity is high. While earlier LLMs tend to use ReLU activations, recent LLMs are moving away from using ReLU activations to using activation functions such as the sigmoid linear unit (SiLU) and the Gaussian-error linear unit (GELU) which are dense.
[0034] SiLU function can be represented as follows:
[0035] The GELU function can be approximated as follows: GELU (x) =xσ (1.702x) (eq. 3)
[0036] Dense rectifiers or dense activation functions output dense tensors, where not many of the elements of the tensor are zero. In contrast, ReLU activation functions output sparse tensors, where many of the elements of the tensor are zero.
[0037] When a dense rectifier is used, post-hoc techniques may be applied to induce activation sparsity. One technique involves replacing pre-trained non-ReLU activations with ReLU. The technique may further append ReLU to other activations such as normalization output to further increase sparsity. Such technique involves expensive uptraining (e.g., a form fine-tuning where a pre-trained model undergoes modifications and then continues training using its pre-training objective) to recover the language ability. Another technique involves training look ahead predictors to determine which attention heads and projection channels in FFNs can be skipped. Various techniques hinge on the inherent sparsity in the output of ReLU function. Some techniques have non-trivial degradation in task quality. Some techniques involve an ultra-expensive process to scale out (e.g., uptraining, training predictors, etc. ) . Some techniques offer little flexibility for diverse use-cases.
[0038] To address some of these concerns, an improved activation sparsity technique can be implemented to offer a low-cost, post-training calibration solution. The activation sparsity technique involves a few-shot post-training calibration method for pre-trained or instruction-tuned LLMs. The method strategically induces sparsity directly in activations of interest with just a small, representative dataset (e.g., a few batches of text prompts) . A text prompt may include one or more sentences. A text prompt may include 128 words. The direct activation pruning approach involves pruning an activation tensor using a calibrated importance threshold value. The calibrated importance threshold value can be determined using the small dataset. The mode of the activation tensor is centered, through statistical conditioning, in a lossless manner using an estimated mode value to improve activation sparsity further. The estimated mode value can be determined using the small dataset. If preferred, the estimated mode value can be updated based on actual data so that the estimated mode value can adapt to shifts in input data. Mode-centering can address shifts in mode value in deeper layers of the neural network and increase sparsity of non-ReLU activations in those layers. Because the mode-centering mechanism can be implemented in the neural network in a lossless manner, representation loss is not an issue.
[0039] Just before a neural network is deployed onto a processor, such as an AI processor, a neural network can be analyzed to determine activations of interest as candidates for pruning. Pruning and mode-centering mechanisms can be inserted into the neural network (thus modifying the model definition) strategically and post-training to implement sparsification. A two-stage greedy grid search algorithm is implemented to determine the calibrated importance threshold values of various pruners and the estimated mode values used for mode-centering using the small dataset. The search algorithm is tunable according to a user’s tolerance for task degradation. A modified neural network with pruning and lossless mode-centering can be deployed onto hardware.
[0040] The technique can deliver better tunability of quality-performance trade-offs. Users can make trade-offs and tune sparsity on a use-case by use-case basis. The technique can be adapted for a wide variety of different use-cases. Furthermore, the technique can generalize well across many LLM architectures. The technique does not involve replacing non-ReLU activations with ReLU activations, which means that the technique can avoid drastic representation loss, and the technique is free from training (e.g., backpropagation) . If desired, the technique can be (readily and easily) repeated in the event if the user’s tolerance for task degradation changes. The technique can complement other compression techniques such as quantization (e.g., weight quantization) to achieve joint acceleration. The technique can speed up LLM generation by exploiting dynamic sparsity. Only a small dataset is used to determine the calibrated importance threshold values and no uptraining or fine-tuning is needed. Therefore, the solution can allow the possibility of in-situ optimization at inference runtime and can be multiple orders of magnitude faster than training-based sparsification.
[0041] Some embodiments described herein can be applied to any activation, or activation tensor in a neural network. A pruner, or a pruner plus mode-centering mechanisms, can be added to induce sparsity for any input tensor or any output tensor in a neural network. A pruner, or a pruner plus mode-centering mechanisms, are preferably added to activation tensors where sparsity can be exploited for computational and memory bandwidth efficiencies. Some embodiments described herein illustrate exploiting sparsity in a FFN, or FFN layer, which can realize sparse matrix multiplication. The teachings can be extended readily to exploit sparsity in other types of layers (e.g., fully-connected layers, convolution layers, attention layers, etc. ) that can realize sparse matrix multiplication.
[0042] Transformer-based neural networks or transformer-based models
[0043] FIG. 1 illustrates an exemplary LLM 100, according to some embodiments of the disclosure. LLM 100 may include one or more components: tokenizer (s) 104, a stack of transformer blocks 110 (e.g., shown as transformer block 0, transformer block 1, transformer block 2, …. Transformer N) , one or more classifiers 112, and detokenizer (s) 114. Tokenizer (s) 104 can break input data (e.g., prompt 102) into tokens. For example, prompt 102 may be include text and tokenizer (s) 104 may break prompt 102 into sub-words. One or more tokens, represented as X 106, may be converted into embedding (s) 108, which includes high-dimensional input features for the stack of transformer blocks 110. The stack of transformer blocks 110 can acquire knowledge about the input data.
[0044] A transformer block in the stack of transformer blocks 110 can include two types of layers equipped with learning parameters: attention layers and FFN layers. One exemplary arrangement of a transformer block is illustrated in FIG. 2. Another exemplary arrangement of a transformer block is illustrated in FIG. 3. Attention layers allow the model to weigh the importance of tokens based on their contextual relevance and to capture their dependencies. FFN layers provide non-linear transformations to tokens independently.
[0045] One or more classifiers 112 can produce predictions or generate tokens based on the learned representations of the stack of transformer blocks 110. The tokens may be used by one or more detokenizer (s) 114 to produce generated text 116.
[0046] LLM 100 can serve as a framework for modeling complex relationships in text, images, audio, video, point clouds, graphs, etc. The number of learning parameters can be scaled up using the framework to model even more complex relationships.
[0047] LLM 100 is formulated to model sequential text in an autoregressive manner. Each subsequent token, shown as Y 182, is determined by the context of preceding tokens. During the training process of LLM 100, the transformer architecture is tasked to learn to predict the next token, Y 182, through slices of text with known succeeding tokens. Leveraging the abundance of text data available on the Internet, the size of transformers can be scaled up tremendously to hundred-billions of parameters. LLM 100 may be known as autoregressive transformer, causal transformer, decoder-only transformer, and decoding transformer. Subsequent alignment stage can make LLM 100 converse contextually and to human preference. A conversational LLM involving LLM 100 can be referred to as a Generative Pre-trained Transformer (GPT) . Aligned LLMs may be known as instruction-tuned, instruction-following, and supervised fine-tuned LLMs.
[0048] Autoregressive modeling entails a sequential prediction during its deployment, hence LLM-based applications is, by and large, text generation, outputting next token after token, it means engaging the whole model structures for every token prediction. Attributed to the vast number of model parameters (currently reaching scale of billions) , the sequence inference is computationally demanding, characterized by an initial compute-intensive first prediction, followed by subsequent token-to-token predictions that are bottlenecked by memory bandwidth.
[0049] To improve inference efficiency of LLMs, such as LLM 100, many optimization techniques have been developed. Weight-only quantization is the predominant adopted approach while others like weight pruning, activation sparsity, KV cache pruning, head pruning, token reduction, neural architecture search and more have been explored by the research community.
[0050] FIG. 2 illustrates serial transformer block 200, according to some embodiments of the disclosure. Serial transformer block 200 includes attention layers 204, and FFN layers 206. An input, X 202, is first processed by attention layers 204, and the output of attention layers 204 is passed to FFN layers 206. FFN layers 206 may produce output, X’ 208. In some cases, serial transformer block 200 may include a skip connection that passes the input, X 202, to be added the output, X’ 210. Serial transformer block 200 may be implemented as one of the transformer blocks of the stack of transformer blocks 110 in FIG. 1.
[0051] FIG. 3 illustrates parallel transformer block 300, according to some embodiments of the disclosure. Parallel transformer block 300 includes attention layers 304, and FFN layers 306. An input, X 302, is processed by attention layers 304, and the input, X 302, is processed (in parallel) by FFN layers 306. The output of attention layers 304 and the output of FFN layers 306 are combined at adder 308. Adder 308 may produce a sum of its inputs, e.g., the output of attention layers 304 and the output of FFN layers 306. Adder 308 may produce a weighted sum of its inputs, e.g., the output of attention layers 304 and the output of FFN layers 306. Adder 308 may produce output, X’ 310. In some cases, parallel transformer block 300 may include a skip connection that passes the input, X 302, to be added to the output, X’ 310. Parallel transformer block 300 may be implemented as one of the transformer blocks of the stack of transformer blocks 110 in FIG. 1.
[0052] FIG. 4 illustrates attention layer 400 of a transformer block, according to some embodiments of the disclosure. Attention layer 400 may be included as part of a transformer block in the stack of transformer blocks 110 in FIG. 1. As an example, attention layer 400 illustrates a multi-head attention layer. The input, X 402, be converted into queries (Q) , keys (K) , and values (V) . Attention layer 400 includes parallel linear projections 404 of queries using the query weight matrix WQ. Attention layer 400 includes parallel linear projections 406 of keys using the key weight matrix WK. Attention layer 400 includes parallel linear projections 408 of values using the value weight matrix WV. Results of linear projections are provided to parallel attention heads 410. An attention head 410 may apply an attention function using an output from one of the linear projections 404, an output from one of the linear projections 406, and an output from one of the linear projections 408. The attention function can be defined as:
[0053] Q in equation 4 represents an output from one of the linear projections 404. K in equation 4 represents an output from one of the linear projections 406. V in equation 4 represents an output from one of the linear projections 408. dk represents a scaling factor.
[0054] Outputs of parallel attention heads 410 may be concatenated together and passed to linear projection 412 using an output matrix WO. The output of linear projection 412 is the output, X’ 414, of attention layer 400.
[0055] A linear projection used in attention layer 400 may include multiplying an input to the linear projection with a learned weight matrix. In some cases, the matrix multiplication is followed by an optional non-linearity, such as an activation function.
[0056] FIG. 5 illustrates FFN layer 500 of a transformer block, according to some embodiments of the disclosure. FFN layer 500 may be included as part of a transformer block in the stack of transformer blocks 110 in FIG. 1. FFN layer 500 may include upward linear projection 504 using an up weight matrix WU, activation function 506, and downward linear projection 508 using a down weight matrix WD. An input to FFN layer 500, X 502, may be provided to upward linear projection 504. In some embodiments, the input, X 502, may be normalized using a normalization function before it is provided to upward linear projection 504. Output of upward linear projection 504 may be provided to activation function 506. Output of activation function 506 may be provided to downward linear projection 508. Output of downward linear projection 508 is the output, X’ 510, of FFN layer 500. A linear projection used in FFN layer 500 may include multiplying an input to the linear projection with a learned weight matrix. In some cases, the matrix multiplication is followed by an optional non-linearity, such as an activation function. In some cases, FFN layer 500 may include a skip connection that passes the input, X 302, to be added to the output, X’ 310.
[0057] FIG 6 illustrates a gated version of FFN layer 600 of a transformer block, according to some embodiments of the disclosure. FFN layer 600 may be included as part of a transformer block in the stack of transformer blocks 110 in FIG. 1. The gated version of FFN layer 600 may be referred to as a Gated Linear Unit (GLU) . The gated version of FFN layer 600 may be a variation or alternative to FFN layer 500. Both FFN layer 500 and FFN layer 600 includes an activation function, e.g., activation function 506 and activation function 608 respectively. Both FFN layer 500 and FFN layer 600 include downward linear projection downstream of an activation function, e.g., downward linear projection 508 and downward linear projection 612 respectively. FFN layer 600 may include upward linear projection 604 using an up weight matrix WU, gated linear projection 606 using a gated weight matrix WG, activation function 608, element-wise multiplier 610, and downward linear projection 612 using a down weight matrix WD. An input to FFN layer 600, X 602, may be provided to upward linear projection 604. An input to FFN layer 600, X 602, may be provided to gated linear projection 606 in parallel. The gated weight matrix WG may have learned parameters that can control which elements in the output of the upward linear projection 604 should be passed through or blocked. In some embodiments, the input, X 602, may be normalized using a normalization function before it is provided to upward linear projection 604 and gated linear projection 606. Output of gated linear projection 606 may be provided to activation function 608. Output of upward linear projection 604 and output of activation function 608 may be provided to element-wise multiplier 610. Output of element-wise multiplier 610 (e.g., the Hadamard product) is provided to downward linear projection 612. Output of downward linear projection 612 is the output, X’ 614, of FFN layer 600. A linear projection used in FFN layer 600 may include multiplying an input to the linear projection with a learned weight matrix. In some cases, the matrix multiplication is followed by an optional non-linearity, such as an activation function. In some cases, FFN layer 600 may include a skip connection that passes the input, X 602, to be added to the output, X’ 614.
[0058] Implementing DNNs on processors
[0059] 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. A DNN accelerator may be or include one or more data processing units. A data processing unit may also be referred to as a compute block or compute tile. A data processing unit may include one or more processing engines that can carry out neural network operations. A processing engine may include one or more processing cells to perform arithmetic operations associated with neural network operations.
[0060] FIG. 7 illustrates DNN system 700, according to some embodiments of the disclosure. The whole DNN system 700 or a part of the DNN system 700 may be implemented in one or more computing devices, such as the computing device 2200 in FIG. 22. DNN system 700 can generate and execute DNNs, such as transformer-based neural networks, convolutional neural networks, and so on. As shown in FIG. 7, DNN system 700 includes DNN module 701 and DNN accelerator 702. In other embodiments, alternative configurations, different or additional components may be included in DNN system 700. For instance, DNN system 700 may include multiple DNN modules or multiple DNN accelerators. Further, functionality attributed to a component of the DNN system 700 may be accomplished by a different component included in the DNN system 700 or a different system.
[0061] Examples of DNN accelerator 702 may include one or more graphical processing units (GPUs) , tensor processing units (TPUs) , data processing units (DPUs) , neural processing units (NPUs) , field-programmable gate arrays (FPGAs) , one or more central processing units (CPUs) , application specific integrated circuits (ASICs) . The DNN accelerator 702 may be referred to as an AI accelerator, or AI processor.
[0062] In some embodiments, DNN module 701 and DNN accelerator 702 may include or be implemented by different types of processing units. In an example, the DNN module 701 may be implemented by one or more CPUs. The DNN module 701 and DNN accelerator 702 may be implemented in the same chip or as separate chips.
[0063] DNN module 701 facilitates generation and deployment of DNNs. In some embodiments, the DNN module 701 may generate and train DNNs. For instance, the DNN module 701 can define the layered architecture of a DNN. The DNN module 701 can also determine the internal parameters of the DNN through a DNN training process. The DNN module 701 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.
[0064] DNN module 701 may compress DNNs, e.g., during or after training. In some embodiments, DNN module 701 may prune weights in one or more layers of a DNN by changing nonzero valued weight to zeros. DNN module 701 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 701 prunes weight during DNN training, the DNN module 701 may prune weight of a layer to achieve a target sparsity ratio after one or more epochs. DNN module 701 may prevent the pruned weights from changing values during the rest of the training process. Alternatively, DNN module 701 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 701 may prune weights of the layer again after one or more additional epochs.
[0065] DNN module 701 may deploy trained, compressed, or validated DNNs for use in deep learning applications. In some embodiments, DNN module 701 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 701 may facilitate deployment of the DNNs using the DNN accelerator 702. For instance, DNN module 701 may receive data from a device or system coupled with DNN system 700 and input the received data (or data generated by DNN module 701, e.g., based on the received data) into a DNN. DNN module 701 may compile instructions executable by DNN accelerator 702 to perform operations of a DNN in accordance with a model definition of the DNN. DNN module 701 may generate instructions (e.g., configuration files) that control the operation of the DNN accelerator 702 during the DNN execution. DNN module 701 may receive an output of the DNN from the DNN accelerator 702. DNN module 701 may transmit the output of the DNN (or a result of processing the output of the DNN by DNN module 701) to the device or system. In some embodiments, DNN module 701 may control execution processes of trained, compressed, or validated DNNs. DNN module 701 may function as a compiler for DNNs executed by DNN accelerator 702. DNN module 701 may perform compilation of DNNs and generate configuration files, based on which the DNNs may be executed.
[0066] In some embodiments, DNN module 701 implements post-training optimization to modify a neural network model definition by inserting pruner operators and mode-centering mechanisms into the neural network, and to determine calibrated importance threshold values and estimated mode values. Certain aspects of the DNN module 701 are described and illustrated in FIG. 10.
[0067] DNN accelerator 702 executes DNNs provided by DNN module 701. For instance, DNN accelerator 702 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 tasks.
[0068] As shown in FIG. 7, DNN accelerator 702 includes memory 710, DMA (direct memory access) engine 720, and data processing units 730 (individually referred to as “data processing unit 730” ) . In other embodiments, alternative configurations, different or additional components may be included in DNN accelerator 702. For example, DNN accelerator 702 may include more than one memory 710 or DMA engine 720. As another example, DNN accelerator 702 may include a single data processing unit 730. Further, functionality attributed to a component of DNN accelerator 702 may be accomplished by a different component included in DNN accelerator 702 or by a different system. A component of DNN accelerator 702 may be implemented in hardware, software, firmware, or some combination thereof.
[0069] Memory 710 stores data associated with deep learning operations performed by DNN accelerator 702. In some embodiments, memory 710 may store data to be used by the data processing units 730 for DNN execution. memory 710 may store weights, such as weights of convolutional layers, which are determined by training DNNs. Memory 710 may further store inputs to DNN layers or outputs of DNN layers, such as data generated by the data processing units 730 from performing deep learning operations in DNNs. Example deep learning operations include convolutions (also referred to as “convolutional operations” ) , layer normalization operations, SoftMax operations, matrix multiplication operations, pooling operations, element-wise operations, activation functions, other types of deep learning operations, or some combination thereof. Memory 710 may store instructions executable by DNN accelerator 702, such as instructions executable by data processing unit 730. Memory 710 may be a main memory of DNN accelerator 702. In some embodiments, memory 710 includes one or more dynamic random-access memories (DRAMs) .
[0070] DMA engine 720 facilitates data transfer between memory 710 and local memories 740 of the data processing units 730. For example, DMA engine 720 can read data from memory 710 and write data into local memory 740 of data processing unit 730. As another example, DMA engine 720 can read data from local memory 740 of data processing unit 730 and write data into memory 710. DMA engine 720 provides a DMA feature that allows data processing unit 730 to initiate data transfer between memory 710 and local memories 740 of the data processing units 730 and to perform other operations while the data transfer is being conducted. In some embodiments, DMA engine 720 may read tensors from memory 710, modify the tensors in a way that is optimized for data processing unit 730 before it writes the tensors into local memories 740 of data processing units 730.
[0071] Input or output data of deep learning operations may be arranged in data structures called tensors. A tensor is a data structure having multiple elements across one or more dimensions. Examples of tensors include vector (which is one-dimensional (1D) tensor) , matrix (which is two-dimensional (2D) tensor) , three-dimensional (3D) tensors, four-dimensional (4D) tensors, and even higher dimensional tensors. A dimension of a tensor may correspond to an axis, e.g., an axis in a coordinate system. A dimension may be measured by the number of data points along the axis. The dimensions of a tensor may define the shape of the tensor. A DNN layer may receive one or more input tensors and compute an output tensor from the one or more input tensors. Taking a convolutional layer for example, the input tensors include an activation tensor (also referred to as “input feature map (IFM) ” or “input activation tensor” ) including one or more activations (also referred to as “input elements” ) and a weight tensor. The weight tensor may be a kernel (a2D weight tensor) , a filter (a3D weight tensor) , or a group of filters (a4D weight tensor) . A convolution may be performed on the input activation tensor and weight tensor to compute an output activation tensor in the convolutional layer.
[0072] Data processing units 730 perform deep learning operations in DNNs. For instance, data processing unit 730 may execute a DNN layer by running one or more deep learning operations in the DNN layer. Data processing unit 730 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 730 in parallel. For instance, multiple data processing units 730 may each perform a portion of a workload for a deep learning operation. Data may be shared between data processing units 730. Data processing unit 730 may also be referred to as a compute block, or a compute tile.
[0073] Data processing units 730 may be capable of running various types of deep learning operations, such as convolution, layer normalization, SoftMax operation, pooling, element-wise operation, linear operation, non-linear operation, and so on. Deep learning operations performed by the data processing units 730 include tensor operations, i.e., operations whose inputs are tensors or operations whose outputs are tensors. In an example, data processing unit 730 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 730 or another data processing unit 730.
[0074] In the embodiments of FIG. 7, each data processing unit 730 includes local memory 740, sparsity mode module 750, load module 760, processing engine 770, post-processing engine 780, and drain module 790. Some or all the components of the data processing unit 730 can be implemented on the same chip. In other embodiments, alternative configurations, different or additional components may be included in the data processing unit 730. Further, functionality attributed to a component of data processing unit 730 may be accomplished by a different component included in the data processing unit 730, a different data processing unit 730, another component of the DNN accelerator 702, or a different system. A component of the data processing unit 730 may be implemented in hardware, software, firmware, or some combination thereof.
[0075] Local memory 740 is local to the corresponding data processing unit 730. In the embodiments of FIG. 7, local memory 740 is inside the data processing unit 730. In other embodiments, local memory 740 may be outside the data processing unit 730. Data in local memory 740 may be transferred to or from memory 710, e.g., through DMA engine 720. In some embodiments, data in local memory 740 may be transferred to or from local memory 740 of another data processing unit 730. Local memory 740 may store data received, used, or generated by sparsity mode module 750, load module 760, processing engine 770, post-processing engine 780, or drain module 790. Examples of the data may include input activations, weights, output activations, instructions, configuration files, and so on.
[0076] In some embodiments, local memory 740 may store tensors to be processed by the processing engine 770 or the post-processing engine 780. The tensors may be input tensors of deep learning operations. Local memory 740 may also store tensors generated by processing engine 770 or post-processing engine 780. The tensors may be output tensors of deep learning operations. The layout of data points of a tensor in local memory 740 may depend on the format in which the tensor is stored. In some embodiments, local memory 740 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 740 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 740. For a tensor with the ZXY format or ZYX format, local memory 740 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 740. For a tensor with X-major format, local memory 740 may store data points having the same (y, z) coordinate contiguously. For a tensor with Y-major format, local memory 740 may store data points having the same (x, z) coordinate contiguously.
[0077] In some embodiments, local memory 740 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 be 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.
[0078] In some embodiments, local memory 740 includes one or more static random-access memories (SRAMs) . Local memory 740 may be byte-addressable, and each memory address identifies a single byte (eight bits) of storage. In some embodiments, local memory 740 may include memory banks. The number of data banks in the local memory 740 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 740 in a single read cycle. In other embodiments, 16 bits can be transferred from local memory 740 in multiple read cycles, such as two cycles.
[0079] Sparsity mode module 750 determines sparsity modes in which the data processing unit 730 operates to execute DNN layers. For instance, sparsity mode module 750 may determine whether to accelerate a layer based on weight sparsity, activation sparsity, or both. Sparsity mode module 750 select the sparsity mode for a layer from a group of sparsity modes that includes, for example, combined sparsity mode in which the layer is accelerated based on both weight sparsity and activation sparsity, activation sparsity mode in which the layer is accelerated based on activation sparsity but not based on weight sparsity, weight sparsity mode in which the layer is accelerated based on weight sparsity but not based on activation sparsity, and a dense mode in which the layer is not accelerated based on sparsity. In some embodiments (e.g., embodiments where a layer is executed by multiple data processing units 730) , sparsity mode module 750 may determine the sparsity mode for all the data processing units 730 that executes the layer. In some embodiments, sparsity mode module 750 may receive configuration parameters from DNN module 701. A configuration parameter may correspond to a layer and indicate whether to accelerate the layer based on weight sparsity. Sparsity mode module 750 may determine the sparsity mode of the layer based on the configuration parameter.
[0080] Load module 760 loads data from local memory 740 to the processing engine 770 or to post-processing engine 780. Load module 760 may read tensors from the local memory 740. The tensors may include sparse activation tensors, sparse weight tensors, activation sparsity tensors, weight sparsity tensors, and so on. In some embodiments, load module 760 may load data based on the sparsity mode determined by sparsity mode module 750. Load module 760 may select different data to transmit to processing engine 770 in different sparsity modes. For instance, load module 760 may transmit an activation sparsity tensor and a weight sparsity tensor of a layer to processing engine 770 in the combined sparsity mode, while transmit the activation sparsity tensor but not the weight sparsity tensor to processing engine 770 in the activation sparsity mode and transmit the weight sparsity tensor but not the activation sparsity tensor the processing engine 770 in the weight sparsity mode. In the dense mode, load module 760 does not transmit either the activation sparsity tensor or the weight sparsity tensor to the processing engine 770.
[0081] In some embodiments, load module 760 may process (e.g., densify) data stored in local memory 740 before providing the data to processing engine 770. In an example, the load module 760, while operating in the weight sparsity mode, may densify sparse activation tensors to generate dense activation tensors based on corresponding activation sparsity tensors. For instance, load module 760 may add one or more zeros into a sparse activation tensor based on an activation sparsity tensor associated with the sparse activation tensor to generate the dense activation tensor. The dense activation tensor includes one or more elements than the sparse activation tensor. The additional element (s) are zero-valued. The load module 760 may identify one or more elements in the activation sparsity tensor that correspond to the zero-valued element (s) , determine the position of each of the zero-valued element (s) in the dense activation tensor, and insert the zero-valued element (s) into the sparse activation tensor based on the determined positions. After the densification, load module 760 may transmit the dense activation tensors to processing engine 770. Load module 760 may also transmit corresponding sparse weight tensors and weight sparsity tensors to the processing engine 770. Activation sparsity tensor of the dense activation tensors may not be loaded to the processing engine 770.
[0082] In another example, load module 760, while operating in the activation sparsity mode, may densify sparse weight tensors to generate dense weight tensors based on corresponding weight sparsity tensors by inserting zeros into sparse weight tensors. The densification of sparse weight tensors may be similar to the densification of sparse activation tensors described above. After the densification, load module 760 may transmit the dense weight tensors to processing engine 770. Load module 760 may also transmit corresponding sparse activation tensors and activation sparsity tensors to processing engine 770. Weight sparsity tensor of the dense weight tensors may not be loaded to processing engine 770.
[0083] In yet another example, load module 760, while operating in the dense mode, may densify both sparse weight tensors and sparse activation tensors. Load module 760 may generate the input tensor and weight tensor of the layer and transmit the tensors to processing engine 770 for executing the layer without sparsity acceleration.
[0084] Load module 760 loads instructions, e.g., configuration files, from local memory 740 to the processing engine 770. The instructions may be used to configure or control processing cells of processing engine 770 to perform one or more deep neural network operations.
[0085] Processing engine 770 performs neural network operations of DNNs. An exemplary processing engine 770 is described and illustrated in FIG. 8. Processing engine 770 may accelerate neural network operations based on sparsity in activations and / or weights.
[0086] Processing engine 770 may include one or more processing cells. In some embodiments, the processing cells may be arranged in one or more rows and one or more columns in the processing engine 770. Each processing cell may include processing elements that may be arranged in an array that includes rows and columns.
[0087] An example processing element of a processing cell may be or may include one or more Multiply-and-Accumulate (MAC) units that can perform MAC operations. An example is illustrated in FIG. 9. In some embodiments (e.g., embodiments where the data processing unit 730 executes a convolutional layer) , a computation in an MAC unit may be an MAC operation on an activation operand and a weight operand. The activation operand may be an activation tensor that may include one or more activations in the input tensor of the convolution. Different activations may be in different input channels. The weight operand may be a weight tensor that may include one or more weights in the filter of the convolution. The values of the weights are determined through training the DNN. The weights in the weight operand may be in different input channels.
[0088] In some embodiments, an MAC unit includes one or more multipliers for performing multiplications. An MAC unit may also include one or more accumulators (“adders” ) for performing accumulations. A column of MAC units is referred to as an MAC column. An MAC column may be associated with one or more MAC lanes. A MAC lane is a path for loading data e.g., by load module 760, into an MAC column. A MAC lane may be also referred to as a data transmission lane or data loading lane. An MAC column may have multiple MAC lanes. The loading bandwidth of the MAC column is an aggregation of the loading bandwidths of all the MAC lanes associated with the MAC column. With a certain number of MAC lanes, data can be fed into the same number of independent MAC units simultaneously. In some embodiments where an MAC column has four MAC lanes for feeding activations or weights into the MAC column and each MAC lane may have a bandwidth of 16 bytes, the four MAC lanes can have a total loading bandwidth of 64 bytes. MAC units may be particularly suitable for performing matrix multiplications and convolutions.
[0089] In some embodiments, processing engine 770 may be capable of depth-wise convolution, standard convolution, or both. In a depth-wise convolution, an MAC unit may perform an MAC operation that includes a sequence of multiplications for an input operand and a weight operand. Each multiplication in the sequence (also referred to as a cycle) is a multiplication of a different activation in the input operand with a different weight in the weight operand. The activation and weight in the same cycle may correspond to the same channel. The sequence of multiplication produces a product operand that includes a sequence of products. The MAC operation may also include accumulations in which multiple product operands are accumulated to produce an output operand of the MAC unit. Processing engine 770 may output multiple output operands at a time, each of which is generated by a different MAC unit. In a standard convolution, MAC operations may include accumulations across the channels. For instance, as opposed to generating an output operand, a MAC unit may accumulate products across different channels to generate a single output point.
[0090] In some embodiments, the processing engine 770 may perform MAC operations in quantized deep learning operations, such as MAC operations in a quantized convolution. In some embodiments, an MAC unit in the processing engine 770 may receive quantized activation and quantized weights and compute a quantized MAC result. The quantized MAC result may be a quantized value in an integer format and may be the output of the MAC unit. In some embodiments, the MAC unit may also include a quantization multiplier that can multiply a quantization scale with the quantized MAC result, and the output of the MAC unit may be a real value in a floating-point format. The MAC unit may include no quantization subtractors as zero-point offsetting is not needed for the MAC operations in quantized deep learning operations.
[0091] In some embodiments, processing engine 770 may include sparsity accelerator logic 796 for facilitating sparsity acceleration. For instance, each processing cell in processing engine 770 may include one or more sparsity accelerators as part of sparsity accelerator logic 796. An example of a sparsity accelerator is illustrated in FIG. 9. In an example, each MAC column or each MAC row may have a corresponding sparsity accelerator that accelerates MAC operations in the MAC column or MAC row. In some embodiments, a sparsity accelerator accelerates computations in processing engine 770 based on sparsity in activations, sparsity in weights, or both. The sparsity accelerator may include a storage unit that stores a sparsity tensor, which may be loaded to the storage unit by load module 760. The sparsity tensor may be an activation sparsity tensor, a weight sparsity tensor, or a combined sparsity tensor.
[0092] An activation sparsity tensor may be the sparsity tensor of an activation tensor and has the same number of elements as the activation tensor. An element in the activation sparsity tensor may indicate whether the corresponding element in the activation tensor is zero or not. For instance, a zero-valued in the activation sparsity tensor may indicate that the corresponding element in the activation tensor is zero. A one-valued in the activation sparsity tensor may indicate that the corresponding element in the activation tensor is nonzero.
[0093] A weight sparsity tensor may be the sparsity tensor of a weight tensor and has the same number of elements as the weight tensor. An element in the weight sparsity tensor may indicate whether the corresponding element in the weight tensor is zero or not. For instance, a zero-valued in the weight sparsity tensor may indicate that the corresponding element in the weight tensor is zero. A one-valued in the weight sparsity tensor may indicate that the corresponding element in the weight tensor is nonzero.
[0094] The sparsity accelerator may generate a combined sparsity tensor using an activation sparsity tensor and a weight sparsity tensor. For instance, the sparsity accelerator may multiply an element of the activation sparsity tensor with a corresponding element of the weight sparsity tensor to compute an element of the combined sparsity tensor. The positions of the three elements in their corresponding sparsity tensors may match. In some embodiments, each element in a sparsity tensor may be a bit, and the sparsity tensor may be referred to as a sparsity bitmap.
[0095] The sparsity accelerator may use the sparsity tensor to identify activations and weights to be used in MAC operations by the MAC units. In an embodiment where processing engine 770 operates in the combined sparsity mode, the sparsity accelerator may identify activations and weights that correspond to nonzero valued elements of a combined sparsity tensor. In an embodiment where the processing engine 770 operates in the activation sparsity mode, the sparsity accelerator may identify activations and weights that correspond to nonzero valued elements of an activation sparsity tensor. In an embodiment where processing engine 770 operates in the weight sparsity mode, the sparsity accelerator may identify activations and weights that correspond to nonzero valued elements of a weight sparsity tensor. The sparsity accelerator may be bypassed in the dense mode as no sparsity acceleration would be conducted.
[0096] Post-processing engine 780 processes outputs of processing engine 770. The post-processing engine 780 may include one or more post-processing elements. In some embodiments, the post-processing elements in the post-processing engine 780 may be arranged in an arrangement that has rows and columns. In some embodiments, post-processing engine 780 computes activation functions. Post-processing engine 780 may receive outputs of processing engine 770 as inputs to the activation functions. In addition, or alternative to activation functions, post-processing engine 780 may perform other types of post-processing on outputs of processing engine 770. For instance, post-processing engine 780 may apply a bias on an output of processing engine 770. In some embodiments, post-processing engine 780 may be bypassed for certain neural network operations.
[0097] In one example, post-processing engine 780 includes apply fused bias 798 in a manner described herein.
[0098] Drain module 790 drains data from processing engine 770 and / or from post-processing engine 780. Drain module 790 may write the data to local memory 740. The drained data may be tensors, such as output tensors of neural network operations. In some embodiments, drain module 790 may drain data on a cell level of processing engine 770. For each processing cell, drain module 790 may drain outputs of processing elements in the processing cell based on a row index or column index of each processing element. For instance, drain module 790 may use a sequence of cycles to drain data from a processing cell. Drain module 790 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 760. The drained data, e.g., tensors, may be further loaded to memory 710, e.g., through the DMA engine 720. Additionally or alternatively, the drained data may be loaded by the load module 760 to the processing engine 770 for further computation, e.g., for performing a deep learning operation in the next layer.
[0099] In some embodiments, drain module 790 includes sparsity encoding logic 794 that can convert outputs of processing engine 770 from a dense format to a sparse format. For instance, drain module 790 may be implemented with one or more sparsity encoders as the sparsity encoding logic 794. A sparsity encoder converts dense data to compressed data based on sparsity in the dense data. For instance, the sparsity encoder may remove zeros in an activation tensor computed by processing engine 770 to convert the activation tensor to a compressed activation tensor. The sparsity encoder may also generate sparsity tensors, including activation sparsity tensors.
[0100] In some embodiments, sparsity encoding logic 794 may implement a pruner operator as described herein (e.g., pruner 1502 of FIG. 15) .
[0101] In some embodiments, the data drained from processing engine 770 may be at least part of an output tensor of a deep learning operation. The sparsity encoder may generate a compressed version of the output tensor. The sparsity encoder may identify every zero-valued activation in the output tensor and remove these activations from the output tensor to generate a compressed activation tensor (aka “sparse activation tensor” ) . The sparsity encoder may also generate one or more sparsity tensors for the output tensor. A sparsity tensor may correspond to a portion of the output tensor. The sparsity tensor may include sparsity elements (e.g., bits) , each of which corresponds to a different activation in the vector and indicates whether the corresponding activation is zeroed or not. The sparsity tensor may be referred to as a binary mask.
[0102] Drain module 790 may write the compressed activation tensor and the one or more sparsity tensors into local memory 740. The sparse activation tensor and the one or more sparsity tensors may be further loaded to memory 710, e.g., through DMA engine 720. Additionally, or alternatively, the sparse activation tensor and the one or more sparsity tensors may be loaded by load module 760 to processing engine 770 for further computation, e.g., for performing a deep learning operation in the next layer.
[0103] FIG. 8 illustrates processing engine 770, according to some embodiments of the disclosure. Processing engine 770 may be included as part of a data processing unit, such as data processing unit 730 of FIG. 7. Processing engine 770 may include one or more processing cells 802. In some embodiments, the processing cells 802 may be arranged in one or more rows and / or one or more columns in the processing engine 770. In some embodiments, the processing cells 802 may be arranged as one or more sets or arrays of processing cells 802 performing different operations.
[0104] Each processing cell may include one or more processing elements. An example is illustrated in FIG. 9. 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.
[0105] 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.
[0106] Processing engine 770 may include controller 804, which may configure circuitry of one or more processing cells 802 to perform the arithmetic operations. In some cases, controller 804 may configure one or more processing cells 802 (or individual processing elements in a processing cell 802) to perform operations in a particular sequence or manner. In some cases, controller 804 may configure one or more processing cells 802 (or individual processing elements in a processing cell 802) according to instructions loaded in instruction buffer 806. Controller 804 may include a program counter to determine the instructions loaded in instruction buffer 806 to be executed by one or more processing cells 802 (or individual processing elements in a processing cell 802) .
[0107] The instructions loaded in instruction buffer 806 (e.g., by load module 760 of FIG. 7) may signal which processing cells 802 (or individual processing elements in a processing cell 802) is to execute or carry out one or more operations.
[0108] Data may be loaded in data buffers 808 by load module 760 of FIG. 7. The data may be used by processing cells 802. Data produced by processing cells 802 may be drained from data buffers 808 by drain module 790 to local memory 740 of FIG. 7.
[0109] Data buffers 808 may include one or more of: one or more input data buffers, and one or more output data buffers. Data buffers 808 may include one or more weights / parameters buffers. Data buffers 808 may store operands for one or more processing elements of processing cell 802. Data buffers 808 may store generated outputs of one or more processing elements of processing cell 802.
[0110] The instructions loaded in instruction buffer 806 may signal which data stored in data buffers 808 is to be processed by processing cells 802 (or individual processing elements in a processing cell 802) . In some cases, the processing cells 802 (or individual processing elements in a processing cell 802) may read data from data buffers 808 at a default location for the processing cell 802 or an individual processing element in the processing cell 802.
[0111] The instructions loaded in instruction buffer 806 may signal where to store output data in data buffers 808 after processing cells 802 produces the output data. In some cases, the processing cells 802 (or individual processing elements in a processing cell 802) may write data to data buffers 808 at a default location for the processing cell 802 or an individual processing element in the processing cell 802.
[0112] Load module 760 of FIG. 7 may load data to certain locations in data buffers 808. Drain module 790 of FIG. 7 may drain data from data buffers 808 to be stored in local memory 740 and / or memory 710 of FIG. 7.
[0113] FIG. 9 illustrates processing element 900 of a processing cell, according to some embodiments of the disclosure. Processing element 900 may be a part of processing cell 802 in processing engine 770 of FIG. 7. Processing element 900 includes MAC unit 905, activation register file 910, weight register file 920, output register file 950, and sparsity accelerator 960. MAC unit 905 includes multiplier 930 and adder 940. In other embodiments, processing element 900 may include fewer, more, or different components.
[0114] Activation register file 910 stores an activation operand, which may be a context. Weight register file 920 stores a weight operand. The activation operand and weight operand may be loaded from a memory (e.g., local memory 740) into activation register file 910 and weight register file 920, respectively. Sparsity accelerator 960 receives sparsity bitmap 915 that corresponds to the sparse tensor in the weight register file 920. Sparsity bitmap 915 may be a combined sparsity bitmap when the MAC unit 905 operates in a combined sparsity mode. Sparsity bitmap p15 may be an activation sparsity bitmap when MAC unit 905 operates in an activation sparsity mode. Sparsity bitmap 915 may be a weight sparsity bitmap when the MAC unit 905 operates in a weight sparsity mode. sparsity bitmap 915 may have the same size (e.g., the same number of elements) as or a larger size than the activation operand or the weight operand.
[0115] Using sparsity bitmap 915, sparsity accelerator 960 selects four activations from activation register file 910 and selects four weights from the weight register file 920. The sparsity accelerator 960 transmits the selected activations and weights to the multiplier 930. These selected data elements correspond to the nonzero valued elements of sparsity bitmap 915. The four selected activations and the four selected weights may constitute four activation-weight pairs. The multiplier 930 may compute a product based on each activation-weight pair and therefore, compute four products in total. The four products may be provided to adder 940. Even though FIG. 9 shows a single multiplier 930, MAC unit 905 may include multiple multipliers that can perform multiple multiplication operations at the same time.
[0116] Adder 940 accumulates the four products and computes a unit-level internal partial sum. The four unselected elements of the dense tensor are not processed to save power and time, which would not impact the value of the unit-level internal partial sum. For instance, when the dense tensor is a dense activation tensor, the weights corresponding to the unselected activations are zeros so the products of the unselected activations and the weights would all be zero and have no contribution to the unit-level internal partial sum or other partial sums computed by the processing cell. Similarly, when the dense tensor is a dense weight tensor, the activations corresponding to the unselected weights are zeros so the products of the unselected weights and the activations would all be zero and have no contribution to the unit-level internal partial sum or other partial sums computed by the processing cell. In other embodiments, MAC unit 905 may operate in a dense mode in which sparsity bitmap 915 is not used and sparsity accelerator 960 is inactive. MAC unit 905 may process all the activations in the activation operand and all the weights in the weight operand.
[0117] The unit-level internal partial sum may be stored in output register file 950. In some embodiments, the unit-level internal partial sum may be used multiple times. For instance, the activation operand may represent N data blocks in the input tensor of the convolution, where N is an integer greater than 1. Instead of processing all the N data blocks to compute N unit-level internal partial sums, the unit-level internal partial sum is computed once and used N times in the convolutional layers as N unit-level internal partial sums.
[0118] In some embodiments, processing element 900 receives one or more processing element-level internal partial sums from one or more other processing elements of a processing cell. Adder 940 or an accumulator (not shown in FIG. 9) can accumulate the one or more processing element-level internal partial sums with the processing element-level internal partial sum of processing element 900 and store the result of the accumulation (i.e., a multi-processing element internal partial sum) in output register file 950. The one or more other processing elements may be in the same column as processing element 900 in a processing cell. The multi-unit internal partial sum may be a column-level internal partial sum. In some embodiments, the processing element-level internal partial sum of processing element 900 or the multi-unit internal partial sum may be sent to one or more other processing elements for further accumulation.
[0119] Referring to FIGS. 7-9, DNN system 700 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 data processing units, the number of processing engines, the number of processing cells, support for vector processing, support for sparsity modes, the types or collection of processing elements, amount of memory and buffer size, etc.
[0120] Deployment of DNNs with post-training optimization
[0121] FIG. 10 illustrates DNN module 701, according to some embodiments of the disclosure. DNN module 701 includes interface module 1010, training module 1020, compressing module 1080, validating module 1040, post-training optimization 1084, and datastore 1060. In other embodiments, alternative configurations, different or additional components may be included in the DNN module 701. Further, functionality attributed to a component of DNN module 701 may be accomplished by a different component included in DNN module 701 or a different module or system.
[0122] Interface module 1010 facilitates communications of DNN module 701 with other modules or systems. For example, interface module 1010 establishes communications between DNN module 701 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 1010 supports DNN module 701 to distribute DNNs to other systems, e.g., computing devices configured to apply DNNs to perform tasks.
[0123] Training module 1020 trains DNNs by using a training dataset. Training module 1020 forms the training dataset. In an example where training module 1020 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 1020 trains a transformer-based neural network to predict the next token, the training dataset 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 1040 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.
[0124] Training module 1020 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.
[0125] Training module 1020 can define the architecture of the DNN, e.g., based on some of the hyperparameters. In some cases, training module 1020 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 1020 defines the architecture of the DNN, training module 1020 inputs a training dataset into the DNN. The training dataset includes a plurality of training samples. The training module 1020 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 1020 uses a cost function to minimize the error.
[0126] Training module 1020 may train the DNN for a predetermined 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 1020 finishes the predetermined number of epochs, training module 1020 may stop updating the parameters in the DNN. The DNN having the updated parameters is referred to as a trained DNN.
[0127] Validating module 1040 verifies accuracy of trained DNNs. In some embodiments, validating module 1040 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 1040 may determine an accuracy score measuring the precision, recall, or a combination of precision and recall of the DNN. The validating module 1040 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.
[0128] Validating module 1040 may compare the accuracy score with a threshold score. In an example where validating module 1040 determines that the accuracy score of the DNN is less than the threshold score, validating module 1040 instructs training module 1020 to re-train the DNN. In one embodiment, training module 1020 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.
[0129] Compiler 1050 compiles information of DNNs, such as the model definition, to executable instructions (e.g., configuration files) that can be executed, e.g., by DNN accelerator 702, to carry out neural network operations in DNNs. The model definition may include one or more neural network operations to be performed by the DNN. In some embodiments, compiler 1050 may generate a 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, and so on. Compiler 1050 may use the graph to generate instructions (e.g., configuration files, configuration parameters, etc. ) . The instructions may include low-level machine code that can be executed by components of the DNN accelerator 702 (e.g., processing engine 770) . The low-level machine code may be in a binary format, which may be loaded onto DNN accelerator 702 and executed by components of the DNN accelerator 702 (e.g., processing engine 770) . The instructions would be executed by components of the DNN accelerator 702 (e.g., processing engine 770) to execute the DNN.
[0130] Datastore 1060 stores data received, generated, used, or otherwise associated with the DNN module 701. For example, datastore 1060 stores the datasets used by training module 1020 and validating module 1040. Datastore 1060 may also store data generated by training module 1020 and validating module 1040, 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 1060 may store configuration parameters, configuration files, instructions generated by compiler 1050, etc. The datastore 1060 may include one or more memories. In the embodiment of FIG. 4, datastore 1060 is a component of DNN module 701. In other embodiments, datastore 1060 may be external to DNN module 701 and communicate with the DNN module 701 through a network.
[0131] Compressing module 1080 compresses DNNs. For instance, compressing module 1080 may add pruning operations to DNN layers to reduce computational complexity or memory usage. A pruning operation may prune weight tensors of a DNN layer by changing one or more nonzero valued weights of the layer to zeros. The modification may be done before, during, or after training. Weights may be pruned during training, during inference, or a combination of both. Compressing module 1080 may determine a sparsity ratio for a DNN layer. The sparsity ratio may be a ratio of the number of zero-valued weight to the total number of weights in the layer. Compressing module 1080 may perform the pruning operation till the sparsity ratio of the DNN layer meets a target sparsity ration, such as 10%, 20%, 30%, 40%, 50%, and so on.
[0132] In some embodiments, compressing module 1080 may select one or more layers in a DNN and modify each selected layer with a pruning operation. For instance, the compressing module 1080 may select computationally complex layers, such as layers with large filters. For a pruning operation of a layer or of a type of layer, compressing module 1080 may determine a weight threshold that would not cause a loss of the accuracy of the DNN to exceed an accuracy loss constraint. A pruning operation may modify weights having absolute values above the weight threshold to zeros and leave the other weights unchanged. The weight pruning can reduce memory storage as zero-valued weights may not be stored. Also, the number of operations in the layer can be reduced as computations on zero-valued weights can be skipped without impacting the output of the layer. In some embodiments, compressing module 1080 may also measure energy saving, final DNN accuracy, or layer-wise sparsity caused by pruning operations.
[0133] In some embodiments, compressing module 1080 may quantize one or more layers of a DNN. Compressing module 1080 may estimate the range of values for the weights and activations of the neural network. Compressing module 1080 may perform a forward pass on a representative dataset and tracking the minimum and maximum values encountered for each layer. Compressing module 1080 may define a quantization function to map the full-precision (e.g., 32-bit floating-point) values to lower-precision (e.g., 8-bit integer) values. An example of a quantization function is a linear quantization function, which maps the input range of values to a discrete set of quantized values. Compressing module 1080 may apply the quantization function to the weights and activations of the neural network, effectively converting them to lower-precision representations. Application of the quantization function can be performed either during training (quantization-aware training) or as a post-processing step after training (post-training quantization) . Compressing module 1080 may change some of the arithmetic operations into specialized arithmetic operations designed to operate on low-precision data types efficiently, taking advantage of hardware-accelerated instructions or dedicated arithmetic units.
[0134] After compressing a DNN, compressing module 1080 may fine tune the DNN, e.g., through a retraining process. Compressing module 1080 may fine tune DNNs after weights are pruned. Compressing module 1080 may fine tune DNNs after weights and / or activations are quantized. In some embodiments, the fine-tuning process is a retraining or further training process.
[0135] For instance, after weights in a DNN are pruned, compressing module 1080 may further train the DNN by inputting a training dataset into the DNN. The values of the unpruned weights in the DNN may be modified based on outputs of the DNN and ground-truth labels of the training samples in the training dataset. In some embodiments, the values of the pruned weights (i.e., zero) are not changed during the fine-tuning process. For instance, the compressing module 1080 may place a mask over a pruned weight block and the mask can prevent values in the pruned weight blocks from being changed during the fine-tuning process. In other embodiments, the values of all weights, including the pruned weights, may be changed during the fine-tuning process. After one or more cycles of retraining and weight changing by compressing module 1080, compressing module 1080 may perform a new pruning process, e.g., by selecting weight blocks and pruning the selected weight blocks. In some embodiments, the weight pruning process may be repeated multiple times before the fine-tuning process is done. In some embodiments, the number of epochs in the fine-tuning process may be different from the number of epochs in the training process in which the pre-pruning values of the weights are determined. For instance, the fine-tuning process may have less epochs than the training process. In an example, the number of epochs in the fine-tuning process may be relatively small, such as 2, 3, 4, 5, and so on.
[0136] In another instance, after weights and / or activations are quantized, the DNN may have a drop in accuracy when compared to a full-precision DNN. Compressing module 1080 may calibrate and adjust the quantization ranges based on the observed activations during inference. Compressing module 1080 may perform fine-tuning by training the quantized DNN with a smaller learning rate to recover accuracy loss caused by quantization.
[0137] Notably, DNN module 701 includes post-training optimization 1084 to receive a pre-trained or fine-tuned DNN and perform modifications to insert pruner operators strategically to induce sparsity. To increase sparsity, post-training optimization 1084 can include lossless mode-centering mechanisms into the DNN to statically condition the pruner operators. Post-training optimization 1084 can perform a two-stage greedy grid search to determine optimal importance threshold values to be used by the pruner operators. Post-training optimization 1084 may determine (initial) estimated mode values to be used in the mode-centering mechanisms, including the calculation of a fused bias. The optimized DNN may then be compiled into low-level machine code by compiler 1050 and deployed onto a DNN accelerator, e.g., DNN accelerator 702 of FIG. 7. Further details about post-training optimization 1084 are described in FIG. 11. Post-training optimization 1084 may complement compressing module 1080 for joint acceleration of DNNs.
[0138] FIG. 11 illustrates post-training optimization 1084, according to some embodiments of the disclosure. Post-training optimization 1084 may be implemented as part of DNN module 701 of FIG. 7.
[0139] Post-training optimization 1084 may receive one or more model definitions 1110 of neural networks. In some embodiments, the model definition specifies a pre-trained neural network, where the model definition includes the structure of the neural network and the parameters of the neural network. In some embodiments, the pre-trained neural network is quantized or compressed (e.g., using compressing module 1080 seen in FIG. 10) .
[0140] Post-training optimization 1084 may receive one or more target metrics 1112 for the neural network. One or more target metrics 1112 may include a target quality of the neural network. Target quality may be associated with one or more of: accuracy of the neural network, precision of the neural network, recall of the neural network, F1 score of the neural network, values of a loss function of the neural network, task performance of the neural network, etc. One or more target metrics 1112 may include a target performance of the neural network. Target performance may be associated with one or more of: target sparsity of the neural network, inference time or latency of the neural network, number of memory accesses or memory usage, etc. One or more target metrics 1112 may include a target size of the neural network. Target size may be associated with one or more of: number of processing operations to complete an inference, number of parameters, precision of parameters, memory footprint, etc.
[0141] One or more target metrics 1112 may be provided by a user that is looking to deploy the neural network onto hardware, such as DNN accelerator 702 of FIG. 7. One or more target metrics 1112 may vary depending on the neural network. One or more target metrics 1112 may vary depending on the target application. One or more target metrics 1112 may vary depending on the limitations of the hardware. One or more target metrics 1112 may vary depending on the available resources of the hardware. One or more target metrics 1112 may depend on the type of data that the neural network is expected to process.
[0142] Post-training optimization 1084 may receive one or more datasets 1114. One or more datasets 1114 may include a calibration dataset (e.g., a few batches of text) . In some embodiments, the calibration dataset may include in the order of tens or hundreds of text prompts. The calibration dataset may be representative of expected input data to the neural network. The calibration dataset may be a sample of input data selected based on a particular use-case of the neural network. The calibration dataset may be associated with a task to be performed by a machine learning model. One or more datasets 1114 may include a validation dataset. A validation dataset may include data that is held out from training data. The inputs of the validation dataset may be used as the calibration dataset. In some cases, a few randomly selected inputs of the validation dataset may be used as the calibration dataset. One or more datasets 1114 may include a test dataset. A test dataset may include data that is fully held out that is never used for training or validation. The inputs of the test dataset may be used as the calibration dataset. In some cases, a few randomly selected inputs of the test dataset may be used as the calibration dataset.
[0143] Post-training optimization 1084 emphasizes practicality. Post-training optimization 1084 also aims to be scalable and lightweight. Post-training optimization 1084 aims to be flexible and tunable. Post-training optimization 1084 implements optimization of a pre-trained neural network model with just a small calibration data set. Post-training optimization 1084 may achieve one or more target metrics 1112 within hours instead of days.
[0144] Post-training optimization 1084 may include neural network modification 1102. Neural network modification 1102 may make modifications to one or more model definitions 1110. In some cases, neural network modification 1102 may modify the structure of the neural network. In some cases, neural network modification 1102 may modify a configuration of the neural network (e.g., enable activation sparsity mode, enable weight sparsity mode, enable quantization, etc. ) In some cases, neural network modification 1102 may modify the parameters (e.g., weights and biases) of the neural network. In some cases, neural network modification 1102 may modify one or more operations of the neural network.
[0145] Neural network modification 1102 may insert one or more pruners to a neural network to induce activation sparsity. One or more model definitions 1110 may be analyzed to determine locations of interest where activation sparsity can speed up inferencing. The structure of the neural network can be modified by neural network modification 1102 to include the one or more pruners at certain locations of interest. Neural network modification 1102 may modify the neural network to include lossless activation mode-centering mechanisms to increase sparsity at the locations of interest. The lossless activation mode-centering mechanisms may include adjusting the mode of an activation tensor by a certain amount prior to pruning, then modifying an output tensor of a sparse operation in a manner that effectively reverses the mode adjustment that was performed prior to pruning (e.g., adjusting the mode of the output tensor by the same amount in the opposite direction) . Examples of how the neural network is modified are illustrated in FIGS. 12-16.
[0146] Post-training optimization 1084 may include two-stage greedy grid search 1104. Two-stage greedy grid search 1104 implements an optimization to maximize sparsity while maintaining one or more target metrics 1112 within an acceptable tolerance. One or more datasets 1114 can be used in the optimization. Two-stage greedy grid search 1104 can determine one or more optimal importance threshold candidates. Two-stage greedy grid search 1104 may also determine one or more estimated mode values to be used for mode-centering. Details relating to the two-stage greedy grid search 1104 are described with FIGS. 17-19 and 21.
[0147] Post-training optimization 1084 may include mode value determination 1106. Mode value determination 1106 may determine one or more initial estimated mode values for activation tensors using one or more datasets 1114. Mode value determination 1106 may monitor the mode values of the activation tensors of interest while a neural network model is deployed and update the estimated mode values of activation tensors.
[0148] Post-training optimization 1084 can output one or more optimized model definition 1116 of an optimized neural network having dynamically sparse activations.
[0149] Implementation of pruner operators and lossless mode-centering mechanisms
[0150] Neural network modification 1102 of FIG. 11 may analyze a model definition and determine locations of interest where activation sparsity may make inference more efficient. In some embodiments, sparsification may be induced at certain locations of interest within a neural network. A location of interest may include the output of a normalization layer or a normalization operation. A location of interest may include a location just before a matrix multiplication is to be performed, such as a location just before a linear projection. Introducing activation sparsity at such a location can help reduce computations to be performed for the matrix multiplication and potentially the memory accesses needed to perform the matrix multiplication. One or more locations of interest may be identified in an attention layer, such as attention layer 400. Attention layer 400 (or other similar attention layers) may have one or more pruners inserted at the input of a linear projection block in the attention layer. One or more locations of interest may be identified in a FFN layer, such as FFN layer 500 and FFN layer 600. FFN layer 500 and FFN layer 600 (or other similar FFN layers) may have one or more pruners inserted at the input feeding into the FFN layer. FFN layer 500 and FFN layer 600 (or other similar FFN layers) may have one or more pruners inserted just after a normalization block. FFN layer 500 and FFN layer 600 (or other similar FFN layers) may have one or more pruners inserted at the input of a linear projection block in the FFN layer.
[0151] A pruner or a pruner operator involves measuring the importance of neurons (aneuron is a single element of an activation tensor) on-the-fly and outputting a binary mask such that only neurons with importance above threshold value can propagate downstream. Neurons having an importance or importance value below the threshold is essentially zeroed out and activation sparsity is induced. The importance function can be applied at different granularity from per element of the activation tensor (neuron) , per channel of the activation tensor, up to per tensor basis depending on the needs due to other aspects like acceleration scheme. The output of importance function serves as input to generate a binary mask where any value that exceeds a specified threshold results in activated value in the mask and nullified value otherwise. The pruner completes the activation sparsification by filtering the activation based on the binary mask by means of applying an element-wise multiplication of the mask and activation tensor. An exemplary implementation of a pruner is illustrated in FIG. 15.
[0152] An example of inserting pruners into FFN layer 500 is illustrated in FIG. 12. An example of inserting pruners into FFN layer 600 is illustrated in FIG. 14. An exemplary implementation of a pruner and lossless mode-centering mechanism is illustrated in FIG. 17.
[0153] FIG. 12 illustrates one or more pruners added to a neural network 1200, according to some embodiments of the disclosure. Neural network 1200 may be a modified version of FFN layer 500 with one or more pruners inserted at certain locations of interest. Input to neural network 1200, X 1202, may first be processed by normalization 1282. Pruner 1204 prunes the activation tensor produced by normalization 1282 and provides a sparse activation tensor to upward linear projection 504. Output of upward linear projection 504 is provided to activation function 506. Pruner 1210 prunes the activation tensor produced by activation function 506 and provides a sparse activation tensor to downward linear projection 508. Downward linear projection 508 generates an output of neural network 1200, X’ 1214.
[0154] Pruner 1204 may be inserted after normalization 1282 and in front of upward linear projection 504. Computations and potentially memory accesses to perform matrix multiplication in upward linear projection 504 are saved by introducing pruner 1204.
[0155] Pruner 1210 may be inserted in front of downward linear projection 508. Computations and potentially memory accesses to perform matrix multiplication in downward linear projection 508 are saved by introducing pruner 1210.
[0156] FIG. 13 illustrates computational and memory access savings when pruners are added to a neural network, according to some embodiments of the disclosure. In the example illustrated, some of the operations performed in a neural network having a FFN layer are depicted. One or more pruners may be inserted into the FFN layer (e.g., as illustrated in FIG. 12) to induce activation sparsity.
[0157] The mathematical operation on an input X to an FFN layer to produce an output X’ can be represented as follows: X′=σ (XWU) WD (eq. 5)
[0158] Matrix multiplication is performed on the input X and the upward weight matrix WU to obtain XWU. Then, the result of the matrix multiplication undergoes activation function 1390 to obtain σ (XWU) . Then, matrix multiplication is performed on the result of the activation function and the downward weight matrix WD to obtain σ (XWU) WD to obtain the output X’ of the FFN layer.
[0159] Matrix multiplication involves many vector dot products or MAC operations. When input X has sparsity, e.g., one or more zeros (illustrated as one or more black cells) , the matrix multiplication of X and upward weight matrix WU can be made more computationally and memory efficient. Multiplication with values in one or more rows (or columns) of the upward weight matrix WU can be skipped. Loading operations from memory for values in one or more rows (or columns) of the upward weight matrix WU can be skipped. When tensor σ (XWU) has sparsity, e.g., one or more zeros (illustrated as one or more black cells) , the matrix multiplication of σ (XWU) and downward weight matrix WD can be made more computationally and memory efficient. Multiplication with values in one or more rows (or columns) of the downward weight matrix WD can be skipped. Loading operations from memory for values in one or more rows (or columns) of downward weight matrix WD can be skipped.
[0160] The example illustrated in FIG. 13 is an example of vector-matrix multiplication. The benefits of sparsity can be extended to other types of multiplications, such as matrix-matrix multiplication as well.
[0161] It is noted that sparsity observed for input X and tensor σ (XWU) may be artificially induced or achieved using pruner 1204 of FIG. 12 and pruner 1210 of FIG. 12 respectively. Sparsity can be observed for tensor σ (XWU) , even if activation function 1390 is not a ReLU activation function.
[0162] FIG. 14 illustrates one or more pruners added to a neural network, according to some embodiments of the disclosure. Neural network 1200 may be a modified version of FFN layer 600 with one or more pruners inserted at certain locations of interest. Input to neural network 1400, X 1402, may first be processed by normalization 1482. Pruner 1404 prunes the activation tensor produced by normalization 1482 and provides a sparse activation tensor to upward linear projection 604 and gated linear projection 606. Output of gated linear projection 606 is provided to activation function 608. Element-wise multiplier 610 performs element-wise multiplication of the output of upward linear projection 604 and the output of activation function 608. Pruner 1414 prunes the activation tensor produced by element-wise multiplier 610 and provides a sparse activation tensor to downward linear projection 612. Downward linear projection 612 generates an output of neural network 1400, X’ 1418.
[0163] Pruner 1404 may be inserted after normalization 1482 and in front of upward linear projection 604 and / or gated linear projection 606. Computations and potentially memory accesses to perform matrix multiplication in upward linear projection 604 and / or gated linear projection 606 are saved by introducing pruner 1404.
[0164] Pruner 1414 may be inserted in front of downward linear projection 612. Computations and potentially memory accesses to perform matrix multiplication in downward linear projection 612 are saved by introducing pruner 1414.
[0165] FIG. 15 illustrates pruner 1502, according to some embodiments of the disclosure. Pruner 1502 illustrates an exemplary implementation of pruners seen in FIG. 12 and 14.
[0166] Pruner 1502 may receive a calibrated importance threshold value τ 1520. Pruner 1502 may receive a (dense) activation tensor X 1522. Pruner 1502 may produce a sparsified activation tensor X’ 1540. In other words, pruner 1502 may prune a (dense) activation tensor X 1522 to be a sparsified activation tensor X’ 1540.
[0167] Pruner 1502 may include importance function operator 1504. Importance function operator 1504 may receive activation tensor X 1522. Importance function operator 1504 may apply an importance function, I (X) , to one or more elements of the activation tensor X 1522 to determine one or more importance values.
[0168] Importance, or an importance value I, is a metric quantifying a neuron’s contribution or correlation to the final prediction outcome. In some cases, importance I is preferably magnitude only and unidirectional such that relativity / ranking between neurons can be performed easily. The importance I can be designed to derive from neuron values, e.g. p-norm magnitudes, statistical measurement, or a formulation factoring in the associated weight values. Considering importance computation during inference, one choice is L1 norm: I (X) =L1 (X) =|x| (eq. 6)
[0169] According to equation 6, the importance function calculates an absolute value of each one of the one or more elements of the activation tensor X 1522.
[0170] In some embodiments, the importance function ranks the elements of the activation tensor X 1522 based on the elements' (individual) contribution to a prediction. The importance function may assign importance values based on the ranking.
[0171] In some embodiments, the importance function ranks the elements of the activation tensor X 1522 based on one or more weights corresponding to one or more (or each) element of activation tensor. An element of activation tensor X 1522 (e.g., a neuron) , may have a set of weights corresponding to connections of the neuron to the neurons in the next layer. The importance value for the element of activation tensor X 1522 may take the set of weights into account. The importance function may assign importance values based on the ranking.
[0172] Pruner 1502 may include binary mask generator 1506. Binary mask generator 1506 may generate a binary mask, e.g., mask 1508, based on the one or more importance values I determined by importance function operator 1504 and calibrated importance threshold value τ 1520. The operation may be represented by:
[0173] Binary mask generator 1506 may set a first value in the binary mask (e.g., mask 1508) to 1 in response to a first importance value (e.g., I) in the one or more importance values being greater than the calibrated importance threshold value (e.g., τ 1520) . Binary mask generator 1506 may set the first value in the binary mask (e.g., mask 1508) to 0 in response to the first importance value (e.g., I) being smaller than the calibrated importance threshold value (e.g., τ 1520) . Binary mask generator 1506 may set a first value at a first location in the binary mask (e.g., mask 1508) to 1 in response to a first importance value at the same first location (e.g., I) in the one or more importance values being greater than the calibrated importance threshold value (e.g., τ 1520) . Binary mask generator 1506 may set the first value at the first location in the binary mask (e.g., mask 1508) to 0 in response to the first importance value at the same first location (e.g., I) being smaller than the calibrated importance threshold value (e.g., τ 1520) . These operations of binary mask generator 1506 may be performed for further locations in the same fashion.
[0174] Mask 1508 may have the same dimensions of activation tensor X 1522. Mask 1508 may have 0’s and 1’s, where the values have a direct correspondence to the elements of activation tensor X 1522. Values of mask 1508 may control which element (s) of activation tensor X 1522 may be a part of sparsified activation tensor X’ 1540. If a value in mask 1508 is 1, then the element of activation tensor X 1522 may be a part of sparsified activation tensor X’ 1540. If a value in mask 1508 is 0, then the element of activation tensor X 1522 may omitted from sparsified activation tensor X’ 1540 (or zeroed out) .
[0175] Pruner 1502 includes element-wise multiplier 1510 to apply the binary mask (e.g., mask 1508) to the activation tensor X 1522 to generate sparsified activation tensor X’ 1540. Element-wise multiplier 1510 may perform element-wise multiplication of activation tensor X 1522 and mask 1508. Element-wise multiplier 1510 performs a filtering operation based on mask 1508 to produce sparsified activation tensor X’ 1540, where an element of activation tensor X 1522 is passed on to sparsified activation tensor X’ 1540 if the value in the binary mask is 1, and an element of activation tensor X 1522 is nullified in sparsified activation tensor X’ 1540 if the value in the binary mask is 0. The operation of element-wise multiplier 1510 may be represented as follows: X′=Mask⊙X (eq. 8)
[0176] Calibrated importance threshold value τ 1520 may be a hyperparameter which correlates to the intensity of pruning being performed by pruner 1502. Calibrated importance threshold value τ 1520 can be determined specifically for the location at which pruner 1502 is inserted. Calibrated importance threshold value τ 1520 can be associated with the activation tensor to be pruned. Calibrated importance threshold value τ 1520 can be associated with the machine learning model. Calibrated importance threshold value τ 1520 can be set based on a target sparsity percentage (e.g., a percentage of elements of activation tensor X 1522 to zero out) . Calibrated importance threshold value τ 1520 can be determined based on a target sparsity and a calibration dataset. In some embodiments, calibrated importance threshold value τ 1520 can be represented as follows: τ=Quantile (I, Target Sparsity) (eq. 9)
[0177] Calibrated importance threshold value τ 1520 can be determined by post-training optimization 1084, such as two-stage greedy grid search 1104 of FIG. 11, where sparsity may be maximized while maintaining neural network performance.
[0178] By feeding a small calibration dataset, the activation tensors of interest can be saved / stored, forming a representative sample for estimating population importance. Subsequently, a quantile (percentile) function on this importance sample can identify corresponding importance value equivalent to a density, or target sparsity if a particular value is used as calibrated importance threshold value τ 1520 by binary mask generator 1506 to produce mask 1508. To illustrate, consider an example where activation tensor X 1522 is the input activation of a downward linear projection block in a FFN layer, denoted as X ∈ RNxTxD where N represents the number of batches in the calibration dataset, T is the token length, and D is the activation dimensionality. Importance of the sample follows the same tensor shape. According to equation 9, τ = Quantile (|X|, 0.3) means thresholding on |X| with value of τ is expected to yield 30%of sparsity in activation X.
[0179] In some experiments, the calibrated importance threshold value τ 1520 determined using the schemes described herein based on a small batches text prompt can attain target sparsity across many zero shot tasks. The experiments demonstrates that the technique can achieve actual sparsity and generalize across diverse task, even in view of the dynamic nature of activation by input and contextually by domain.
[0180] In situations where calibrated importance threshold value τ 1520 does not achieve the desired sparsity, or does not perform as expected for certain tasks, it is possible to apply the efficient scheme implemented by two-stage greedy grid search 1104 of FIG. 11 with a calibration dataset that is more relevant to the task, context, or domain. In other words, calibrated importance threshold value τ 1520 can be recalibrated for different contexts and domains using different calibration datasets. Also, it is possible to apply the efficient scheme implemented by two-stage greedy grid search 1104 of FIG. 11 using higher target metric (s) to recalibrate calibrated importance threshold value τ 1520.
[0181] Furthermore, in some experiments, inserting pruner 1502 into a neural network and setting calibrated importance threshold value τ 1520 using the schemes described herein have been shown to attain satisfactory sparsity-accuracy. For some experiments, pruner 1502 outperforms other compression techniques with lower degradation and sparsity at a similar degree without the need for fine-tuning or uptraining. At the same time, the calibration scheme is 65 times faster than fine-tuning / uptraining.
[0182] For some LLMs, pruner 1502 may not be able to prune activation tensors at a high rate (e.g., 1%) and below of task deterioration, due to the inherent nature of thresholding on the L1-norm value. Thresholding on the L1-norm value may be ineffective if the values being pruned do not have a peak around zero, or the values are the densest around zero. It has been observed that the output of GELU function, which can be an input activation function in front of a downward linear projection block in a FFN layer can have a low prunability. In addition, it has been observed that the output of GELU function at various transformer blocks are unimodal, but the peak (e.g., mode) is not always centered at zero, especially those at the deeper transformer blocks. If the mode of the output of the GELU function can be centered at zero (e.g., the peak is moved to zero) , more elements of the output of the GELU function can be pruned. By shifting the mode of the activation tensor with a suitable mode value (e.g., the peak) so that the density distribution is centered around zero, more elements of the activation tensor would have an importance value below the calibrated importance threshold value, and higher sparsity can be achieved. It is not trivial to determine the mode value that can be used for a given activation tensor to be pruned, especially due to the dynamism of activation by any input. The mode value can be determined in an online manner, or the mode value can be determined in an offline manner. Also, it is not trivial to reverse the adjustment made to the mode in the density distribution to ensure that the mechanism is lossless and does not impact the calculations being performed by the neural network. Implementing a lossless mechanism ensures that task performance is not degraded by the mode-centering mechanisms. Lossless mode-centering mechanisms can condition the activation tensor to center around zero to achieve elevated sparsity without sacrificing quality.
[0183] FIG. 16 illustrates pruning and lossless mode-centering, according to some embodiments of the disclosure. Linear projection 1602 can be found in an FFN layer. Linear projection 1602 can also be found in an attention layer. Linear projection 1602 may perform the following operation: Y=WX+B (eq. 10)
[0184] Linear projection 1602 multiplies the activation tensor X by a weight matrix W, and adds a bias B to the result of the matrix multiplication to produce the output tensor Y.The activation tensor X (the input tensor to linear projection 1602) is the activation tensor of interest for sparsification and pruning. If the activation tensor X is pruned, the matrix multiplication with the weight matrix W can be made more computationally and memory efficient.
[0185] A mode value -M, may be introduced to shift the value of elements in X, and compensating +M may be added for functional equivalence. Equation 10 may be rewritten as follows: Y=W (X-M+M) +B (eq. 11)
[0186] Equation 11 may be manipulated algebraically as follows: Y=W (X-M) +WM+B (eq. 12)
[0187] According to equation 12, it is possible for linear projection 1602 to perform the operations in equation 10 in a mathematically equivalent manner using a mode-centered activation tensor (X-M) and subsequently applying a shift WM to the result of the matrix multiplication W (X-M) when the bias B is applied.
[0188] To produce a mode-centered activation tensor, the model definition of a neural network may be modified to insert an element-wise subtractor or shift operation to shift the values of the value of elements in X to produce the mode-centered activation tensor (X-M) . The model definition may be modified by neural network modification 1102 of FIG. 11.
[0189] In some embodiments, M can be determined online (as the neural network is running) . An online determination of M is preferably fast. A mode of X can be measured online or estimated based on a statistical mean or median value of X. Mean or median involves basic arithmetic such as sorting and counting operations. The mean or median may serve as a good approximation of the mode since the mean or median for a unimodal asymmetric distribution are near the mode.
[0190] In some embodiments, M can be determined offline. M can be determined by mode value determination 1106 of FIG. 11. M can be fixed at the time of calibration and prior to deployment. In some embodiments, M can be updated based on batches of data collected for the activation tensor in case the input data shifts. In some embodiments, M can be updated based on samples of new input data in case the input data shifts. If optimal peak density value or accurate mode value is desired, M can be determined using a probability density estimation algorithm, such as a kernel density estimate function. Using a calibration dataset, data on the activation tensor X can be collected and the mode value can be determined.
[0191] If M is fixed for the neural network, it is possible to determine a fused bias bfused that is equal to WM+b. Equation 12 can be rewritten as: Y=W (X-M) +BfuSed (eq. 13)
[0192] W, M, and B can be static during deployment, and Bfused can be pre-calculated based on W, M, and B and applied in the same manner as applying B to the result of the matrix multiplication. Using the fused bias Bfused can avoid the need to determine the mode M online and the just-in-time realization of the term WM. The bias B in the model definition for the neural network may be updated (e.g., by neural network modification 1102) to be the fused bias Bfused. Pre-calculating the fused bias Bfused means that layer performs adding the bias in the same manner as before, with only one added operation (e.g., an element-wise shift operation) of shifting the activation tensor X by M to produce the mode-centered activation tensor (X-M) .
[0193] In some embodiments, M may be initially set to an initial estimated mode value. M can be updated based on data of the activation tensor of interest X monitored or collected over a period of time. M can be updated by inputting into the neural network a new calibration dataset representative of recent input data and determining the mode value for the activation tensor of interest X when the neural network model processes the new calibration dataset.
[0194] Pruned linear projection 1604 illustrates an implementation of pruning with mode-centering. One or more elements of activation tensor X may be subtracted by the mode value M using the subtractor operator 1620 to generate a mode-centered activation tensor (X-M) . Pruner 1502 may receive the mode-centered activation tensor (X-M) . Pruner 1502 (as illustrated in FIG. 15) may apply an importance function to one or more elements of the activation tensor to determine one or more importance values, generate a binary mask based on the one or more importance values and a calibrated importance threshold value, and apply the binary mask to the mode-centered activation tensor to generate a sparse activation tensor X′. Matrix multiplication operator 1630 can perform a sparse matrix multiplication of the sparse activation tensor X′and a trained weight matrix Wto generate a product WX′. Addition operator 1640 can apply a fused bias Bfused to the product. The fused bias Bfused can be determined based on the trained weight matrix W, a mode value M, and a trained bias B, e.g., according to Bfused=WM+B.
[0195] In some cases, the activation tensor X and thus the mode-centered activation tensor (X-M) is based on an output of a normalization function. Pruner 1502 may be inserted at the output of the normalization function and at the input to a linear projection. An example is illustrated in FIG. 12. A different example is illustrated in FIG. 14.
[0196] In some cases, the activation tensor X and thus the mode-centered activation tensor (X-M) is based on an output of an activation function, e.g., a dense output of a non-ReLU activation function. Pruner 1502 of pruned linear projection 1604 may be inserted at the output of an activation function and at the input to a linear projection. An example is illustrated in FIG. 12. Pruner 1502 of pruned linear projection 1604 may be inserted at the output of an element-wise multiplier that has multiplied an output of an activation function (e.g., a dense output of a non-ReLU activation function) with an output of a linear projection to perform a gating function. In such a scenario, pruner 1502 may be inserted at the input to a further linear projection. An example is illustrated in FIG. 14. The activation function need not be a ReLU activation function. The activation function can be a SiLU activation function. The activation function can be a GELU activation function. The activation function can be a dense rectifier function.
[0197] When an element of the activation tensor X′equals 0, one or more operations associated with matrix multiplication can be skipped because multiplication with 0 results in 0 and adding 0 to a number results in no change in the number. Computation no longer has to be performed, and the need to load one or more values from memory is obviated. Matrix multiplication involves one or more pairs of compute operations, each pair involving multiplying two numbers and adding the product to a running sum. The pairs of compute operations can produce a dot product, and matrix multiplication can involve producing many dot products. Because the sparse activation tensor X′has one or more elements equaling zero, due to the operation of pruner 1502, at least one of or both compute operations in the pair operating on an element of the sparse activation tensor X′equaling zero can be skipped. In addition, one or more memory accesses (e.g., loading of values) associated with the pair of operations that would have otherwise be performed for the zero-valued elements can be skipped as well.
[0198] Matrix multiplication operator 1630 performs sparse matrix multiplication by skipping a first multiply operation in response to a first element of the sparse activation tensor X′being equal to 0 and performing a second multiply operation in response to a second element of the sparse activation tensor X′not being equal to 0. Matrix multiplication operator 1630 performs sparse matrix multiplication by skipping at least a first multiply operation in response to a first element of the sparse activation tensor X′being equal to 0. Matrix multiplication operator 1630 performs sparse matrix multiplication by skipping at least a first adding / summing / accumulating operation in response to a first element of the sparse activation tensor X′being equal to 0. Matrix multiplication operator 1630 performs sparse matrix multiplication by skipping a first multiply operation and a first adding / summing / accumulating operation in response to a first element of the sparse activation tensor X′being equal to 0.
[0199] Matrix multiplication operator 1630 performs sparse matrix multiplication by skipping loading from a memory of a first corresponding weight of the trained weight matrix W in response to a first element of the sparse activation tensor X′being equal to 0 and performing loading from the memory a second corresponding weight of the trained weight matrix W in response to a second element of the sparse activation tensor X′not being equal to 0.
[0200] An example illustrating sparse matrix multiplication in a linear projection is illustrated in FIG. 13. Sparse matrix multiplication can be performed by a processing element illustrated in FIG. 9.
[0201] Two-stage greedy grid search to determine parameters for pruning and mode-centering
[0202] Calibration for importance threshold values involves an optimization or search for optimal set of calibrated importance thresholds to be used that can maximize sparsity of many targeted activation tensors while maintaining prediction quality within an acceptable tolerance. In principle, a globally optimal set of calibrated importance thresholds achieving optimal sparsification per tolerance target can be determined per activation tensor of interest using the following objective function:
[0203] Objectives, obj0 (LLM) , obj1 (LLM) , …, can be a function of memory footprint, number of compute operations, sparsity, etc. The objectives maybe a function of one or more target metrics 1112 of FIG. 11. This optimization problem can be solved using a suitable algorithm such as binary search, gradient-based, evolutionary search, Bayesian optimization, reinforcement learning, etc.
[0204] Due to the ever-increasing depth of LLMs coupled with its expensive forward pass, activation-wise search is still resource intensive despite post-training calibration being significantly cheaper than training-based optimization. To illustrate, consider a single activation threshold search can be optimally found by binary search or exhaustive grid search, says N iterations per activation where each iteration is evaluating data of calibration set or validation set. While parallelizing the search across multiple activations could theoretically alleviate this burden, it fails to account for the distortion introduced by other pruned activations. Combining importance thresholds found in parallel does not guarantee outcome of the desired quality. Sequential search on each activation exacerbates the turnaround time by incurring N iterations scaled up by the total number of target activation. For instance, sparsifying only the activations in FFN layers of a smaller 7 billion parameters LLM necessitates a staggering 96 sequential loops of N iterations.
[0205] FIG. 17 illustrates a two-stage greedy grid search, according to some embodiments of the disclosure. Method 1700 illustrating a two-stage greedy grid search may be implemented by two-stage greedy grid search 1104 of FIG. 11 based on one or more target metrics 1112 of FIG. 11. The two-stage greedy grid search can address some of the issues mentioned above. The two-stage greed grid search is greedy in two respects: (1) group-wise target sparsity level, and (2) greedy search space descent. One benefit of the greediness design is to shorten the turnaround time by implementing a parallelizable first stage and reducing number of candidate evaluations in a second, subsequent stage.
[0206] In 1702, a neural network model is split into groups. More specifically, activation tensors of interest for pruning are split into different groups, referred to as activation grouping. A user may provide a grouping specification comprising a plurality of activation groups.
[0207] Activation grouping in 1702 can reduce the sequential loop (e.g., search per group instead of per activation) , thereby accelerating the search turnaround time. A threshold search on each group can yield a uniform anticipated sparsity across activations within the group. While the average sparsity of a group is expected to be uniform or closely aligned, the pruning importance thresholds can be unequal.
[0208] One way to produce activation groups is by type of activation. In the context of transformer blocks, activation tensors can be grouped according to the type of projection, such as Q, K, V, O, up, down, and gate projections (as seen in FIG. 4) . A first group may be associated with a first type of projection in the neural network, and a second group is associated with a second type of projection in the neural network. In some cases, a group may be associated with projects in FFN layers (and not in the attention layers) . A first group may be associated with one or more feed forward layers in the neural network.
[0209] Activation grouping gives users the flexibility to intentionally exclude certain activations based on prior knowledge. For example, users can choose to prune FFN layers based on ample research indicating that smaller models have less redundancy, and that FFN layers are easier to sparsify.
[0210] An alternative embodiment is automatic grouping of activation with analytical model. For example, generation phase of LLMs is memory-bounded where acceleration is directly proportional to size, grouping by size of certain types can be automated, e.g. FFN layers’ memory footprint is 2 / 3 of a transformer block. Activation groups can be determined by analyzing the neural network to assess memory footprint and different activation groups may be created according to the memory footprint.
[0211] In 1704, group-wise coarse sensitivity analysis, as part of the first stage of the two-stage greedy grid search, is performed. The coarse sensitivity analysis may be performed in parallel (and independently) for different groups, since the analysis for one group is independent of the analysis of a different group. Group-wise coarse sensitivity analysis can give a rough idea or rough range of values that can be used for each group. The search space for the importance threshold value can be confined to a localized region, filtering unnecessary candidates, and facilitates a more refined joint group sparsity search space in a subsequent stage. In 1706, coarse target sparsity candidates (corresponding to importance threshold values) that meet target metrics within an acceptable tolerance can be selected. Details of the first stage are described with FIG. 18.
[0212] In 1708, fine-grained joint group grid search, involving recursive filtering and step size descent, as part of the second stage of the two-stage greedy grid search, is performed. The fine-grained joint group grid search determines optimal joint sparsity candidates (corresponding to importance threshold values) through a joint space grid search with a finer step size. The fine-grained joint group grid search considers a filtered space for lower computational cost while also accounting for the interdependence between the activation groups. In neural networks, the sequential structure means that distortions introduced in earlier layers propagate to later layers. Therefore, it is assumed linearly that average (summation-then-normalization) of degradation resulting from independently group pruned model can be close enough or sufficiently close to the best possible outcome for joint group pruning. The algorithm greedily assumes that the optimal solution (s) attaining the user’s target quality will be locally close to the independent sparsities / thresholds where their average degradation falls within the user specification. To avoid being overly greedy, it is possible to marginally relax the user input tolerance to enlarge search space pragmatically. The fine-grained joint group search completes when any candidate meets target metrics within an acceptable tolerance and step size has reached its lower limit. In 1710, found / optimal candidates are post-processed to extract parameters for deployment. Details of the second stage are described with FIG. 19.
[0213] For illustration, one or more first pruner operators and one or more second pruner operators are inserted into a model definition of a neural network. The one or more first pruner operators may belong to a first activation group. The one or more second pruner operators may belong to a second activation group. There may be additional activation groups.
[0214] Note that a target sparsity translates directly to a set of importance threshold values that can be used for pruning activation tensors. A search space having target sparsity candidates is equivalent to a search space having different candidate sets of importance threshold values.
[0215] FIG. 18 illustrates first stage 1800 of the two-stage greedy grid search, according to some embodiments of the disclosure. First stage 1800 involves performing group independent searches. To illustrate first stage 1800, the following description describes performing group independent searches for the first activation group and for the second activation group, as an example.
[0216] In 1802, coarse target sparsity candidates for the first activation group may be generated. One or more coarse target sparsity candidates may be generated for the first activation group. Coarse target sparsity candidates may be generated using a coarse target sparsity step size (e.g., 10%, 20%, etc. ) . Target sparsity candidates may be generated by discretizing candidate sparsities using the coarse step size. A coarse step size may yield 9 target sparsity candidates, e.g., S1: {10%, 20%, …90%} . A coarse step size may yield 4 target sparsity candidates, e.g., S1: {20%, 40%, …80%} .
[0217] In 1806, each coarse target sparsity candidate for the first activation group may be evaluated using a calibration dataset, e.g., one or more first performances of the first activation group at one or more first coarse target sparsity candidates for the first group may be evaluated. Examples of calibration dataset is described in FIG. 11. The performance of the neural network where the first activation group is set to have a particular coarse target sparsity candidate can be evaluated. The performance may be associated with task degradation. The performance may be evaluated against one or more target metrics 1112 of FIG. 11. The performance may be associated with memory footprint. The performance may be associated with a number of compute operations. Evaluation of performance may be performed by determining whether the performance meets or does not meet one or more target metrics 1112 of FIG. 11 within an acceptable tolerance. In 1806, one or more ones of the first coarse target sparsity candidates may be removed or filtered out based on the one or more first performances, e.g., if the one or more first performances do not meet one or more target metrics 1112 of FIG. 11 within an acceptable tolerance. In 1806, it is possible to determine or estimate the mode values of the activation tensors being pruned by the first pruner operators of the first activation group. The mode values may be estimated using the calibration dataset. For example, a first mode value may be determined for a first activation tensor pruned by the first pruner operator using the calibration dataset. Performance may be evaluated with mode-centering mechanisms and the estimated mode values incorporated in the neural network.
[0218] In 1804, coarse target sparsity candidates for the second activation group may be generated in a similar manner as 1802. One or more second coarse target sparsity candidates for the second activation group may be generated.
[0219] In 1808, each coarse target sparsity candidate for the second activation group may be evaluated using the calibration dataset, e.g., one or more second performances of the second activation group at one or more second coarse target sparsity candidates for the second group may be evaluated in a similar manner as 1806. In 1808, one or more ones of the second coarse target sparsity candidates may be removed or filtered out based on the one or more second performances, e.g., if the one or more second performances do not meet one or more target metrics 1112 of FIG. 11 within an acceptable tolerance. In 1808, it is possible to determine or estimate the mode values of the activation tensors being pruned by the second pruner operators of the second activation group. The mode values may be estimated using the calibration dataset. For example, a second mode value may be determined for a second activation tensor pruned by the second pruner operator using the calibration dataset. Performance may be evaluated with mode-centering mechanisms and the estimated mode values incorporated in the neural network.
[0220] By using a coarse step size, the search space is reduced significantly. In addition, because the search is done independently for each activation group, parallelization over groups is possible, enabling scalability and can facilitate finer activation grouping if more compute power for calibration is available. The result of the first stage of the two-stage greedy grid search is a filtered set of coarse target sparsity candidates that align with one or more target metrics 1112 of FIG. 11 within tolerance specifications. The filtered set of coarse target sparsity candidates can be provided as input to the second stage of the two-stage greedy grid search.
[0221] FIG. 19 illustrates second stage 1900 of the two-stage greedy grid search, according to some embodiments of the disclosure. Second stage 1900 involves performing recursive filtering and step size descent. To illustrate second stage 1900, the following description describes performing a joint search space search for the first activation group and for the second activation group, as an example. The first stage, such as first stage 1800, may pass the remaining first coarse target sparsity candidates and the remaining second coarse target sparsity candidates to second stage 1900.
[0222] In 1902, bounded search space per activation group may be formed according to an initial step size. In some cases, the initial step size may be the coarse step size used in the first stage, such as first stage 1800. The bounded search space for the first activation group may be bounded by the remaining first coarse target sparsity candidates. For example, the bounded search space for the first activation group may be S1: {min1, min1+stepsize, …max1} . The bounded search space for the second activation group may be S2: {min2, min2+stepsize, …max2} . The bounded search space for a further activation group may be Sn: {minn, minn+stepsize, …maxn} . Based on the bounded search spaces for the different activation groups, a joint search space for the first activation group and the second activation group can be formed based on the bounded search space for the first activation group and the bounded search space for the second activation group. The joint search space may be formed based on the remaining first coarse target sparsity candidates and the remaining second coarse target sparsity candidates and the initial step size. For example, the joint search space may be the combinatorial search space formed by the bounded search space for the first activation group and the bounded search space for the second activation group: {S1xS2} . The joint search space may be the combinatorial search space formed by the bounded search spaces of various activation groups: {S1xS2x…xSn} . The joint search space includes one or more fine target sparsity candidates.
[0223] Due to the exponential increasing of number of candidates in the combinatorial space, compounded by the number of groups and finer division in sparsity range, the grid search is designed to recursively and iteratively reduce the joint search space. Each iteration involves step size descent and further filtering out candidates to reduce the search space, effectively bounding overall search cost. The search is completed when any candidate meets target metrics and step size has reached its lower limit.
[0224] In 1904, one or more third performances of one or more fine target sparsity candidates of the joint search space. Each fine target sparsity candidate in the joint search space may be evaluated using the calibration dataset, e.g., one or more third performances at one or more fine target sparsity candidates may be evaluated in a similar manner as 1806. Performance may be evaluated with mode-centering mechanisms and the estimated mode values incorporated in the neural network.
[0225] In 1906, it is determined whether any one of the fine target sparsity candidates in the joint search space meets target metrics (e.g., one or more target metrics 1112 of FIG. 11) and step size has been reduced to a smallest allowable step size or a lower limit of the step size. If both conditions are true, the fine target sparsity candidate that meets target metrics within an acceptable tolerance is selected as the solution. If neither condition nor one of the conditions is false (not true) , the second stage 1900 proceeds to 1908.
[0226] In some embodiments, when the solution is identified, a first optimal importance threshold and a second optimal importance threshold are determined for the first pruner operator and the second pruner operator respectively, based on the optimal fine target sparsity identified in the solution.
[0227] In 1908, one or more fine target sparsity candidates may be removed or filtered out based on the one or more third performances, e.g., if the one or more third performances do not meet one or more target metrics 1112 of FIG. 11 within an acceptable tolerance. In 1908, the joint search space is filtered to reduce the joint search space.
[0228] In 1910, the step size that is used to form the bounded search spaces that forms the joint search space is decreased.
[0229] The second stage 1900 returns to 1902 to form a reduced joint search space after 1908 and 1910 are performed. 1904 is repeated for the reduced joint search space. 1906, 1908, and 1910 may be performed in a recursive fashion or in an iterative fashion to reduce the joint search space, decrease the step size of the joint search space, and evaluate further performances of the remaining fine target sparsities of the reduced joint search space until an optimal fine target sparsity is found and the step size is reduced to a smallest allowable step size.
[0230] Methods for pruning and mode-centering
[0231] FIG. 20 a flowchart illustrating method 2000 for pruning and mode-centering, according to some embodiments of the disclosure. Method 2000 can be performed using a computing device, such as computing device 2200 in FIG. 22. Method 2000 may be performed using one or more parts illustrated FIGS. 7-9. Method 2000 may be an exemplary method performed by DNN accelerator 702 as illustrated in FIGS. 7-9. Method 2000 may be an exemplary method performed by an LLM as illustrated and described herein during inference.
[0232] In 2002, a mode-centered activation tensor may be received.
[0233] In 2004, an importance function may be applied to one or more elements of the mode-centered activation tensor to determine one or more importance values.
[0234] In 2006, a binary mask may be generated based on the one or more importance values and a calibrated importance threshold value.
[0235] In 2008, the binary mask may be applied to the mode-centered activation tensor to generate a sparse activation tensor.
[0236] In 2010, a sparse matrix multiplication of the sparse activation tensor and a trained weight matrix may be performed to generate a product.
[0237] In 2012, a fused bias may be applied to the product. The fused bias may be based on the trained weight matrix, a mode value, and a trained bias.
[0238] Methods for post-training calibration for activation sparsity
[0239] FIG. 21 a flowchart illustrating method 2100 for post-training calibration for activation sparsity, according to some embodiments of the disclosure. Method 2100 can be performed using a computing device, such as computing device 2200 in FIG. 22. Method 2100 may be performed using one or more parts illustrated FIGS. 7 and 10-11. Method 2100 may be an exemplary method performed by DNN module 701 as illustrated in FIGS. 7 and 10-11. Method 2100 may be an exemplary method performed by post-training optimization 1084 as illustrated in FIGS. 10-11. Method 2100 may be an exemplary method performed on a pre-trained LLM as illustrated and described herein to calibrate the LLM. After the method is performed, the LLM may be deployed onto hardware, such as a DNN accelerator 702.
[0240] In 2102, a first pruner operator and a second pruner operator may be inserted into a model definition of a neural network. The first pruner operator may belong to a first group. A second pruner operator may belong to a second group.
[0241] In 2104, one or more first performances at one or more first coarse target sparsity candidates for the first group may be evaluated using a dataset (e.g., a calibration dataset described and illustrated in FIG. 11) . One or more second performances at one or more second coarse target sparsity candidates for the first group may be evaluated using the dataset.
[0242] In 2106, one or more ones of first coarse target sparsity candidates may be removed based on the one or more first performances. One or more ones of second coarse target sparsity candidates may be removed based on the one or more second performances.
[0243] In 2108, a joint search space for the first group and the second group may be formed based on the remaining first coarse target sparsity candidates, the remaining second coarse target sparsity candidates, and a step size. One or more third performances of one or more fine target sparsity candidates of the joint search space may be evaluated.
[0244] In 2110, method 2100 includes recursively reducing the joint search space, decreasing the step size of the joint search space, and evaluating one or more further performances of one or more fine target sparsities of the joint search space until an optimal fine target sparsity is found and the step size is reduced to a smallest allowable step size.
[0245] In 2112, a first optimal importance threshold and a second optimal importance threshold may be determined for the first pruner operator and the second pruner operator respectively, based on the optimal fine target sparsity found in 2110.
[0246] In some embodiments, method 2100 further includes determining a first mode value for a first activation tensor pruned by the first pruner operator and a second mode value for a second activation tensor pruned by the second pruner operator using the dataset.
[0247] In some embodiments, method 2100 further includes inserting one or more mode-centering mechanisms into the model definition of the neural network. Mode-centering mechanisms may be applied when performances are evaluated in 2104, 2108, and 2110.
[0248] In some embodiments, method 2100 further includes compiling one or more instructions (e.g., low-level machine code) for carrying out operations of the neural network on a processing engine (e.g., DNN accelerator 702 of FIGS. 7-9) based on the model definition, the first optimal importance threshold, and the second optimal importance threshold. In some cases, the compiling is further based on the first mode value, and the second mode value.
[0249] Exemplary computing device
[0250] FIG. 22 is a block diagram of an apparatus or a system, e.g., an exemplary computing device 2200, according to some embodiments of the disclosure. One or more computing devices 2200 may be used to implement the functionalities described with the FIGS. and herein. A number of components illustrated in FIG. 22 can be included in the computing device 2200, 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 computing device 2200 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, computing device 2200 may not include one or more of the components illustrated in FIG. 22, and computing device 2200 may include interface circuitry for coupling to the one or more components. For example, the computing device 2200 may not include display device 2206, and may include display device interface circuitry (e.g., a connector and driver circuitry) to which a display device 2206 may be coupled. In another set of examples, computing device 2200 may not include audio input device 2218 or an audio output device 2208 and may include audio input or output device interface circuitry (e.g., connectors and supporting circuitry) to which an audio input device 2218 or audio output device 2208 may be coupled.
[0251] Computing device 2200 may include processing device 2202 (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) . Processing device 2202 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 2202 may include a CPU, a GPU, a quantum processor, a machine learning processor, an artificial intelligence processor, a neural network processor, an artificial intelligence accelerator, an ASIC, an analog signal processor, an analog computer, a microprocessor, a digital signal processor, a FPGA, a TPU, a DPU, etc.
[0252] The computing device 2200 may include a memory 2204, 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 2204 includes one or more non-transitory computer-readable storage media. In some embodiments, memory 2204 may include memory that shares a die with the processing device 2202.
[0253] In some embodiments, memory 2204 includes one or more non-transitory computer-readable media storing instructions executable to perform operations described with the FIGS. and herein, such as the methods and operations illustrated in the FIGS. In some embodiments, memory 2204 includes one or more non-transitory computer-readable media storing instructions executable to perform operations of method 1700 of FIG. 17, first stage 1800 of FIG. 18, second stage 1900 of FIG. 19, method 2000 of FIG. 20, and method 2100 OF FIG. 21. Exemplary parts that may be encoded as instructions and stored in memory 2204 are depicted. Memory 2204 may store instructions that encode one or more exemplary parts, such as DNN module 701, one or more parts of DNN module 701, post-training optimization 1084, or one or more parts of post-training optimization 1084. The instructions stored in the one or more non-transitory computer-readable media may be executed by processing device 2202.
[0254] In some embodiments, memory 2204 may store data, e.g., data structures, binary data, bits, metadata, files, blobs, etc., as described with the FIGS. and herein. For example, memory 2204 may store data depicted in FIG. 11, such as one or more model definitions 1110, one or more target metrics 1112, one or more datasets 1114, and one or more optimized model definition 1116.
[0255] In some embodiments, memory 2204 may store one or more DNNs (or parts thereof) . Memory 2204 may store training data for training (trained) a DNN. Memory 2204 may store instructions that perform operations associated with training a DNN. Memory 2204 may store input data, output data, intermediate outputs, intermediate inputs of one or more DNNs. Memory 2204 may store one or more parameters used by the one or more DNNs. Memory 2204 may store information that encodes how nodes of the one or more DNNs are connected with each other. Memory 2204 may store instructions (e.g., low-level machine code) to perform one or more operations of the one or more DNNs. Memory 2204 may store a model definition that specifies one or more operations of a DNN. Memory 2204 may store instructions, such as configuration files, that are generated by a compiler based on the model definition.
[0256] In some embodiments, the computing device 2200 may include a communication device 2212 (e.g., one or more communication devices) . For example, the communication device 2212 may be configured for managing wired and / or wireless communications for the transfer of data to and from the computing device 2200. 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 2212 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 2212 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 2212 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 2212 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 2212 may operate in accordance with other wireless protocols in other embodiments. The computing device 2200 may include an antenna 2222 to facilitate wireless communications and / or to receive other wireless communications (such as radio frequency transmissions) . The computing device 2200 may include receiver circuits and / or transmitter circuits. In some embodiments, the communication device 2212 may manage wired communications, such as electrical, optical, or any other suitable communication protocols (e.g., the Ethernet) . As noted above, the communication device 2212 may include multiple communication chips. For instance, a first communication device 2212 may be dedicated to shorter-range wireless communications such as Wi-Fi or Bluetooth, and a second communication device 2212 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 2212 may be dedicated to wireless communications, and a second communication device 2212 may be dedicated to wired communications.
[0257] The computing device 2200 may include power source / power circuitry 2214. The power source / power circuitry 2214 may include one or more energy storage devices (e.g., batteries or capacitors) and / or circuitry for coupling components of the computing device 2200 to an energy source separate from the computing device 2200 (e.g., DC power, AC power, etc. ) .
[0258] The computing device 2200 may include a display device 2206 (or corresponding interface circuitry, as discussed above) . The display device 2206 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.
[0259] The computing device 2200 may include an audio output device 2208 (or corresponding interface circuitry, as discussed above) . The audio output device 2208 may include any device that generates an audible indicator, such as speakers, headsets, or earbuds, for example.
[0260] The computing device 2200 may include an audio input device 2218 (or corresponding interface circuitry, as discussed above) . The audio input device 2218 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) .
[0261] The computing device 2200 may include a GPS device 2216 (or corresponding interface circuitry, as discussed above) . The GPS device 2216 may be in communication with a satellite-based system and may receive a location of the computing device 2200, as known in the art.
[0262] The computing device 2200 may include a sensor 2230 (or one or more sensors) . The computing device 2200 may include corresponding interface circuitry, as discussed above) . Sensor 2230 may sense physical phenomenon and translate the physical phenomenon into electrical signals that can be processed by, e.g., processing device 2202. Examples of sensor 2230 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.
[0263] The computing device 2200 may include another output device 2210 (or corresponding interface circuitry, as discussed above) . Examples of the other output device 2210 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.
[0264] The computing device 2200 may include another input device 2220 (or corresponding interface circuitry, as discussed above) . Examples of the other input device 2220 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.
[0265] The computing device 2200 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 2200 may be any other electronic device that processes data.
[0266] Select examples
[0267] Example 1 provides a method, including receiving an activation tensor of a machine learning model; applying an importance function to one or more elements of the activation tensor to determine one or more importance values; generating a binary mask based on the one or more importance values and an importance threshold value; applying the binary mask to the activation tensor to generate a sparse activation tensor of the machine learning model; performing a sparse matrix multiplication of the sparse activation tensor and a trained weight matrix of the machine learning model to generate a product; and generating a biased product by applying a fused bias to the product, the fused bias being based on the trained weight matrix, a mode value, and a trained bias of the machine learning model.
[0268] Example 2 provides the method of example 1, further including subtracting one or more elements of a further activation tensor by the mode value to generate the activation tensor.
[0269] Example 3 provides the method of example 2, further including updating the mode value based on data of the further activation tensor monitored over a period of time.
[0270] Example 4 provides the method of any one of examples 1-3, where the activation tensor is based on an output of a normalization function.
[0271] Example 5 provides the method of any one of examples 1-3, where the activation tensor is based on a dense output of an activation function.
[0272] Example 6 provides the method of any one of examples 1-5, where the importance function ranks the one or more elements of the activation tensor based on the one or more elements' individual contribution to a prediction.
[0273] Example 7 provides the method of any one of examples 1-6, where the importance function ranks the one or more elements of the activation tensor based on one or more weights corresponding to one or more elements of the activation tensor.
[0274] Example 8 provides the method of any one of examples 1-7, where the importance function calculates an absolute value of each one of the one or more elements of the activation tensor.
[0275] Example 9 provides the method of any one of examples 1-8, where the importance threshold value is determined based on a target sparsity of the activation tensor and a calibration dataset associated with a task to be performed by the machine learning model.
[0276] Example 10 provides the method of any one of examples 1-9, where generating the binary mask includes setting a first value in the binary mask to 1 in response to a first importance value in the one or more importance values being greater than the importance threshold value; and setting the first value in the binary mask to 0 in response to the first importance value being smaller than the importance threshold value.
[0277] Example 11 provides the method of any one of examples 1-10, where applying the binary mask to the activation tensor includes performing an element-wise multiplication of the activation tensor and the binary mask.
[0278] Example 12 provides the method of any one of examples 1-11, where performing the sparse matrix multiplication includes skipping a first multiply operation in response to a first element of the sparse activation tensor being equal to 0; and performing a second multiply operation in response to a second element of the sparse activation tensor not being equal to 0.
[0279] Example 13 provides the method of any one of examples 1-12, where performing the sparse matrix multiplication includes skipping loading from a memory of a first corresponding weight of the trained weight matrix in response to a first element of the sparse activation tensor being equal to 0; and performing loading from the memory a second corresponding weight of the trained weight matrix in response to a second element of the sparse activation tensor not being equal to 0.
[0280] Example 14 provides a method, including inserting a first pruner operator and a second pruner operator into a model definition of a neural network, the first pruner operator belonging to a first group, and a second pruner operator belonging to a second group; evaluating one or more first performances at one or more first coarse target sparsity candidates for the first group using a dataset; evaluating one or more second performances at one or more second coarse target sparsity candidates for the second group using the dataset; removing one or more ones of the one or more first coarse target sparsity candidates based on the one or more first performances; removing one or more ones of the one or more second coarse target sparsity candidates based on the one or more second performances; forming a joint search space for the first group and the second group based on one or more remaining first coarse target sparsity candidates, one or more remaining second coarse target sparsity candidates, and a step size; evaluating one or more third performances of one or more fine target sparsity candidates of the joint search space; recursively reducing the joint search space, decreasing the step size of the joint search space, and evaluating one or more further performances of one or more fine target sparsities of the joint search space until an optimal fine target sparsity is found and the step size is reduced to a smallest allowable step size; and determining a first optimal importance threshold and a second optimal importance threshold for the first pruner operator and the second pruner operator respectively, based on the optimal fine target sparsity.
[0281] Example 15 provides the method of example 14, further including determining a first mode value for a first activation tensor pruned by the first pruner operator and a second mode value for a second activation tensor pruned by the second pruner operator using the dataset; and compiling one or more instructions for carrying out operations of the neural network on a processing engine based on the model definition, the first optimal importance threshold, the second optimal importance threshold, the first mode value, and the second mode value.
[0282] Example 16 provides the method of example 14 or 15, where the first pruner operator includes a first importance function operator; a first binary mask generator to produce a first binary mask based on the first optimal importance threshold and a first output of the first importance function operator; and a first element-wise multiplication operator to apply the first binary mask onto a first activation tensor to produce a first sparse activation tensor.
[0283] Example 17 provides the method of example 16, further including inserting a first subtraction operator into the model definition, the first subtraction operator to produce the first activation tensor based on the first mode value; and modifying a first addition operator of the model definition, the first addition operator to apply a first fused bias determined based on a first trained weight matrix, the first mode value, and a first trained bias.
[0284] Example 18 provides the method of any one of examples 14-17, where the first pruner operator includes a second importance function operator; a second binary mask generator to produce a second binary mask based on the second optimal importance threshold and a second output of the second importance function operator; and a second element-wise multiplication operator to apply the second binary mask onto a second activation tensor to produce a first sparse activation tensor.
[0285] Example 19 provides the method of example 18, further including inserting a second subtraction operator into the model definition, the second subtraction operator to produce the second activation tensor based on the second mode value; and modifying a second addition operator of the model definition, the second addition operator to apply a second fused bias determined based on a second trained weight matrix, the second mode value, and a second trained bias.
[0286] Example 20 provides the method of any one of examples 14-19, where the first pruner operator is inserted at an output of a normalization function operator in the neural network.
[0287] Example 21 provides the method of any one of examples 14-20, where the first pruner operator is inserted at a dense output of an activation function operator in the neural network.
[0288] Example 22 provides the method of any one of examples 14-21, further including receiving a grouping specification from a user, the grouping specification including the first group and the second group.
[0289] Example 23 provides the method of any one of examples 14-22, where the first group is associated with a first type of projection in the neural network, and the second group is associated with a second type of projection in the neural network.
[0290] Example 24 provides the method of any one of examples 14-23, where the first group is associated with one or more feed forward layers in the neural network.
[0291] Example 25 provides the method of any one of examples 14-24, where the one or more first performances are associated with one or more first task degradations, and the one or more second performances are associated with one or more second task degradations.
[0292] Example 26 provides one or more non-transitory computer-readable media storing instructions that, when executed by one or more processors, cause the one or more processors to: receive an activation tensor of a machine learning model; apply an importance function to one or more elements of the activation tensor to determine one or more importance values; generate a binary mask based on the one or more importance values and an importance threshold value; apply the binary mask to the activation tensor to generate a sparse activation tensor of the machine learning model; perform a sparse matrix multiplication of the sparse activation tensor and a trained weight matrix of the machine learning model to generate a product; and generate a biased product by applying a fused bias to the product, the fused bias being based on the trained weight matrix, a mode value, and a trained bias of the machine learning model.
[0293] Example 27 provides the one or more non-transitory computer-readable media of example 26, where the instructions further cause the one or more processors to: subtract one or more elements of a further activation tensor by the mode value to generate the activation tensor.
[0294] Example 28 provides the one or more non-transitory computer-readable media of example 27, where the instructions further cause the one or more processors to: update the mode value based on data of the further activation tensor monitored over a period of time.
[0295] Example 29 provides the one or more non-transitory computer-readable media of any one of examples 26-28, where the activation tensor is based on an output of a normalization function.
[0296] Example 30 provides the one or more non-transitory computer-readable media of any one of examples 26-28, where the activation tensor is based on a dense output of an activation function.
[0297] Example 31 provides the one or more non-transitory computer-readable media of any one of examples 26-30, where the importance function ranks the one or more elements of the activation tensor based on the one or more elements' individual contribution to a prediction.
[0298] Example 32 provides the one or more non-transitory computer-readable media of any one of examples 26-31, where the importance function ranks the one or more elements of the activation tensor based on one or more weights corresponding to one or more elements of the activation tensor.
[0299] Example 33 provides the one or more non-transitory computer-readable media of any one of examples 26-32, where the importance function calculates an absolute value of each one of the one or more elements of the activation tensor.
[0300] Example 34 provides the one or more non-transitory computer-readable media of any one of examples 26-33, where the importance threshold value is determined based on a target sparsity of the activation tensor and a calibration dataset associated with a task to be performed by the machine learning model.
[0301] Example 35 provides the one or more non-transitory computer-readable media of any one of examples 26-34, where generating the binary mask includes setting a first value in the binary mask to 1 in response to a first importance value in the one or more importance values being greater than the importance threshold value; and setting the first value in the binary mask to 0 in response to the first importance value being smaller than the importance threshold value.
[0302] Example 36 provides the one or more non-transitory computer-readable media of any one of examples 26-35, where applying the binary mask to the activation tensor includes performing an element-wise multiplication of the activation tensor and the binary mask.
[0303] Example 37 provides the one or more non-transitory computer-readable media of any one of examples 26-36, where performing the sparse matrix multiplication includes skipping a first multiply operation in response to a first element of the sparse activation tensor being equal to 0; and performing a second multiply operation in response to a second element of the sparse activation tensor not being equal to 0.
[0304] Example 38 provides the one or more non-transitory computer-readable media of any one of examples 26-37, where performing the sparse matrix multiplication includes skipping loading from a memory of a first corresponding weight of the trained weight matrix in response to a first element of the sparse activation tensor being equal to 0; and performing loading from the memory a second corresponding weight of the trained weight matrix in response to a second element of the sparse activation tensor not being equal to 0.
[0305] Example 39 provides one or more non-transitory computer-readable media storing instructions that, when executed by one or more processors, cause the one or more processors to: insert a first pruner operator and a second pruner operator into a model definition of a neural network, the first pruner operator belonging to a first group, and a second pruner operator belonging to a second group; evaluate one or more first performances at one or more first coarse target sparsity candidates for the first group using a dataset; evaluate one or more second performances at one or more second coarse target sparsity candidates for the second group using the dataset; remove one or more ones of the one or more first coarse target sparsity candidates based on the one or more first performances; remove one or more ones of the one or more second coarse target sparsity candidates based on the one or more second performances; form a joint search space for the first group and the second group based on one or more remaining first coarse target sparsity candidates, one or more remaining second coarse target sparsity candidates, and a step size; evaluate one or more third performances of one or more fine target sparsity candidates of the joint search space; recursively reduce the joint search space, decrease the step size of the joint search space, and evaluate one or more further performances of one or more fine target sparsities of the joint search space until an optimal fine target sparsity is found and the step size is reduced to a smallest allowable step size; and determine a first optimal importance threshold and a second optimal importance threshold for the first pruner operator and the second pruner operator respectively, based on the optimal fine target sparsity.
[0306] Example 40 provides the one or more non-transitory computer-readable media of example 39, where the instructions further cause the one or more processors to: determine a first mode value for a first activation tensor pruned by the first pruner operator and a second mode value for a second activation tensor pruned by the second pruner operator using the dataset; and compile one or more instructions for carrying out operations of the neural network on a processing engine based on the model definition, the first optimal importance threshold, the second optimal importance threshold, the first mode value, and the second mode value.
[0307] Example 41 provides the one or more non-transitory computer-readable media of example 39 or 40, where the first pruner operator includes a first importance function operator; a first binary mask generator to produce a first binary mask based on the first optimal importance threshold and a first output of the first importance function operator; and a first element-wise multiplication operator to apply the first binary mask onto a first activation tensor to produce a first sparse activation tensor.
[0308] Example 42 provides the one or more non-transitory computer-readable media of example 41, where the instructions further cause the one or more processors to: insert a first subtraction operator into the model definition, the first subtraction operator to produce the first activation tensor based on the first mode value; and modify a first addition operator of the model definition, the first addition operator to apply a first fused bias determined based on a first trained weight matrix, the first mode value, and a first trained bias.
[0309] Example 43 provides the one or more non-transitory computer-readable media of any one of examples 39-42, where the first pruner operator includes a second importance function operator; a second binary mask generator to produce a second binary mask based on the second optimal importance threshold and a second output of the second importance function operator; and a second element-wise multiplication operator to apply the second binary mask onto a second activation tensor to produce a first sparse activation tensor.
[0310] Example 44 provides the one or more non-transitory computer-readable media of example 43, where the instructions further cause the one or more processors to: insert a second subtraction operator into the model definition, the second subtraction operator to produce the second activation tensor based on the second mode value; and modify a second addition operator of the model definition, the second addition operator to apply a second fused bias determined based on a second trained weight matrix, the second mode value, and a second trained bias.
[0311] Example 45 provides the one or more non-transitory computer-readable media of any one of examples 39-44, where the first pruner operator is inserted at an output of a normalization function operator in the neural network.
[0312] Example 46 provides the one or more non-transitory computer-readable media of any one of examples 39-45, where the first pruner operator is inserted at a dense output of an activation function operator in the neural network.
[0313] Example 47 provides the one or more non-transitory computer-readable media of any one of examples 39-46, where the instructions further cause the one or more processors to: receive a grouping specification from a user, the grouping specification including the first group and the second group.
[0314] Example 48 provides the one or more non-transitory computer-readable media of any one of examples 39-47, where the first group is associated with a first type of projection in the neural network, and the second group is associated with a second type of projection in the neural network.
[0315] Example 49 provides the one or more non-transitory computer-readable media of any one of examples 39-48, where the first group is associated with one or more feed forward layers in the neural network.
[0316] Example 50 provides the one or more non-transitory computer-readable media of any one of examples 39-49, where the one or more first performances are associated with one or more first task degradations, and the one or more second performances are associated with one or more second task degradations.
[0317] Example 51 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: receive an activation tensor of a machine learning model; apply an importance function to one or more elements of the activation tensor to determine one or more importance values; generate a binary mask based on the one or more importance values and an importance threshold value; apply the binary mask to the activation tensor to generate a sparse activation tensor of the machine learning model; perform a sparse matrix multiplication of the sparse activation tensor and a trained weight matrix of the machine learning model to generate a product; and generate a biased product by applying a fused bias to the product, the fused bias being based on the trained weight matrix, a mode value, and a trained bias of the machine learning model.
[0318] Example 52 provides the apparatus of example 51, where the instructions further cause the one or more data processing units to: subtract one or more elements of a further activation tensor by the mode value to generate the activation tensor.
[0319] Example 53 provides the apparatus of example 52, where the instructions further cause the one or more data processing units to: update the mode value based on data of the further activation tensor monitored over a period of time.
[0320] Example 54 provides the apparatus of any one of examples 51-53, where the activation tensor is based on an output of a normalization function.
[0321] Example 55 provides the apparatus of any one of examples 51-53, where the activation tensor is based on a dense output of an activation function.
[0322] Example 56 provides the apparatus of any one of examples 51-55, where the importance function ranks the one or more elements of the activation tensor based on the one or more elements' individual contribution to a prediction.
[0323] Example 57 provides the apparatus of any one of examples 51-56, where the importance function ranks the one or more elements of the activation tensor based on one or more weights corresponding to one or more elements of the activation tensor.
[0324] Example 58 provides the apparatus of any one of examples 51-57, where the importance function calculates an absolute value of each one of the one or more elements of the activation tensor.
[0325] Example 59 provides the apparatus of any one of examples 51-58, where the importance threshold value is determined based on a target sparsity of the activation tensor and a calibration dataset associated with a task to be performed by the machine learning model.
[0326] Example 60 provides the apparatus of any one of examples 51-59, where generating the binary mask includes setting a first value in the binary mask to 1 in response to a first importance value in the one or more importance values being greater than the importance threshold value; and setting the first value in the binary mask to 0 in response to the first importance value being smaller than the importance threshold value.
[0327] Example 61 provides the apparatus of any one of examples 51-60, where applying the binary mask to the activation tensor includes performing an element-wise multiplication of the activation tensor and the binary mask.
[0328] Example 62 provides the apparatus of any one of examples 51-61, where performing the sparse matrix multiplication includes skipping a first multiply operation in response to a first element of the sparse activation tensor being equal to 0; and performing a second multiply operation in response to a second element of the sparse activation tensor not being equal to 0.
[0329] Example 63 provides the apparatus of any one of examples 51-62, where performing the sparse matrix multiplication includes skipping loading from a memory of a first corresponding weight of the trained weight matrix in response to a first element of the sparse activation tensor being equal to 0; and performing loading from the memory a second corresponding weight of the trained weight matrix in response to a second element of the sparse activation tensor not being equal to 0.
[0330] Example 64 provides a apparatus, including one or more processors; and one or more non-transitory computer-readable memories to store instructions, where the instructions, when executed by the one or more processors, cause the one or more processors to: insert a first pruner operator and a second pruner operator into a model definition of a neural network, the first pruner operator belonging to a first group, and a second pruner operator belonging to a second group; evaluate one or more first performances at one or more first coarse target sparsity candidates for the first group using a dataset; evaluate one or more second performances at one or more second coarse target sparsity candidates for the second group using the dataset; remove one or more ones of the one or more first coarse target sparsity candidates based on the one or more first performances; remove one or more ones of the one or more second coarse target sparsity candidates based on the one or more second performances; form a joint search space for the first group and the second group based on one or more remaining first coarse target sparsity candidates, one or more remaining second coarse target sparsity candidates, and a step size; evaluate one or more third performances of one or more fine target sparsity candidates of the joint search space; recursively reduce the joint search space, decrease the step size of the joint search space, and evaluate one or more further performances of one or more fine target sparsities of the joint search space until an optimal fine target sparsity is found and the step size is reduced to a smallest allowable step size; and determine a first optimal importance threshold and a second optimal importance threshold for the first pruner operator and the second pruner operator respectively, based on the optimal fine target sparsity.
[0331] Example 65 provides the apparatus of example 64, where the instructions further cause the one or more processors to: determine a first mode value for a first activation tensor pruned by the first pruner operator and a second mode value for a second activation tensor pruned by the second pruner operator using the dataset; and compile one or more instructions for carrying out operations of the neural network on a processing engine based on the model definition, the first optimal importance threshold, the second optimal importance threshold, the first mode value, and the second mode value.
[0332] Example 66 provides the apparatus of example 64 or 65, where the first pruner operator includes a first importance function operator; a first binary mask generator to produce a first binary mask based on the first optimal importance threshold and a first output of the first importance function operator; and a first element-wise multiplication operator to apply the first binary mask onto a first activation tensor to produce a first sparse activation tensor.
[0333] Example 67 provides the apparatus of example 66, where the instructions further cause the one or more processors to: insert a first subtraction operator into the model definition, the first subtraction operator to produce the first activation tensor based on the first mode value; and modify a first addition operator of the model definition, the first addition operator to apply a first fused bias determined based on a first trained weight matrix, the first mode value, and a first trained bias.
[0334] Example 68 provides the apparatus of any one of examples 64-67, where the first pruner operator includes a second importance function operator; a second binary mask generator to produce a second binary mask based on the second optimal importance threshold and a second output of the second importance function operator; and a second element-wise multiplication operator to apply the second binary mask onto a second activation tensor to produce a first sparse activation tensor.
[0335] Example 69 provides the apparatus of example 68, where the instructions further cause the one or more processors to: insert a second subtraction operator into the model definition, the second subtraction operator to produce the second activation tensor based on the second mode value; and modify a second addition operator of the model definition, the second addition operator to apply a second fused bias determined based on a second trained weight matrix, the second mode value, and a second trained bias.
[0336] Example 70 provides the apparatus of any one of examples 64-69, where the first pruner operator is inserted at an output of a normalization function operator in the neural network.
[0337] Example 71 provides the apparatus of any one of examples 64-70, where the first pruner operator is inserted at a dense output of an activation function operator in the neural network.
[0338] Example 72 provides the apparatus of any one of examples 64-71, where the instructions further cause the one or more processors to: receive a grouping specification from a user, the grouping specification including the first group and the second group.
[0339] Example 73 provides the apparatus of any one of examples 64-72, where the first group is associated with a first type of projection in the neural network, and the second group is associated with a second type of projection in the neural network.
[0340] Example 74 provides the apparatus of any one of examples 64-73, where the first group is associated with one or more feed forward layers in the neural network.
[0341] Example 75 provides the apparatus of any one of examples 64-74, where the one or more first performances are associated with one or more first task degradations, and the one or more second performances are associated with one or more second task degradations.
[0342] Example A is an apparatus comprising means for carrying out any one of the methods according to examples 1-22.
[0343] Example B includes a DNN module as described and illustrated herein.
[0344] Example C includes a DNN module to carry out any one of the methods according to examples 14-25.
[0345] Example D includes a post-training optimization part as described and illustrated herein.
[0346] Example E includes a post-training optimization part to carry out any one of the methods according to examples 14-25.
[0347] Example F includes a DNN accelerator as described and illustrated herein.
[0348] Example G includes a DNN accelerator to carry out any one of the methods according to examples 1-13.
[0349] Example H includes one or more data processing units to carry out any one of the methods according to examples 1-13.
[0350] Example I includes one or more processing engines to carry out any one of the methods according to examples 1-13.
[0351] Example J includes a DNN system comprising a DNN module and a DNN accelerator as described and illustrated herein.
[0352] Example K includes a DNN system comprising a DNN module according to example C and a DNN accelerator according to example G.
[0353] Variations and other notes
[0354] Although the operations of the example method shown in and described with reference to FIGS. 17-20 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 FIGS. 17-20 may be combined or may include more or fewer details than described.
[0355] 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.
[0356] 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.
[0357] 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.
[0358] 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.
[0359] 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.
[0360] 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.
[0361] 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.
[0362] 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.
[0363] 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.
[0364] 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. ”
[0365] 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.A method, comprising:receiving an activation tensor of a machine learning model;applying an importance function to one or more elements of the activation tensor to determine one or more importance values;generating a binary mask based on the one or more importance values and an importance threshold value;applying the binary mask to the activation tensor to generate a sparse activation tensor of the machine learning model;performing a sparse matrix multiplication of the sparse activation tensor and a trained weight matrix of the machine learning model to generate a product; andgenerating a biased product by applying a fused bias to the product, the fused bias being based on the trained weight matrix, a mode value, and a trained bias of the machine learning model.2.The method of claim 1, further comprising:subtracting one or more elements of a further activation tensor by the mode value to generate the activation tensor.3.The method of claim 2, further comprising:updating the mode value based on data of the further activation tensor monitored over a period of time.4.The method of claim 1, wherein the activation tensor is based on an output of a normalization function.5.The method of claim 1, wherein the activation tensor is based on a dense output of an activation function.6.The method of claim 1, wherein the importance function ranks the one or more elements of the activation tensor based on the one or more elements' individual contribution to a prediction.7.The method of claim 1, wherein the importance function ranks the one or more elements of the activation tensor based on one or more weights corresponding to one or more elements of the activation tensor.8.The method of claim 1, wherein the importance threshold value is determined based on a target sparsity of the activation tensor and a calibration dataset associated with a task to be performed by the machine learning model.9.One or more non-transitory computer-readable media storing instructions that, when executed by one or more processors, cause the one or more processors to:receive an activation tensor of a machine learning model;apply an importance function to one or more elements of the activation tensor to determine one or more importance values;generate a binary mask based on the one or more importance values and an importance threshold value;apply the binary mask to the activation tensor to generate a sparse activation tensor of the machine learning model;perform a sparse matrix multiplication of the sparse activation tensor and a trained weight matrix of the machine learning model to generate a product; andgenerate a biased product by applying a fused bias to the product, the fused bias being based on the trained weight matrix, a mode value, and a trained bias of the machine learning model.10.The one or more non-transitory computer-readable media of claim 9, wherein the instructions further cause the one or more processors to:subtract one or more elements of a further activation tensor by the mode value to generate the activation tensor.11.The one or more non-transitory computer-readable media of claim 10, wherein the instructions further cause the one or more processors to:update the mode value based on data of the further activation tensor monitored over a period of time.12.The one or more non-transitory computer-readable media of claim 9, wherein the activation tensor is based on an output of a normalization function.13.The one or more non-transitory computer-readable media of claim 9, wherein the activation tensor is based on a dense output of an activation function.14.The one or more non-transitory computer-readable media of claim 9, wherein the importance function ranks the one or more elements of the activation tensor based on the one or more elements' individual contribution to a prediction.15.The one or more non-transitory computer-readable media of claim 9, wherein the importance function ranks the one or more elements of the activation tensor based on one or more weights corresponding to one or more elements of the activation tensor.16.The one or more non-transitory computer-readable media of claim 9, wherein the importance threshold value is determined based on a target sparsity of the activation tensor and a calibration dataset associated with a task to be performed by the machine learning model.17.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:receive an activation tensor of a machine learning model;apply an importance function to one or more elements of the activation tensor to determine one or more importance values;generate a binary mask based on the one or more importance values and an importance threshold value;apply the binary mask to the activation tensor to generate a sparse activation tensor of the machine learning model;perform a sparse matrix multiplication of the sparse activation tensor and a trained weight matrix of the machine learning model to generate a product; andgenerate a biased product by applying a fused bias to the product, the fused bias being based on the trained weight matrix, a mode value, and a trained bias of the machine learning model.18.The apparatus of claim 17, wherein the instructions further cause the one or more data processing units to:subtract one or more elements of a further activation tensor by the mode value to generate the activation tensor.19.The apparatus of claim 17, wherein the activation tensor is based on a dense output of an activation function.20.The apparatus of claim 17, wherein the importance function ranks the one or more elements of the activation tensor based on one or more weights corresponding to one or more elements of the activation tensor.
Citation Information
Patent Citations
Exploiting activation sparsity in deep neural networks
CN112740236A
System and method for group balanced sparse activation and joint activation weight sparse training for neural networks
CN116157808A
Dynamic activation sparsity in neural networks
US20220383121A1
Method and apparatus for accelerating deep leaning inference based on HW-aware sparsity pattern
WO2023164950A1
Exploiting data sparsity at a machine-learning hardware accelerator
WO2023224614A1
Cited By
System based on AI multi-dimensional model and intelligent decision-making method
CN121880912A