Single-axis sparse tensor processing unit

The single-axis sparse tensor processing circuit addresses inefficiencies in traditional tensor cores by optimizing computational efficiency and energy usage through dynamic sparsity-based acceleration, enhancing neural network performance.

WO2026081187A1PCT designated stage Publication Date: 2026-04-23MOFFETT TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
MOFFETT TECH CO LTD
Filing Date
2024-10-18
Publication Date
2026-04-23

AI Technical Summary

Technical Problem

Traditional tensor core architectures face challenges in balancing increased performance with energy consumption, failing to dynamically scale computational acceleration in proportion to the degree of input data sparsity.

Method used

A single-axis sparse tensor processing circuit that includes a tensor processing circuit with components like tensor caches, gather circuits, multiplier arrays, and accumulation circuits, designed to cache, transform, and compute sparse tensors efficiently, optimizing computational efficiency and energy usage.

Benefits of technology

Enhances computational efficiency and reduces energy consumption by aligning computational acceleration with sparsity levels, improving neural network performance without proportional energy demands.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024125789_23042026_PF_FP_ABST
    Figure CN2024125789_23042026_PF_FP_ABST
Patent Text Reader

Abstract

A tensor processing circuit is disclosed. The circuit includes a first tensor cache for storing a first tensor and a second tensor cache for storing a second tensor, both used in the neural network operations. A tensor mask cache stores a tensor mask corresponding to the second tensor, facilitating sparsification. A gather circuit, coupled to the second tensor cache and tensor mask cache, transforms the second tensor into a condensed tensor based on the tensor mask, reducing computational complexity. The circuit further includes a multiplier array that receives data from the first tensor cache and the condensed second tensor, producing an intermediate tensor. An accumulation circuit performs summation operations on the intermediate tensor and another tensor retrieved from an accumulate cache, generating an output tensor of the neural network computation.
Need to check novelty before this filing date? Find Prior Art

Description

Single-Axis Sparse Tensor Processing UnitTECHNICAL FIELD

[0001] The present invention relates to the field of computer processors and machine learning, specifically to a single-axis sparse tensor processing circuit designed for efficient and flexible processing of tensor computations.BACKGROUND

[0002] As AI applications grow in complexity and scale, the need for more robust computational power intensifies. Traditional tensor core architectures, while effective, face significant challenges in balancing increased performance with energy consumption. Higher throughput often results in greater power usage and thermal output, leading to operational inefficiencies and higher costs. To address these issues, innovative techniques that enhance computational capabilities without proportionally increasing energy demands are essential.

[0003] Sparsification has emerged as a promising strategy to optimize tensor core performance. This technique involves reducing the number of non-essential elements in data structures, such as weight matrices and activation tensors, thereby decreasing the computational load and memory requirements.

[0004] Despite the potential of sparsification, existing tensor core designs often fall short in fully leveraging its benefits due to inherent design limitations. Conventional implementations may support only basic sparsity patterns and fail to dynamically scale computational acceleration in direct proportion to the degree of input data sparsity.

[0005] In response, this disclosure introduces an advanced sparse tensor core architecture that enables computational acceleration proportional to the level of sparsity. This innovative design ensures that increased sparsity directly translates to enhanced performance, optimizing tensor core efficiency and aligning with the theoretical advantages of sparse computing. This architecture for sparse matrix multiplication not only enhances efficiency but also aligns with the industry’s push towards achieving greater performance with lower energy consumption.SUMMARY

[0006] Various embodiments of the present specification may include a chip design of a single-axis sparse tensor circuit. A system composed of one or more computers can be configured to perform specific operations or actions by installing software, firmware, hardware, or a combination of these elements. This configuration enables the system to carry out the designated actions. Similarly, computer programs can be designed to perform particular operations by including instructions that, when executed by data processing apparatus, prompt the apparatus to execute these actions.

[0007] In one aspect, a tensor processing circuit is described. The tensor processing circuit may include a first tensor cache configured to cache a first tensor for a neural network computation; a second tensor cache configured to cache a second tensor for the neural network computation; a tensor mask cache configured to cache a tensor mask corresponding to the second tensor; a gather circuit coupled to the second tensor cache and the tensor mask cache, where the gather circuit is configured to transform the second tensor into a condensed format based on the tensor mask; a multiplier array configured to receive data from the first tensor cache and the gather circuit and output an intermediate tensor; and an accumulation circuit configured to perform summation operations based on the intermediate tensor and another tensor from an accumulate cache, thereby generating an output tensor of the neural network computation.

[0008] In some embodiments, the tensor processing circuit may further include a plurality of cast circuits configured for data type conversion, where the plurality of cast circuit include: a first cast circuit configured to receive data from the first tensor cache; and a second cast circuit configured to receive data from the gather circuit, where both of the first and second cast circuits are configured to output cast result to the multiplier array.

[0009] In some embodiments, the plurality of cast circuits further include a third cast circuit configured to receive data from the accumulation circuit, and output cast results to a shared memory.

[0010] In some embodiments, the tensor processing circuit may further include a scaling cache for caching a scaling parameter, where the scaling parameter is used to scale data in the intermediate tensor before the summation operation is performed in the accumulation circuit.

[0011] In some embodiments, the tensor processing circuit may further include a control circuit configured to send instructions to components in the tensor processing circuit, where the control circuit includes: a local instruction first-in-first-out (FIFO) as a staging area for storing to-be-executed instructions; a plurality of instruction queues, each configured to execute one type of instruction; and an instruction fetching circuit configured to receive status information of the plurality of instruction queues, and dispatch an incoming instruction based on the type of the incoming instruction and the status information of the queue executing the type of the incoming instruction.

[0012] In some embodiments, the plurality of instruction queues include: a first instruction queue for loading activation tensors and weight tensors; a second instruction queue for loading scaling factors and tensor masks; a third instruction queue for executing general matrix multiplication (GEMM) instructions; and a fourth instruction queue for storing data to memory.

