Dequantization method of floating point data, mixed precision dequantization device
By preprocessing and multiplying the weighted data, the problem of high hardware resource consumption in existing technologies is solved, resulting in a reduction in hardware area and an improvement in energy efficiency, making it suitable for efficient deployment in large-scale parallel inference scenarios.
Patent Information
- Application Number
- CN202611413291.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-11
- Publication Date
- 2026-11-27
AI Technical Summary
Existing dequantization architectures have poor adaptability to mixed weights of integers and low-precision floating-point numbers, resulting in high hardware resource overhead and making it difficult to meet the high-efficiency deployment requirements of large-scale parallel inference scenarios.
By preprocessing the weighted data, a target value is generated, and multiplication is performed using fp16 formatted mantissa and exponent. Combined with leading zero detection and exponent shifting, cross-type multiplication is achieved, simplifying circuit logic and reducing hardware area.
It achieves a significant reduction in hardware area and an improvement in energy efficiency, meeting the requirements for large-scale parallel deployment in AI acceleration chips and ensuring computational accuracy.
Smart Images

Figure CN123177779A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and to a method for dequantizing floating-point data and a device for dequantizing mixed-precision data. Background Technology
[0002] In AI model inference and deployment scenarios, low-precision quantization is a core technique for achieving lightweight models, improving inference throughput, and reducing storage and computing overhead. Low-precision quantized data cannot directly participate in high-precision floating-point operations; it must be restored to high-precision floating-point values through dequantization algorithms to achieve precision compatibility between low-precision quantized models and high-precision computing links. Therefore, dequantization is a crucial step in balancing model deployment efficiency and inference accuracy.
[0003] However, existing conventional dequantization architectures are mostly designed with fixed processing paths for single data types, and have poor uniformity in adapting to mixed weights of multiple types such as integers and low-precision floating points. In AI-specific acceleration hardware, dequantization units often need to be deployed in large numbers of instantiations. This low-reuse architecture leads to increased hardware resource overhead and poor performance in key indicators such as chip area and power consumption, making it difficult to adapt to the high-efficiency deployment requirements of large-scale parallel inference scenarios. Summary of the Invention
[0004] Therefore, it is necessary to provide a floating-point data dequantization method and a mixed-precision dequantization device to address the technical problems in the existing technology. This method can at least achieve multiplication of fused data types, simplify circuit logic and processing steps, and significantly reduce hardware area.
[0005] Firstly, this application provides a method for dequantizing floating-point data, including: The weighted data is preprocessed based on the weighted data type to obtain the target value corresponding to the weighted data; the target value includes the weight mantissa, or the formatted weight mantissa and the formatted weight exponent; The mantissa of the scaling factor in fp16 format is extracted and biased, and the exponent is compensated by subtracting 15 to obtain the fp16 format mantissa and fp16 format exponent. Based on the weight data type, select the weight mantissa or format the weight mantissa and perform a multiplication operation with the fp16 formatted mantissa to obtain the multiplication result; Perform leading zero detection on the multiplication result and count the number of consecutive high-order zeros; Calculate the index value; where, when the target value includes the weighted tail, the index value is obtained based on the fp16 formatted index and the number of high-order zeros; or, when the target value includes the formatted weighted index, the index value is obtained based on the fp16 formatted index and the formatted weighted index. The multiplication result is shifted based on the exponent value and the number of high-order zeros to obtain the normalized mantissa. The normalized mantissa is rounded to a floating point and a special value judgment is performed to obtain the dequantization result.
[0006] In some embodiments, the weight data type includes asymmetric integer, symmetric integer, and low-precision floating-point number; When the weight data type is asymmetric integer or symmetric integer, the target value only includes the weight mantissa; when the weight data type is low-precision floating-point number, the target value includes the formatted weight mantissa and the formatted weight exponent.
[0007] In some embodiments, when the weight data type is asymmetric integer, preprocessing the weight data based on the weight data type to obtain the target value includes: After sign-extending the weight data to convert it to int9 data, a subtraction operation is performed with the zero-point parameter to obtain the subtraction result; The subtraction result is mapped to generate a uint8 weighted mantissa.
[0008] In some embodiments, when the weight data type is a symmetric integer, preprocessing the weight data based on the weight data type to obtain the target value includes: After the weight data is sign-extended to int9, it is mapped to generate uint8 weight mantissas.
[0009] In some embodiments, the exponent value is obtained based on the fp16 formatted exponent and the number of high-order zeros, including: Subtract the number of consecutive high-order zeros from the formatted fp16 exponent to obtain the exponent value.
[0010] In some embodiments, when the weight data type is a low-precision floating-point number, preprocessing the weight data based on the weight data type to obtain the target value includes: The non-standard number judgment, exponent bias compensation, and mantissa alignment operations are performed sequentially on the weight data to obtain the uint8 formatted weight mantissa and the 6-bit formatted weight exponent.
[0011] In some embodiments, the index value is obtained based on the fp16 formatting index and the formatting weight index, including: Add the fp16 formatting index to the formatting weight index to obtain the index value.
[0012] In some embodiments, shifting the multiplication result according to the exponent value and the number of high-order zeros includes: The multiplication result is left-scaled based on the number of high-order zeros to obtain intermediate data; Determine if the intermediate data is non-normal; if it is determined to be non-normal, perform a right normalized shift on the intermediate data based on the exponent value to obtain the normalized mantissa. If the number is determined to be non-normal, the intermediate data will be used as the normalized mantissa.
[0013] Secondly, this application provides a mixed-precision dequantization apparatus for performing the floating-point data dequantization method described in any of the above embodiments, comprising: The preprocessing unit is used to receive weight data, preprocess the weight data based on the weight data type, and output the corresponding target value. The target value contains only the weight mantissa, or contains both the formatted weight mantissa and the formatted weight exponent. The scaling factor processing unit is used to extract the mantissa and perform bias processing on the scaling factor in fp16 format, and perform a 15-fold bias compensation on the exponent to obtain the fp16 format mantissa and fp16 format exponent. The multiplication unit, connected to the preprocessing unit and the scaling factor processing unit, performs multiplication operations with the weight mantissa or formatted weight mantissa based on the weight data type and the fp16 formatted mantissa to obtain the multiplication result. The post-processing unit, connected to the multiplication unit, scaling factor processing unit, and preprocessing unit, is used to obtain the inverse quantization result based on the multiplication result, the target value, and the fp16 formatted mantissa.
[0014] In some embodiments, the preprocessing unit includes: The first judgment module is used to receive weight data, select the corresponding branch for calculation according to the weight data type, and output the target value. The first processing module, connected to the first judgment module, is used to convert the weight data into int9 data after sign expansion when the weight data is an asymmetric integer, perform a subtraction operation with the zero point parameter, and map the subtraction result to generate a uint8 weight mantissa. The second processing module, connected to the first judgment module, is used to convert the weight data into int9 data by sign extension when the weight data is a symmetric integer, and then map and generate uint8 weight mantissa. The third processing module, connected to the first judgment module, is used to extract and process the mantissa and exponent when the weight data is a low-precision floating-point number, and generate formatted weight mantissa and formatted weight exponent.
[0015] In some embodiments, both the third processing module and the scaling factor processing unit include: The second judgment module is used to perform non-standard number judgment operations on the weighted data; The bias compensation module, connected to the output of the second judgment module, is used to perform exponential bias compensation calculations on the exponential components of the weight data or scaling factor. The alignment module, connected to the output of the second judgment module, is used to complete the tail alignment processing of weight data or scaling factors.
[0016] In some embodiments, the post-processing unit includes: an exponent calculation module, a shift module, a rounding module, and a special value judgment module; The index calculation module is connected to the detection module, the preprocessing unit, and the scaling factor processing unit, respectively. It is used to perform calculations based on the formatted weight index, the fp16 formatted index, and the number of high-order zeros, and output the index value. The shift module, connected to the multiplication unit and the exponent calculation module, is used to perform shift operations based on the multiplication result and the exponent value and output the normalized mantissa obtained by the shift. The rounding module, connected to the shift module, is used to perform floating-point rounding based on the normalized mantissa; The special value judgment module, connected to the rounding module, is used to judge special values based on the exponent value and the rounded mantissa, and output the inverse quantization result.
[0017] The unexpected technical effects that this application can produce are: Compared to the redundant process in existing solutions that require converting integer and low-precision floating-point data to high-precision floating-point numbers before performing full floating-point multiplication, the floating-point data dequantization method and mixed-precision dequantization device provided in this application preprocess the weight data of different data types (asymmetric integer, symmetric integer, and low-precision floating-point) into a target value containing the weight mantissa or formatted weight mantissa and exponent, and also processes the scaling factor into a formatted mantissa and exponent. This allows the same dequantization circuit to handle inputs of multiple data types, and then uses an unsigned multiplier to complete cross-type multiplication, realizing the core dequantization calculation and reducing the area occupied by dedicated hardware modules from the root.
[0018] In addition, by combining the mantissa shift logic of the leading zero or exponent shift indicator in the post-processing unit with standard rounding processing, the calculation accuracy of cross-type multiplication is guaranteed. While ensuring the accuracy of dequantization, the chip's area utilization and energy efficiency ratio are effectively improved, meeting the needs of large-scale parallel deployment of dequantization units in AI acceleration chips. Attached Figure Description
[0019] Figure 1 This is a schematic diagram of the dequantization scheme for floating-point data in a comparative embodiment; Figure 2 This is a flowchart illustrating a method for dequantizing floating-point data in one embodiment; Figure 3 This is a flowchart illustrating step 1 in one embodiment; Figure 4 This is a flowchart illustrating step 6 in one embodiment; Figure 5 This is one of the structural block diagrams of a hybrid precision inverse quantization device provided in one embodiment; Figure 6 This is a second structural block diagram of a hybrid precision inverse quantization device provided in one embodiment.
[0020] Explanation of reference numerals in the attached figures: 1. Preprocessing unit; 11. First judgment module; 12. First processing module; 13. Second processing module; 14. Third processing module; 2. Scaling factor processing unit; 21. Second judgment module; 22. Offset compensation module; 23. Alignment module; 3. Multiplication unit; 4. Postprocessing unit; 41. Detection module; 42. Exponent calculation module; 43. Shift module; 44. Rounding module; 45. Special value judgment module. Detailed Implementation
[0021] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of systems and methods consistent with some aspects of this disclosure as detailed in the appended claims.
[0022] The terminology used in this disclosure is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. The singular forms “a,” “the,” and “the” as used in this disclosure and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any and all possible combinations of one or more of the associated listed items.
[0023] It should be understood that although the terms first, second, third, etc., may be used in this disclosure to describe various information, such information should not be limited to these terms. These terms are used only to distinguish information of the same type from one another. For example, without departing from the scope of this disclosure, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to determination."
[0024] As mentioned earlier, in the field of AI model inference and deployment, dequantization is a core algorithmic step in achieving compatibility between low-precision quantized models and high-precision floating-point calculations. It is a crucial step in balancing model storage efficiency and computational accuracy. Its core principle is to map low-precision quantized data back to the unquantized floating-point values using the scaling factor and zero point determined during the quantization stage. Depending on the granularity of the scaling factor and the handling of the zero point, dequantization can be further subdivided into layer-by-layer dequantization, channel-by-channel dequantization, block-by-block dequantization, asymmetric dequantization, and symmetric dequantization. The data format before dequantization is typically int4, uint4, int8, uint8, fp4, fp8, etc.
[0025] Figure 1 A comparative implementation of the anti-quantization scheme is presented, which includes the following steps: 1) For weight data that requires asymmetric dequantization, including uint4 and uint8, it is necessary to input them to the subtractor along path (1), perform subtraction with the zero point parameter to complete the zero point offset mapping, and then convert them into high-precision floating-point data through the precision converter. After passing the scaling factor through the floating-point multiplier, the dequantization result is obtained. 2) For weight data that requires symmetric dequantization, including int4, int8, fp8, fp4, etc., since zero-point correction is not required, they are directly sent to the precision converter along path (2) to be converted into high-precision floating-point data, such as fp16, and dequantized by the scaling factor through the floating-point multiplier.
[0026] Because all data of different precisions need to be independently converted into high-precision floating-point data before undergoing complex, high-level floating-point multiplication, the dequantization units in the above scheme often require a large number of instantiations, leading to increased hardware resource overhead and poor performance in key indicators such as chip area and power consumption. This makes it difficult to meet the high-efficiency deployment requirements of large-scale parallel inference scenarios.
[0027] Based on this, in an exemplary embodiment, such as Figure 2 As shown, this application provides a method for dequantizing floating-point data, including the following steps 1 to 7.
[0028] Step 1: Preprocess the weight data based on the weight data type to obtain the target value corresponding to the weight data; the target value includes the weight mantissa, or formatted weight mantissa, formatted weight exponent.
[0029] The weight data type refers to the quantization encoding type and data storage format used by the original weight data in the model quantization stage. This type determines the zero-point offset rule, sign bit extension method, and whether the floating-point exponent and mantissa need to be decomposed in the dequantization preprocessing stage. It can be further refined into asymmetric integer (e.g., uint4, uint8), symmetric integer (e.g., int4, int8), and low-precision floating-point number (e.g., fp4, fp8).
[0030] For example, based on the weight data type to which the current weight data belongs, the corresponding standardization conversion rule is retrieved, and at least one of the following processes is selectively performed on the original weight data: zero-point offset calculation, sign bit extension, bit width adaptation mapping, non-standard number judgment, exponent bias compensation, and mantissa alignment.
[0031] Step 2: Extract the mantissa and perform offset processing on the scaling factor in fp16 format, and perform offset compensation of minus 15 on the exponent to obtain the fp16 format mantissa and fp16 format exponent.
[0032] The scaling factor is a floating-point scale correction coefficient used to restore low-precision weight values during the model quantization inference process. In this application, it is encoded and stored using the fp16 standard floating-point format.
[0033] For example, according to the IEEE 754 fp16 encoding rules, the original mantissa and original exponent of the scaling factor are extracted; the original mantissa is biased to obtain an unbiased valid fp16 formatted mantissa; the original exponent is subjected to a 15-fold bias compensation to offset the inherent offset of fp16 floating-point storage encoding, thereby obtaining a true and valid fp16 formatted exponent.
[0034] Step 3: Based on the weight data type, select the weight mantissa or format the weight mantissa and perform a multiplication operation with the fp16 formatted mantissa to obtain the multiplication result.
[0035] For example, based on the weight data type determined in the preceding steps, the corresponding mantissa component is selected from the target value of the preprocessed output as the first 8-bit multiplier, and the fp16 formatted mantissa is used as the second 11-bit multiplier. The multiplication result is calculated by an unsigned multiplier.
[0036] Step 4: Perform leading zero detection on the multiplication result and count the number of consecutive high-order zeros.
[0037] For example, the multiplication result is scanned bit by bit according to the priority order of binary bits from high to low. The position of the first valid bit 1 in the multiplication result is located, the number of all consecutive leading zero bits before the valid bit is counted, and this count value is output and stored as the number of high-order zeros to the subsequent operation stage.
[0038] Step 5: Calculate the index value; where, when the target value includes the weighted tail, the index value is obtained based on the fp16 formatted index and the number of high-order zeros; or when the target value includes the formatted weighted index, the index value is obtained based on the fp16 formatted index and the formatted weighted index.
[0039] The exponent value is an exponential parameter used to characterize the magnitude of the final dequantization result.
[0040] For example, the exponentiation is performed in two ways depending on the composition type of the preprocessed target value. For instance, if the target value only contains the weight mantissa, the number of high-order zeros is subtracted from the fp16 formatted exponent, and an integer-type exponentiation correction is performed to obtain the exponent value. If the target value contains both the formatted weight mantissa and the formatted weight exponent, the fp16 formatted exponent and the formatted weight exponent are added together, and a floating-point-type exponentiation correction is performed to obtain the exponent value.
[0041] Step 6: Shift the multiplication result according to the exponent value and the number of high-order zeros to obtain the normalized mantissa.
[0042] The normalized mantissa is the mantissa component obtained by performing a shift operation on the multiplication result so that the valid numerical segment is aligned to the target bit width required by the floating-point storage format. Step 7: Perform floating-point rounding on the normalized mantissa and perform special value judgment to obtain the dequantization result.
[0043] Among them, floating-point rounding refers to truncating and carrying over normalized mantissas that exceed the storage length according to the floating-point storage bit width limit, so as to adapt them to the standard floating-point encoding format; special value judgment is to combine the combination state of the exponent value and the mantissa to determine whether the operation result belongs to non-standard floating-point special values such as zero, infinity, non-numeric NaN, underflow non-normal number, etc.
[0044] In some embodiments, further, such as Figure 3 As shown, step 1, based on the weight data type, is specifically divided into three processing paths: In one embodiment, the weight data is an asymmetric integer (e.g., uint4, uint8).
[0045] According to the quantization encoding rules, asymmetric integer weights such as uint4 and uint8 have no sign bit. They need to be padded with a sign bit first, and then a subtractor is used to perform a subtraction operation with the zero point parameter to calculate the zero point offset. The weights are then further converted into target values that do not contain an exponent component and only contain the 8-bit mantissa of the uint8 weight.
[0046] In another embodiment, the weight data is a symmetric integer (e.g., int4, int8).
[0047] The original weight data is directly sign-extended and bit-width-mapped to generate an 8-bit uint8 weight mantissa, which also does not contain an exponent component.
[0048] In another embodiment, if the weight data is a low-precision floating-point number (e.g., fp4, fp8).
[0049] For fp8 type weight data, depending on whether it is in e4m3 or e5m2 format, the low-precision floating-point type weight data is sequentially subjected to non-standard number judgment, and then the implicit 1 and low-bit 0 of the mantissa are aligned and supplemented in different cases, and the signed valid exponent is extracted to obtain an 8-bit formatted weight mantissa and a 6-bit formatted weight exponent; for fp4 type weight data, similar processing is performed as fp8, but because there is only the e2m1 format with a very small bit width, it is greatly simplified.
[0050] In some embodiments, such as Figure 4 As shown, step 6 further includes: Step 61: Perform a left-scale shift on the multiplication result based on the number of high-order zeros to obtain intermediate data.
[0051] Step 62: Determine whether the intermediate data is a non-normal number; if it is determined to be a non-normal number, perform a right normalized shift on the intermediate data based on the exponent value to obtain the normalized mantissa; if it is determined not to be a non-normal number, use the intermediate data as the normalized mantissa.
[0052] Specifically, left specification shift is used to align the most significant bit of the significant value segment to 1 to meet the mantissa format requirements of normalized floating-point numbers. However, when this left specification shift causes the exponent value to underflow to the minimum exponent allowed by the floating-point format, it is determined that the current result cannot be represented in normal number form; at this time, an additional right specification shift is performed to raise the exponent value back to the minimum exponent value of the floating-point format, obtaining a normalized mantissa in non-normal number form.
[0053] Based on the same inventive concept, this application also provides a mixed-precision dequantization apparatus for implementing the above-described dequantization method for floating-point data. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations in one or more mixed-precision dequantization apparatus embodiments provided below can be found in the limitations of the dequantization method described above, and will not be repeated here.
[0054] In one exemplary embodiment, such as Figure 5 As shown, a mixed-precision inverse quantization device is provided, comprising: a preprocessing unit 1, a scaling factor processing unit 2, a multiplication unit 3, and a postprocessing unit 4.
[0055] The preprocessing unit 1 is used to receive weight data, preprocess the weight data based on the weight data type, and output the corresponding target value.
[0056] The scaling factor processing unit 2 is used to extract the mantissa and perform bias processing on the scaling factor in fp16 format, and to perform a 15-fold bias compensation on the exponent to obtain the fp16 format mantissa and fp16 format exponent.
[0057] Multiplication unit 3, connected to preprocessing unit 1 and scaling factor processing unit 2, is used to select the weight mantissa or format the weight mantissa based on the weight data type, and perform multiplication operation with the fp16 formatted mantissa to obtain the multiplication result.
[0058] The post-processing unit 4 is connected to the multiplication unit 3, the scaling factor processing unit 2, and the preprocessing unit 1, and is used to obtain the inverse quantization result based on the multiplication result, the target value, and the fp16 format exponent.
[0059] In one exemplary embodiment, such as Figure 6 As shown, the preprocessing unit 1 includes a first judgment module 11, and a first processing module 12, a second processing module 13 and a third processing module 14 respectively connected to the first judgment module 11.
[0060] In this process, the first judgment module 11 receives the weight data and identifies the data type of the weight data. If the weight data is an asymmetric integer (e.g., uint4, uint8), it is assigned to the first processing module 12, which performs a subtraction operation on the weight data and the zero-point parameter, converts it to int9 data after sign expansion, and then maps it to generate a uint8 weight mantissa. In this case, the target value only contains the weight mantissa. If the weight data is a symmetric integer (e.g., int4, int8), it is assigned to the second processing module 13, which performs sign expansion on the weight data, converts it to int9 data, and then maps it to generate a uint8 weight mantissa. In this case, the target value only contains the weight mantissa. If the weight data is a low-precision floating-point number (e.g., fp4, fp8), it is assigned to the third processing module 14, which sequentially performs non-standard number judgment, exponent bias compensation, and mantissa alignment processing on the weight data to generate a formatted weight mantissa and a formatted weight exponent. In this case, the target value contains both the formatted weight mantissa and the formatted weight exponent.
[0061] In an exemplary embodiment, both the third processing module 14 and the scaling factor processing unit 2 include a second judgment module 21, and an offset compensation module 22 and an alignment module 23 respectively connected to the second judgment module 21.
[0062] For the third processing module, the second judgment module is used to perform non-normal number judgment operation on the weight data, the bias compensation module is used to perform exponential bias compensation operation on the exponential component of the weight data, and the alignment module is used to complete the tail alignment processing of the weight data.
[0063] For scaling factor processing unit 2, the second judgment module 21 is used to perform non-standard number judgment operation on the scaling factor in fp16 format, the offset compensation module 22 is used to perform an exponential offset compensation operation of minus 15 on the exponential component of the scaling factor, and the alignment module 23 is used to complete the mantissa alignment processing of the scaling factor.
[0064] In one exemplary embodiment, such as Figure 6 As shown, the post-processing unit 4 includes: a detection module 41, an exponent calculation module 42, a shift module 43, a rounding module 44, and a special value judgment module 45.
[0065] The detection module 41 performs leading zero detection on the multiplication result and counts the number of consecutive high-order zeros. The exponent calculation module 42, connected to the detection module 41, the third processing module 14, and the bias compensation module 22, performs calculations based on the number of high-order zeros, the multiplication result, the formatted weight exponent, and the fp16 formatted exponent, and outputs the exponent value. The shift module 43, connected to the multiplication unit 3 and the exponent calculation module 42, performs shift operations based on the multiplication result and the exponent value, and outputs the normalized mantissa obtained from the shift. The rounding module 44, connected to the shift module 43, performs floating-point rounding on the normalized mantissa.
[0066] The special value judgment module 45 is connected to the rounding module 44 and the exponent calculation module 42. It is used to judge special values based on the exponent value and the rounded mantissa, and output the inverse quantization result.
[0067] It should be noted that the rounding module 44 has multiple rounding options, such as rounding to zero or rounding to the nearest value, which are floating-point standard rounding methods. This only changes the rounding and carry rules of the mantissa and does not affect the overall circuit path and the core dequantization process.
[0068] In an exemplary embodiment, the unsigned multiplier in multiplication unit 3 can be replaced with other multiplier units of the same bit width, changing only the execution method of multiplication without changing the core logic of the overall floating-point operation.
[0069] Please see Figure 6 In a specific example, the working principle of the mixed-precision inverse quantization device is as follows: Taking low-precision floating-point weight data as an example, the first judgment module 11 sends the low-precision floating-point weight to the third processing module 14 according to the weight data type. After a series of operations such as non-standard number judgment, bias compensation module, and alignment, the formatted weight index and formatted weight mantissa are generated.
[0070] Multiplication unit 3 receives the formatted weight mantissa and the fp16 formatted mantissa, and the unsigned multiplier calculates the multiplication result, which is then sent to detection module 41 and shift module 43. Detection module 41 counts the number of consecutive high-order zeros in the multiplication result, and exponent calculation module 42 calculates the exponent value by combining the fp16 formatted exponent and the formatted weight exponent. Shift module 43 shifts the multiplication result based on the number of high-order zeros and the exponent value to obtain the normalized mantissa. After the normalized mantissa is truncated by rounding module 44, special value judgment module 45 determines whether it is a special floating-point value such as NaN, infinity, or zero, based on the exponent value, and finally outputs the dequantized result in standard floating-point format.
[0071] It should be noted that the division of units in this embodiment is illustrative and represents only one logical functional division; other division methods may be used in actual implementation. The integrated units described above can be implemented in hardware or as software functional units.
[0072] Each module in the aforementioned mixed-precision inverse quantization device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0073] Thus, specific embodiments of the subject matter have been described. Other embodiments are within the scope of the appended claims. In some cases, the actions recited in the claims may be performed in a different order and still achieve the desired result. Furthermore, the processes depicted in the drawings are not necessarily shown in a specific order or sequence to achieve the desired result. In some implementations, multitasking and parallel processing may be advantageous.
[0074] The above description is merely a preferred embodiment of this disclosure and is not intended to limit this disclosure. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.
Claims
1. A method for inverse quantization of floating-point data, characterized in that, include: The weight data is preprocessed based on the weight data type to obtain the target value corresponding to the weight data; The target value includes the weighted tail, or the formatted weighted tail, or the formatted weighted index; The mantissa of the scaling factor in fp16 format is extracted and biased, and the exponent is compensated by subtracting 15 to obtain the fp16 format mantissa and fp16 format exponent. Based on the weight data type, the weight mantissa or the formatted weight mantissa is selected and multiplied with the fp16 formatted mantissa to obtain the multiplication result; Perform leading zero detection on the multiplication result and count the number of consecutive high-order zeros; Calculate the index value; wherein, when the target value includes a weighted tail, the index value is obtained based on the fp16 formatted index and the number of high-order zeros; or, when the target value includes a formatted weighted index, the index value is obtained based on the fp16 formatted index and the formatted weighted index. The multiplication result is shifted according to the exponent value and the number of high-order zeros to obtain the normalized mantissa; The normalized mantissa is rounded to a floating point and a special value judgment is performed to obtain the dequantization result.
2. The inverse quantization method according to claim 1, characterized in that, The weighted data types include asymmetric integer, symmetric integer, and low-precision floating-point number; When the weight data type is asymmetric integer or symmetric integer, the target value only includes the weight mantissa; when the weight data type is low-precision floating-point number, the target value includes the formatted weight mantissa and the formatted weight exponent.
3. The inverse quantization method according to claim 2, characterized in that, When the weight data type is asymmetric integer, the preprocessing of the weight data based on the weight data type to obtain the target value includes: After the weight data is sign-extended to convert it to int9 data, a subtraction operation is performed with the zero-point parameter to obtain the subtraction result; The subtraction result is mapped to generate a uint8 weighted mantissa.
4. The inverse quantization method according to claim 2, characterized in that, When the weight data type is a symmetric integer, the preprocessing of the weight data based on the weight data type to obtain the target value includes: After the weight data is sign-extended to int9 data, it is mapped to generate uint8 weight mantissas.
5. The inverse quantization method according to claim 3 or 4, characterized in that, The process of obtaining the exponent value based on the fp16 formatted exponent and the number of high-order zeros includes: The index value is obtained by subtracting the number of consecutive high-order zeros from the fp16 format index.
6. The inverse quantization method according to claim 2, characterized in that, When the weight data type is a low-precision floating-point number, the preprocessing of the weight data based on the weight data type to obtain the target value includes: The non-standard number judgment, exponent bias compensation, and mantissa alignment operations are performed sequentially on the weight data to obtain the uint8 formatted weight mantissa and the 6-bit formatted weight exponent.
7. The inverse quantization method according to claim 6, characterized in that, The process of obtaining the index value based on the fp16 formatting index and the formatting weight index includes: The index value is obtained by adding the fp16 formatting index to the formatting weight index.
8. The inverse quantization method according to claim 1, characterized in that, The step of shifting the multiplication result according to the exponent value and the number of high-order zeros includes: The multiplication result is left-scaled based on the number of high-order zeros to obtain intermediate data; Determine whether the intermediate data is an irregular number; if it is determined to be an irregular number, perform a right normalized shift on the intermediate data based on the exponent value to obtain the normalized mantissa; If the intermediate data is determined not to be a non-normal number, then the intermediate data is used as the normalized mantissa.
9. A hybrid precision inverse quantization device, characterized in that, A method for performing the inverse quantization of floating-point data according to any one of claims 1 to 8, comprising: The preprocessing unit is used to receive weight data, preprocess the weight data based on the weight data type, and output the corresponding target value. The target value contains only the weight mantissa, or simultaneously contains the formatted weight mantissa and the formatted weight exponent. The scaling factor processing unit is used to extract the mantissa and perform bias processing on the scaling factor in fp16 format, and perform a 15-fold bias compensation on the exponent to obtain the fp16 format mantissa and fp16 format exponent. The multiplication unit, connected to the preprocessing unit and the scaling factor processing unit, performs a multiplication operation with the weight mantissa or the formatted weight mantissa based on the weight data type and the fp16 formatted mantissa to obtain the multiplication result. The post-processing unit, connected to the multiplication unit, the scaling factor processing unit, and the preprocessing unit, is used to obtain the inverse quantization result based on the multiplication result, the target value, and the fp16 formatted mantissa.
10. The hybrid precision inverse quantization device according to claim 9, characterized in that, The preprocessing unit includes: The first judgment module is used to receive weight data, select the corresponding branch for calculation according to the weight data type, and output the target value. The first processing module, connected to the first judgment module, is used to convert the weight data into int9 data after sign expansion when the weight data is an asymmetric integer, perform a subtraction operation with the zero point parameter, and map the subtraction result to generate a uint8 weight mantissa. The second processing module, connected to the first judgment module, is used to convert the weight data into int9 data by sign expansion when the weight data is a symmetric integer, and then map and generate uint8 weight mantissas. The third processing module, connected to the first judgment module, is used to extract and process the mantissa and exponent when the weight data is a low-precision floating-point number, and generate a formatted weight mantissa and a formatted weight exponent.
11. The hybrid precision inverse quantization device according to claim 10, characterized in that, Both the third processing module and the scaling factor processing unit include: The second judgment module is used to perform a non-standard number judgment operation on the weighted data; The bias compensation module is connected to the output of the second judgment module and is used to perform exponential bias compensation calculation on the weight data or the exponential component of the scaling factor. The alignment module, connected to the output of the second judgment module, is used to complete the tail alignment processing of the weight data or the scaling factor.
12. The hybrid precision inverse quantization device according to claim 9, characterized in that, The post-processing unit includes: a detection module, an exponent calculation module, a shift module, a rounding module, and a special value judgment module; The detection module, connected to the multiplication unit, is used to perform leading zero detection on the multiplication result and count the number of consecutive high-order zeros; An index calculation module is connected to the detection module, the preprocessing unit, and the scaling factor processing unit, respectively, and is used to perform calculations based on the formatted weight index, the fp16 formatted index, and the number of high-order zeros, and output the index value. The shift module, connected to the multiplication unit and the exponent calculation module, is used to perform shift operations based on the multiplication result and the exponent value and output the normalized mantissa obtained by the shift. A rounding module, connected to the shift module, is used to perform floating-point rounding based on the normalized mantissa; The special value judgment module, connected to the rounding module, is used to judge special values based on the exponent value and the rounded mantissa, and output the inverse quantization result.
