Deep learning model quantification precision improvement method

By introducing a precision compensation layer and pseudo-quantization nodes into the deep learning model, the problem of precision loss during quantization is solved, enabling efficient deployment and precision improvement of the model on hardware-constrained devices.

CN121809569APending Publication Date: 2026-04-07OMNIVISION TECH (SHANGHAI) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-16
Publication Date
2026-04-07

AI Technical Summary

Technical Problem

Deep learning models suffer from accuracy loss during quantization, making them difficult to deploy and maintain efficient operation on devices with limited hardware storage space.

Method used

A precision compensation layer is used to compensate for the quantization precision of the deep learning model after training. The model accuracy is improved by increasing the quantization bit width, and pseudo-quantization nodes are added to the model for compensation training. The precision compensation layer is constructed to reduce quantization error.

Benefits of technology

It improves the quantization accuracy of deep learning models, reduces storage resource consumption, and enhances the ability to deploy models on hardware-constrained devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121809569A_ABST
    Figure CN121809569A_ABST
Patent Text Reader

Abstract

The invention provides a deep learning model quantification precision improvement method. The method comprises the following steps: providing a deep learning model in a high-precision data format; a precision compensation layer is adopted to carry out quantized precision compensation after training and / or quantized perception training precision compensation on the deep learning model; the quantization bit width in the precision compensation layer is greater than the quantization bit width of a target layer and / or a target block in the deep learning model; and outputting a final quantitative model after compensation. According to the invention, the deep learning model is subjected to quantized precision compensation after training and / or quantized precision compensation of perceptual training. The quantization bit width in the precision compensation layer is larger than the quantization bit width of the target layer and / or the target block in the deep learning model, so that the precision of the deep learning model is improved, and the deep learning model is lighter.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of computer technology, specifically relating to a method for improving the quantization accuracy of deep learning models. Background Technology

[0002] Deploying deep learning models on mobile devices breaks through the limitations of traditional cloud computing, enabling more efficient, secure, and universally applicable intelligent services through localized processing. Specifically, this manifests in: 1. Offline availability: continuous service capability even without a network connection; 2. Enhanced data privacy and security: sensitive data (such as personal conversations and location information) is processed directly on the device, avoiding uploads to cloud servers and significantly reducing the risk of data leakage; 3. Low-latency, real-time interactive experience: local DSP / NPU (neural network processor) is optimized for AI tasks, offering 3-5 times better energy efficiency compared to traditional CPUs / GPUs.

[0003] Because deep learning models involve a large amount of computation and parameters, they are difficult to deploy directly on mobile devices. They need to be compressed and quantized before deployment. Similarly, when deep learning models (neural network models) are executed on hardware (such as AI chips), they are limited by the hardware's storage space. Quantizing the neural network helps reduce the consumption of hardware storage resources during neural network processing and improves processing speed. However, quantization causes a certain degree of accuracy loss in deep learning models, therefore, it is necessary to improve quantization accuracy. Summary of the Invention

[0004] The purpose of this invention is to provide a method for improving the quantization accuracy of deep learning models, which involves precision compensation for quantization after training and / or precision compensation for quantization-aware training of the deep learning model; the quantization bit width in the precision compensation layer is greater than the quantization bit width of the target layer and / or target block in the deep learning model, thereby improving the accuracy of the deep learning model and making it more lightweight.

[0005] This invention provides a method for improving the quantization accuracy of deep learning models, comprising:

[0006] Provides deep learning models with high-precision data formats;

[0007] The precision compensation layer is used to perform precision compensation for quantization after training the deep learning model and / or precision compensation for quantization-aware training; the quantization bit width in the precision compensation layer is greater than the quantization bit width of the target layer and / or target block in the deep learning model.

[0008] The final quantization model is output after compensation.

[0009] Furthermore, the accuracy compensation layer is lighter and has a shallower network compared to the target layer and / or the target block.