[0013] In some embodiments, the gather circuit includes a plurality of gather blocks for parallel processing, each gather block comprising a plurality of 2-dimensional (2D) flattened butterfly networks, and each of the plurality of 2D flattened butterfly networks being configured to compress a dimension of a given tensor data.

[0014] In some embodiments, multiple of the plurality of 2D flattened butterfly networks are activated simultaneously to achieve a desired compression ratio.

[0015] In some embodiments, the given tensor data is fed into the multiple 2D flattened butterfly networks simultaneously, and outputs from the multiple 2D flattened butterfly networks are combined to achieve the desired compression ratio.

[0016] In some embodiments, a larger number of 2D flattened butterfly networks are simultaneously activated to achieve a higher desired compression ratio.

[0017] In some embodiments, within each gather block, the plurality of 2D flattened butterfly networks include: a first 2D flattened butterfly network compressing a dimension of the given tensor data to achieve a first compression ratio; and a second 2D flattened butterfly network compressing the dimension of the given tensor data to achieve a second compression ratio, wherein the first compression ratio is greater than the second compression ratio..

[0018] In some embodiments, within each gather block, the plurality of 2D flattened butterfly networks include: a first 2D flattened butterfly network compressing a 64-element vector into a 16-element vector; a second 2D flattened butterfly network compressing the 64-element vector into an 8-element vector; and a third 2D flattened butterfly network compressing the 64-element vector into a 4-element vector.

[0019] In some embodiments, the multiplier array includes a plurality of multiplier circuits, each of the plurality of multiplier circuits comprising a plurality of hybrid multipliers supporting tensor data multiplication using different data formats.

[0020] In some embodiments, each of the plurality of hybrid multipliers includes a first multiplier supporting a first data format with a lower bit depth, and a second multiplier supporting the first data format with the lower bit depth and a second data format with a higher bit depth.

[0021] In some embodiments, the first multiplier and the second multiplier generate output data using different data formats.

[0022] In some embodiments, each of the plurality of hybrid multipliers includes (1) a pair of input interfaces for receiving input tensor data, and (2) a zero-flag indicating whether one of the input tensor data is zero, where in response to the zero-flag being set, the hybrid multiplier directly outputs a zero value.

[0023] In some embodiments, the accumulation circuit includes a plurality of adder circuits, each adder circuit coupled to a dedicated register, where: the adder circuit stores a temporary tensor to the register; and the register sends the temporary tensor to a selector, where the selector includes a first output port directing the temporary tensor back to the adder circuit, and a second output port directing the temporary tensor to the accumulate cache.

[0024] In some embodiments, the accumulate cache includes a pair of buffer pages, each buffer page comprising a plurality of Static Random-Access Memory (SRAMs) .

[0025] In some embodiments, the accumulate cache includes a read pipeline accepting a first control signal or a second control signal, where: the first control signal instructs reading data from the accumulate cache into the adder circuit for computation, and the second control signal instructs reading data from the accumulate cache into a shared memory for storage.

[0026] In another aspect, a method implemented by the above-described tensor processing circuit is introduced. The method may include receiving a first tensor, a second tensor, and a tensor mask corresponding to the second tensor; transforming the second tensor into a condensed tensor based on the tensor mask, wherein the condensed tensor stores non-zero elements in the second tensor; casting the first tensor and the condensed tensor of the second tensor into a same data type to obtain two input tensors; feeding the two input tensors into a multiplier for generating an intermediate tensor; accumulating the intermediate tensor with a previously cached intermediate tensor to obtain an output tensor; and storing the output tensor.

[0027] These and other features of the systems, methods, and non-transitory computer-readable media disclosed herein, as well as the methods of operation and functions of the related elements of structure and the combination of parts and economies of manufacture, will become more apparent upon consideration of the following description and the appended claims with reference to the accompanying drawings, all of which form a part of this specification, wherein like reference numerals designate corresponding parts in the various figures. It is to be expressly understood, however, that the drawings are for purposes of illustration and description only and are not intended as a definition of the limits of the invention.BRIEF DESCRIPTION OF THE DRAWINGS

[0028] FIG. 1 illustrates an exemplary architecture diagram of a single-axis sparse tensor processing circuit for improving efficiency of neural network computations, in accordance with various embodiments.

[0029] FIG. 2A illustrates an exemplary data flow in a reconfigurable gather circuit in the sparse tensor processing circuit, in accordance with various embodiments.

[0030] FIG. 2B illustrates an exemplary architecture diagram of the reconfigurable gather circuit in the sparse tensor processing circuit, in accordance with various embodiments.

[0031] FIG. 3 illustrates an exemplary architecture diagram of an adder tree module in the sparse tensor processing circuit, in accordance with various embodiments.

[0032] FIG. 4 illustrates an exemplary architecture diagram of a multiplier array in the sparse tensor processing circuit, in accordance with various embodiments.

[0033] FIG. 5 illustrates an exemplary diagram of the control circuit in the sparse tensor processing circuit, in accordance with various embodiments.

[0034] FIG. 6 illustrates an exemplary diagram of the scaling circuit in the sparse tensor processing circuit, in accordance with various embodiments.

[0035] FIG. 7A illustrates an exemplary diagram of the accumulation circuit in the sparse tensor processing circuit, in accordance with various embodiments.

[0036] FIG. 7B illustrates an exemplary diagram of the accumulate cache in the sparse tensor processing circuit, in accordance with various embodiments.

[0037] FIG. 8 illustrate an example method performed by the sparse tensor processing circuit, in accordance with various embodiments.

[0038] DETAIL DESCRIPTION OF THE EMBODIMENTS

[0039] Embodiments described herein provide methods, systems, apparatus for accelerating and improving efficiency of neural network computations by using a specially designed sparse tensor processing circuit.

