Method and apparatus for quantizing weights of neural network model

WO2026178860A1PCT designated stage Publication Date: 2026-09-03ROBERT BOSCH GMBH +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2025/079906
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Filing Date
2025-02-28
Publication Date
2026-09-03

Smart Images

  • Figure CN2025079906_03092026_PF_FP_ABST
    Figure CN2025079906_03092026_PF_FP_ABST
Patent Text Reader

Abstract

The present disclosure provides a computer implemented method for quantizing weights of a neural network (NN) model, comprising: quantizing a first set of weights of the NN model into a second set of weights; computing at least one sensitivity metrics based on performances of the NN model with the first set of weights and the second set of weights; selecting a third set of weights from the first set of weights based on the at least one sensitivity metrics; and determining a fourth set of weights for representation of the third set of weights, wherein the fourth set of weights is of a first precision higher than a second precision of the second set of weights.
Need to check novelty before this filing date? Find Prior Art

Description

METHOD AND APPARATUS FOR QUANTIZING WEIGHTS OF NEURAL NETWORK MODELFIELD

[0001] Aspects of the present disclosure relate generally to artificial intelligence (AI) , and more particularly, to method and apparatus for quantizing weights of a neural network (NN) model.BACKGROUND

[0002] Neural network (NN) models (e.g., large language models (LLMs) ) have become integral to various applications, including natural language processing and complex reasoning tasks. However, these models often demand substantial computational resources and memory, leading to elevated operational costs. To address these challenges, existing techniques have employed post-training quantization (PTQ) methods that compress the weights of pre-trained models, thereby reducing model size and conserving bandwidth during deployment.

[0003] Despite these advantages, quantization can introduce errors that significantly degrade model performance, affecting accuracy and capabilities in language expression, mathematical computations, and logical reasoning, and so on. For example, traditional post-training quantization (PTQ) methods simply convert high-precision weights into lower-precision representations indiscriminately. As a result, the quantization process is relatively coarse, often leading to a significant degradation in model performance, since critical weights that have a greater impact on model accuracy may be improperly quantized, causing a noticeable decline in the model’s capabilities.

[0004] Therefore, there is a need for an improved quantization method and system that selectively processes quantized weights to enhance model performance while maintaining compression efficiency.SUMMARY

[0005] The following summary is provided to introduce certain concepts of the selection in a simplified manner. These concepts will be further described in the detailed description that follows. This summary is not intended to highlight key or essential features of the claimed subject matter, nor is it intended to limit the scope of the claimed subject matter.

[0006] Based on the above problems, the present application provides a novel computer implemented method, and correspondingly a novel system, for quantizing weights of a NN model. With the methods of the various embodiments of the application, the accuracy and reliability of an NN model with quantized weights is improved while the compression efficiency is ensured. To achieve equivalent model performance, the method of the present disclosure enables quantization with significantly fewer bits compared to the conventional methods, thereby reducing computing and storage resource requirements for a computing device. The aspects of the application may be easily combined with the existing quantization process. For example, the method and apparatus of the disclosure may enable further optimization without significant modifications to existing PTQ systems.

[0007] According to an aspect of the present application, there provides a computer implemented method for quantizing weights of a neural network (NN) model, comprising: quantizing a first set of weights of the NN model into a second set of weights; computing at least one sensitivity metrics based on performances of the NN model with the first set of weights and the second set of weights; selecting a third set of weights from the first set of weights based on the at least one sensitivity metrics; and determining a fourth set of weights for representation of the third set of weights, wherein the fourth set of weights is of a first precision higher than a second precision of the second set of weights.

[0008] According to an aspect of the present application, there provides an apparatus for quantizing weights of a neural network (NN) model, comprising: a quantization module for quantizing a first set of weights of the NN model into a second set of weights; a computing module for computing at least one sensitivity metrics based on performances of the NN model with the first set of weights and the second set of weights; a selection module for selecting a third set of weights from the first set of weights based on the at least one sensitivity metrics; and a determination module for determining a fourth set of weights for representation of the third set of weights, wherein the fourth set of weights is of a first precision higher than a second precision of the second set of weights.

[0009] According to an embodiment, there provides a computer system, which comprises one or more processors and one or more storage devices storing computer-executable instructions that, when executed, cause the one or more processors to perform the operations of the method as mentioned above as well as to perform the operations of the method according to aspects of the disclosure.

[0010] According to an embodiment, there provides one or more computer readable storage media storing computer-executable instructions that, when executed, cause one or more processors to perform the operations of the method as mentioned above as well as to perform the operations of the method according to aspects of the disclosure.

[0011] According to an embodiment, there provides a computer program product comprising computer-executable instructions that, when executed, cause one or more processors to perform the operations of the method as mentioned above as well as to perform the operations of the method according to aspects of the disclosure.

[0012] According to various aspects of the disclosure, the technical solution for weight quantization provided by the disclosure comprises a computing module and a selection module. The computing module enables a more accurate assessment of weight sensitivity by considering both the original and quantized weights, leading to a better understanding of quantization impact. Based on the accurately-computed sensitivity metrics, the selection module ensures that critical weights, which require higher precision, are identified and preserved, thereby improving the overall model performance after quantization. Other advantages of the various aspects of the present disclosure will be described below.BRIEF DESCRIPTION OF THE DRAWINGS

[0013] The disclosed aspects will hereinafter be described in connection with the appended drawings that are provided to illustrate and not to limit the disclosed aspects.

[0014] Fig. 1 illustrates an exemplary apparatus for quantizing weights of an NN model according to aspects of the disclosure.

[0015] Figs. 2A-2B illustrate exemplary apparatus for selecting weights of an NN model based on sensitivity metrics according to aspects of the disclosure.

[0016] Figs. 3A-3B illustrate exemplary apparatus for determining quantized weights for representation of the third set of weights according to aspects of the disclosure.

[0017] Fig. 4 illustrates an exemplary apparatus for quantizing weights of an NN model according to aspects of the disclosure.

[0018] Fig. 5 illustrates an exemplary method for quantizing weights of an NN model according to aspects of the disclosure.

[0019] Fig. 6 illustrates a block diagram of an apparatus for quantizing weights of an NN model according to aspects of the disclosure.

[0020] Fig. 7 illustrates a block diagram of a processing device according to one embodiment.DETAILED DESCRIPTION

[0021] The present disclosure will now be discussed with reference to several example implementations. It is to be understood that these implementations are discussed only for enabling those skilled in the art to better understand and thus implement the embodiments of the present disclosure, rather than suggesting any limitations on the scope of the present disclosure.