[0010] Furthermore, in the precision compensation of the quantization perception training, the input port of the target layer and / or the target block is used as a reference, and then pseudo-quantization nodes are added inside the target layer and / or the target block. The precision compensation layer is used to perform compensation training on the pseudo-quantization nodes; the corresponding precision compensation layer is built; after the compensation training converges, the final quantization model is output.

[0011] Furthermore, in the precision compensation of post-training quantization, the precision compensation layer adopts a linear compensation layer.

[0012] Furthermore, the final output of the target layer and / or the target block and the final output bit width of the precision compensation layer are kept consistent; the final output of the target layer and / or the target block and the final output of the precision compensation layer are fused using an additive fusion or a dot-multiplicative fusion method to obtain the compensated output corresponding to the pseudo-quantization node.

[0013] Furthermore, if the compensation object is the target layer and / or the target block, then the deployment processor in the accuracy compensation layer is consistent with the target layer and / or the target block;

[0014] If the compensation target is the entire deep learning model, that is, to add a target layer or target block to the entire deep learning model, then the deployment processor in the precision compensation layer is a heterogeneous core with a higher bit width.

[0015] Furthermore, the quantization bit width of the weights in the precision compensation layer is greater than or equal to the quantization bit width of the weights in the target layer and / or target block; the quantization bit width of the activation values ​​in the precision compensation layer is greater than or equal to the quantization bit width of the activation values ​​in the target layer and / or target block.

[0016] Furthermore, the quantization bit width of the target layer and / or target block corresponds to at least one of the multiple quantization bit widths of the weights in the precision compensation layer, and also corresponds to at least one of the multiple quantization bit widths of the activation values ​​in the precision compensation layer.

[0017] Furthermore, regarding the selection of various quantization bit widths for the precision compensation layer, a greedy algorithm is used to evaluate and determine the most suitable high-bit quantization bit width configuration while minimizing computational load and memory usage, based on the premise of improving quantization accuracy.

[0018] The value of various quantization bit width combinations in improving quantization accuracy is evaluated. If the accuracy is not improved, the corresponding quantization bit width is deleted. Based on improving quantization accuracy, the lowest quantization bit width is selected.

[0019] Furthermore, the layers in the accuracy compensation layer include at least one of the following: a fully connected layer, a convolutional layer, an activation layer, a pooling layer, and a batch normalization layer.

[0020] Compared with the prior art, the present invention has the following beneficial effects:

[0021] This invention provides a method for improving the quantization accuracy of a deep learning model, comprising: providing a deep learning model with a high-precision data format; employing a precision compensation layer to perform precision compensation for quantization after training the deep learning model and / or precision compensation for quantization-aware training; wherein the quantization bit width in the precision compensation layer is greater than the quantization bit width of the target layer and / or target block in the deep learning model;

[0022] The final quantized model is output after compensation. This invention improves the accuracy of the deep learning model by performing precision compensation on quantization after training and / or precision compensation on quantization-aware training. The quantization bit width in the precision compensation layer is larger than the quantization bit width of the target layer and / or target block in the deep learning model, thereby making the deep learning model more lightweight. Attached Figure Description

[0023] Figure 1 This is a schematic diagram of a method for improving the quantization accuracy of a deep learning model according to an embodiment of the present invention.

[0024] Figure 2 This is a schematic diagram of the precision compensation layer in the deep learning model quantization precision improvement method according to an embodiment of the present invention.

[0025] Figure 3 This is a schematic diagram illustrating the accuracy compensation principle in the deep learning model quantization accuracy improvement method according to an embodiment of the present invention.

[0026] Figure 4 These are two example schematic diagrams illustrating precision compensation in the deep learning model quantization precision improvement method of this invention.

[0027] Figure 5 This diagram illustrates the multiple quantization bit widths of weights and multiple quantization bit widths of activation values ​​in the precision compensation layer corresponding to different quantization bit widths of the target layer / block in the deep learning model quantization precision improvement method of this invention.

[0028] Figure 6 This is a schematic diagram of the overall accuracy compensation in the deep learning model quantization accuracy improvement method according to an embodiment of the present invention.