[0040] A neural network computation involves the interaction between activation tensors and weight tensors to process and transform data through the network’s layers. Activation tensors represent the input data or the outputs from preceding layers, encapsulating multi-dimensional arrays of numerical values that carry essential information for tasks such as classification or prediction. Weight tensors contain the network’s learnable parameters, determining the strength and direction of connections between neurons. During computation, the weight tensor is applied to the activation tensor through operations like matrix multiplication or convolution, effectively aggregating and transforming the input data based on the learned weights. This process is typically followed by adding a bias tensor and applying an activation function, which introduces non-linearity and enables the network to model complex patterns. The continuous interplay between activation and weight tensors allows the neural network to learn from data, adjust its parameters during training, and make accurate predictions during inference.

[0041] As mentioned in the background section, sparsification in neural networks involves reducing the number of non-zero elements in weight tensors or activation tensors, thereby lowering the computational burden and memory requirements. The sparsity of neural networks can be achieved through methods such as pruning, quantization, and regularization. These methods reduce the density of neural network tensors, leading to more efficient model execution.

[0042] In certain applications, sparsification eliminates zero-valued elements while retaining non-zero elements. In other applications, sparsification removes zero-valued elements and preserves non-zero elements. For simplicity, the following description uses the zero / non-zero example.

[0043] As mentioned in the background section, sparsification in neural networks involves reducing the number of non-zero elements in weight tensors or activation tensors, thereby lowering the computational burden and memory requirements. The sparsity of neural networks can be achieved through methods such as pruning, quantization, and regularization. These methods reduce the density of neural network tensors, leading to more efficient model execution.

[0044] FIG. 1 illustrates an exemplary architecture diagram of a single-axis sparse tensor processing circuit for improving efficiency of neural network computations, in accordance with various embodiments. The diagram in FIG. 1 is for illustrative purposes with example components. Depending on the implementation, the sparse tensor processing circuit may have additional, fewer, or alternative components. The term “single axis” here refers to the one dimension of the input tensors on which a tensor sparsification is performed.

[0045] Referring to the diagram in FIG. 1, the sparse tensor processing circuit may include a control circuit 100 and a computation module 150. The control circuit 100 receives neural network computation instructions from high level in the system, such as a host device, and dispatches the instructions to the components in the computation module to carry out the neural network computation.

[0046] In some embodiments, the control circuit 100 includes various components designed to manage and direct neural network computations. These components may include an instruction queue configured to receive computation instructions, such as memory addresses for input tensors, the type of computation to be performed, and the destination memory address for storing the output tensor. The control circuit 100 also comprises local (engine) registers, which serve as the interface for configuring and instructing the computation module 150. The control circuit 100 may further include an instruction parser for interpreting the instructions within the instruction queue. Additionally, the control circuit 100 includes a register read / write controller that is used to get necessary data flow read / write control information from control / status registers (CSR) or instructions, a pipeline instruction buffer that acts as a staging area for buffering instructions, local registers that materialize the configurations specified by the engine registers, and pipeline controller responsible for executing the instructions fetched from the pipeline instruction buffer. FIG. 5 includes more detailed description of the control circuit 100.

[0047] In some embodiments, the computation module 150 implements a pipeline for executing the neural network computations. As shown, the computation module 150 may include a data distribute interface accepting input data as well as other parameters from the control circuit 100, a first tensor L1 cache 151, a second tensor L1 cache 153, a tensor mask L1 Cache 155, a group of reconfigurable gather circuits 160, a plurality of cast circuits 161A-161C (denoted as Cast 161A, Cast 161B and Cast 161C in FIG. 1) , a multiplier array 170, an adder tree module 180, a scaling multiplier module 184, a scale parameter cache 186, an accumulation circuit 190 (denoted as ACC Circuit 190 in FIG. 1) , an accumulate cache 188 (denoted as ACC Cache 188 in FIG. 1) , and a shared memory 194.

[0048] A basic neural network computation involves two tensors, such as an activation tensor and a weight tensor. The first tensor L1 cache 151 and the second tensor L1 cache 153 are configured to cache the input tensors, including a first tensor (e.g., the activation tensor) and a second tensor (e.g., the weight tensor) . The tensor mask L1 cache 155 is configured to cache a tensor mask corresponding to the second tensor. In some embodiments, the tensor mask is a bitmask received from the control circuit or computed by the computation module 150. This tensor mask identifies non-zero tensor data (e.g., non-zero data or data exceeding a specific threshold) within the second tensor, thereby facilitating the sparsification of the second tensor by eliminating zero-valued data.

[0049] In some embodiments, the reconfigurable gather circuits 160 is configured to receive data from the second tensor L1 cache 153 and the tensor mask L1 cache 155, and execute the sparsification of the second tensor based on the tensor mask. The sparsification transforms the second tensor from a dense format into a condensed format based on the tensor mask. In some embodiments, the condensed format of the second tensor includes a condensed tensor that only contains the non-zero elements (in some cases, these elements are also quantized to reduce the bit-depth to reduce memory footprint and computational cost) , a low-bit bitmask indicating the zero-valued elements that are pruned out, and optional quantization parameters when the sparsification involves quantizing the tensor data. In some cases, the sparsification performed by the reconfigurable gather circuits 160 may be based on one axis (e.g., single axis sparsification) of the second tensor, such as the input channel of the weight tensor, the input channel of the activation tensor, or the output channel of the activation tensor.

[0050] In some embodiments, sparsification of the second tensor may alter its data type, for example, converting it from a high-precision format (e.g., 32-bit in the dense format) to a low-precision format (e.g., 8-bit in the condensed format) , while the first tensor in the first tensor L1 cache 151 remains in its original format (e.g., either a dense format or a condensed format from anther engine) . To continue tensor operations, these two tensors are passed through cast circuits for data type conversion, ensuring they are converted to the same data type. The output from the cast circuits is then fed into the multiplier array 170 to proceed with the computation. As illustrated in FIG. 1, a first cast circuit 161A is connected to the first tensor L1 cache 151 for casting the first tensor, and a second cast circuit 161B is connected to the reconfigurable gather circuits 160 to cast the condensed format of the second tensor.