[0022] Various embodiments will be described in detail with reference to the accompanying drawings. Wherever possible, the same reference numbers will be used throughout the drawings to refer to the same or like parts. References made to examples and embodiments are for illustrative purposes, and are not intended to limit the scope of the disclosure.

[0023] Fig. 1 illustrates an exemplary apparatus 100 for quantizing weights of an NN model according to aspects of the disclosure. In the example of Fig. 1, the apparatus 100 comprises an NN model 110 and a quantized NN model 110’ respectively with a first set of weights w and a second set of weights a quantization module 120, a performance determination module 130, a computing module 140, a selection module 150 and a determination module 160. It may be understood that the apparatus 100 may comprise other modules as well, and that Fig. 1 only illustrates modules related with the embodiment. It may be understood that the apparatus 100 may be implemented in a computer processing system, for example, the various modules comprised in the apparatus 100 can be implemented through software code, through dedicated hardware processing modules, or through a combination of software code and dedicated hardware modules.

[0024] The apparatus 100 may be input with a calibration set D 105. According to an aspect of the application, the calibration set D 105 comprises a set of labeled data used to evaluate and adjust the sensitivity metrics of the NN model during the quantization process. For example, in natural language processing tasks, the calibration set D 105 could comprise a variety of sentences or documents that span different domains, such as scientific text, casual conversation, and formal writing. As another example, in image classification tasks, the calibration set D 105 might comprise images with varying resolutions, lighting conditions, and content, allowing for comprehensive adjustment of the quantization parameters. The calibration set D 105 is crucial in the quantization process to retain high performance despite the reduced precision of its weights. It may be understood that the calibration set D 105 may comprise any suitable data depending on the need of the tasks of the NN model.

[0025] In the embodiment depicted in Fig. 1, an NN model 110 is initially configured with a first set of weights w. The first set of weights w may be high-precision weights. For example, the high-precision weights may be the original weights obtained after training the model. In one example, the first set of weights w may be represented with 16 bits or 32 bits in floating-point format.

[0026] The quantization module 120 may process the first set of weights w to produce a second set of weights for example, to optimize the model for deployment on resource-constrained devices, resulting in a quantized NN model 110' . The quantization module 120 may employ suitable quantization techniques to convert the first set of weights w (e.g., high-precision weights) into the second set of weights  (e.g., lower-precision representations) . For instance, it may apply 8-bit integer quantization, reducing the bit-width of each weight from 32 bits to 8 bits. The second set of weights  configured for the quantized NN model 110’ may be represented with 8 bits in integer format, as an example. It may be understood that the first set of weights w and the second set of weights may adopt any suitable representation of weights.

[0027] The NN model 110, utilizing the first set of weights w (e.g., high-precision weights) , generates a set of output denoted as O (w) 115. The quantized NN model 110' , employing the second set of weights (e.g., quantized weights) , produces a corresponding set of output represented as 125.

[0028] In the embodiment depicted in Fig. 1, the NN model 110 and its quantized counterpart 110' are evaluated based on their respective performances under the first sets of weights w and second sets of weights The performance determination module 130 assesses the outputs O (w) 115 and 125 to determine the models' performance, F(w) 135 and 145, respectively.

[0029] In an example, the performance determination module 130 may be implemented with a loss function module that respectively compares the outputs O (w) 115 and 125 against labeled data from the calibration set D 105. For example, for both the NN model 110 and quantized NN model 110’ , the performance F (w) 135 and  145 may be computed based on the discrepancy (e.g., the cross-entropy loss) between the model's predictions and the actual labels. As another example, the performance determination module 130 may employ various evaluation metrics (e.g., accuracy, precision, recall, F1-score, Mean Squared Error (MSE) or Mean Absolute Error (MAE) , etc. and any combination of them) , to determine the performance F (w) 135 of the NN model 110 and the performance 145 of the quantized NN model 110’ . It may be understood that the performance determination module 130 may be implemented in any suitable manner to determine the performance of an NN model.

[0030] In an aspect of the disclosure, a sensitivity metric v may be used to quantify the impact that quantizing individual weights has on the NN model's performance. The sensitivity metric v may be computed prior to quantization, based on the model's performance F (w) with original weights w. For instance, v can be derived by calculating  or This sensitivity metric v is then utilized during the quantization process Q to produce quantized weights expressed as

[0031] However, for some of large-scale neural networks, such as large language models (LLMs) , this pre-quantization sensitivity metric v may lack accuracy. One reason is that the sensitivity of weights can change after quantization. For example, previously sensitive weights may lose importance after quantization, and other non-sensitive weights may emerge as sensitive. This change can lead to a misalignment of sensitivity between w and Additionally, estimating performance changes based solely on w assumes that lies within the convergence radius of w. However, given the vast number of parameters in large-scale neural networks (e.g., LLMs) , the distance  might be substantial, causing some to fall outside this convergence radius. Consequently, using an inaccurate sensitivity metric v for quantization can result in suboptimal quantized weights leading to significantly degraded model performance after quantization.

[0032] In accordance with aspects of the disclosure, the at least one sensitivity metric v 155 may be computed by the computing module 140 by considering both the original weights w and the quantized weights thereby aligning the sensitivity between them. This dual consideration enhances the precision of the sensitivity assessment. In one example, the change in NN model performance from F (w) to denoted as ΔF, is computed based on an integral of gradient of the performance over the path from w to  For example, ΔF may be computed as: wherein C refers to the path from w to In an example, the performance function F  might be derived from the NN model's loss function, as described in the disclosure.

[0033] When computing total ΔF with equation (1) , positive and negative integral contributions might offset each other, potentially leading to overfitting problems. To mitigate this issue, in an example, the computing module 140 may compute sensitivity metrics v without considering the sign of the integral contributions, treating both positive and negative elements equally in their impact on quantization outcomes, thereby enhancing generalization performance. As an example, further based on equation (1) , the sensitivity metrics v may be instead computed based on an absolute value of the integration, with the following equation: the sensitivity metric v 155 computed in this manner may help alleviate overfitting  issues.

[0034] In accordance with aspects of the disclosure, to compute the sensitivity metric v 155 more accurately, the computing module may divide the path from w to into a plurality of smaller segments. For example, within each segment,  may be closer to w, so that more values may fall within the convergence radius of w. Specifically, continuing with the above examples, by numerical integrating the absolute values of the gradient of the performance along each segment, an overall integral may be computed. For example, the computing module 140 may compute the sensitivity metric v 155 based on rectangle approximation of integrals on each segment as: wherein N denotes the number of divided segments. For example, to control the error  within ~0.1%, N may take a value greater than or equal to 32. It may be understood that in addition to rectangle approximation, the computing module 140 may compute the sensitivity metric v 155 based on any suitable integral approximation.