[0029] In the attached figures, the reference numerals are: 10 - target layer and / or target block; 20 - accuracy compensation layer. Detailed Implementation

[0030] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. The advantages and features of the present invention will become clearer from the following description. It should be noted that the drawings are in a very simplified form and use non-precise proportions, and are only used to facilitate and clarify the illustration of the embodiments of the present invention.

[0031] For ease of description, some embodiments of this application may use spatially relative terms such as “above,” “below,” “top,” and “under” to describe the relationship between one element or component and another (or more) elements or components as shown in the accompanying drawings. It should be understood that, in addition to the orientations described in the drawings, spatially relative terms are also intended to include different orientations of the device during use or operation. For example, if the device in the drawings is flipped, it is described as an element or component “below” or “under” other elements or components, and will subsequently be positioned “above” or “on” other elements or components. The terms “first,” “second,” etc., used below are used to distinguish between similar elements and are not necessarily used to describe a particular order or temporal sequence. It should be understood that these terms, as used, may be replaced where appropriate.

[0032] This invention provides a method for improving the quantization accuracy of deep learning models, such as... Figure 1 As shown, it includes:

[0033] S1. Provides deep learning models with high-precision data formats;

[0034] S2. Precision compensation for quantization after training of the deep learning model using a precision compensation layer and / or precision compensation for quantization-aware training; the quantization bit width in the precision compensation layer is greater than the quantization bit width of the target layer and / or target block in the deep learning model.

[0035] S3, Output the final quantization model after compensation.

[0036] The steps of the method for improving the quantization accuracy of deep learning models according to embodiments of the present invention are described in detail below with reference to the accompanying drawings.

[0037] Step S1: Provide a deep learning model with high-precision data format. For example, a deep learning model might be in 32-bit floating-point (FP32) format. The parameters in a deep network model are high-precision floating-point numbers. To reduce model size, improve inference speed, and reduce memory and power consumption, they need to be converted to low-precision values. Quantization is the process of representing continuous or high-precision values ​​(such as FP32) in the model using lower-precision, discrete values ​​(such as INT8, INT4). Essentially, it's an information compression technique that reduces the number of bits required to represent each value, thus shrinking the model. Compression reduces model storage size and memory usage. Quantization is one of the most important and effective means of model compression. Quantization is a lossy process; mapping high-precision numbers to low-precision numbers introduces quantization errors, inevitably leading to a decrease in model accuracy. Therefore, the higher the compression ratio (e.g., from INT8 to INT4), the greater the risk of accuracy loss.

[0038] Step S2: Apply a precision compensation layer to the deep learning model for precision compensation after training quantization and / or precision compensation during quantization-aware training; the quantization bit width in the precision compensation layer is greater than the quantization bit width of the target layer and / or target block in the deep learning model. Post-training quantization (PTQ) and quantization-aware training (QAT) are two mainstream model quantization techniques. Post-training quantization (PTQ) performs quantization directly after the deep learning model has been trained, without the need for retraining. Post-training quantization directly adjusts weights and activation values ​​using calibration data.

[0039] In precision compensation during quantization-aware training, the input ports of the target layer and / or target block serve as the baseline. Then, pseudo-quantization nodes are added within the target layer and / or target block, and a precision compensation layer is used for compensation training on these pseudo-quantization nodes. The corresponding precision compensation layer is then constructed. After the compensation training converges, the final quantization model is output. Pseudo-quantization nodes are a technique used in quantization-aware training to simulate quantization errors during the training phase.

[0040] In the precision compensation of post-training quantization, the precision compensation layer can be a linear compensation layer, or other forms of compensation.

[0041] The precision compensation layer provides high precision for small modules. Higher compensation precision is achieved when the quantization bit width in the precision compensation layer is greater than the quantization bit width of the target layer and / or target block in the deep learning model. Even when the quantization bit width in the precision compensation layer is less than or equal to the quantization bit width of the target layer and / or target block in the deep learning model, the compensation effect is still limited.