[0051] In some embodiments, the multiplier array 170 performs the tensor computation based on the first tensor and the condensed format of the second tensor, and generate an intermediate tensor. The intermedia tensor may be fed into the adder tree 180 for accumulation, thereby completing one cycle of MAC (Multiplication-and-Accumulation) operations on the input tensors.

[0052] Subsequently, the output of the adder tree 180 may go through the scaling multiplier 184 based on a scale parameter stored in the scale param cache 186. The scaling process on the tensor may include adjusting the magnitude or range of tensor values before the subsequent accumulation with another intermediate tensor. This scaling process may be needed to support mixed-precision techniques, where different parts of the computation in the sparse tensor processing circuit use varying levels of numerical precision to balance performance and accuracy.

[0053] The accumulation circuit 190 may be configured to perform summation on the intermediate tensor output from the scaling multiplier 184 and another tensor read from the accumulate cache 188 (e.g., another intermedia tensor from a previous computation cycle) . In some cases, the output of the accumulation circuit 190 may be stored in the accumulate cache 188 for the next round of computation. In other cases, the output of the accumulation circuit 190 may go through another cast circuit 161C before being stored into the shared memory 194 as the output tensor of the neural network computation.

[0054] FIG. 2A illustrates an exemplary data flow in the reconfigurable gather circuits 160 of FIG. 1 in the sparse tensor processing circuit, in accordance with various embodiments. The data flow in FIG. 2A represents the sparsification of a tensor using a K-bit data precision, where K may be 8, 16 bits. The data flow may include a plurality of phases, including an input phase 210, a first optional data rearrangement phase 212, a gathering (sparsification) phase 214, and a second optional data rearrangement phase 218.

[0055] In some embodiments, the input phase 210 involves receiving input data, such as a tensor to be sparsified (e.g., the second tensor from the second tensor L1 cache 153 in FIG. 1) .

[0056] The first optional data rearrangement phase 212 may be triggered when the data precision (i.e., the bit-depth) used in the input tensor is greater than the data precision used in the gather circuits 160 of FIG. 1. For instance, if the input tensor uses 16 bits to represent each element, while the gather circuits 160 of FIG. 1 uses 8 bits data precision, the first optional data rearrangement phase 212 may be configured to split input tensor into two sub-tensors. In particular, each 16-bit element includes high 8 bits and low 8 bits, and the first optional data rearrangement phase 212 groups the high 8 bits of all tensor elements into the first subtensor, and the low 8 bits of all tensor elements into the second subtensor. The two subtensors may be fed into multiple butterfly networks to perform the sparsification simultaneously.

[0057] The gathering phase 214 is where the sparsification of the input tensor occurs. These butterfly networks may be implemented as 2D flattened structures to optimize hardware efficiency by minimizing the number of nodes and the total wiring length, as described in international patent application PCT / CN2024 / 122216, filed on September 29, 2024, which is fully incorporated herein by reference. Each butterfly network is designed to compress a dimension of the tensor data (e.g., reducing the number of elements in the particular dimension) , with different networks capable of compressing the dimension by varying degrees.

[0058] The output data from the gathering phase 214 may proceed through the second, optional data rearrangement phase 218 to produce the final sparsified tensor. This second phase is necessary if the first optional data rearrangement phase 212 was triggered. For example, if 16-bit elements were split into two subtensors (each with 8-bit elements) during the first phase, and both subtensors underwent sparsification, the resulting sparsified subtensors would be recombined in an interleaving manner-merging the high 8 bits and low 8 bits of the same elements-to form the sparsified version of the input tensor.

[0059] FIG. 2B illustrates an exemplary architecture diagram of the reconfigurable gather circuits 160 in the sparse tensor processing circuit, in accordance with various embodiments. As shown, the reconfigurable gather circuits 160 may include an array of gather blocks 262. These gather blocks 262 may perform tensor sparsification operations in parallel. Each of the gather blocks 262 may include a plurality of butterfly networks configured to compress a dimension of a given tensor (e.g., a vector) with different ratios.

[0060] An inventive aspect of the gather block 262 is its design, which allows the plurality of butterfly networks within the gather block to function as modular building blocks. These networks can be combined and activated simultaneously to achieve varying levels of sparsification while optimizing hardware resource utilization.

[0061] For example, FIG. 2B illustrates the configuration of four butterfly networks 271-274. Butterfly network 271 accepts 64 inputs and produces 16 outputs, achieving a 4x compression ratio by gathering 16 elements from the 64 input elements. Butterfly network 272 similarly accepts 64 inputs but generates 8 outputs, providing an 8x compression ratio. Butterfly networks 273 and 274 also take 64 inputs each, but both produce 4 outputs, resulting in a 16x compression ratio.

[0062] In some cases, activating a single butterfly network may be sufficient to achieve the desired level of sparsification while fully utilizing the available processing units (e.g., the multipliers) . For example, if the desired compression ratio is 4x, only butterfly network 271 would need to be activated. This network would gather 16 elements from the 64 input elements and distribute them for parallel processing, ensuring optimal use of the processing resources.

[0063] In other cases, multiple butterfly networks may be activated simultaneously, not only to achieve the desired compression ratio but also to fully utilize the processing units (e.g., the multipliers) in the downstream computing engine. For example, while butterfly network 272 alone can achieve an 8x compression ratio, it only generates 8 elements per cycle, which would utilize only half of the available multipliers. To address this, the gather block 262 activates both butterfly network 271 and butterfly network 272 at the same time. This configuration achieves the 8x compression ratio while generating 8 elements from each network, producing 16 elements in total to fully utilize the multipliers array. Notably, although butterfly network 271 is originally designed for 64-to-16 sparsification, it can be reconfigured to perform 64-to-8 sparsification by utilizing only half of its output nodes.

