Accuracy-preserving quantization
Accuracy-preserving quantization techniques using unrounded offsets and differential scaling factors address the accuracy loss in data conversion, enabling efficient and accurate machine learning operations on lower-precision integers.
Patent Information
- Application Number
- PCT/CN2024/106077
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2024-07-18
- Publication Date
- 2026-01-22
AI Technical Summary
Existing data quantization techniques result in a loss of accuracy when converting high-precision floating-point numbers to lower-precision integers, leading to inefficiencies in computational power and performance in machine learning operations.
Implementing accuracy-preserving quantization methods that use unrounded offsets and differential scaling factors for positive and negative ranges, or endpoint alignment, to minimize the difference between original and dequantized data, thereby maintaining accuracy while reducing computational complexity.
Enhances the accuracy of machine learning operations by minimizing the intersection over union (IoU) loss between floating-point and quantized data, allowing for more efficient and accurate execution on simpler hardware.
Smart Images

Figure CN2024106077_22012026_PF_FP_ABST
Abstract
Description
ACCURACY-PRESERVING QUANTIZATION
[0001] INTRODUCTION
[0002] Aspects of the present disclosure relate to efficient execution of complex operations using data quantization techniques.
[0003] Various computational operations, such as those involving training and / or inferencing operations using neural networks, are based on complex data types, such as floating-point data types. For example, in machine learning applications, a trained model may be generated using high-precision floating-point numbers (e.g., 16-bit half-precision floating-point numbers, 32-bit single-precision floating-point numbers, 64-bit double-precision floating-point numbers, etc. ) . The use of higher-precision floating-point numbers in a machine learning model (sometimes referred to as a “high accuracy model” ) may provide higher accuracy when an inference is run on new data relative to the use of lower-precision floating-point numbers or integers in a machine learning model (sometimes referred to as a “high efficiency model” ) ; however, the use of these higher-precision floating-point numbers may not be power or compute efficient.
[0004] BRIEF SUMMARY
[0005] Certain aspects of the present disclosure provide a processor-implemented method for executing operations on a computing system based on data quantization. The method generally includes quantizing an input based on a range of values for the input. A quantized output of a function is generated based on executing the function using the quantized input. The quantized output is dequantized based on a scaling factor and an unrounded offset associated with the quantization of the input, and one or more actions are taken based on the dequantized output.
[0006] Certain aspects of the present disclosure provide a processor-implemented method for executing operations on a computing system based on data quantization. The method generally includes quantizing an input based on a range of values for the input using a first scaling factor for negative values of the input and a second scaling factor for positive values of the input. A quantized output of a function is generated based on executing the function using the quantized input. The quantized output is dequantized based at least on a scaling factor associated with the quantization of the input, and one or more actions are taken based on the dequantized output.
[0007] Certain aspects of the present disclosure provide a processor-implemented method for executing operations on a computing system based on data quantization. The method generally includes quantizing an input based on a range of values for the input using a first scaling factor for a first set of values of the input and using a second scaling factor for a second set of values of the input. Generally, the first scaling factor corresponds to a longer side of a signed integer range, and the second scaling factor corresponds to a shorter side of the signed integer range. A quantized output of a function is generated based on executing the function using the quantized input. The quantized output is dequantized based at least on a scaling factor associated with the quantization of the input, and one or more actions are taken based on the dequantized output.
[0008] Certain aspects of the present disclosure provide a processor-implemented method for executing operations on a computing system based on data quantization. The method generally includes quantizing an input based on matching endpoints of a range of values for the input to endpoints of a range of quantized values for the input. A quantized output of a function is generated based on executing the function using the quantized input. The quantized output is dequantized based at least on a scaling factor associated with the quantization of the input, and one or more actions are taken based on the dequantized output.
[0009] Other aspects of the present disclosure provide processing systems configured to perform the aforementioned methods as well as those described herein; non-transitory, computer-readable media comprising instructions that, when executed by one or more processors of a processing system, cause the processing system to perform the aforementioned methods as well as those described herein; a computer program product embodied on a computer-readable storage medium comprising code for performing the aforementioned methods as well as those further described herein; and a processing system comprising means for performing the aforementioned methods as well as those further described herein.
[0010] The following description and the related drawings set forth in detail certain illustrative features of one or more aspects.BRIEF DESCRIPTION OF THE DRAWINGS
[0011] The appended figures depict example features of certain aspects of the present disclosure and are therefore not to be considered limiting of the scope of this disclosure.
[0012] FIG. 1 illustrates an example of quantization and dequantization of data based on an unrounded offset associated with quantization of an input, according to aspects of the present disclosure.
[0013] FIG. 2 illustrates example operations for executing a function in a computing system using quantization and dequantization of data based on an unrounded offset associated with quantization of the input, according to aspects of the present disclosure.
[0014] FIG. 3 illustrates an example of quantization and dequantization of data using different scaling factors for positive and negative values of an input, according to aspects of the present disclosure.
[0015] FIG. 4 illustrates example operations for executing a function in a computing system using quantization and dequantization of data based on different scaling factors for positive and negative values of an input, according to aspects of the present disclosure.
[0016] FIG. 5 illustrates an example of quantization and dequantization of data based on scaling factors for longer and shorter sides of a range of values for an input, according to aspects of the present disclosure.
[0017] FIG. 6 illustrates example operations for executing a function in a computing system using quantization and dequantization of data based on scaling factors for longer and shorter sides of a range of values for an input, according to aspects of the present disclosure.
[0018] FIG. 7 illustrates an example of quantization and dequantization of data based on matching endpoints of a range of values for an input to endpoints of a range of quantized values for the input, according to aspects of the present disclosure.
[0019] FIG. 8 illustrates example operations for executing a function in a computing system using quantization and dequantization of data based on matching endpoints of a range of values for an input to endpoints of a range of quantized values for the input, according to aspects of the present disclosure.
[0020] FIG. 9 depicts an example processing system configured to perform various aspects of the present disclosure.
[0021] To facilitate understanding, identical reference numerals have been used, where possible, to designate identical elements that are common to the drawings. It is contemplated that elements and features of one aspect may be beneficially incorporated in other aspects without further recitation.DETAILED DESCRIPTION
[0022] Aspects of the present disclosure provide apparatuses, methods, processing systems, and non-transitory computer-readable mediums for executing functions in computing systems based on accuracy-preserving data quantization techniques.
[0023] Computer systems may perform operations on various numerical types of data. These data types may include integers and floating-point numbers. Integers are generally whole numbers that may be represented by any sequence of bits, with a maximum and minimum value defined by a number of bits in the representation and whether the integer is signed or unsigned. Generally, the maximum value of an unsigned integer may be calculated as 2n –1 for any bit size n. The minimum value of a signed integer may be calculated as -2n-1, and the maximum value of a signed integer may be calculated as 2n-1 –1 for any bit size n. For example, an 8-bit integer may range in value from 0 to 255 in an unsigned representation and from -128 to 127 in a signed representation. As the number of bits increases, the number of possible values increases. Floating-point numbers, however, are represented in a more complex manner. Typically, floating-point numbers are defined in terms of a bit reserved for a sign (positive or negative) , a number of exponent bits, and a number of precision bits.
[0024] Because integer and floating-point numbers are represented differently, mathematical operations may involve different levels of computational expense based on whether a mathematical operation is operating on integers or floating-point numbers. For example, addition of two integers may be a trivial bitwise operation in which each bit is combined and overflow is carried to the next bit. However, floating-point operations may be more complex, as multiple operations may be performed to combine the exponent and precision bits, and a multiplication operation may be performed based on the exponent and precision bits to generate a result. Thus, integer-based logic may be implemented on simpler, more power-efficient hardware than floating-point-based logic.
[0025] While quantization of data from larger, more complex data types (e.g., floating-point numbers) to smaller, less complex data types (e.g., integers) may allow for the execution of various functions in a computing system using simpler and more power-efficient hardware, quantization of data from a larger data type to a smaller data type generally involves some loss of data during the quantization process. For example, various rounding operations may reduce the intersection over union (IoU) between floating-point and quantized data. In other examples, differences in the range of values represented by quantized data may waste data resolution and reduce the IoU between floating-point and quantized data.
[0026] Certain aspects of the present disclosure provide techniques for improving the accuracy of operations involving quantized data. As discussed in further detail herein, during the quantization process in which data in larger data types is quantized into a smaller data type (e.g., floating-point data is quantized into integer data) , the range of values usable in representing the source data in a quantized form may be maximized, or at least increased. Further, in the dequantization process, a relaxed offset from rounding may be used, which allows for the difference between the source data and the dequantized data to be minimized, or at least reduced. By doing so, certain aspects of the present disclosure may allow for operations using quantized data to be performed with higher accuracy while leveraging the computational expense reductions achievable due to quantization from larger data types to smaller data types.
[0027] Background on Data Quantization
[0028] Data may be quantized from a larger data type, such as a floating-point data type, to a smaller data type, such as an integer data type, using asymmetric quantization techniques or using symmetric quantization techniques.
[0029] Generally, in asymmetric quantization, the range of values which may be represented by the quantized data may be bounded by the minimum value θmin=min (z) and maximum value θmax=max (x) of the source data x to be quantized. The quantized data may be quantized into a number of bins k defined by the number of bits b used to define the smaller data type, such that k=2b-1, with bins having indices between 0 and k. A scaling factor s may be defined based on the number of bins k, according to the equation:
[0030] A shifting factor z, which allows for the value of 0 to be represented in both the source data and the quantized data, may be defined according to the equation:
[0031] The quantized version of the source data x may be calculated according to the equation:
[0032] where the clip function limits the values of to values between n and p.
[0033] The dequantized version of may be calculated according to the equation:
[0034] Generally, the rounding of may shift the mapping of rounded data to quantization bins by up to resulting in a reduction of the IoU metric between data in the larger data type and quantized data in the smaller data type. As the number of bits used by the smaller data type decreases, this shift may significantly decrease the accuracy of operations performed using the quantized data, as the quantized data itself may be shifted significantly from the source data.
[0035] In symmetric quantization, the range of data which can be represented by the values of the smaller data type may be based on the maximum absolute value of the source data x, such that the range of values which may be represented by the quantized data may be bounded by the maximum value θmax=max (|x|) and minimum value θmin=-θmax. The scaling factor used in quantizing the source data x may be represented by the equation:
[0036] The quantized value of the source data x in a symmetric quantization scheme may be represented by the equation:
[0037] The dequantized version of may be calculated according to the equation:
[0038] Because symmetric quantization quantizes source data in a larger data type into representations in a smaller data type based on the absolute value of the largest valid value of the source data, symmetric quantization may inefficiently use the bit width of the smaller data type. For example, as the difference between the absolute value of the largest negative value and the largest positive value of the source data increases, the number of effective bins into which the source data is quantized generally decreases. Thus, the range of values of the source data may be compressed into a number of bits that is fewer than the bit width of the smaller data type and thus cause a loss of accuracy in the quantization process and decrease an IoU metric measured between data in the source larger data type and dequantized data after dequantization from the smaller data type.
[0039] Example Relaxed Offset for Improving Quantization Accuracy
[0040] FIG. 1 illustrates an example 100 of quantization and dequantization of data based on an unrounded offset associated with quantization of an input, according to aspects of the present disclosure.
[0041] In the example 100, as illustrated, the source data x has a valid range of -9.8 to 4.2, and the source data is to be quantized into a three-bit integer (e.g., with b=3) having valid values between 0 and 7, inclusive. Thus, in an asymmetric quantization scheme, the scaling factor s may be calculated according to the equations above as:
[0042] Further, the offset z may be calculated according to the equations above as:
[0043] Thus, at block 110, the scaling factor may be used to reduce the resolution of the source data x from the range of -9.8 to 4.2 to the scaled range of -4.9 to 2.1. With a rounding operation, at block 120, the resulting scaled range may be represented as -5 through 2, which, in turn, at block 130, may be converted into quantized data based on the offset z to the range of values between 0 and 7.
[0044] To increase the accuracy of the resulting dequantized data, the offset z added to the quantized data at block 140 prior to scaling at block 150 may be an unrounded offset z. Thus, unlike the asymmetric quantization schemes discussed above, in which the dequantized approximation of x is represented by the equation and thus involves the use of a rounded offset certain aspects of the present disclosure allow for the use of the raw, unrounded offset z to generate a dequantized representation of xaccording to the equation Thus, while the use of a rounded offset results in the generation of dequantized data having a range of -10 through 4, the use of the unrounded offset results in the generation of dequantized data having a range of -9.2 to 4.2. Thus, the quantization and dequantization of data illustrated in the example 100 may increase the IoU between the floating-point range and the dequantized range relative to quantization and dequantization techniques that use a rounded offset in some aspects up to an amount equal to
[0045] In some aspects, the quantization and dequantization of data illustrated in the example 100 may not allow for the exact representation of 0.0. Because the quantization and dequantization of data illustrated in the example 100 may not allow for an exact representation of 0.0, the quantization and dequantization techniques illustrated in the example 100 may be suitable for machine learning model operations including activations that do not depend on the existence of an exact representation of 0.0. Further, the quantization and dequantization techniques illustrated in the example 100 may be usable in improving the stability of quantization-aware training (QAT) of a machine learning model, in which a model and model parameters (e.g., weights) are quantized during the training process.
[0046] FIG. 2 illustrates example operations 200 for executing a function in a computing system using quantization and dequantization of data based on an unrounded offset associated with quantization of the input, according to aspects of the present disclosure.
[0047] As illustrated, the operations 200 begin at block 210 with quantizing an input based on a range of values for the input.
[0048] At block 220, the operations 200 proceed with generating a quantized output of a function based on executing the function using the quantized input. In some aspects, the function comprises a machine learning model function. For example, the function may include a model training function in which the machine learning model is trained using quantization-aware techniques. In other examples, the function may include an inferencing function based on quantized input data, which generates a quantized output which can be dequantized prior to performing an action (e.g., generating an inference, taking actions based on the inference, etc. ) .
[0049] At block 230, the operations 200 proceed with dequantizing the quantized output based on a scaling factor and an unrounded offset associated with the quantization of the input.
[0050] At block 240, the operations 200 proceed with taking one or more actions based on the dequantized output. In some aspects, the one or more actions may include generating an inference relative to the input. The inference may include, for example, predictions of object motion, object depth (relative to a reference point) , or the like, object detection or semantic segmentation in visual content, the generation of responses to input queries (e.g., where the machine learning model is a generative model trained to generate a response based on the identification of tokens that have a high probability of being a portion of a valid response to an input query) , denoising of an image, or other operations based on the output of the machine learning model.
[0051] Example Improving Quantization Accuracy Based on Different Scales for Different Ranges of Data
[0052] FIG. 3 illustrates an example 300 of quantization and dequantization of data using different scaling factors for positive and negative values of an input, according to aspects of the present disclosure.
[0053] To improve the utilization of the integer range when quantizing data, the example 300 illustrates the use of different scaling factors for different portions of the range of values for the source data x which is to be quantized. Using the example discussed above with respect to FIG. 1, symmetric quantization based on the full range of floating-point and integer values in the example 310 may result in quantization of values from the range of values -9.8 to 9.8 to the range of values -4 to 3. In such a case, the scaling factor s may be calculated as
[0054] Because the highest positive value of the source data x illustrated in FIG. 3 is 4.2, some integer values may not be used in quantizing the source data x into quantized data Thus, the source data x may be scaled during quantization operations using a coarser (larger) scaling factor than would be used in an asymmetric quantization scheme (e.g., as discussed above with respect to FIG. 1) and may thus inefficiently use the range of integers used to represent the source data x after quantization.
[0055] To efficiently use the integer range for the quantization of the source data x, the example 300 uses different scaling factors for the long side of the range of values for the source data x and the short side of the range of values for the source data x. Generally, the long side of the range of values for the source data x may be the range, terminating or starting with 0, having a larger starting or ending point (in absolute value terms) , Meanwhile, the short side of the range of values for the source data x may be the range , terminating or starting with 0, having a smaller starting or ending point (in absolute value terms) . In the example 300 illustrated in FIG. 3, the long side may be the negative side of the range of values for the source data x (e.g., the range of values between -9.8 and 0, inclusive) . Meanwhile, the short side may be the positive side of the range of values for the source data x (e.g., the range of values between 0 and 4.2, inclusive) .
[0056] As illustrated, the long side 320 may be quantized using the two bits of the negative side of the integer range for a 3-bit integer (i.e., quantized into values from -4 to 0, inclusive) . The resulting scaling factor snegative may be calculated as snegative=9.8 / 4=2.45. Similarly, the short side 330 may be quantized using the two-bits of the positive side of the integer range for a 3-bit integer (i.e., quantized into values from 0 to 3, inclusive) . The resulting scaling factor spositive may be calculated as spositive=4.2 / 3=1.4. By using different scaling factors for the long side and short side of values in quantizing the source data x, certain aspects of the present disclosure may allow for the use of finer scales for different portions of the source data x that express the range of values for the source data x more tightly than a scaling factor defined in quantization techniques in which a single scaling factor is used.
[0057] FIG. 4 illustrates example operations 400 for executing a function in a computing system using quantization and dequantization of data based on one scaling factor for positive values of an input and a different scaling factor for negative values of the input, according to aspects of the present disclosure.
[0058] As illustrated, the operations 400 may begin at block 410 with quantizing an input based on a range of values for the input using a first scaling factor for negative values of the input and a second scaling factor for positive values of the input.
[0059] In some aspects, the input is quantized using the first scaling factor and the second scaling factor over a valid range of values associated with a bit width of a data type into which the input is quantized. That is, the negative values may be scaled using a first scaling factor associated with values of the input from a minimum value to 0, using b-1 bits and the negative side of a signed integer range. Meanwhile, the positive values may be scaled using a second scaling factor associated with values of the input from 0 to a maximum value, using b-1 bits and the positive side of the signed integer range.
[0060] The first and second scaling factors may, in some aspects, be different from each other. Where the range of negative values exceeds the range of positive values for the input, the first scaling factor may be larger than the second scaling factor. Similarly, where the range of positive values exceeds the range of negative values for the input, the first scaling factor may be smaller than the second scaling factor.
[0061] At block 420, the operations 400 proceed with generating a quantized output of a function based on executing the function using the quantized input.
[0062] In some aspects, the function comprises a machine learning model function. For example, the function may include a model training function in which the machine learning model is trained using quantization-aware techniques. In other examples, the function may include an inferencing function based on quantized input data, which generates a quantized output which can be dequantized prior to performing an action (e.g., generating an inference, taking actions based on the inference, etc. ) .
[0063] At block 430, the operations 400 proceed with dequantizing the quantized output based at least on a scaling factor associated with the quantization of the input.
[0064] In some aspects, the dequantizing may further be based on an offset associated with the quantization of the input (e.g., where an asymmetric quantization scheme is used) . The offset may, in some aspects, be a non-zero, non-rounded offset that allows for the recovery of a dequantized version data that is not rounded to the nearest integer value, and thus allows for increased accuracy in dequantization.
[0065] At block 440, the operations 400 proceed with taking one or more actions based on the dequantized output. The one or more actions may be similar to those described above with respect to FIG. 2.
[0066] FIG. 5 illustrates an example 500 of quantization and dequantization of data based on scaling factors for longer and shorter sides of a range of values for an input, according to aspects of the present disclosure.
[0067] A signed integer may include a larger range of negative values than positive values. For example, a signed three-bit integer may have a range of negative values between -4 and 0 and a range of positive values between 0 and 3. To further improve the granularity of the scaling factor used in quantizing input data, the larger side of the integer range may be assigned for use in representing the larger range of values of the source data x bounded by 0 on either side, while the shorter side of the integer range may be assigned for use in representing the smaller range of values of the source data x bounded by 0 on either side.
[0068] To do so, as illustrated, a sign-flipping operation may be introduced into the quantization function, as illustrated in the example 500. The source data x 510 may be fed into a sign flipper 520, which inverts the sign of the source data x prior to quantization. In doing so, the value of x may be modified so that the long side of the range of values for the source data x is aligned with the long side of the range of values for a signed integer into which the source data is quantized, while the short side of the range of values for the source data x is aligned with the short side of the range of values for a signed integer into which the source data is quantized.
[0069] At block 530, the scaling factor s and (optionally) offset z are determined for the source data x, as discussed above with respect to FIGs. 1 or 3. The source data x may be quantized at block 540 into quantized data and operations with respect to may be performed. Subsequently, may be dequantized into at the dequantization block 550. Because may have an opposite sign compared to x, may be processed through a sign flipper 560 to restore to the proper range of values, and the final version of 570 may be output.
[0070] FIG. 6 illustrates example operations 600 for executing a function in a computing system using quantization and dequantization of data based on scaling factors for longer and shorter sides of a range of values for an input, according to aspects of the present disclosure.
[0071] As illustrated, the operations 600 may begin at block 610 with quantizing an input based on a range of values for the input using a first scaling factor for a first set of values of the input and using a second scaling factor for a second set of values of the input. In some aspects, the first scaling factor corresponds to a longer side of a signed integer range, and the second scaling factor corresponds to a shorter side of the signed integer range.
[0072] In some aspects, the first scaling factor is a scaling factor for negative values of the input, and wherein the second scaling factor is a scaling factor for positive values of the input.
[0073] In some aspects, the input is quantized using the first scaling factor and the second scaling factor over a valid range of values associated with a bit width of a data type into which the input is quantized.
[0074] In some aspects, the offset associated with the quantization of the input comprises an unrounded offset.
[0075] At block 620, the operations 600 proceed with generating a quantized output of a function based on executing the function using the quantized input.
[0076] In some aspects, the function comprises a machine learning model function. For example, the function may include a model training function in which the machine learning model is trained using quantization-aware techniques. In other examples, the function may include an inferencing function based on quantized input data, which generates a quantized output which can be dequantized prior to performing an action (e.g., generating an inference, taking actions based on the inference, etc. ) .
[0077] At block 630, the operations 600 proceed with dequantizing the quantized output based at least on a scaling factor associated with the quantization of the input.
[0078] At block 640, the operations 600 proceed with taking one or more actions based on the dequantized output. The one or more actions may be similar to those described above with respect to FIG. 2.
[0079] Example Improving Quantization Accuracy Based on Endpoint Alignment
[0080] FIG. 7 illustrates an example 700 of quantization and dequantization of data based on matching endpoints of a range of values for an input to endpoints of a range of quantized values for the input, according to aspects of the present disclosure.
[0081] The example 700 illustrates quantization and dequantization techniques in which the ends of a range of floating-point values for the source data x are matched to the endpoints of the integer range into which the source data x is quantized. That is, |INT_range|=|FP_range|. By doing so, the resolution of low-bit representations of the source data x may be increased.
[0082] To do so, as illustrated, a scaling factor and offset may be established at block 710 such that the range of values into which the source data x can be rounded matches the range of values into which data can be quantized. In the example illustrated in FIG. 7, thus, at block 720, the scaled source data x may be rounded into bins having values between -5 and 2. The range of values between -5 and 2 may allow for the quantization of the source data x into eight bins, which matches the number of bins associated with a 3-bit integer into which the source data x is quantized at block 530.
[0083] FIG. 8 illustrates example operations 800 for executing a function in a computing system using quantization and dequantization of data based on matching endpoints of a range of values for an input to endpoints of a range of quantized values for the input, according to aspects of the present disclosure.
[0084] As illustrated, the operations 800 begin at block 810 with quantizing an input based on matching endpoints of a range of values for the input to endpoints of a range of quantized values for the input.
[0085] In some aspects, quantizing the input may include quantizing the input based on a first scaling factor for negative values of the input and quantizing the input based on a second scaling factor for positive values of the input. In some aspects, the first scaling factor corresponds to a longer side of a signed integer range and wherein the second scaling corresponds to a shorter side of the signed integer range, when a range of negative values of the input exceeds a range of positive values of the input. In some aspects, the first scaling factor corresponds to a shorter side of a signed integer range and wherein the second scaling factor corresponds to a longer side of the signed integer range, when a range of positive values of the input exceeds a range of negative values of the input.
[0086] At block 820, the operations 800 proceed with generating a quantized output of a function based on executing the function using the quantized input.
[0087] In some aspects, the function comprises a machine learning model function. For example, the function may include a model training function in which the machine learning model is trained using quantization-aware techniques. In other examples, the function may include an inferencing function based on quantized input data, which generates a quantized output which can be dequantized prior to performing an action (e.g., generating an inference, taking actions based on the inference, etc. ) .
[0088] At block 830, the operations 800 proceed with dequantizing the quantized output based at least on a scaling factor associated with the quantization of the input.
[0089] In some aspects, the dequantizing is further based on an offset associated with the quantization of the input. The offset may be, for example, an unrounded offset which, as discussed above, allows for increases in the accuracy of the dequantized data vis-à-vis the original source data, while allowing for the representation of dequantized values other than exactly zero.
[0090] At block 840, the operations 800 proceed with taking one or more actions based on the dequantized output. The one or more actions may be similar to those described above with respect to FIG. 2.
[0091] It should be understood that the quantization and dequantization techniques described with respect to FIGs. 1 through 8 may be used alone or in any combination thereof.
[0092] Example Processing System for Execution of Functions Based on Accurate Quantization and Dequantization of Source Data
[0093] FIG. 9 depicts an example processing system 900 configured to perform various aspects of the present disclosure, including, for example, the techniques and methods described with respect to FIGS. 1-8. In some aspects, the processing system 900 may train, implement, or provide a machine learning model which uses quantized data to accelerate operations and perform machine learning model operations using less power than would be used if such operations were performed using non-quantized data. Although depicted as a single system for conceptual clarity, in at least some aspects, as discussed above, the operations described below with respect to the processing system 900 may be distributed across any number of devices.
[0094] The processing system 900 includes a central processing unit (CPU) 902, which in some examples may be a multi-core CPU. Instructions executed at the CPU 902 may be loaded, for example, from a program memory associated with the CPU 902 or may be loaded from a partition of memory 924.
[0095] The processing system 900 also includes additional processing components tailored to specific functions, such as a graphics processing unit (GPU) 904, a digital signal processor (DSP) 906, a neural processing unit (NPU) 908, a multimedia processing unit 910, and a wireless connectivity component 912.
[0096] An NPU, such as NPU 908, is generally a specialized circuit configured for implementing control and arithmetic logic for executing machine learning algorithms, such as algorithms for processing artificial neural networks (ANNs) , deep neural networks (DNNs) , random forests (RFs) , and the like. An NPU may sometimes alternatively be referred to as a neural signal processor (NSP) , tensor processing unit (TPU) , neural network processor (NNP) , intelligence processing unit (IPU) , vision processing unit (VPU) , or graph processing unit.
[0097] NPUs, such as the NPU 908, are configured to accelerate the performance of common machine learning tasks, such as image classification, machine translation, object detection, and various other predictive models. In some examples, a plurality of NPUs may be instantiated on a single chip, such as a system-on-a-chip (SoC) , while in other examples the NPUs may be part of a dedicated neural-network accelerator.
[0098] NPUs may be optimized for training or inference, or in some cases configured to balance performance between both. For NPUs that are capable of performing both training and inference, the two tasks may still generally be performed independently.
[0099] NPUs designed to accelerate training are generally configured to accelerate the optimization of new models, which is a highly compute-intensive operation that involves inputting an existing dataset (often labeled or tagged) , iterating over the dataset, and then adjusting model parameters, such as weights and biases, in order to improve model performance. Generally, optimizing based on a wrong prediction involves propagating back through the layers of the model and determining gradients to reduce the prediction error.
[0100] NPUs designed to accelerate inference are generally configured to operate on complete models. Such NPUs may thus be configured to input a new piece of data and rapidly process this new data through an already trained model to generate a model output (e.g., an inference) .
[0101] In some implementations, the NPU 908 is a part of one or more of the CPU 902, the GPU 904, and / or the DSP 906.
[0102] In some examples, the wireless connectivity component 912 may include subcomponents, for example, for third generation (3G) connectivity, fourth generation (4G) connectivity (e.g., 4G Long-Term Evolution (LTE) ) , fifth generation (5G) connectivity (e.g., New Radio (NR) ) , Wi-Fi connectivity, Bluetooth connectivity, and other wireless transmission standards. The wireless connectivity component 912 is further coupled to one or more antennas 914.
[0103] The processing system 900 may also include one or more sensor processing units 916 associated with any manner of sensor, one or more image signal processors (ISPs) 918 associated with any manner of image sensor, and / or a navigation component 920, which may include satellite-based positioning system components (e.g., GPS or GLONASS) as well as inertial positioning system components.
[0104] The processing system 900 may also include one or more input and / or output devices 922, such as screens, touch-sensitive surfaces (including touch-sensitive displays) , physical buttons, speakers, microphones, and the like.
[0105] In some examples, one or more of the processors of the processing system 900 may be based on an ARM or RISC-V instruction set.
[0106] The processing system 900 also includes the memory 924, which is representative of one or more static and / or dynamic memories, such as a dynamic random access memory, a flash-based static memory, and the like. In this example, the memory 924 includes computer-executable components, which may be executed by one or more of the aforementioned processors of the processing system 900.
[0107] In particular, in this example, the memory 924 includes an input quantizing component 924A, a quantized output generating component 924B, an output dequantizing component 924C, and an action taking component 924D. Though depicted as discrete components for conceptual clarity in FIG. 4, the illustrated components (and others not depicted) may be collectively or individually implemented in various aspects.
[0108] Generally, the processing system 900 and / or components thereof may be configured to perform the methods described herein.
[0109] Notably, in other aspects, aspects of the processing system 900 may be omitted, such as where the processing system 900 is a server computer or the like. For example, the multimedia processing unit 910, the wireless connectivity component 912, the sensor processing units 916, the ISPs 918, and / or the navigation component 920 may be omitted in other aspects. Further, aspects of the processing system 900 may be distributed between multiple devices.
[0110] Example Clauses
[0111] Implementation details of various aspects of the present disclosure are described in the following numbered clauses:
[0112] Clause 1: A processor-implemented method for data quantization, comprising: quantizing an input based on a range of values for the input; generating a quantized output of a function based on executing the function using the quantized input; dequantizing the quantized output based on a scaling factor and an unrounded offset associated with the quantization of the input; and taking one or more actions based on the dequantized output.
[0113] Clause 2: The method of Clause 1, wherein the unrounded offset comprises an unrounded floating-point offset.
[0114] Clause 3: The method of Clause 1 or 2, wherein quantizing the input comprises: quantizing the input based on a first scaling factor for negative values of the input; and quantizing the input based on a second scaling factor for positive values of the input.
[0115] Clause 4: The method of Clause 3, wherein the first scaling factor is a different scaling factor than the second scaling factor.
[0116] Clause 5: The method of Clause 3 or 4, wherein the first scaling factor corresponds to a longer side of a signed integer range and wherein the second scaling corresponds to a shorter side of the signed integer range, when a range of negative values of the input exceeds a range of positive values of the input.
[0117] Clause 6: The method of any of Clauses 3 through 5, wherein the first scaling factor corresponds to a shorter side of a signed integer range and wherein the second scaling factor corresponds to a longer side of the signed integer range, when a range of positive values of the input exceeds a range of negative values of the input.
[0118] Clause 7: The method of any of Clauses 1 through 6, wherein quantizing the input is based on matching endpoints of the range of values for the input to endpoints of a range of quantized values for the input.
[0119] Clause 8: The method of any of Clauses 1 through 7, wherein the function comprises a machine learning model function.
[0120] Clause 9: A processor-implemented method for data quantization, comprising: quantizing an input based on a range of values for the input using a first scaling factor for negative values of the input and a second scaling factor for positive values of the input; generating a quantized output of a function based on executing the function using the quantized input; dequantizing the quantized output based at least on a scaling factor associated with the quantization of the input; and taking one or more actions based on the dequantized output.
[0121] Clause 10: The method of Clause 9, wherein the input is quantized using the first scaling factor and the second scaling factor over a valid range of values associated with a bit width of a data type into which the input is quantized.
[0122] Clause 11: The method of Clause 9 or 10, wherein the first scaling factor is a different scaling factor than the second scaling factor.
[0123] Clause 12: The method of any of Clauses 9 through 11, wherein the first scaling factor corresponds to a longer side of a signed integer range and wherein the second scaling corresponds to a shorter side of the signed integer range, when a range of negative values of the input exceeds a range of positive values of the input.
[0124] Clause 13: The method of any of Clauses 9 through 12, wherein the first scaling factor corresponds to a shorter side of a signed integer range and wherein the second scaling factor corresponds to a longer side of the signed integer range, when a range of positive values of the input exceeds a range of negative values of the input.
[0125] Clause 14: The method of any of Clauses 9 through 13, wherein the dequantizing is further based on an offset associated with the quantization of the input.
[0126] Clause 15: The method of any of Clauses 9 through 14, wherein quantizing the input is further based on matching endpoints of the range of values for the input to endpoints of a range of quantized values for the input.
[0127] Clause 16: The method of any of Clauses 9 through 15, wherein the function comprises a machine learning model function.
[0128] Clause 17: A processor-implemented method for data quantization, comprising: quantizing an input based on a range of values for the input using a first scaling factor for a first set of values of the input and using a second scaling factor for a second set of values of the input, wherein the first scaling factor corresponds to a longer side of a signed integer range and wherein the second scaling factor corresponds to a shorter side of the signed integer range; generating a quantized output of a function based on executing the function using the quantized input; dequantizing the quantized output based at least on a scaling factor associated with the quantization of the input; and taking one or more actions based on the dequantized output.
[0129] Clause 18: The method of Clause 17, wherein the first scaling factor is a scaling factor for negative values of the input, and wherein the second scaling factor is a scaling factor for positive values of the input.
[0130] Clause 19: The method of Clause 17 or 18, wherein the input is quantized using the first scaling factor and the second scaling factor over a valid range of values associated with a bit width of a data type into which the input is quantized.
[0131] Clause 20: The method of any of Clauses 17 through 19, wherein the offset associated with the quantization of the input comprises an unrounded offset.
[0132] Clause 21: The method of any of Clauses 17 through 20, wherein quantizing the input is further based on matching endpoints of the range of values for the input to endpoints of a range of quantized values for the input.
[0133] Clause 22: The method of any of Clauses 17 through 21, wherein the function comprises a machine learning model function.
[0134] Clause 23: A processor-implemented method for data quantization, comprising: quantizing an input based on matching endpoints of a range of values for the input to endpoints of a range of quantized values for the input; generating a quantized output of a function based on executing the function using the quantized input; dequantizing the quantized output based at least on a scaling factor associated with the quantization of the input; and taking one or more actions based on the dequantized output.
[0135] Clause 24: The method of Clause 23, wherein the dequantizing is further based on an offset associated with the quantization of the input.
[0136] Clause 25: The method of Clause 23 or 24, wherein quantizing the input comprises: quantizing the input based on a first scaling factor for negative values of the input; and quantizing the input based on a second scaling factor for positive values of the input.
[0137] Clause 26: The method of Clause 25, wherein the first scaling factor corresponds to a longer side of a signed integer range and wherein the second scaling corresponds to a shorter side of the signed integer range, when a range of negative values of the input exceeds a range of positive values of the input.
[0138] Clause 27: The method of Clause 25 or 26, wherein the first scaling factor corresponds to a shorter side of a signed integer range and wherein the second scaling factor corresponds to a longer side of the signed integer range, when a range of positive values of the input exceeds a range of negative values of the input.
[0139] Clause 28: The method of any of Clauses 23 through 27, wherein the function comprises a machine learning model function.
[0140] Clause 29: A processing system comprising: a memory comprising computer-executable instructions; and one or more processors configured to execute the computer-executable instructions and cause the processing system to perform a method in accordance with any of Clauses 1 through 28.
[0141] Clause 30: A processing system comprising means for performing a method in accordance with any of Clauses 1 through 28.
[0142] Clause 31: A non-transitory computer-readable medium comprising computer-executable instructions that, when executed by one or more processors of a processing system, cause the processing system to perform a method in accordance with any of Clauses 1 through 28.
[0143] Clause 32: A computer program product embodied on a computer-readable storage medium comprising code for performing a method in accordance with any of Clauses 1 through 28.
[0144] Additional Considerations
[0145] The preceding description is provided to enable any person skilled in the art to practice the various aspects described herein. The examples discussed herein are not limiting of the scope, applicability, or aspects set forth in the claims. Various modifications to these aspects will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other aspects. For example, changes may be made in the function and arrangement of elements discussed without departing from the scope of the disclosure. Various examples may omit, substitute, or add various procedures or components as appropriate. For instance, the methods described may be performed in an order different from that described, and various steps may be added, omitted, or combined. Also, features described with respect to some examples may be combined in some other examples. For example, an apparatus may be implemented or a method may be practiced using any number of the aspects set forth herein. In addition, the scope of the disclosure is intended to cover such an apparatus or method that is practiced using other structure, functionality, or structure and functionality in addition to, or other than, the various aspects of the disclosure set forth herein. It should be understood that any aspect of the disclosure disclosed herein may be embodied by one or more elements of a claim.
[0146] As used herein, the word “exemplary” means “serving as an example, instance, or illustration. ” Any aspect described herein as “exemplary” is not necessarily to be construed as preferred or advantageous over other aspects.
[0147] As used herein, a phrase referring to “at least one of” a list of items refers to any combination of those items, including single members. As an example, “at least one of: a, b, or c” is intended to cover a, b, c, a-b, a-c, b-c, and a-b-c, as well as any combination with multiples of the same element (e.g., a-a, a-a-a, a-a-b, a-a-c, a-b-b, a-c-c, b-b, b-b-b, b-b-c, c-c, and c-c-c or any other ordering of a, b, and c) .
[0148] As used herein, the term “determining” encompasses a wide variety of actions. For example, “determining” may include calculating, computing, processing, deriving, investigating, looking up (e.g., looking up in a table, a database or another data structure) , ascertaining, and the like. Also, “determining” may include receiving (e.g., receiving information) , accessing (e.g., accessing data in a memory) , and the like. Also, “determining” may include resolving, selecting, choosing, establishing, and the like.
[0149] The methods disclosed herein comprise one or more steps or actions for achieving the methods. The method steps and / or actions may be interchanged with one another without departing from the scope of the claims. In other words, unless a specific order of steps or actions is specified, the order and / or use of specific steps and / or actions may be modified without departing from the scope of the claims. Further, the various operations of methods described above may be performed by any suitable means capable of performing the corresponding functions. The means may include various hardware and / or software component (s) and / or module (s) , including, but not limited to a circuit, an application specific integrated circuit (ASIC) , or processor. Generally, where there are operations illustrated in figures, those operations may have corresponding counterpart means-plus-function components with similar numbering.
[0150] The following claims are not intended to be limited to the aspects shown herein, but are to be accorded the full scope consistent with the language of the claims. Within a claim, reference to an element in the singular is not intended to mean “one and only one” unless specifically so stated, but rather “one or more. ” Unless specifically stated otherwise, the term “some” refers to one or more. No claim element is to be construed under the provisions of 35 U.S.C. § 112 (f) unless the element is expressly recited using the phrase “means for” or, in the case of a method claim, the element is recited using the phrase “step for. ” All structural and functional equivalents to the elements of the various aspects described throughout this disclosure that are known or later come to be known to those of ordinary skill in the art are expressly incorporated herein by reference and are intended to be encompassed by the claims. Moreover, nothing disclosed herein is intended to be dedicated to the public regardless of whether such disclosure is explicitly recited in the claims.
Claims
1.A processor-implemented method for data quantization, comprising:quantizing an input based on a range of values for the input;generating a quantized output of a function based on executing the function using the quantized input;dequantizing the quantized output based on a scaling factor and an unrounded offset associated with the quantization of the input; andtaking one or more actions based on the dequantized output.2.The method of Claim 1, wherein the unrounded offset comprises an unrounded floating-point offset.3.The method of Claim 1, wherein quantizing the input comprises:quantizing the input based on a first scaling factor for negative values of the input; andquantizing the input based on a second scaling factor for positive values of the input.4.The method of Claim 3, wherein the first scaling factor is a different scaling factor than the second scaling factor.5.The method of Claim 3, wherein the first scaling factor corresponds to a longer side of a signed integer range and wherein the second scaling corresponds to a shorter side of the signed integer range, when a range of negative values of the input exceeds a range of positive values of the input.6.The method of Claim 3, wherein the first scaling factor corresponds to a shorter side of a signed integer range and wherein the second scaling factor corresponds to a longer side of the signed integer range, when a range of positive values of the input exceeds a range of negative values of the input.7.The method of Claim 1, wherein quantizing the input is based on matching endpoints of the range of values for the input to endpoints of a range of quantized values for the input.8.The method of Claim 1, wherein the function comprises a machine learning model function.9.A processor-implemented method for data quantization, comprising:quantizing an input based on a range of values for the input using a first scaling factor for negative values of the input and a second scaling factor for positive values of the input;generating a quantized output of a function based on executing the function using the quantized input;dequantizing the quantized output based at least on a scaling factor associated with the quantization of the input; andtaking one or more actions based on the dequantized output.10.The method of Claim 9, wherein the input is quantized using the first scaling factor and the second scaling factor over a valid range of values associated with a bit width of a data type into which the input is quantized.11.The method of Claim 9, wherein the first scaling factor is a different scaling factor than the second scaling factor.12.The method of Claim 9, wherein the first scaling factor corresponds to a longer side of a signed integer range and wherein the second scaling corresponds to a shorter side of the signed integer range, when a range of negative values of the input exceeds a range of positive values of the input.13.The method of Claim 9, wherein the first scaling factor corresponds to a shorter side of a signed integer range and wherein the second scaling factor corresponds to a longer side of the signed integer range, when a range of positive values of the input exceeds a range of negative values of the input.14.The method of Claim 9, wherein the dequantizing is further based on an offset associated with the quantization of the input.15.The method of Claim 9, wherein quantizing the input is further based on matching endpoints of the range of values for the input to endpoints of a range of quantized values for the input.16.The method of Claim 9, wherein the function comprises a machine learning model function.17.A processor-implemented method for data quantization, comprising:quantizing an input based on a range of values for the input using a first scaling factor for a first set of values of the input and using a second scaling factor for a second set of values of the input, wherein the first scaling factor corresponds to a longer side of a signed integer range and wherein the second scaling factor corresponds to a shorter side of the signed integer range;generating a quantized output of a function based on executing the function using the quantized input;dequantizing the quantized output based at least on a scaling factor associated with the quantization of the input; andtaking one or more actions based on the dequantized output.18.The method of Claim 17, wherein the first scaling factor is a scaling factor for negative values of the input, and wherein the second scaling factor is a scaling factor for positive values of the input.19.The method of Claim 17, wherein the input is quantized using the first scaling factor and the second scaling factor over a valid range of values associated with a bit width of a data type into which the input is quantized.20.The method of Claim 17, wherein the offset associated with the quantization of the input comprises an unrounded offset.21.The method of Claim 17, wherein quantizing the input is further based on matching endpoints of the range of values for the input to endpoints of a range of quantized values for the input.22.The method of Claim 17, wherein the function comprises a machine learning model function.23.A processor-implemented method for data quantization, comprising:quantizing an input based on matching endpoints of a range of values for the input to endpoints of a range of quantized values for the input;generating a quantized output of a function based on executing the function using the quantized input;dequantizing the quantized output based at least on a scaling factor associated with the quantization of the input; andtaking one or more actions based on the dequantized output.24.The method of Claim 23, wherein the dequantizing is further based on an offset associated with the quantization of the input.25.The method of Claim 23, wherein quantizing the input comprises:quantizing the input based on a first scaling factor for negative values of the input; andquantizing the input based on a second scaling factor for positive values of the input.26.The method of Claim 25, wherein the first scaling factor corresponds to a longer side of a signed integer range and wherein the second scaling corresponds to a shorter side of the signed integer range, when a range of negative values of the input exceeds a range of positive values of the input.27.The method of Claim 25, wherein the first scaling factor corresponds to a shorter side of a signed integer range and wherein the second scaling factor corresponds to a longer side of the signed integer range, when a range of positive values of the input exceeds a range of negative values of the input.28.The method of Claim 23, wherein the function comprises a machine learning model function.
Citation Information
Patent Citations
Accelerated quantized multiply-and-add operations
CN111937010A
Optimizing low precision inference models for deployment of deep neural networks
CN115053230A
Systems and methods for asymmetrical scaling factor support for negative and positive values
US20210012202A1
Learned step size quantization
US20210264279A1