[0042] Quantization-aware training simulates quantization effects during the forward propagation of model training, allowing the model to "learn" to adapt to low-precision representations during training. Quantization-aware training introduces quantization error simulation techniques into the model training phase, optimizing model parameters to adapt to low-precision computing environments, thereby reducing precision loss during inference. Different precisions (bit widths) can be used for different layers or modules in quantization-aware training and deployment inference. Quantization is an extremely effective compression technique that can significantly reduce model size and accelerate inference, enabling deployment on resource-constrained edge devices.

[0043] In deep learning models, layers and blocks are two core concepts in building neural networks, differing in granularity and functional focus. A layer is the most basic computational unit in a neural network, responsible for implementing specific mathematical operations and feature extraction, such as fully connected layers, convolutional layers (Conv2d), activation layers (ReLU), pooling layers, and batch normalization layers (BatchNorm2d). It has a single function, typically performing only one specific computation, such as a linear transformation or activation function. A block, on the other hand, is a macroscopic module composed of multiple layers, representing a further abstraction and encapsulation of these layers. It focuses more on combining multiple layers to achieve a specific structure or function, solving specific problems, or meeting specific performance requirements. Examples of blocks include residual blocks, and the EncoderBlock and Decoder Block in Transformers. Relationally, a block is composed of layers; multiple layers combined according to certain rules form a block. In programming implementation, layers and blocks in frameworks like PyTorch typically inherit from the `nn.Module` base class, thus maintaining consistency in their interfaces. This design allows blocks to be reused and combined like "super layers," thereby building complex network architectures.

[0044] like Figure 2 and Figure 3As shown, the precision compensation layer includes at least one of the following: fully connected layer, convolutional layer, activation layer, pooling layer, and batch normalization layer. Precision compensation layer 20 is lighter and shallower than the target layer and / or target block 10. The input port of the target layer and / or target block 10 is a pseudo-quantization node, and a corresponding precision compensation layer is built using it; for example, a precision compensation layer can be built using convolutional layers and ReLU activation layers. In precision compensation layer 30, the quantization bit width x2 of the weight W is greater than or equal to the quantization bit width x1 of the weight W in the target layer and / or target block 10; the quantization bit width y2 of the activation value A in precision compensation layer 20 is greater than or equal to the quantization bit width y1 of the activation value A in the target layer and / or target block 10. The number of floating-point operations is a core indicator for measuring the computational complexity of an AI model, referring to the number of floating-point operations required to complete one forward propagation, used for quantization algorithm / model computation. The number of floating-point operations of the precision compensation layer 20 is less than or equal to the product of the number of floating-point operations of the target layer and / or the target block 10 and the coefficient, with the coefficient value being, for example, 0.1.

[0045] like Figure 3 and Figure 4 As shown, the final output of the target layer and / or target block 10 and the final output of the precision compensation layer 20 have the same bit width. This facilitates the fusion of the final output of the target layer and / or target block 10 and the final output of the precision compensation layer 20 using methods such as additive fusion or dot-multiplicative fusion to obtain the compensated output corresponding to the pseudo-quantized node. The target layer and / or target block 10 is quantized using two parameters: weight W and activation value A, and the bit width of activation value A is greater than or equal to the bit width of weight W.

[0046] Figure 4 Two examples of accuracy compensation in the deep learning model quantization accuracy improvement method of this embodiment of the invention are shown. Figure 4 In the example on the left, the weight W of the target layer and / or target block 10 has a bit width of 4, and the activation value A has a bit width of 8; the weight W of the precision compensation layer 20 has a bit width of, for example, 8, and the activation value A has a bit width of 16. The final output bit width of the target layer and / or target block 10 and the final output bit width of the precision compensation layer 20 are consistent, for example, both are 16; after the two are fused by addition fusion or dot product fusion or other methods, the compensated output bit width of the pseudo-quantized node is also 16. Figure 4 In the example on the right, the weight W of the target layer and / or target block 10 has a bit width of 4, and the activation value A has a bit width of 8; the weight W of the precision compensation layer 20 has a bit width of, for example, 8, and the activation value A has a bit width of 8. The final output bit width of the target layer and / or target block 10 and the final output bit width of the precision compensation layer 20 are consistent, for example, both are 8; after the two are fused by addition fusion or dot product fusion or other methods, the compensated output bit width of the pseudo-quantized node is also 8.