[0064] As another example, when a 16x compression ratio is required, all four butterfly networks 271, 272, 273, and 274 can be activated simultaneously. In this scenario, butterfly networks 271 and 272 may be reconfigured as two 64-to-4 networks, allowing all four networks to collectively generate 16 output elements, ensuring full utilization of the downstream processing units (e.g., the multipliers) . That is, a larger number of 2D flattened butterfly networks can be reconfigured and simultaneously activated to achieve a higher desired compression ratio.

[0065] It is important to note that the butterfly networks 271-274 can be reconfigured to achieve a higher compression ratio by using only a subset of their output nodes. This flexibility allows the gather block 262 to activate different combinations of networks to achieve various compression ratios, while also generating the exact number of output elements required to fully optimize the efficiency of the processing units (e.g., the multipliers) .

[0066] As shown in FIG. 2B, the gather block 262 may include two input ports: one for the data (i.e., the tensor) and another for the tensor mask. The input data from these ports undergoes a data rearrangement process, splitting into two data streams for sparsification. Each data stream is processed through a set of butterfly networks. For example, the second data stream in FIG. 2B passes through butterfly networks 281-284 to achieve the desired  compression ratio while ensuring maximum utilization of the downstream processing multipliers.

[0067] FIG. 3 illustrates an exemplary architecture diagram of an adder tree module 180 in the sparse tensor processing circuit, in accordance with various embodiments. In some embodiments, the adder tree module 180 may include a plurality of adder trees 300 providing parallel processing across output channels. Each of the adder trees 300 may support three-input computation.

[0068] FIG. 4 illustrates an exemplary architecture diagram of the multiplier array 170 in the sparse tensor processing circuit, in accordance with various embodiments. The multiplier array 170 may include an array of parallel multiplier circuits 400 (denoted as Parallel Multiplier Unit 400 in FIG. 4) for parallel processing. The multiplier array 170 receives input data (e.g., from the tensor L1 cache 151 and the gather circuits 160 in FIG. 1) and control signals from a controller, and generates output tensor as a result of the tensor multiplication.

[0069] In some embodiments, each multiplier circuit 400 includes a plurality of hybrid multipliers 420. The hybrid multipliers 420 are considered “hybrid” because they are configured to support various data formats (with different data precisions / bit-depths) . Each hybrid multiplier 420 may include multiple multipliers (e.g., 430 and 440) , each supporting different data formats. For instance, the multiplier 430 supports INT8 and FP8, and the multiplier 440 in FIG. 4 supports INT8, FP16, and BF16. In other words, the multiplier 430 supports a first data format with a lower bit depth, and the multiplier 440 supports the first data format with the lower bit depth and a second data format with a higher bit depth. In some embodiments, the output of the multiplier 430 have different data formats. For instance, multiplier 430 in FIG. 4 generates 16 bits in each cycle, and multiplier 440 generates 32 bits in each cycle.

[0070] In some cases, only one of the multipliers needs to be activated to perform the tensor computation. For instance, if both input data “a” and “b” in FIG. 4 are FP8, the multiplier 430 may be activated to handle the two 8-bit FP8 data and generate the 16-bit output. The output then goes through a cast circuit to be converted to a 32-bit data for output.

[0071] In other cases, multiple multiplier circuits may be activated simultaneously to support the use cases where the input data using different (i.e., hybrid) data format. The hybrid multiplier 420 may further include a cast circuit 422 to cast one data format to another data format in order to reuse one of the multipliers 430 and 440.

[0072] In some embodiments, the hybrid multiplier 420 may also include a zero flag to accelerating the computation involving zero-valued data. When the flat is set, the hybrid multiplier 420 may directly output the result, bypassing the multipliers 430 and 440.

[0073] FIG. 5 illustrates an exemplary diagram of the control circuit 100 in the sparse tensor processing circuit, in accordance with various embodiments. For simplicity, the control circuit 100 from FIG. 1 is divided into three logic components: an instruction preprocessing component 500, an instruction dispatching component 510, and a plurality of instruction queues 520 for execution.

[0074] In some embodiments, the instruction preprocessing component 500 read instructions from the instruction buffer. The pre-decoding step is to detect and resolve nested loops.

[0075] The instruction is then sent to the instruction local First-In-First-Out (FIFO) buffer for storage. If the FIFO is almost full, it will signal to pause the instruction fetch. Instructions in the FIFO are processed sequentially. Each instruction first goes into a decode circuit to determine the instruction type, e.g., a tensor loading instruction, a computing instruction, a storage instruction, or an operation end instruction. The type of the instruction is then sent to the local fetch circuit. The local fetch circuit is configured to determine the target instruction queue to distribute the instruction based on the instruction type and queue status of the available instruction queues.

[0076] The plurality of instructions queues 520 in FIG. 5 includes a load 0 queue (e.g., storing instructions for loading activation tensors and weight tensors) , a local 1 queue (e.g., storing instructions for loading scaling factors and tensor masks) , a compute queue (e.g., storing instructions for executing general matrix multiplication (GEMM) instructions) , a store queue (e.g., storing instructions to store the output tensor as a result of the computation) , and an op end queue (e.g., storing instructions indicating the end of the operation) . These queues may report their respective queue status to the local fetch circuit.

[0077] FIG. 6 illustrates an exemplary diagram of the scaling circuit in the sparse tensor processing circuit, in accordance with various embodiments. The scaling multiplier 184 illustrated in FIG. 1 may include a plurality of scaling circuits 600 (denoted as Scaling Unit 600 in FIG. 6) for parallel processing. Each of the scaling circuit 600 may include a plurality of cast circuits for scaling up or down the bit-depth of the received tensor data.

[0078] For example, the scaling circuit 600 in FIG. 6 features three data paths, all receiving FP32 data. The first data path converts FP32 to INT8 or FP8 by applying a scale factor and a cast circuit. The second data path rounds the FP32 data to generate BF16 or FP16 data, while the third data path serves as a bypass, outputting the FP32 data without modification.