[0035] In an example, the computed sensitivity metric v 155 may be element-wise, providing a distinct sensitivity value for each weight within the NN model. This granularity allows for precise assessment of how the quantization of each individual weight affects the model's performance, as described in this disclosure. In another example, the sensitivity metric is computed on a layer-wise basis, resulting in multiple sensitivity metrics v 155 corresponding to the various layers of the NN model. This approach evaluates the collective sensitivity of all weights within a given layer, determining the layer's overall impact on model performance upon quantization.

[0036] The term "layer" in this disclosure encompasses various levels of granularity within the NN model architecture. For instance, in a transformer model, a layer could refer to a block, or even more granularly, to sublayers within a block. Examples of sublayers include those responsible for query (Q) , key (K) , value (V) , output (O) , gate, up, and down operations, each contributing to the overall functionality of the model. It may be understood that a layer may refer to any suitable component of an NN model.

[0037] The sensitivity metric v 155, computed by the computing module 140, serves as a fine-grained measure to predict the impact of quantizing individual weights on the performance (e.g., loss function) of the NN model. By accurately determining this sensitivity metric v based on w and the apparatus 100 may more precisely forecast how quantizing each weight affects the NN model's performance, enabling differentiated quantization strategies for various types of weights, as mentioned elsewhere in this disclosure.

[0038] For instance, based on the sensitivity metric v 155, a selection module 150 may select a third set of weights wh 165 from the first set of weights w. The selection module 150 may be as described with reference to Figs. 2A-2B of the disclosure. For example, the third set of weights wh 165 may comprise weights that require high-precision representation. In some examples, the third set of weights wh 165 may comprise outlier weights-weights with magnitudes significantly deviating from the average-that are particularly sensitive to quantization and, if not handled with higher precision, could lead to substantial performance degradation. Alternatively or additionally, the third set of weights wh 165 might comprise significant weights, which are crucial for the model's final output. For example, there may be top 5.25%significant weights covering over 30%of total performance change ΔF of the NN model from F (w) to Thus, the significant weights necessitate high-precision to maintain overall accuracy of a quantized NN model.

[0039] Optionally, the selection module 150 may also output a set of weights wl 175, comprising weights that may tolerate low-precision quantization without significantly affecting the performance of the quantized NN model. For example, the set of weights wl 175 may comprise all weights from the first set w excluding those in the third set of weights wh 165. Based on the third set of weights wh 165 and optionally, the set of weights wl 175, the apparatus 100 may apply mixed-precision quantization, allocating higher precision to more sensitive weights and lower precision to others. This approach optimizes computational resources while maintaining model accuracy.

[0040] Based on the selected third set of weights wh 165, a determination module 160 may determine a fourth set of weights 185 to represent these the third set of weights wh 165 with a precision higher than that of the second set of weights The determination module 160 may be as described with reference to Figs. 3A-3B of the disclosure. This ensures that critical weights precisely retain their influence on the NN model's performance. Additionally, the determination module 160 may determine a fifth set of weights 195, representing the remaining weights at a lower precision. For example, the fifth set 195 may comprise weights from the second set of weights  that are not corresponding to any of the third set of weights wh 165.

[0041] The fourth set of weights 185 and the fifth set of weights 195 may be used for representation of quantized weights of the NN model and are stored in memory of the apparatus 100. By assigning higher precision to essential weights and lower precision to others, apparatus 100 may achieve a balance between computational efficiency and model performance. This mixed-precision quantization strategy leverages the accurately determined sensitivity metric v 155 to inform precision allocation, thereby optimizing resource usage without compromising accuracy.

[0042] The disclosure may facilitate a decrease in memory usage and computational load. For example, to achieve a certain model performance, less storage space and fewer computational resources are needed based on the quantization method and apparatus of the disclosure. This reduction not only accelerates processing times but also diminishes energy consumption, which is crucial for battery-powered devices and large-scale data centers aiming to improve energy efficiency.

[0043] Fig. 2A illustrates an exemplary apparatus 200A for selecting weights of an NN model based on sensitivity metrics according to aspects of the disclosure. In the example of Fig. 2A, the apparatus 200A comprises a selection module 150, which further comprises a performance change module 210 and a first weight selection module 220. It may be understood that the apparatus 200A may comprise other modules as well, and that Fig. 2A only illustrates modules related with the embodiment. It may be understood that the apparatus 200A may be implemented in a computer processing system, for example, the various modules comprised in the apparatus 200A can be implemented through software code, through dedicated hardware processing modules, or through a combination of software code and dedicated hardware modules.

[0044] In accordance with an aspect of the disclosure, the selection module 150 may select a subset of weights, termed the third set of weights wh165, from the first set of weights w. In an example, this selection may be performed based on a weight ratio and the sensitivity metric v 205. In an example, the weight ratio may be dynamically determined or indicated as an input (e.g., by a hyper-parameter or a pre-defined value) .

[0045] The selection module 150 may comprise a performance change module 210 to compute the performance change of the NN model, denoted as ΔF 235. The performance change module 210 may integrate the at least one sensitivity metrics v 205 with the distances between corresponding weights in the first set of weights w 215 and the second set of weights 225. As an example, the distance metric may be calculated using the element-wise absolute difference between corresponding weights, expressed as As another example, the distance metric may be layer-wise, wherein the distance metric for each layer may be computed based on summation of each distance value It can be understood that any suitable distance metric may be employed for the calculation of distances between corresponding weights.

[0046] In an example, the performance change module 210 may compute a performance change ΔF 235 of the NN model by: wherein v refers to a sensitivity metrics v 205 derived using methods described in this  disclosure (e.g., using equation (1) , (2) or (3) ) . In one example, the computed ΔF 235 may be element-wise. For example, one ΔF 235 may comprise a performance change for each individual weight. As another example, ΔF 235 may be layer-wise. For example, ΔF 235 may be computed for respective layers based on an overall performance change based on quantization of all weights of that layer, resulting in a {ΔF (i) } 1≤i≤l, wherein l denotes the number of layers of the NN model. It may be understood that ΔF may be computed in any suitable granularity.