[0047] like Figure 5As shown, the precision compensation layer and / or precision compensation block correspond to multiple high-precision options relative to the target layer and / or target block. The quantization bit width of one target layer and / or target block corresponds to at least one of multiple quantization bit widths for the weights in the precision compensation layer, and also corresponds to at least one of multiple quantization bit widths for the activation values ​​in the precision compensation layer. Quantization precision is equivalent to quantization bit width. The quantization bit width of the weight W in the precision compensation layer is greater than or equal to the quantization bit width of the weight W in the target layer and / or target block; the quantization bit width of the activation value A in the precision compensation layer is greater than or equal to the quantization bit width of the activation value A in the target layer and / or target block. For example, when the quantization precision of the target layer and / or target block is INT8, the weights in the corresponding precision compensation layer use any one of FP32, FP16, INT16, and FP16, and the activation values ​​in the corresponding precision compensation layer use any one of FP32, FP16, INT16, and FP16, where FP represents a floating-point number, INT represents an integer, and the numbers after FP and INT represent the bit width.

[0048] like Figure 6 As shown, regarding the selection of various quantization bit widths for the precision compensation layer, a greedy algorithm is used to evaluate the optimal high-bit quantization bit width configuration while minimizing multiply-accumulate operations and memory usage, based on the goal of improving quantization accuracy. The algorithm evaluates the value of each quantization bit width combination in improving quantization accuracy; if accuracy is not improved, the corresponding quantization bit width is deleted. Based on improving quantization accuracy, the lowest quantization bit width is selected at the cost of multiply-accumulate operations (computational efficiency) / memory usage (storage efficiency). If the compensation target is the target layer and / or target block, the deployment processor (e.g., DSP) in the precision compensation layer is the same as that of the target layer and / or target block. If the compensation target is the entire deep learning model, i.e., adding a target layer or target block to the entire deep learning model, the deployment processor in the precision compensation layer can be a heterogeneous core, such as a GPU / CPU; a higher bit width can be used to ensure higher compensation accuracy.

[0049] The quantization-aware training method includes: a. Performing quantization-aware training and recording the value of the loss function; b. Constructing precision compensation layers in stages from top to bottom of the network, freezing all other layers except the precision compensation layer constructed in this step, performing quantization-aware training again, recording the loss value of the loss function, and comparing it with the previous value. If there is an improvement, it indicates that the constructed precision compensation layer is effective; c. Continue with b.

[0050] This invention provides a quantization solution for lightweight model deployment, which can improve model accuracy. This method allows deep learning models to be deployed in NPU edge products (such as image sensor products with integrated NPUs), achieving lighter models and higher accuracy. Examples of model applications include integrating eye tracking, simultaneous localization and mapping (SLT), image enhancement, and video stabilization into the NPU.

[0051] In summary, this invention provides a method for improving the quantization accuracy of a deep learning model, comprising: providing a deep learning model with a high-precision data format; performing precision compensation for post-training quantization and / or quantization-aware training using a precision compensation layer; wherein the quantization bit width in the precision compensation layer is greater than the quantization bit width of the target layer and / or target block in the deep learning model; and outputting the final quantized model after compensation. This invention improves the accuracy of the deep learning model and makes it more lightweight by performing precision compensation for post-training quantization and / or quantization-aware training on the deep learning model, and by ensuring that the quantization bit width in the precision compensation layer is greater than the quantization bit width of the target layer and / or target block in the deep learning model.