[0079] FIG. 7A illustrates an exemplary diagram of the accumulation circuit 190 in the sparse tensor processing circuit, in accordance with various embodiments. The accumulation circuit 190 is configured to perform accumulation on the intermediate tensor generated from the previous stage and a previously cached intermediate tensor in the accumulate cache 188.

[0080] In some embodiments, the accumulation circuit 190 may include a plurality of adders 700 (also called adder circuits) respectively coupled with dedicated local registers 720. The local register 720 serves a local buffer of the adder 700. The temporary result generated from the adder 700 may be first stored in the register 720. In some cases, a control signal may instruct the register 720 to transmit the temporary result, through an output port of the register 720, to the accumulate cache 188 for storage (e.g., for next round of computation) . In other cases, the control signal may instruct the register 720 to send the temporary result back to the adder 700 (as a partial sum) , through another output port of the register 720, to continue the computation. In yet other cases, a selector may be configured to select from the temporary result (from the register 720) or a previously cached tensor (from the accumulate cache 188) to continue the computation.

[0081] FIG. 7B illustrates an exemplary diagram of the accumulate cache 188 in the sparse tensor processing circuit, in accordance with various embodiments.

[0082] In some embodiments, the accumulate cache 188 may include a ping-pong buffer for caching the intermediate tensor data. The ping-pong buffer may include a ping page 730 and a pong page 740, two identical buffer pages that can be used in an alternating manner to improve memory efficiency. Each of the pages may include an array of Static Random-Access Memory (SRAMs) .

[0083] During the write phase, any data to be stored in the accumulate cache 188 may go through a selector selecting which of the ping-pong pages to use. The selector is controlled by a control signal. The to-be-stored data may be a tensor or a control signal.

[0084] During the read phase, different control signals trigger distinct data pipelines, allowing the system to handle various data flow requirements. When reading a tensor from the accumulate cache 188, the tensor could either be an intermediate tensor that needs to be fed back into the processing pipeline for further computation, or it could be a final output tensor meant for storage in shared memory 194 of FIG. 1. The read control signal directs the accumulate cache 188 to retrieve the appropriate data from the correct buffer page and dispatch it to the correct output port. For example, partial sums may be sent back to the adder circuit for further accumulation, while final output tensors are written to shared memory for use in subsequent operations or external retrieval. This flexible data handling mechanism ensures efficient management of both intermediate and final data within the processing flow.

[0085] FIG. 8 illustrate an example process 800 performed by the sparse tensor processing circuit, in accordance with various embodiments.

[0086] As shown in FIG. 8, process 800 may include receiving a first tensor (block 810) . For example, the sparse tensor processing circuit may receive a first tensor, as described above.

[0087] As also shown in FIG. 8, process 800 may include receiving a second tensor and a corresponding tensor mask (block 820) . For example, device may receive a second tensor and a corresponding tensor mask, as described above.

[0088] As further shown in FIG. 8, process 800 may include transforming the second tensor into a condensed format based on the corresponding tensor mask (block 830) . For example, the sparse tensor processing circuit may transform the second tensor into a condensed format based on the corresponding tensor mask, as described above.

[0089] As also shown in FIG. 8, process 800 may include casting the first tensor and the condensed format of the second tensor into a same data type to obtain two input tensors (block 840) . For example, the sparse tensor processing circuit may cast the first tensor and the condensed format of the second tensor into a same data type to obtain two input tensors, as described above.

[0090] As further shown in FIG. 8, process 800 may include feeding the two input tensors into a multiplier for generating an intermediate tensor (block 850) . For example, the sparse tensor processing circuit may feed the two input tensors into a multiplier for generating an intermediate tensor, as described above.

[0091] As also shown in FIG. 8, process 800 may include accumulating the intermediate tensor with a previously cached intermediate tensor to obtain an output tensor (block 860) . For example, the sparse tensor processing circuit may accumulate the intermediate tensor with a previously cached intermediate tensor to obtain an output tensor, as described above.

[0092] As further shown in FIG. 8, process 800 may include storing the output tensor (block 870) . For example, the sparse tensor processing circuit may store the output tensor, as described above.

[0093] Although FIG. 8 shows example blocks of process 800, in some implementations, process 800 may include additional blocks, fewer blocks, different blocks, or differently arranged blocks than those depicted in FIG. 8. Additionally, or alternatively, two or more of the blocks of process 800 may be performed in parallel.

[0094] The performance of certain of the operations may be distributed among the processors, not only residing within a single machine, but deployed across a number of machines. In some example embodiments, the processors or processor-implemented engines may be located in a single geographic location (e.g., within a home environment, an office environment, or a server farm) . In other example embodiments, the processors or processor-implemented engines may be distributed across a number of geographic locations.

[0095] Each of the processes, methods, and algorithms described in the preceding sections may be embodied in, and fully or partially automated by, code modules executed by one or more computer systems or computer processors comprising computer hardware. The processes and algorithms may be implemented partially or wholly in application-specific circuit.

[0096] When the functions disclosed herein are implemented in the form of software functional circuits and sold or used as independent products, they can be stored in a processor executable non-volatile computer-readable storage medium. Particular technical solutions disclosed herein (in whole or in part) or aspects that contributes to current technologies may be embodied in the form of a software product. The software product may be stored in a storage medium, comprising a number of instructions to cause a computing device (which may be a personal computer, a server, a network device, and the like) to execute all or some steps of the methods of the embodiments of the present application. The storage medium may comprise a flash drive, a portable hard drive, ROM, RAM, a magnetic disk, an optical disc, another medium operable to store program code, or any combination thereof.

[0097] Particular embodiments further provide a system comprising a processor and a non-transitory computer-readable storage medium storing instructions executable by the processor to cause the system to perform operations corresponding to steps in any method of the embodiments disclosed above. Particular embodiments further provide a non-transitory computer-readable storage medium configured with instructions executable by one or more processors to cause the one or more processors to perform operations corresponding to steps in any method of the embodiments disclosed above.

