Method and apparatus for compressing and decompressing sparse data sets
Through multi-level compression technology and decompression circuits, bit masks are used to specify non-zero value positions, which solves the problem of low storage efficiency of large amounts of data in digital systems, achieves faster data processing and memory bandwidth improvement, and is suitable for artificial intelligence applications. .
Patent Information
- Application Number
- CN202280091530.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2022-03-04
- Filing Date
- 2022-11-29
- Publication Date
- 2024-09-24
AI Technical Summary
When modern digital systems process large amounts of digital values, there are a large number of zero values, resulting in low storage and processing efficiency. Especially in artificial intelligence applications, sparsity features need to be supported on hardware to achieve performance acceleration, but existing technologies are difficult to effectively compress. Decompressing data results in long memory read and write times and insufficient bandwidth.
Using multi-level compression technology, through the combination of memory and decompression circuitry, multi-level compression algorithms are used to compress and decompress digital value sets, using bit masks to specify non-zero value positions, and hierarchical decompression to reduce memory transaction time and improve processor data Get speed.
It significantly reduces memory read and write times, improves memory bandwidth, is suitable for sparse data collections, and especially enables faster data retrieval and processing in artificial intelligence processors.
Smart Images

Figure CN118696506A
Abstract
Description
Background Art
[0001] The present disclosure relates generally to digital circuits and systems, and more particularly to methods and apparatus for compressed multiplexing for sparse computations.
[0002] Many modern digital systems and applications need to process large volumes of digital values. For example, artificial intelligence applications may need to store (e.g., in memory) and process (e.g., perform mathematical operations on) large arrays of digital values representing activations or weights. However, in many cases, such large volumes of data may contain a large number of zero values. Calculations on zero values are often handled as an exception, and the system may skip or otherwise ignore it.
[0003] The input data set typically has zero and non-zero values randomly distributed across the data set, where zero values typically represent a certain percentage of the total data set (known as sparsity). For example, for AI accelerators and workloads, sparsity is an increasingly important feature that needs to be supported in hardware to achieve performance acceleration. Specifically, storing and retrieving data sets from memory is a heavy overhead for the system.
[0004] Embodiments described herein advantageously store compressed data in memory to reduce memory bandwidth associated with reading data from memory into a processor. BRIEF DESCRIPTION OF THE DRAWINGS
[0005] Figure 1 A digital circuit according to an embodiment is illustrated.
[0006] Figure 2 A method according to an embodiment is illustrated.
[0007] Figure 3 Example compression and decompression techniques according to embodiments are illustrated.
[0008] Figure 4 An algorithm for compressing and decompressing data according to an embodiment is illustrated.
[0009] Figure 5 Another example compression and decompression technique according to an embodiment is illustrated.
[0010] Figure 6 A system for compressing and decompressing data according to an embodiment is illustrated.
[0011] Figure 7 A simplified block diagram of an example computer system used to execute code in accordance with various embodiments is shown. DETAILED DESCRIPTION
[0012] Described herein is a layered compression technique. In the following description, for the purpose of explanation, many examples and specific details are set forth in order to provide a thorough understanding of some embodiments. Various embodiments defined by the claims may include some or all of the features in these examples alone or in combination with other features described below, and may further include modifications and equivalents of the features and concepts described herein.
[0013] In some embodiments, features and advantages of the present disclosure include circuit techniques for compressing and decompressing sets of digital values to and from memory to advantageously reduce memory read and write times and increase memory bandwidth. The techniques described herein have a wide range of uses, including, for example, use with artificial intelligence processors.
[0014] Figure 1 A digital circuit according to an embodiment is illustrated. Features and advantages of the present disclosure include retrieving compressed digital values from a memory, decompressing the digital values using a first decompression algorithm, and sending the compressed digital values to a processor for further processing. For example, in some embodiments, the processor may further decompress the digital values, and in some embodiments, the processor may be able to operate on the compressed values. As mentioned above, the currently disclosed hierarchical method reduces the memory transaction time and allows the processor to retrieve data faster. In one embodiment, the present disclosure includes a memory 101, which stores data including a plurality of digital values. In various embodiments, a multi-level (also known as a multi-level) compression algorithm is used to compress data. Therefore, data can be read from the memory 101 and received by a decompression circuit 102, which performs a first decompression 114. For example, the decompression circuit 102 can receive N non-zero digital values and generate two digital value sets of length N. The processor 103 can receive the result of the first decompression from the circuit 102 and perform a second decompression 115. In various embodiments, the present techniques may be advantageously used on sparse data sets, as described in more detail below, and the first and second decompressions are, for example, part of a multi-stage interdependent sparsity-based compression algorithm.
[0015] More specifically, in an example embodiment, the memory 101 stores N non-zero digital values in a block 110, where N is a first integer (e.g., N=32). In addition, the N non-zero digital values 110 may be associated with a bit mask 111 specifying the positions of the N non-zero digital values. In this example, the length of the bit mask is 2*N. It should be understood that the bit mask described herein may use various techniques to specify the position of the NZ value, such as including various forms of incremental encoding or position encoding. The decompression circuit 102 receives the N non-zero digital values 110 and the 2*N length bit mask 111 and generates two N length digital value sets 112 and 113. Each of the two N length digital value sets 112 and 113 may include N / 2 non-zero digital values from the N non-zero digital values. For example, the positions of the N / 2 non-zero digital values in each of the two N length digital value sets 112 and 113 may be set based on the 2*N length bit mask. The processor 103 receives two N-length digital value sets and two M-length bit masks (not shown), where M is a second integer greater than N, and decompresses the two N-length digital value sets into two M-length digital value sets, each including N / 2 non-zero elements. M divided by N (M / N) can be a power of 2, such as (e.g., 128 / 32=4=2 2 ), as shown in the following example.
[0016] Figure 2 The method for decompressing data according to an embodiment is illustrated. At 201, N non-zero digital values and 2*N length bit mask are received from memory (e.g., in a decompression circuit). At 202, 2*N length bit mask is used to decompress N non-zero digital values to produce two N length digital value sets, each digital value set includes N / 2 non-zero digital values from N non-zero digital values. For example, the position of N / 2 non-zero digital values in each of two N length digital value sets can be set based on 2*N length bit mask. At 203, a processor receives two N length digital value sets and two M*N length bit masks, wherein M is a second integer greater than N. The processor can decompress two N length digital value sets into two M length digital value sets, each digital value set includes N / 2 non-zero elements. However, as mentioned above, in some embodiments, the processor may be able to operate on the compressed value.
[0017] Figure 3An example compression and decompression technique according to an embodiment is illustrated. This example illustrates a multi-stage compression technique for storing data in a memory. In this example, two data sets 301 and 302 each have M=128 digital values. For the first level of compression, 16 (e.g., N / 2=16) NZ digital values are selected from each of the 128 digital values. For example, the selected digital values can be the 16 largest values in each data set. The result is two data sets 304 and 305, which are called "sparse" (i.e., become sparse), each data set includes 128 values, 16 of which are NZ in each set. For example, a 128-length data set can include an 8-bit mantissa, a sign bit, and a shared exponent, as illustrated in 303a-b. In addition, first and second 128-length bit masks 308 and 309 specifying the positions of the 16 NZ values in each set are generated. Next, two 32-length sets 306 and 307 are generated, each from the 128-length sets 304 and 305 . The 32-length sets 306 and 307 each include 16 NZ values from the corresponding 128-length set.
[0018] For the second level of compression, a 64-bit length bit mask 311 is generated. The bit mask 311 specifies the positions of the 16 NZ values in each 32-bit length set 306 and 307. For example, the first half of the 64-bit bit mask may contain "1"s at positions where the value is NZ in set 306, and the second half of the 64-bit bit mask may contain "1"s at positions where the value is NZ in set 307. Next, the NZ values of the 32-bit length set 310 are generated from the NZ values in the two 32-bit length sets 306 and 307. The NZ values of the 32-bit length set 310 may be stored in memory together with the 64-bit length bit mask 311 and the 128-bit length bit masks 308 and 309.
[0019] Compared with uncompressed or less compressed data, the retrieval rate of multi-stage compressed data can be much higher. For example, 32 length NZ value sets 310, 2*N length bit masks 311 and first and second 128 length bit masks can be retrieved from the memory and coupled to the second-stage decompression circuit 312. Decompression circuit 312 decompresses 32 length NZ value sets 310 into two 32 length sets, each set having 16 NZ values. 64 length bit masks 311 are used for second-stage decompression. Circuit 312 is referred to as "second-stage" decompression because it decompresses 32 length NZ values back into two 32 length values 306 and 307, which is the decompression associated with the above-mentioned second-stage compression. Finally, the 32-length sets 306 and 307 and the 128-length bit masks 308 and 309 (as well as the shared exponents 303a-b) may be sent to the processor for a first level of decompression, where the first and second 128-length bit masks 308 and 309 are used to decompress the two 32-length sets into two 128-length sets 304 and 305, each having 16 NZ-digit values.
[0020] Figure 4 An algorithm for compressing and decompressing data according to an embodiment is illustrated. At 401, a first and a second M-length digital value set are received. At 402, N / 2 non-zero (NZ) digital values are selected from the first set, and N / 2 non-zero (NZ) digital values are selected from the second set. At 403, a first and a second M-length bit mask are generated. The M-length bit mask specifies the positions of the N / 2 NZ values in each set selected at 402. At 404, two N-length value sets are generated. Each N-length value set includes N / 2 NZ values from two M-length sets. Steps 402-404 constitute the first level of compression in the multi-level compression in this example.
[0021] The following steps 405-406 constitute the second level of compression of the multi-level compression in this example. At 405, a 2*N length bit mask is generated, which specifies the positions of the N / 2 NZ values in each N length set. At 406, an N length NZ value set is generated from the NZ values in the two N length sets. At 407, the N length NZ value set, the 2*N length bit mask, and the first and second M length bit masks can be stored in a memory circuit.
[0022] At 408, the N-length NZ value set, the 2*N-length bit mask, and the first and second M-length bit masks can be retrieved from the memory. At 409, a second-level decompression step occurs, wherein the 2*N-length bit mask is used to decompress the N-length NZ value set into two N-length sets with N / 2 NZ values. A first-level decompression occurs at 410, wherein the first and second M-length bit masks are used to decompress the two N-length sets into two M-length sets with N / 2 NZ digital values. The first-level compression can be performed by a processor, such as an artificial intelligence processor or other processor configured to process sparse data sets (e.g., data sets with a large number of zero values, where zero values are skipped and / or NZ value processing is accelerated).
[0023] Figure 5 Another example compression and decompression technique according to an embodiment is illustrated. In various embodiments, the compressed digital value can be represented in different formats. For example, Figure 3 The examples in can represent numeric data values using an 8-bit mantissa, a sign bit, and a shared exponent. Figure 5 In the example shown in , the value is represented as a 4-bit mantissa, a sign bit, and a shared exponent. However, the same hardware can perform B and B / 2 bit representations using essentially the same algorithm as illustrated below, where B is the bit length (B=8 or B / 2=4).
[0024] exist Figure 5, two data sets 501 and 502 each have M=128 digital values. For the first level of compression, 16 (e.g., N / 2=16) NZ digital values are selected from the 128 digital values. However, in this case, these values are selected in adjacent pairs ("pairs") so that the total length of the selected values is 8 bits, which is conducive to the algorithm (slightly modified) running on the same hardware. For example, the selected digital values can be the largest 16 values in each data set. In another embodiment, the value pairs can be selected based on the highest (absolute) value in pairs. It should be understood that various other algorithms are possible. The result is two sparse data sets 504 and 505, each of which includes 128 values, 16 of which are NZ value pairs 504a and 505a in each set. For example, a 128-length data set can include a 4-bit mantissa, a sign bit, and a shared exponent illustrated by 503a-b. In addition, first and second 128-length bit masks 506 and 507 are generated, which specify the positions of the 16 NZ values in each set. Each mask specifies the position of the bit pairs in each sparse data set. Since the mask specifies the bit pairs, in some embodiments, the length of each mask can be half of the vector (e.g., N / 2=128 / 2=64), thereby further compressing the data. Next, two 32-length sets 510 and 511 are generated, each from the 128-length sets 504 and 505. The 32-length sets 510 and 511 each include 16 NZ value pairs from the corresponding 128-length sets.
[0025] For the second level compression, a 64-bit length bit mask 520 is generated. In some embodiments, the length of the bit mask 520 can also be reduced to reduce the number of bits stored. The bit mask 520 specifies the positions of the 16 NZ values in each 32-length set 510 and 511. For example, the first half of the 64-bit bit mask may contain "1" at the position where the value is NZ in the set 510, and the second half of the 64-bit bit mask may contain "1" at the position where the value is NZ in the set 511. Next, a 32-length NZ value set 521 is generated from the NZ values in the two 32-length sets 510 and 511. The 32-length NZ value set 521 can be stored in a memory together with the 64-length bit mask 520 and the 64-length bit masks 512 and 513.
[0026] Compared with uncompressed or low-compression data, the retrieval rate of multi-stage compressed data can be much higher.For example, 32 length NZ value sets 521, 64 length bit masks 520 and first and second 64 length bit masks can be retrieved from memory, and coupled to second-level decompression circuit 550. Decompression circuit 550 decompresses 32 length NZ value sets 521 into two 32 length sets 510-511, and each set has 16 NZ values. 64 length bit masks 520 are used for second-level decompression. Finally, 32 length sets 510 and 511 and 64 length bit masks 512 and 513 (and shared index 503a-b) can be sent to processor and carry out first-level decompression, wherein use first and second 64 length bit masks 512 and 513 that two 32 length sets are decompressed into two 128 length sets 504 and 505, and each set has 16 NZ digital value pairs.
[0027] Figure 6 A system for compressing and decompressing data according to an embodiment is illustrated. In this example, digital data values 610 and 611 are compressed and loaded into a memory 630 by a computer system 601, which is located on the same integrated circuit 602 as a processor 650 and a decompression circuit 650. The computer system 601 can perform first and second level compression according to various embodiments shown in the examples herein. For example, the computer system 601 can be a server, and the integrated circuit 602 can be coupled to the computer system via a local bus or a network connection (e.g., Ethernet). For example, the computer system 601 can implement first and second level compression in hardware (e.g., a state machine, an ASIC or an FPGA), software, or a combination of hardware and software. The input vector of M data values 610 and 611 is compressed into N length vectors 612 and 613, each vector having N / 2 NZ values, and M length bit masks 614 and 615 (or a bit mask of a length of M / 2 for a value selected in pairs). Next, a 2*N length bit mask 617 is used to generate an N length NZ value vector 616. The multi-level compressed data 620 including the bit mask 617, the NZ value vector 616, and the bit masks 618 and 619 of length M (or M / 2) are loaded into the memory 630. Then, the processor 650 can read the data values from the memory 630. The retrieved data is received by the decompression circuit 630, which performs the first level decompression described above. For example, the processor 650 can perform the second level decompression.
[0028] Thus, large volumes of digital data values can be compressed and loaded into memory 630 through a multi-stage algorithm, thereby correspondingly reducing memory usage and memory read and write transactions, thereby reducing memory bandwidth used to move data into the processor. In one embodiment, the data includes neural network activations or neural network weights, and processor 650 is an artificial intelligence (AI) processor optimized for neural network calculations (e.g., multiplication, accumulation, etc.). The example processor can be optimized for sparse calculations, where zeros are ignored and multipliers, accumulators, or other hardware resources only process NZ results to produce faster results.
[0029] Figure 7 A simplified block diagram of an example computer system used to execute program code according to various embodiments is illustrated. In some embodiments, the computer system 700 executes code to compress data, decompress data, or both, as described herein. In another embodiment, the computer system 700 executes hardware description code to generate decompression circuits and / or other parts of an integrated circuit to perform the techniques described herein. Hardware Description Language (HDL) is a specialized computer language that is used to describe the structure and behavior of electronic circuits, most commonly digital logic circuits. HDL code can be executed on a computer system to generate digital logic circuits, including the circuits described herein. Figure 7 A simplified block diagram of an example computer system 700 is shown, which can be used to implement the techniques described in the foregoing disclosure. In some embodiments, the computer system 700 can be used to implement a control processor 702. Figure 7 As shown in , computer system 700 includes one or more processors 702, which communicate with multiple peripheral devices via bus subsystem 704. These peripheral devices may include storage subsystem 706 (e.g., including memory subsystem 708 and file storage subsystem 710) and network interface subsystem 716. Some computer systems may also include user interface input device 712 and / or user interface output device 714.
[0030] The bus subsystem 704 may provide a mechanism for the various components and subsystems of the computer system 700 to communicate with each other as intended. Although the bus subsystem 704 is schematically shown as a single bus, alternative embodiments of the bus subsystem may utilize multiple busses.
[0031] The network interface subsystem 716 may be used as an interface for transferring data between the computer system 700 and other computer systems or networks. Embodiments of the network interface subsystem 716 may include, for example, Ethernet, Wi-Fi, and / or cellular adapters, modems (telephone, satellite, cable, ISDN, etc.), digital subscriber line (DSL) units, and the like.
[0032] Storage subsystem 706 includes memory subsystem 708 and file / disk storage subsystem 710. Subsystems 708 and 710, as well as other memories described herein, are examples of non-transitory computer-readable storage media that may store executable program code and / or data that produce circuitry having the functionality of embodiments of the present disclosure.
[0033] The memory subsystem 708 includes several memories, including a main random access memory (RAM) 718 for storing instructions and data during program execution and a read-only memory (ROM) 720 in which fixed instructions are stored. The file storage subsystem 710 can provide persistent (e.g., non-volatile) storage for program and data files, and can include a magnetic or solid-state hard drive, an optical drive and associated removable media (e.g., CD-ROM, DVD, Blu-ray, etc.), a removable flash drive or card, and / or other types of storage media known in the art.
[0034] It should be appreciated that computer system 700 is illustrative and that many other configurations having more or fewer components than system 700 are possible.
[0035] Additional Examples
[0036] Each of the following non-limiting features in the following examples may exist independently or may be combined with one or more other features in the following examples in various permutations or combinations.
[0037] In one embodiment, the present disclosure includes a digital circuit comprising: a memory storing data including a plurality of digital values, wherein N non-zero digital values are stored in a block, wherein N is a first integer, and the N non-zero digital values are associated with a first bit mask specifying the positions of the N non-zero digital values; a decompression circuit to receive the N non-zero digital values and the first bit mask, and to generate two N-length digital value sets from the N non-zero digital values, wherein the positions of the non-zero digital values in each of the two N-length digital value sets are set based on the first bit mask; and a processor to receive the two N-length digital value sets and the two second bit masks, and to process the two N-length digital value sets using the two second bit masks.
[0038] In another embodiment, the present disclosure includes a method for decompressing data, comprising: receiving N non-zero digital values and a first bit mask specifying the positions of the N non-zero digital values from a memory, wherein N is a first integer, and wherein the N non-zero digital values are stored in a block associated with the first bit mask; decompressing the N non-zero digital values using the first bit mask to produce two N-length digital value sets, each digital value set including non-zero digital values from the N non-zero digital values, wherein the positions of the non-zero digital values in each of the two N-length digital value sets are set based on the first bit mask; and receiving the two N-length digital value sets and two second bit masks in a processor, wherein M is a second integer greater than N, and processing the two N-length digital value sets by the processor using the second bit mask.
[0039] In another embodiment, the present disclosure includes a machine-readable medium storing a computer executable program, the program including a set of instructions for: receiving N non-zero digital values and a first bit mask specifying the positions of the N non-zero digital values from a memory, wherein N is a first integer, and wherein the N non-zero digital values are stored in a block associated with the first bit mask; decompressing the N non-zero digital values using the first bit mask to produce two N-length digital value sets, each digital value set including non-zero digital values from the N non-zero digital values, wherein the positions of the non-zero digital values in each of the two N-length digital value sets are set based on the first bit mask; and receiving the two N-length digital value sets and two second bit masks in a processor, wherein M is a second integer greater than N, and processing the two N-length digital value sets by the processor using the second bit mask.
[0040] In one embodiment, the processor further uses two second bit masks to decompress the two sets of N-length digital values into two sets of M-length digital values, where M is a second integer greater than N.
[0041] In one embodiment, a multi-stage compression algorithm is used to compress data including multiple digital values stored in a memory.
[0042] In one embodiment, M divided by N is a power of 2.
[0043] In one embodiment, the length of the first bit mask is at least 2*N, and the two N-length digital value sets each include N / 2 non-zero digital values.
[0044] In one embodiment, two M-length bit masks are stored in the memory along with the N non-zero digital values and the 2*N-length bit mask.
[0045] In one embodiment, the first bit mask includes 2*N bits.
[0046] In one embodiment, the two second bit masks each include M bits.
[0047] In one embodiment, the N non-zero digital values are stored in memory as value pairs.
[0048] In one embodiment, the two second bit masks each include M / 2 bits.
[0049] The above description illustrates various embodiments and examples of how to implement aspects of some embodiments. The above examples and embodiments should not be considered as the only embodiments, but are presented to illustrate the flexibility and advantages of some embodiments as defined by the following claims. Based on the above disclosure and the following claims, other arrangements, embodiments, implementations and equivalents may be adopted without departing from the scope defined by the claims.
Claims
1. A digital circuit comprising: a memory storing data including a plurality of digital values, wherein N non-zero digital values are stored in a block, wherein N is a first integer, the N non-zero digital values being associated with a first bit mask specifying positions of the N non-zero digital values; a decompression circuit to receive the N non-zero digital values and the first bit mask, and to generate two N-length digital value sets from the N non-zero digital values, wherein positions of the non-zero digital values in each of the two N-length digital value sets are set based on the first bit mask; as well as A processor is configured to receive the two N-length digital value sets and two second bit masks, and process the two N-length digital value sets using the two second bit masks.
2. The circuit of claim 1 , wherein the processor further uses the two second bit masks to decompress the two sets of N-length digital values into two sets of M-length digital values, where M is a second integer greater than N.
3. The circuit of claim 1, wherein the data including the plurality of digital values stored in the memory is compressed using a multi-stage compression algorithm.
4. The circuit of claim 1, wherein M divided by N is a power of 2. 5 . The circuit of claim 1 , wherein the first bit mask has a length of at least 2*N, and the two N-length digital value sets each include N / 2 non-zero digital values. 6 . The circuit of claim 5 , wherein the two M-length bit masks are stored in the memory with the N non-zero digital values and the bit mask having a length of 2*N. The circuit of claim 5 , wherein the first bit mask comprises 2*N bits.
8. The circuit of claim 1, wherein the two second bit masks each comprise M bits.
9. The circuit of claim 1, wherein the N non-zero digital values are stored in the memory as value pairs.
10. The circuit of claim 9, wherein the two second bit masks each comprise M / 2 bits.
11. A method for decompressing data, comprising: receiving, from a memory, N non-zero digital values and a first bit mask specifying locations of the N non-zero digital values, wherein N is a first integer, and wherein the N non-zero digital values are stored in a block associated with the first bit mask; decompressing the N non-zero digital values using the first bit mask to generate two N-length digital value sets, each N-length digital value set including non-zero digital values from the N non-zero digital values, wherein positions of the non-zero digital values in each of the two N-length digital value sets are set based on the first bit mask; as well as Two sets of N-length digital values and two second bit masks are received in a processor, where M is a second integer greater than N, and the two sets of N-length digital values are processed by the processor using the second bit masks.
12. The method of claim 11, wherein the processor further uses the two second bit masks to decompress the two sets of N-length digital values into two sets of M-length digital values, where M is a second integer greater than N.
13. The method of claim 11, wherein the N non-zero digital values are stored in the memory as value pairs.
14. The method of claim 11, wherein the data including the plurality of digital values stored in the memory is compressed using a multi-stage compression algorithm.
15. The method of claim 11, wherein the two M-length bit masks are stored in the memory with the N non-zero digital values and the bit masks.