[0047] The first weight selection module 220 may select a subset of weights, referred to as the third set of weights wh 245, from the first set of weights w 215, based on the computed performance change ΔF 235 of the NN model.

[0048] In an example, this weight selection process is guided by a global weight ratio rg, which represents the proportion of weights among all weights in the first set of weights w that require higher precision representation to maintain the model's performance.

[0049] In an example, the global weight ratio rg may be dynamically based on the performance change ΔF 235. To determine this global weight ratio rg, a performance change threshold (ΔF_threshold) may be configured with an input or by default. This threshold may define the acceptable level of performance variation-such as a 1%change-permissible during the quantization process. For example, the sensitivity metric v 205 and accordingly, the performance change ΔF 235 may be element-wise, quantifying the impact of individual weight quantization on the overall model performance. The performance change ΔF for individual weights are then aggregated and ranked (e.g., in a descending order) . Starting with the weight exhibiting the highest sensitivity, the first weight selection module 220 cumulatively sums the performance change values until the accumulated performance change reaches the predefined ΔF_threshold. The weights in the first set of weights w 215 encompassed in this summation constitute the third set of weights wh 245, which are designated for high-precision representation. The remaining weights wl 255 in the first set of weights w 215 are deemed suitable for low-precision representation.

[0050] For instance, consider an NN model comprising 100,000 weights. If the cumulative sensitivity of the top 5,000 weights meets the ΔF_threshold of 1%, the global weight ratio (rg) is determined to be 5% (5,000 out of 100,000) . Consequently, these 5,000 weights are selected as the third set of weights wh 245 for high-precision representation, while the remaining 95,000 weights wl 255 are allocated for low-precision representation.

[0051] It may be understood that the global weight ratio as well as the third set of weights wh 245 may be determined in any suitable manner based on the sensitivity metric v 205.

[0052] By dynamically adjusting the global weight ratio rg based on sensitivity metrics v 205, the selective precision allocation effectively reduces the computational and storage demands of the NN model without compromising its performance, leading to more efficient and scalable implementations.

[0053] In some examples, applying a uniform global weight ratio rg across all layers may lead to suboptimal accuracy, as certain layers i might exhibit higher average performance changes ΔF (i) , indicating a more significant impact on overall model accuracy. To address this, the first weight selection module 220 may dynamically determines a local weight ratio rl for each layer, tailoring the precision allocation to the specific sensitivity of each layer.

[0054] For example, a local weight ratio rl (i) for a layer i in layers of the NN model may be allocated from the global weight ratio rg based on the performance change ΔF (i) for the layer i. In an example, to determine a plurality of local weight ratios rl {rl(i) } 1≤i≤l for layers i (1≤i≤l) of the NN model, a temperature factor t may be employed, such as to enhance the differentiation of local weight ratios across layers. One example of incorporating the temperature factor t is through exponentiation, to allocate the global weight ratio rg to local weight ratios for respective layers, as demonstrated in the following equation: wherein rg is either dynamically determined, as described in this disclosure, or  indicated by a parameter of the NN model or is pre-configured. It may be understood that other methods, such as the softmax function, can also be employed to leverage the temperature factor t in determining local weight ratios.

[0055] Accordingly, based on the local weight ratios {rl (i) } 1≤i≤l for each layer, a number of weights for a layer i that may be quantized in high precision may be determined, for example, with the following equation: high_precision_weight_num (i) = global_weight_num×rl (i)         (6)  In this example, the sensitivity metrics v 205 may comprise a plurality of sensitivity  metrics v (i) 205, each for a layer i, and accordingly, the first weight selection module 220 may determine a plurality of performance changes ΔF (i) , each of the plurality of performance changes being computed for a respective layer i of the NN model.