[0098] Embodiments disclosed herein may be implemented through a cloud platform, a server or a server group (hereinafter collectively the “service system” ) that interacts with a client. The client may be a terminal device, or a client registered by a user at a platform, wherein the terminal device may be a mobile terminal, a personal computer (PC) , and any device that may be installed with a platform application program.

[0099] The various features and processes described above may be used independently of one another or may be combined in various ways. All possible combinations and sub-combinations are intended to fall within the scope of this disclosure. In addition, certain method or process blocks may be omitted in some implementations. The methods and processes described herein are also not limited to any particular sequence, and the blocks or states relating thereto can be performed in other sequences that are appropriate. For example, described blocks or states may be performed in an order other than that specifically disclosed, or multiple blocks or states may be combined in a single block or state. The example blocks or states may be performed in serial, in parallel, or in some other manner. Blocks or states may be added to or removed from the disclosed example embodiments. The exemplary systems and components described herein may be configured differently than described. For example, elements may be added to, removed from, or rearranged compared to the disclosed example embodiments.

[0100] The various operations of exemplary methods described herein may be performed, at least partially, by an algorithm. The algorithm may be comprised in program codes or instructions stored in a memory (e.g., a non-transitory computer-readable storage medium described above) . Such algorithm may comprise a machine learning algorithm. In some embodiments, a machine learning algorithm may not explicitly program computers to perform a function but can learn from training samples to make a prediction model that performs the function.

[0101] The various operations of exemplary methods described herein may be performed, at least partially, by one or more processors that are temporarily configured (e.g., by software) or permanently configured to perform the relevant operations. Whether temporarily or permanently configured, such processors may constitute processor-implemented engines that operate to perform one or more operations or functions described herein.

[0102] Similarly, the methods described herein may be at least partially processor-implemented, with a particular processor or processors being an example of hardware. For example, at least some of the operations of a method may be performed by one or more processors or processor-implemented engines. Moreover, the one or more processors may also operate to support performance of the relevant operations in a “cloud computing” environment or as a “software as a service” (SaaS) . For example, at least some of the operations may be performed by a group of computers (as examples of machines including processors) , with these operations being accessible via a network (e.g., the Internet) and via one or more appropriate interfaces (e.g., an Application Program Interface (API) ) .

[0103] The performance of certain of the operations may be distributed among the processors, not only residing within a single machine, but deployed across a number of machines. In some example embodiments, the processors or processor-implemented engines may be located in a single geographic location (e.g., within a home environment, an office environment, or a server farm) . In other example embodiments, the processors or processor-implemented engines may be distributed across a number of geographic locations.

[0104] Throughout this specification, plural instances may implement components, operations, or structures described as a single instance. Although individual operations of one or more methods are illustrated and described as separate operations, one or more of the individual operations may be performed concurrently, and nothing requires that the operations be performed in the order illustrated. Structures and functionality presented as separate components in example configurations may be implemented as a combined structure or component. Similarly, structures and functionality presented as a single component may be implemented as separate components. These and other variations, modifications, additions, and improvements fall within the scope of the subject matter herein.

[0105] As used herein, “or” is inclusive and not exclusive, unless expressly indicated otherwise or indicated otherwise by context. Therefore, herein, “A, B, or C” means “A, B, A and B, A and C, B and C, or A, B, and C, ” unless expressly indicated otherwise or indicated otherwise by context. Moreover, “and” is both joint and several, unless expressly indicated otherwise or indicated otherwise by context. Therefore, herein, “A and B” means “A and B, jointly or severally, ” unless expressly indicated otherwise or indicated otherwise by context. Moreover, plural instances may be provided for resources, operations, or structures described herein as a single instance. Additionally, boundaries between various resources, operations, engines, and data stores are somewhat arbitrary, and particular operations are illustrated in a context of specific illustrative configurations. Other allocations of functionality are envisioned and may fall within a scope of various embodiments of the present disclosure. In general, structures and functionality presented as separate resources in the example configurations may be implemented as a combined structure or resource. Similarly, structures and functionality presented as a single resource may be implemented as separate resources. These and other variations, modifications, additions, and improvements fall within a scope of embodiments of the present disclosure as represented by the appended claims. The specification and drawings are, accordingly, to be regarded in an illustrative rather than a restrictive sense.

[0106] The term “include” or “comprise” is used to indicate the existence of the subsequently declared features, but it does not exclude the addition of other features. Conditional language, such as, among others, “can, ” “could, ” “might, ” or “may, ” unless specifically stated otherwise, or otherwise understood within the context as used, is generally intended to convey that certain embodiments include, while other embodiments do not include, certain features, elements and / or steps. Thus, such conditional language is not generally intended to imply that features, elements and / or steps are in any way required for one or more embodiments or that one or more embodiments necessarily include logic for deciding, with or without user input or prompting, whether these features, elements and / or steps are included or are to be performed in any particular embodiment.

[0107] Although an overview of the subject matter has been described with reference to specific example embodiments, various modifications and changes may be made to these embodiments without departing from the broader scope of embodiments of the present disclosure. Such embodiments of the subject matter may be referred to herein, individually or collectively, by the term “invention” merely for convenience and without intending to voluntarily limit the scope of this application to any single disclosure or concept if more than one is, in fact, disclosed.

[0108] The embodiments illustrated herein are described in sufficient detail to enable those skilled in the art to practice the teachings disclosed. Other embodiments may be used and derived therefrom, such that structural and logical substitutions and changes may be made without departing from the scope of this disclosure. The Detailed Description, therefore, is not to be taken in a limiting sense, and the scope of various embodiments is defined only by the appended claims, along with the full range of equivalents to which such claims are entitled.

Claims