[0052] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. The methods disclosed in the embodiments are described simply because they correspond to the devices disclosed in the embodiments; relevant details can be found in the method section.

[0053] The above description is merely a description of preferred embodiments of the present invention and is not intended to limit the scope of the present invention. Any person skilled in the art can make possible changes and modifications to the technical solutions of the present invention by utilizing the methods and techniques disclosed above without departing from the spirit and scope of the present invention. Therefore, any simple modifications, equivalent changes and alterations made to the above embodiments based on the technical essence of the present invention without departing from the content of the technical solutions of the present invention shall fall within the protection scope of the technical solutions of the present invention.

Claims

1. A method for improving the quantization accuracy of deep learning models, characterized in that, include: Provides deep learning models with high-precision data formats; The precision compensation layer is used to perform precision compensation for quantization after training the deep learning model and / or precision compensation for quantization-aware training; the quantization bit width in the precision compensation layer is greater than the quantization bit width of the target layer and / or target block in the deep learning model. The final quantization model is output after compensation.

2. The method for improving the quantization accuracy of deep learning models as described in claim 1, characterized in that, The accuracy compensation layer is lighter and has a shallower network compared to the target layer and / or the target block.

3. The method for improving the quantization accuracy of deep learning models as described in claim 1, characterized in that, In the precision compensation of the quantization perception training, the input port of the target layer and / or the target block is used as a reference. Then, pseudo-quantization nodes are added inside the target layer and / or the target block, and the precision compensation layer is used to perform compensation training on the pseudo-quantization nodes; the corresponding precision compensation layer is built. The final quantization model is output after the compensation training converges.

4. The method for improving the quantization accuracy of deep learning models as described in claim 1, characterized in that, In the precision compensation of post-training quantization, the precision compensation layer adopts a linear compensation layer.

5. The method for improving the quantization accuracy of deep learning models as described in claim 1, characterized in that, The final output of the target layer and / or the target block has the same bit width as the final output of the precision compensation layer; the final output of the target layer and / or the target block and the final output of the precision compensation layer are fused using an additive fusion or a dot-multiplicative fusion method to obtain the compensated output corresponding to the pseudo-quantization node.

6. The method for improving the quantization accuracy of deep learning models as described in claim 1, characterized in that, If the compensation object is the target layer and / or the target block, then the deployment processor in the accuracy compensation layer is the same as the target layer and / or the target block; If the compensation target is the entire deep learning model, that is, to add a target layer or target block to the entire deep learning model, then the deployment processor in the precision compensation layer is a heterogeneous core with a higher bit width.

7. The method for improving the quantization accuracy of deep learning models as described in claim 1, characterized in that, The quantization bit width of the weights in the precision compensation layer is greater than or equal to the quantization bit width of the weights in the target layer and / or target block; the quantization bit width of the activation values ​​in the precision compensation layer is greater than or equal to the quantization bit width of the activation values ​​in the target layer and / or target block.

8. The method for improving the quantization accuracy of deep learning models as described in claim 7, characterized in that, The quantization bit width of the target layer and / or target block corresponds to at least one of multiple quantization bit widths of the weights in the precision compensation layer, and also corresponds to at least one of multiple quantization bit widths of the activation values ​​in the precision compensation layer.

9. The method for improving the quantization accuracy of deep learning models as described in claim 8, characterized in that, Regarding the selection of various quantization bit widths for the precision compensation layer, a greedy algorithm is used to evaluate and determine the most suitable high-bit quantization bit width configuration while minimizing computational complexity and memory usage, based on the premise of improving quantization accuracy. The value of various quantization bit width combinations in improving quantization accuracy is evaluated. If the accuracy is not improved, the corresponding quantization bit width is deleted. Based on improving quantization accuracy, the lowest quantization bit width is selected.

10. The method for improving the quantization accuracy of deep learning models as described in claim 1, characterized in that, The layers in the accuracy compensation layer include at least one of the following: a fully connected layer, a convolutional layer, an activation layer, a pooling layer, and a batch normalization layer.