[0056] In an example, the first weight selection module 220 may perform a search (e.g., a grid search) over a range of temperature factors t to identify the optimal value (e.g., t_best) . For each value of t, the high_precision_weight_num (i) for each layer i is calculated using Equation (6) . For example, the temperature factor t that yields the best performance (e.g., the lowest may be selected as t_best.

[0057] The first weight selection module 220 may then determine high_precision_weight_num (i) for each layer i corresponding to the optimal temperature factor t_best. In an example, outlier weights might need more bits to represent and thus may be chosen from the first set of weights w. In this example, based on the calculated high_precision_weight_num (i) , the first weight selection module 220 may select the largest high_precision_weight_num (i) of weights from the weight vector w of each layer i as weights in the third set of weights wh 245. In another example, significant weights may be selected for high precision representation. In this example, the determined performance changes ΔF (i) may comprise performance change for each weight of a layer i. Based on the calculated high_precision_weight_num (i) , the first weight selection module 220 may select the high_precision_weight_num (i) of weights with largest ΔF from the weight vector w of each layer i as weights in the third set of weights wh 245. These selected weights will be represented in high precision.

[0058] It may be understood that the first weight selection module 220 may select the third set of weights using any suitable manner. The remaining weights in the first set of weights w may be quantized using a lower precision, and optionally, the remaining weights may be comprised in wl 255 and output by the selection module 150.

[0059] By dynamically adjusting the local weight ratios based on layer-wise performance changes ΔF (i) , the first weight selection module 220 may ensure that more high-precision weights are allocated to layers with a greater impact on accuracy. This targeted allocation leads to improved overall model performance compared to using a uniform weight ratio for all layers.

[0060] Fig. 2B illustrates an exemplary apparatus 200B for selecting weights of an NN model based on sensitivity metrics according to aspects of the disclosure. In the example of Fig. 2B, the apparatus 200B comprises a selection module 150, which further comprises a performance change module 210 and a second weight selection module 230. It may be understood that the apparatus 200B may comprise other modules as well, and that Fig. 2B only illustrates modules related with the embodiment. It may be understood that the apparatus 200B may be implemented in a computer processing system, for example, the various modules comprised in the apparatus 200B can be implemented through software code, through dedicated hardware processing modules, or through a combination of software code and dedicated hardware modules.

[0061] The performance change module 210 may compute a performance change ΔF 295 based on the input sensitivity metric v 205 and distances between the first set of weights w 215 and the second set of weights 225. In an example, the computed ΔF 295 may be element-wise, including performance change for each individual weight. For example, weights with the largest ΔF values in ΔF 295 have the most significant impact on performance. The performance change ΔF 295 may be computed similar with those described in this disclosure, and thus is not repeated here.

[0062] The second weight selection module 230 may receive a global weight ratio ri 265. For example, the global weight ratio ri 265 may be indicated by a parameter of the NN model (e.g., a hyper parameter) of is pre-configured. The second weight ratio ri 265 indicates the proportion of weights, of the first set of weights w, to be selected as the third set of weights wh 275. In an example, with element-wise ΔF 295, the second weight selection module 230 may rank the weights in descending order based on their ΔF values, and select the top ri 265 of the weights from the first set of weights as the third set of weights wh 275. For example, the third set of weights wh 275 may comprise significant weights and / or outlier weights.

[0063] In an example, to minimize the estimation error, the third set of weights wh 275 may be gradually selected in multiple passes. For example, a global weight ratio (e.g., either ri 265 or a dynamic rg as described herein, although not shown in Fig. 2B) may be divided into multiple sub-ratios. As an example, each sub-ratio may be or wherein β is a positive number. It may be understood that the global weight ratio ri or rg may be divided into multiple sub-ratios in any suitable manner.

[0064] For each pass, the second weight selection module 230 may select a subset of weights based on a sub-ratio (e.g.,  or ) of the global weight ratio ri or rg, and the received performance change ΔF 295. For example, the second weight selection module 230 may select the top or elements with the largest ΔF values from the first set of weights w or from and include the corresponding weights in the third set of weights wh 275.

[0065] In each pass, after the weight selection, the sensitivity metrics v 205 and correspondingly, performance change ΔF 295, are updated based on the selected weights. For example, since the selected weights may be quantized in a precision higher than that of the second set of weights the elements in the second wet of weights may be updated based on the selected weights (e.g., in the second set of weights the selected weights are quantized with a higher precision (e.g., same with w) ) , and thus the sensitivity metrics v 205 (e.g., computed based on equation (1) , (2) or (3) ) , and correspondingly, performance change ΔF 295 may be updated based on the selected weights.

[0066] This iterative process refines the selection of the third set of weights wh 275 by considering the impact of previously selected weights on the NN model's performance. The sub-ratio in each pass is a fraction of the global weight ratio, ensuring that the final selection of weights meets the pre-defined proportion. This method allows for a more dynamic and adaptive selection of weights, potentially leading to better performance compared to direct selection.

[0067] Fig. 3A illustrates an exemplary apparatus 300A for determining quantized weights for representation of the third set of weights according to aspects of the disclosure. In the example of Fig. 3A, the apparatus 300A comprises a determination module 160, which further comprises an optional first high-precision quantization module 310 and a low-precision quantization module 320. It may be understood that the apparatus 300A may comprise other modules as well, and that Fig. 3A only illustrates modules related with the embodiment. It may be understood that the apparatus 300A may be implemented in a computer processing system, for example, the various modules comprised in the apparatus 300A can be implemented through software code, through dedicated hardware processing modules, or through a combination of software code and dedicated hardware modules.

[0068] As described, the third set of weights wh 305 are selected from the first set of weights w and represents weights that need to be quantized with a high precision. In one example, the determination module 160 may determine the fourth set of weights  185 as the third set of weights wh 305, since the third set of weights wh 305 is already represented in a high precision. In this example, the first precision of the fourth set of weights 185 is the same with the precision of the first set of weights w. In this way, the determination module 160 may ensure minimal impact on model accuracy, as these weights are already at their optimal precision level.

[0069] As another example, the first high-precision quantization module 310 may further quantize the third set of weights wh 305 into the fourth set of weights 185 with a first precision, the first precision may be higher than a second precision of the second set of weights and may be lower than the precision of first set of weights w. For example, weights in the first set of weights w may be represented with 4 bits in floating point, and weights in the second set of weights may be represented with 2 bits in floating point. Weights in the fourth set of weights 185 may be represented with 3 bits in floating point. This approach allows for a balance between accuracy and compression by representing the third set of weights wh 305 with a precision between the highest (w) and lowest levels.

[0070] As described, the selection module 150 may optionally output a set of weights wl 315. The set of weights wl 315 may be the remaining weights from the first set of weights w other than the third set of weights wh 305. The set of weights wl 315 may represent weights that are more tolerant with low-precision quantization. Alternatively, the low-precision quantization module 320 may determine the set of weights wl 315, from the first set of weights w, based on the input third set of weights wh 305, in the case that the set of weights wl 315 is not output by other preceding modules.

[0071] As an example, the low-precision quantization module 320 may quantize the set of weights wl 315 into a fifth set of weights wq2 195 with a precision lower than that of the fourth set of weights 185.

[0072] For example, the low-precision quantization module 320 may determine weights from the second set of weights corresponding to the set of weights wl 315, and the fifth set of weights wq2 195 may comprise the determined weights from the second set of weights In this example, the precision of the fifth set of weights wq2 195 is the same with the second precision of the second set of weights This example contributes to a smaller NN model size without significantly affecting the overall accuracy, as the set of weights wl 315 are less sensitive to quantization.

[0073] Fig. 3B illustrates an exemplary apparatus 300B for determining quantized weights for representation of the third set of weights according to aspects of the disclosure. In the example of Fig. 3B, the apparatus 300B comprises a determination module 160, which further comprises an optional first high-precision quantization module 310, a low-precision quantization module 320 and a second high-precision quantization module 330. It may be understood that the apparatus 300B may comprise other modules as well, and that Fig. 3B only illustrates modules related with the embodiment. It may be understood that the apparatus 300B may be implemented in a computer processing system, for example, the various modules comprised in the apparatus 300B can be implemented through software code, through dedicated hardware processing modules, or through a combination of software code and dedicated hardware modules.

[0074] Similar as described with reference to Fig. 3A, the low-precision quantization module 320 may determine a fifth set of weights wq2 195 based on the optional set of weights wl 315 or the third set of weights wh 305. In an example, as described above, the fifth set of weights wq2 195 may comprise weights from the second set of weights  corresponding to the set of weights wl 315.

[0075] In an example, the third set of weights wh 305 may be used by a first high-precision quantization module 310, similar as described above, to determine a set of weights wh’ 325 (which may be same with the third set of weights wh 305 or quantized weights with a high precision based on the third set of weights wh 305) .

[0076] Based on the set of weights wh’ 325 or the third set of weights wh 305, the second high-precision quantization module 330 may determine a set of weights in the second set of weights corresponding to the set of weights wh’ 325 or the third set of weights wh 305, denoted as wh2. The set of weights wh2 are the corresponding weights represented in low precision (e.g., with ) that should be represented with higher precision.

[0077] Based on the set of weights wh’ 325 and wh2, the second high-precision quantization module 330 may determine weight distances between corresponding weights in the set of weights wh’ 325 and the wh2. For example, in the embodiment that the set of weights wh’ 325 comprises weights from the third set of weights wh 305, which may also be represented by corresponding weights from the first set of weights w, the weight distance wd for a weight in the third set of weights wh 305 may be computed as wd = wh -wh2. In an example, the computed weight distance wd may be represented with a precision higher than that of the second set of weights

[0078] A fourth set of weights  185 may be determined by the second high-precision quantization module 330 with a combination of the determined weight distances wd, and the corresponding weight in the set of weights wh2 (e.g., with the same precision as  ) .For example, a quantized weight in the fourth set of weights 185 may be determined based on Based on wd, the precision of may be higher than that of

[0079] It may be understood that the fourth set of weights may be determined in a mixed way. For example, for some weights in the fourth set of weights the corresponding weights in the third set of weights wh may be used, as described with reference to Fig. 3A, while other weights in the fourth set of weights may be determined based on a combination of the determined weight distances wd, and the corresponding weight in the set of weights wh2, similar as described with reference to Fig. 3B. It may be understood that the fifth set of weights wq2 may also be determined in a similarly mixed way.

[0080] Fig. 4 illustrates an exemplary apparatus 400 for quantizing weights of an NN model according to aspects of the disclosure. In the example of Fig. 4, the apparatus 400 comprises an NN model 410 and a quantized NN model 410’ respectively with a first set of weights and a second set of weights, a performance determination module 430, a computing module 440, a selection module 450 and a determination module 460. It may be understood that the apparatus 400 may comprise other modules as well, and that Fig. 4 only illustrates modules related with the embodiment. It may be understood that the apparatus 400 may be implemented in a computer processing system, for example, the various modules comprised in the apparatus 400 can be implemented through software code, through dedicated hardware processing modules, or through a combination of software code and dedicated hardware modules.

[0081] According to an aspect, to select different types of weights that need high-precision quantization, at least part of modules from Fig. 4 may be used multiple times. For example, the NN module 410 and the quantized NN model 410’ , the performance determination module 430, the computing module 440, the selection module 450 and the determination module 460 may be used at first to select outlier weights from all weights of the NN model, the outlier weights may be quantized with a high precision, resulting in a first intermediate set of weights 485. The rest of the weights may be quantized with a low precision, comprised in a second intermediate set of weights wq2 495.

[0082] To be specific, for example, an NN model 410 may be initially configured with a first set of weights w, and may be quantized to a quantized NN model 410' with a second set of weights With calibration set D 405, these two NN models may respectively generate outputs O (w) 415 and 425, which may be used by the performance determination module 430 to determine their respective performance F (w) 435 and 445. These modules may operate similar as described in the disclosure.

[0083] Based on the determined performances F (w) 435 and 445, the computing module 440 may compute layer-wise sensitivity metric v (i) 455 with equation (3) . The selection module 450 may correspondingly compute layer-wise ΔF (i) with equation (4) . Based on the layer-wise ΔF (i) , the selection module 450 may determine a local outlier weight ratio rl (i) for each layer i using a temperature factor t and equation (5) . Based on the determined outlier weight ratios for each layer, the selection module 450 may select outlier weights in respective layers from the first set of weights w and include the selected outlier weights in wh 465. Based on wh 465, the determination module 460 may determine a first intermediate set of weights 485 to represent wh 465 with original precision of the first set of weights w, and represent the remaining weights with the second intermediate set of weights wq2 495. The second intermediate set of weights wq2 495 may be in a same precision with that of the second set of weights

[0084] As an example, the above-mentioned operation for selecting outlier weights may be performed in accordance with the following Table 1. In the following algorithm 1, high_precision_weight_num (i) represents number of outlier weights. Original sensitivity metrics v0 may be computed in any suitable manner. Table 1

[0085] Next, the NN model 410 and 410’ may be respectively configured with the determined first intermediate set of weights 485 and second intermediate set of weights wq2 495. For example, in the newly-configured NN model 410 (denoted as with weights w’ ) , weights corresponding to a first intermediate set of weights 485 (e.g., outlier weights) may be represented with the first intermediate set of weights 485, which may be of a lower or same precision with that of the first set of weight w, while other weights may be of the original precision of the first set of weight w. In the newly-configured quantized NN model 410’ (denoted as with weights ) , weights corresponding to the second intermediate set of weights wq2 may be represented with the second intermediate set of weights wq2 495, while other weights may be represented with the first intermediate set of weights 485. In an example, the precision of the first intermediate set of weights 485 is the same with that of w, and the precision of the second intermediate set of weights wq2 495 is the same with that of

[0086] Based on the newly-configured NN model 410 and 410’ , the performance determination module 430, the computing module 440, the selection module 450 and the determination module 460 may be used again to select significant weights from rest of weights (e.g., other than the selected outlier weights) of the NN model.

[0087] Similarly as mentioned above, the newly-configured NN models 410 and 410’ may respectively generate outputs O (w’ ) 415’a nd 425’ , which may be used by the performance determination module 430 to determine their respective performance F(w’ ) 435’a nd 445’ .

[0088] Based on the determined performances F (w’ ) 435’a nd 445’ , the computing module 440 may compute element-wise sensitivity metric v’ 455’ with equation (3) . The selection module 450 may correspondingly compute element-wise ΔF with equation (4) . Based on the element-wise ΔF, the selection module 450 may gradually (e.g., in multiple passes) select significant weights to be included the selected significant weights in wh’ 465’ based on an indicated global weight ratio ri, wherein wh’ 465’ may be a set of weights initialized with selected outlier weights wh 465.

[0089] Based on wh’ 465’ , the determination module 460 may determine a fourth set of weights 485’ to additionally represent the selected significant weights in wh’ 465’ by a combination of the corresponding weights in second set of weights w and corresponding weight distances wd, and represent the remaining weights with the fifth set of weights wq2’ 495’ . The fifth set of weights wq2’ 495’ may be in a same precision with that of the second set of weights

[0090] In this example, based on the previous outlier weights selection, the selected outlier weights are already quantized with a precision of the first set of weight w in the NN models 410 and 410’ , and thus in addition to the significant weights, the fourth set of weights 485’ may quantify both the outlier weights and significant weights with a high precision. In an example, with the output fourth set of weights 485’ , the fifth set of weights wq2’ 495’ may comprise any weights in not corresponding to any of the fourth set of weights 485’ .

[0091] As an example, the above-mentioned operation for the computing module 440, the selection module 450 and the determination module 460 may be performed in accordance with the following Table 2. In the following algorithm 2, ri is an integer multiple of β. Table 2

[0092] In another example, significant weights may be selected before the selection of outlier weights. It may be understood that the modules of Fig. 4 may be implemented in any suitable manner, to select weight that need higher precision in any suitable order, and to represent the selected weight in any suitable manner, as described in the disclosure.

[0093] By selecting both outlier weights and significant weights, the quantization process of the disclosure may be tailored to minimize the impact of these critical weights on the overall quantization error.

[0094] The methods and apparatuses outlined in the present disclosure provide a means to optimize computing device performance by achieving efficient neural network quantization. By quantizing while preserving accuracy, the methods and apparatuses of the disclosure lower computational and storage requirements, expedite processing, and conserve energy, all while maintaining compatibility with existing systems.

[0095] Fig. 5 illustrates an exemplary method 500 for quantizing weights of an NN model according to aspects of the disclosure.

[0096] At step 510, a first set of weights of the NN model is quantized into a second set of weights.

[0097] At step 520, at least one sensitivity metrics is computed based on performances of the NN model with the first set of weights and the second set of weights.

[0098] At step 530, at least one sensitivity metrics is selected based on performances of the NN model with the first set of weights and the second set of weights.

[0099] At step 540, a fourth set of weights for representation of the third set of weights is determined, wherein the fourth set of weights is of a first precision higher than a second precision of the second set of weights.

[0100] According to an embodiment, the performance of the NN model is based on a loss function of the NN model. According to an embodiment, at step 520, the at least one sensitivity metrics is computed based on integration of gradient of the performance along a path from the first set of weights to the second set of weights. According to an embodiment, the at least one sensitivity metrics is computed based on an absolute value of the integration. According to an embodiment, at step 520, the path from the first set of weights to the second set of weights is divided into a plurality of segments; and the absolute value of the integration is based on absolute values of integrations of gradient of the performance along each of the plurality of the segments.

[0101] According to an embodiment, at step 530, at least one performance change of the NN model is computed based on the at least one sensitivity metrics and distances between corresponding weights in the first set of weights and the second set of weights; and the third set of weights is selected from the first set of weights based on the at least one performance change accounting for a global weight ratio. According to an embodiment, the global weight ratio is based on the at least one performance change. According to an embodiment, the global weight ratio is allocated to a plurality of local weight ratios, each of the plurality of local weight ratios being determined for a respective layer of the NN model; the at least one performance change comprises a plurality of performance changes, each of the plurality of performance changes being computed for a respective layer of the NN model; and for a first layer of the NN network, step 530 further comprises: selecting, based on a first local weight ratio of the first layer and a first performance change for the first layer, at least one weight from weights of the first layer. According to an embodiment, the first local weight ratio of the first layer is allocated from the global weight ratio based on the first performance change for the first layer.

[0102] According to an embodiment, the global weight ratio is indicated by a parameter of the NN model or is pre-configured. According to an embodiment, the third set of weights is selected in multiple passes; and for a pass of selection, step 530 further comprises: selecting, based on a sub-ratio of the global weight ratio and the at least one performance change, at least one weight from the first set of weights; and updating the at least one sensitivity metrics and the at least one performance change based on the selected at least one weight.

[0103] According to an embodiment, the third set of weights comprises at least one of an outlier weight and a significant weight.

[0104] According to an embodiment, at step 540, weights in the third set of weights are determined as the fourth set of weights for representation of the third set of weights.

[0105] According to an embodiment, at step 540, weight distances between corresponding weights in the third set of weights and the second set of weights are computed; and a weight of the fourth set of weights is determined based on a weight of the second set of weights corresponding to the third set of weights and a corresponding weight distance.

[0106] According to an embodiment, the method further comprises determining a fifth set of weights, the fifth set of weights comprising weights in the second set of weights not corresponding to any of the third set of weights; and storing the fourth set of weights and the fifth set of weights.

[0107] Fig. 6 illustrates a block diagram of an apparatus 600 for quantizing weights of an NN model according to aspects of the disclosure.

[0108] The apparatus 600 may comprise a quantization module 610, a computing module 620, a selection module 630 and a determination module 640. The quantization module 610 quantizes a first set of weights of the NN model into a second set of weights. The computing module 620 computes at least one sensitivity metrics based on performances of the NN model with the first set of weights and the second set of weights. The selection module 630 selects a third set of weights from the first set of weights based on the at least one sensitivity metrics. The determination module 640 determines a fourth set of weights for representation of the third set of weights, wherein the fourth set of weights is of a first precision higher than a second precision of the second set of weights.

[0109] According to an embodiment, the performance of the NN model is based on a loss function of the NN model. According to an embodiment, the computing module 620 computes the at least one sensitivity metrics based on integration of gradient of the performance along a path from the first set of weights to the second set of weights. According to an embodiment, the computing module 620 computes the at least one sensitivity metrics based on an absolute value of the integration. According to an embodiment, the computing module 620 computes the at least one sensitivity metrics by dividing the path from the first set of weights to the second set of weights into a plurality of segments; and the absolute value of the integration is based on absolute values of integrations of gradient of the performance along each of the plurality of the segments.

[0110] According to an embodiment, the selection module 630 selects a third set of weights from the first set of weights based on the at least one sensitivity metrics by comprising: a performance change module for computing at least one performance change of the NN model based on the at least one sensitivity metrics and distances between corresponding weights in the first set of weights and the second set of weights; and a weight selection module for selecting the third set of weights accounting for a global weight ratio from the first set of weights based on the at least one performance change. According to an embodiment, the global weight ratio is based on the at least one performance change. According to an embodiment, the global weight ratio is allocated to a plurality of local weight ratios, each of the plurality of local weight ratios being determined for a respective layer of the NN model; the at least one performance change comprises a plurality of performance changes, each of the plurality of performance changes being computed for a respective layer of the NN model; and for a first layer of the NN network, the selection module 630 selects the third set of weights by:selecting, based on a first local weight ratio of the first layer and a first performance change for the first layer, at least one weight from weights in the first layer. According to an embodiment, the first local weight ratio of the first layer is allocated from the global weight ratio based on the first performance change for the first layer.

[0111] According to an embodiment, the global weight ratio is indicated by a parameter of the NN model or is pre-configured. According to an embodiment, the third set of weights is selected by the selection module 630 in multiple passes; and for a pass of selection, the selection module 630 selects the third set of weights by: selecting, based on a sub-ratio of the global weight ratio and the at least one performance change, at least one weight from the first set of weights; and updating the at least one sensitivity metrics and the at least one performance change based on the selected at least one weight.

[0112] According to an embodiment, the third set of weights comprises at least one of an outlier weight and a significant weight.

[0113] According to an embodiment, weights in the third set of weights are determined by the determination module 640 as the fourth set of weights for representation of the third set of weights.

[0114] According to an embodiment, the determination module 640 determines the fourth set of weights by: computing weight distances between corresponding weights in the third set of weights and the second set of weights; and wherein a weight of the fourth set of weights is determined based on a weight of the second set of weights corresponding to the third set of weights and a corresponding weight distance.

[0115] According to an embodiment, the determination module 640 further determines a fifth set of weights, the fifth set of weights comprising weights in the second set of weights not corresponding to any of the third set of weights. And the apparatus 600 further comprises a storing module for storing the fourth set of weights and the fifth set of weights.

[0116] Fig. 7 illustrates an exemplary computing system according to aspects of the disclosure. The computing system 700 may comprise at least one processor 710. The computing system 700 may further comprise at least one storage device 720. The storage device 720 may store computer-executable instructions that, when executed, cause the processor 710 to perform any operations according to the embodiments of the present disclosure as described in connection with Figs. 1-6.

[0117] The embodiments of the present disclosure may be embodied in a computer-readable medium such as non-transitory computer-readable medium. The non-transitory computer-readable medium may comprise instructions that, when executed, cause one or more processors to perform any operations according to the embodiments of the present disclosure as described in connection with Figs. 1-6.

[0118] The embodiments of the present disclosure may be embodied in a computer program product comprising computer-executable instructions that, when executed, cause one or more processors to perform any operations according to the embodiments of the present disclosure as described in connection with Figs. 1-6.

[0119] It should be appreciated that all the operations in the methods described above are merely exemplary, and the present disclosure is not limited to any operations in the methods or sequence orders of these operations, and should cover all other equivalents under the same or similar concepts.

[0120] It should also be appreciated that all the modules in the apparatuses described above may be implemented in various approaches. These modules may be implemented as hardware, software, or a combination thereof. Moreover, any of these modules may be further functionally divided into sub-modules or combined.

[0121] The previous description is provided to enable any person skilled in the art to practice the various aspects described herein. 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. Thus, the claims are not intended to be limited to the aspects shown herein. All structural and functional equivalents to the elements of the various aspects described throughout the present 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.

Claims

1.A computer implemented method for quantizing weights of a neural network (NN) model, comprising:quantizing a first set of weights of the NN model into a second set of weights;computing at least one sensitivity metrics based on performances of the NN model with the first set of weights and the second set of weights;selecting a third set of weights from the first set of weights based on the at least one sensitivity metrics; anddetermining a fourth set of weights for representation of the third set of weights, wherein the fourth set of weights is of a first precision higher than a second precision of the second set of weights.2.The method of claim 1, wherein the performance of the NN model is based on a loss function of the NN model.3.The method of claim 1, wherein computing the at least one sensitivity metrics comprises:computing the at least one sensitivity metrics based on integration of gradient of the performance along a path from the first set of weights to the second set of weights.4.The method of claim 3, wherein the at least one sensitivity metrics is computed based on an absolute value of the integration.5.The method of claim 4, wherein computing the at least one sensitivity metrics comprises: dividing the path from the first set of weights to the second set of weights into a plurality of segments; andwherein the absolute value of the integration is based on absolute values of integrations of gradient of the performance along each of the plurality of the segments.6.The method of claim 1, wherein selecting the third set of weights based on the at least one sensitivity metrics comprises:computing at least one performance change of the NN model based on the at least one sensitivity metrics and distances between corresponding weights in the first set of weights and the second set of weights; andselecting the third set of weights accounting for a global weight ratio from the first set of weights based on the at least one performance change.7.The method of claim 6, wherein the global weight ratio is based on the at least one performance change.8.The method of claim 6, wherein the global weight ratio is allocated to a plurality of local weight ratios, each of the plurality of local weight ratios being determined for a respective layer of the NN model;wherein the at least one performance change comprises a plurality of performance changes, each of the plurality of performance changes being computed for a respective layer of the NN model; andwherein for a first layer of the NN network, selecting the third set of weights comprises:selecting, based on a first local weight ratio of the first layer and a first performance change for the first layer, at least one weight from weights of the first layer.9.The method of claim 8, wherein the first local weight ratio of the first layer is allocated from the global weight ratio based on the first performance change for the first layer.10.The method of claim 6, wherein the global weight ratio is indicated by a parameter of the NN model or is pre-configured.11.The method of claim 6, wherein the third set of weights is selected in multiple passes, andwherein for a pass of selection, selecting the third set of weights comprises:selecting, based on a sub-ratio of the global weight ratio and the at least one performance change, at least one weight from the first set of weights;updating the at least one sensitivity metrics and the at least one performance change based on the selected at least one weight.12.The method of claim 1, wherein the third set of weights comprises at least one of an outlier weight and a significant weight.13.The method of claim 1, wherein weights in the third set of weights are determined as the fourth set of weights for representation of the third set of weights.14.The method of claim 1, wherein determining the fourth set of weights comprises:computing weight distances between corresponding weights in the third set of weights and the second set of weights; andwherein a weight in the fourth set of weights is determined based on a weight in the second set of weights corresponding to the third set of weights and a corresponding weight distance.15.The method of claim 1, the method further comprises:determining a fifth set of weights, the fifth set of weights comprising weights in the second set of weights not corresponding to any of the third set of weights; andstoring the fourth set of weights and the fifth set of weights.16.An apparatus for quantizing weights of a neural network (NN) model, comprising:a quantization module for quantizing a first set of weights of the NN model into a second set of weights;a computing module for computing at least one sensitivity metrics based on performances of the NN model with the first set of weights and the second set of weights;a selection module for selecting a third set of weights from the first set of weights based on the at least one sensitivity metrics; anda determination module for determining a fourth set of weights for representation of the third set of weights, wherein the fourth set of weights is of a first precision higher than a second precision of the second set of weights.17.A computer system, comprising:one or more processors; andone or more storage devices storing computer-executable instructions that, when executed, cause the one or more processors to perform the operations of the method of one of claims 1-15.18.A computer program product comprising computer-executable instructions that, when executed, cause one or more processors to perform the operations of the method of one of claims 1-15.19.One or more computer readable storage media storing computer-executable instructions that, when executed, cause one or more processors to perform the operations of the method of one of claims 1-15.