1.A tensor processing circuit, comprising:a first tensor cache configured to cache a first tensor for a neural network computation;a second tensor cache configured to cache a second tensor for the neural network computation;a tensor mask cache configured to cache a tensor mask corresponding to the second tensor;a gather circuit coupled to the second tensor cache and the tensor mask cache, wherein the gather circuit is configured to transform the second tensor into a condensed tensor based on the tensor mask;a multiplier array configured to receive the first tensor from the first tensor cache and the condensed tensor from the gather circuit, and output an intermediate tensor; andan accumulation circuit configured to perform summation operations based on the intermediate tensor and another tensor from an accumulate cache, thereby generating an output tensor of the neural network computation.2.The tensor processing circuit of claim 1, further comprising:a plurality of cast circuits configured for data type conversion, wherein the plurality of cast circuit comprise:a first cast circuit configured to receive the first tensor from the first tensor cache; anda second cast circuit configured to receive the condensed tensor from the gather circuit, wherein both of the first and second cast circuits are configured to output cast results to the multiplier array.3.The tensor processing circuit of claim 2, wherein the plurality of cast circuits further comprise a third cast circuit configured to receive data from the accumulation circuit, and output a cast result to a shared memory.4.The tensor processing circuit of claim 1, further comprising:a scaling cache for caching a scaling parameter, wherein the scaling parameter is used to scale data in the intermediate tensor before the summation operation is performed in the accumulation circuit.5.The tensor processing circuit of claim 1, further comprising:a control circuit configured to send instructions to components in the tensor processing circuit, wherein the control circuit comprises:a local instruction first-in-first-out (FIFO) as a staging area for storing to-be-executed instructions;a plurality of instruction queues, each configured to execute one type of instruction; andan instruction fetching circuit configured to receive status information of the plurality of instruction queues, and dispatch an incoming instruction based on the type of the incoming instruction and the status information of the queue executing the type of the incoming instruction.6.The tensor processing circuit of claim 5, wherein the plurality of instruction queues comprise:a first instruction queue for loading activation tensors and weight tensors;a second instruction queue for loading scaling factors and tensor masks;a third instruction queue for executing general matrix multiplication (GEMM) instructions; anda fourth instruction queue for storing data to memory.7.The tensor processing circuit of claim 1, wherein the gather circuit comprises a plurality of gather blocks for parallel processing, each gather block comprising a plurality of 2-dimensional (2D) flattened butterfly networks, and each of the plurality of 2D flattened butterfly networks being configured to compress a dimension of a given tensor data.8.The tensor processing circuit of claim 7, wherein multiple of the plurality of 2D flattened butterfly networks are activated simultaneously to achieve a desired compression ratio.9.The tensor processing circuit of claim 8, wherein the given tensor data is fed into the activated 2D flattened butterfly networks simultaneously, and outputs from the activated 2D flattened butterfly networks are combined to achieve the desired compression ratio.10.The tensor processing circuit of claim 7, wherein a larger number of 2D flattened butterfly networks are simultaneously activated to achieve a higher desired compression ratio.11.The tensor processing circuit of claim 7, wherein, within each gather block, the plurality of 2D flattened butterfly networks comprise:a first 2D flattened butterfly network compressing a dimension of the given tensor data to achieve a first compression ratio; anda second 2D flattened butterfly network compressing the dimension of the given tensor data to achieve a second compression ratio, wherein the first compression ratio is greater than the second compression ratio.12.The tensor processing circuit of claim 7, wherein, within each gather block, the plurality of 2D flattened butterfly networks comprise:a first 2D flattened butterfly network compressing a 64-element vector into a 16-element vector;a second 2D flattened butterfly network compressing the 64-element vector into an 8-element vector; anda third 2D flattened butterfly network compressing the 64-element vector into a 4-element vector.13.The tensor processing circuit of claim 1, wherein the multiplier array comprises a plurality of multiplier circuits, each of the plurality of multiplier circuits comprising a plurality of hybrid multipliers supporting tensor data multiplication using different data formats.14.The tensor processing circuit of claim 13, wherein each of the plurality of hybrid multipliers comprises a first multiplier supporting a first data format with a lower bit depth, and a second multiplier supporting the first data format with the lower bit depth and a second data format with a higher bit depth.15.The tensor processing circuit of claim 14, wherein the first multiplier and the second multiplier generate output data using different data formats.16.The tensor processing circuit of claim 13, wherein each of the plurality of hybrid multipliers comprises (1) a pair of input interfaces for receiving input tensor data, and (2) a zero-flag indicating whether one of the input tensor data is zero, wherein in response to the zero-flag being set, the hybrid multiplier directly outputs a zero value.17.The tensor processing circuit of claim 1, wherein the accumulation circuit comprises a plurality of adder circuits, each adder circuit coupled to a dedicated register, wherein:the adder circuit stores a temporary tensor to the register; andthe register sends the temporary tensor to a selector, wherein the selector comprises a first output port directing the temporary tensor back to the adder circuit, and a second output port directing the temporary tensor to the accumulate cache.18.The tensor processing circuit of claim 1, wherein the accumulate cache comprises a pair of buffer pages, each buffer page comprising a plurality of Static Random-Access Memory (SRAMs) .19.The tensor processing circuit of claim 17, wherein the accumulate cache comprises a read pipeline accepting a first control signal or a second control signal, wherein:the first control signal instructs reading data from the accumulate cache into the adder circuit for computation, andthe second control signal instructs reading data from the accumulate cache into a shared memory for storage.20.A method, comprising:receiving a first tensor, a second tensor, and a tensor mask corresponding to the second tensor;transforming the second tensor into a condensed tensor based on the tensor mask, wherein the condensed tensor stores non-zero elements in the second tensor;casting the first tensor and the condensed tensor of the second tensor into a same data type to obtain two input tensors;feeding the two input tensors into a multiplier for generating an intermediate tensor;accumulating the intermediate tensor with a previously cached intermediate tensor to obtain an output tensor; andstoring the output tensor.

Citation Information

Patent Citations

  • Systems and methods for generation of sparse code for convolutional neural networks

    US20200160181A1

  • Hardware architecture for processing data in sparse neural network

    US20220108156A1

  • Switchable one-sided sparsity acceleration

    US20240028895A1

  • Exploiting data sparsity at a machine-learning hardware accelerator

    WO2023224614A1