Precision target optimization method and system adaptive to variable precision arithmetic logic unit, medium, terminal and program product
By combining student and teacher models in a variable-precision ALU, bit-level precision adjustment is achieved, solving the problems of insufficient precision adjustment granularity and insufficient adaptive capability in existing technologies, and improving computational efficiency and precision matching.
Patent Information
- Application Number
- CN202511551518.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-28
- Publication Date
- 2026-02-13
Smart Images

Figure CN121523734A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of floating-point arithmetic technology, and in particular to a method, system, medium, terminal and program product for optimizing the precision target of arithmetic logic units adapted to variable precision. Background Technology
[0002] In the field of computing system design and optimization, the Arithmetic Logic Unit (ALU), as the fundamental component for performing core arithmetic and logical operations, is crucial in terms of performance and energy efficiency. Traditional ALUs generally employ a fixed-precision computing model, such as uniformly using 32-bit or 64-bit precision for processing. While this approach can guarantee computational accuracy in scenarios requiring full precision, in tasks demanding high efficiency and energy saving, fixed precision often leads to a waste of computing resources.
[0003] To overcome the limitations of fixed-precision ALUs, variable-precision ALU technology has emerged. Its core idea is to dynamically adjust the calculation precision according to the specific needs of the task, thereby optimizing energy efficiency and computing efficiency.
[0004] However, current variable precision ALU systems have significant granularity limitations at the implementation level. Their precision adjustment is usually based on "bytes" or "words" as the basic unit, and they cannot achieve finer "bit" granularity control. This results in computing resources not being optimally allocated in tasks with large fluctuations in precision requirements.
[0005] Although the industry has attempted to introduce neural networks to predict and generate accuracy thresholds to guide ALU accuracy selection, existing methods typically rely on static rules and predefined data, which cannot adjust accuracy in real time according to task changes, resulting in insufficient adaptability; they also cannot make fine adjustments for the accuracy requirements of different tasks, leading to wasted accuracy or unstable task execution, resulting in a low degree of matching between accuracy and task requirements.
[0006] Therefore, it is necessary to provide a method, system, medium, terminal, and program product for optimizing the precision target of variable precision arithmetic logic units to solve the above-mentioned problems in the prior art. Summary of the Invention
[0007] In view of the shortcomings of the prior art described above, the purpose of this application is to provide a method, system, medium, terminal and program product for optimizing the precision target of an adaptable variable precision arithmetic logic unit, so as to solve the technical problems of insufficient precision adjustment granularity, insufficient adaptive capability and poor matching between precision and task requirements in the prior art.
[0008] To achieve the above and other related objectives, the first aspect of this application provides a precision target optimization method adapted to variable precision arithmetic logic units, comprising:
[0009] Obtain the output feature set of each group in the previous neural network layer;
[0010] Each corresponding output feature set is input into the student model and the pre-trained teacher model respectively; the accuracy generation network layer of the student model generates a corresponding accuracy target based on each corresponding output feature set, and the ALU calculation layer of the student model performs a calculation task based on the generated accuracy target to generate a prediction result; the teacher model generates a reference target and a true label based on the output feature set.
[0011] Based on the accuracy target generated by the student model, the prediction results, the reference target generated by the teacher model, and the true labels, the task loss, accuracy generation loss, and adversarial loss are calculated to construct the total loss function;
[0012] The student model is optimized by backpropagation based on the constructed total loss function to update the parameters of the student model; the student model is trained iteratively until convergence to obtain the final student model.
[0013] The final student model is then deployed to generate the optimal accuracy target for each group.
[0014] In some embodiments of the first aspect of this application, the specific process of the accuracy generation network layer of the student model generating corresponding accuracy targets based on each corresponding set of output features includes: inputting each corresponding set of output features into a global semantic statistics pathway to extract global features; simultaneously inputting each corresponding set of output features into a distribution morphology modeling pathway to extract distribution features; performing cross-modal fusion of the extracted global features and the distribution features to obtain fused features; and outputting each corresponding accuracy target based on the obtained fused features.
[0015] In some embodiments of the first aspect of this application, the specific process of inputting each corresponding set of output features into a global semantic statistical pathway to extract global features includes: performing multi-dimensional statistical feature extraction based on each corresponding set of input output features, extracting energy characterization features, sparsity features, moment features, gradient sensitivity features, and signal-to-noise ratio features respectively; concatenating the extracted energy characterization features, sparsity features, moment features, gradient sensitivity features, and signal-to-noise ratio features into a statistical feature vector; and inputting the statistical feature vector into a multilayer perceptron with residual connections, wherein the multilayer perceptron outputs the global features.
[0016] In some embodiments of the first aspect of this application, the specific process of inputting each corresponding set of output features into a distribution morphology modeling pathway to extract distribution features includes: constructing a distribution representation for each corresponding set of input output features to establish a logarithmic histogram and quantile curves; concatenating the logarithmic histogram and quantile curves into a distribution feature vector; inputting the distribution feature vector into a Transformer encoder, which outputs a distribution representation sequence; and performing global pooling and fully connected projection on the output distribution representation sequence to obtain the distribution features.
[0017] In some embodiments of the first aspect of this application, the specific process of fusing the extracted global features and the distributed features across modalities to obtain fused features includes: calculating global path weights and distributed path weights based on a linear layer and a Sigmoid activation function, respectively, for the input global features and the distributed features; normalizing the global path weights and distributed path weights based on a Softmax function to obtain normalized global path weights and distributed path weights; and using the normalized global path weights and distributed path weights to perform weighted fusion of the global features and the distributed features to obtain fused features.
[0018] In some embodiments of the first aspect of this application, the Adam optimizer is used to update the parameters of the student model.
[0019] To achieve the above and other related objectives, a second aspect of this application provides a precision target optimization system adapted to variable precision arithmetic logic units, comprising:
[0020] The acquisition module is used to acquire the output feature sets of each group in the previous neural network layer;
[0021] The student model and teacher model output modules are used to input the corresponding output feature sets of each group into the student model and the pre-trained teacher model, respectively; the accuracy generation network layer of the student model generates the corresponding accuracy target based on the corresponding output feature sets of each group, and the ALU calculation layer of the student model performs the calculation task based on the generated accuracy target to generate the prediction result; the teacher model generates the reference target and the true label based on the output feature sets.
[0022] The total loss function construction module is used to calculate the task loss, accuracy generation loss, and adversarial loss based on the accuracy target generated by the student model, the prediction result, the reference target generated by the teacher model, and the true label, so as to construct the total loss function;
[0023] The student model optimization module is used to optimize the student model through backpropagation based on the constructed total loss function, so as to update the parameters of the student model; the student model is iteratively trained until convergence to obtain the final student model;
[0024] The model deployment module is used to deploy the final student models and generate the corresponding optimal accuracy target for each group.
[0025] To achieve the above and other related objectives, a third aspect of this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method.
[0026] To achieve the above and other related objectives, a fourth aspect of this application provides a computer program product comprising computer program code that, when executed on a computer, causes the computer to implement the method.
[0027] To achieve the above and other related objectives, a fifth aspect of this application provides an electronic terminal, including a memory, a processor, and a computer program stored in the memory; the processor executes the computer program to implement the method.
[0028] As described above, the accuracy target optimization method, system, medium, terminal, and program product adapted to variable precision arithmetic logic units of this application have the following beneficial effects:
[0029] (1) Achieve fine precision adjustment at the “bit” granularity: The final student model obtained through repeated iterative training accurately generates the corresponding optimal precision target for each group in each layer of the neural network, enabling dynamic precision adjustment at the “bit” granularity, achieving finer-grained control, and realizing more efficient energy efficiency optimization.
[0030] (2) Enhance the adaptive capability of the model: The final student model obtained through repeated iterative training can dynamically adjust the accuracy target according to the input features and computational requirements of different tasks, so as to ensure the best balance between accuracy requirements and energy efficiency.
[0031] (3) Improve the matching degree between accuracy and task requirements: Through the final student model obtained by repeated iteration training, ensure that the accuracy of each calculation task is accurately matched with the actual requirements, and avoid unnecessary waste of accuracy or task errors caused by excessively low accuracy. Attached Figure Description
[0032] Figure 1 The diagram shown is a flowchart illustrating a precision target optimization method for adapting variable precision arithmetic logic units according to an embodiment of this application.
[0033] Figure 2 The diagram shown illustrates the working principle of a precision target optimization method adapted to a variable precision arithmetic logic unit in one embodiment of this application.
[0034] Figure 3 This is a schematic diagram illustrating the workflow of the accuracy generation network layer generating accuracy targets in one embodiment of this application.
[0035] Figure 4 The diagram shown is a block diagram of a precision target optimization system adapted to a variable precision arithmetic logic unit in one embodiment of this application.
[0036] Figure 5 The diagram shown is a structural schematic of an electronic terminal according to an embodiment of this application. Detailed Implementation
[0037] The following specific examples illustrate the implementation of this application. Those skilled in the art can easily understand other advantages and effects of this application from the content disclosed in this specification. This application can also be implemented or applied through other different specific embodiments, and various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of this application. It should be noted that, unless otherwise specified, the following embodiments and features in the embodiments can be combined with each other.
[0038] In the embodiments of this application, terms such as "first" and "second" are used to distinguish identical or similar items with essentially the same function and effect. For example, "first XX" and "second XX" are merely used to distinguish different XXs and do not limit their order. Those skilled in the art will understand that terms such as "first" and "second" do not limit the quantity or execution order, and that "first" and "second" do not necessarily imply that they are different.
[0039] It should be noted that, in the embodiments of this application, the words "exemplary" or "for example" indicate examples, illustrations, or descriptions. Any embodiment or design described as "exemplary" or "for example" in this application should not be construed as being more preferred or advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present the relevant concepts in a concrete manner.
[0040] In this application embodiment, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple.
[0041] Before providing a further detailed description of the present invention, the nouns and terms used in the embodiments of the present invention are explained, and the nouns and terms used in the embodiments of the present invention are subject to the following interpretations:
[0042] <1> Variable precision arithmetic logic unit (ALU): Its core feature is the ability to dynamically change the format and number of bits (i.e. precision) of the numerical representation used when performing calculations at runtime (on-the-fly).
[0043] <2> A Residual Connected Multi-Layer Perceptron (Residual MLP) is a multi-layer perceptron with a shortcut connection added between two or more layers. This connection allows the input of a layer to skip several subsequent layers and pass it to a deeper layer, where it is element-wise added to the outputs of those layers.
[0044] <3> The Transformer encoder is a neural network architecture based on a self-attention mechanism. Its core function is to transform the input sequence of symbols (such as a sentence or a string of words) into a new sequence representation rich in contextual information. It captures complex global dependencies by allowing each element in the sequence to interact directly with all other elements in the sequence.
[0045] <4> Adam (Adaptive Moment Estimation) optimizer: It is an iterative optimization algorithm used to train deep learning models. Its core idea is to calculate an adaptive, independent learning rate for each parameter in the neural network by combining the estimates of the first moment (mean) and the second moment (uncentered variance) of the gradient.
[0046] <5> MSE (Mean Squared Error): is a commonly used loss function in machine learning and statistics, used to measure the difference between predicted and true values.
[0047] To facilitate understanding of the embodiments of this application, in conjunction with Figure 1 and Figure 2 Detailed explanation. Figure 1 A flowchart illustrating a precision target optimization method for adapting variable precision arithmetic logic units according to an embodiment of the present invention is shown. Figure 2 This diagram illustrates the working principle of the precision target optimization method for adapting variable-precision arithmetic logic units according to an embodiment of the present invention. The precision target optimization method for adapting variable-precision arithmetic logic units in this embodiment mainly includes the following steps:
[0048] Step S11: Obtain the output feature set of each group in the previous neural network layer.
[0049] Predefined for each layer of the neural network Divided into Each computational group learns a scalar for each group. For example, the output channels in a convolutional layer are grouped; the attention heads in a Transformer encoder are grouped; and column blocks in an MLP are grouped.
[0050] For example, the output feature sets of each group in the previous neural network layer It is a set of activation values, gradients, etc.
[0051] The pre-trained gold model is used as the teacher model, whose parameters are frozen during subsequent training and do not participate in updates; and the precision generation network layer and ALU calculation layer of the student model are initialized.
[0052] Step S12: Input the corresponding output feature sets of each group into the student model and the pre-trained teacher model respectively; the accuracy generation network layer of the student model generates the corresponding accuracy target based on the corresponding output feature sets of each group, and the ALU calculation layer of the student model performs the calculation task based on the generated accuracy target to generate the prediction result; the teacher model generates the reference target and the true label based on the output feature sets.
[0053] Each precision generation network layer generates a precision target that depends on the output feature set of the previous layer, and the ALU calculation layer performs calculation tasks based on the precision target of each layer. The final output prediction result is obtained by merging the calculation results of all layers.
[0054] In some embodiments of this application, such as Figure 3As shown, the specific process by which the accuracy generation network layer of the student model generates corresponding accuracy targets based on each set of corresponding output features includes: inputting each set of corresponding output features into the global semantic statistics pathway to extract global features; simultaneously inputting each set of corresponding output features into the distribution morphology modeling pathway to extract distribution features; performing cross-modal fusion of the extracted global features and distribution features to obtain fused features; and outputting each set of corresponding accuracy targets based on the obtained fused features.
[0055] By parallel computing of the global semantic statistical pathway and the distribution morphology modeling pathway, the two pathways can run simultaneously, reducing latency and enabling the extraction of semantics at different levels. Then, cross-modal fusion is performed to merge the features, ensuring that the fused features include both global and distributional information, thus improving computational efficiency. Simultaneously, the accuracy target B_( for each group in each layer) , It is generated based on the output features of the previous layer, and it is necessary to ensure that the accuracy of the generated target does not affect the accuracy of the final calculation task.
[0056] In some embodiments of this application, such as Figure 3 As shown, the specific process of inputting each corresponding output feature set into the global semantic statistical pathway to extract global features includes: performing multi-dimensional statistical feature extraction based on each corresponding input output feature set, extracting energy characterization features, sparsity features, moment features, gradient sensitivity features, and signal-to-noise ratio features respectively; concatenating the extracted energy characterization features, sparsity features, moment features, gradient sensitivity features, and signal-to-noise ratio features into a statistical feature vector; and inputting the statistical feature vector into a multilayer perceptron with residual connections, wherein the multilayer perceptron outputs the global features.
[0057] Specifically, the energy characterization features include mean, variance, and peak energy. The mean represents the overall central tendency, reflecting the average level of the data; the variance represents the range of data fluctuations, reflecting the stability of the data; and the peak energy represents the magnitude of extreme amplitudes, reflecting the maximum dynamic range of the data. The specific calculation formulas are as follows:
[0058] ;Formula (1)
[0059] ;Formula (2)
[0060] ;Formula (3)
[0061] in, It represents the mean, reflecting the average value of all elements within the group and indicating the overall level. This indicates the total number of elements in the group; Indicates the upper level ( The first in group ) The output feature set of each element; Variance is used to measure the dispersion of data within a group; the larger the value, the more volatile the data. Represents peak energy, reflecting the maximum absolute value of the elements in the group, used to capture extreme amplitudes and characterize the upper bound of the dynamic range.
[0062] sparsity characteristics This indicates the proportion of zero elements in the group. If most elements are 0, then... Approaching 1; if almost no 0, then Approaching 0, the specific formula for its calculation is as follows:
[0063] ;Formula (4)
[0064] in, This represents an exponential function; if the condition is true, it takes the value 1; otherwise, it takes the value 0.
[0065] Moment characteristics This indicates the amplitude moment of the group, if Then the average energy magnitude is calculated, similar to the mean square amplitude; if This emphasizes the significant activation contribution and characterizes the thickness of the distribution tail. The specific formula for its calculation is as follows:
[0066] ;Formula (5)
[0067] in, It represents the absolute value.
[0068] Gradient sensitivity features This is used to measure how much the computational task matters to the group, if The larger the value, the more sensitive the group is to task loss, and the higher the precision required. The calculation formula is as follows:
[0069] ;Formula (6)
[0070] in, This represents the task loss function (cross-entropy or MSE). This represents the gradient of the loss with respect to that set of outputs; Represents the norm (the square root of the sum of squares).
[0071] Signal-to-noise ratio characteristics Used to measure the ratio of signal to gradient, if A large value indicates a strong signal, weak gradient, and stable calculation, allowing for low-precision calculations; if... A smaller value indicates a strong gradient and task sensitivity, requiring high-precision calculation. The calculation formula is as follows:
[0072] ;Formula (7)
[0073] in, It reflects the activation intensity, that is, the magnitude of the signal energy; This represents the gradient strength, reflecting the task driving force and noise.
[0074] By combining gradient sensitivity features and signal-to-noise ratio features, if the gradient sensitivity is high and the signal-to-noise ratio is low, high accuracy needs to be maintained; if the gradient sensitivity is low and the signal-to-noise ratio is high, accuracy can be relaxed.
[0075] The extracted energy characterization features, sparsity features, moment features, gradient sensitivity features, and signal-to-noise ratio features are concatenated into a statistical feature vector, resulting in the statistical feature vector. ,as follows:
[0076] ;Formula (8)
[0077] The statistical feature vector obtained by formula (8) is input into a multilayer perceptron with residual connections. Specifically, the input statistical feature vector is layer normalized for stable training. Then, the layer normalized features are input into the first fully connected layer for linear transformation and ReLU activation to extract primary nonlinear features. The primary nonlinear features are then input into the second fully connected layer for linear transformation and ReLU activation to further extract higher-level nonlinear features, thereby improving the expressive power of the model. Finally, residual connections are used to prevent gradient vanishing and enhance the stability of the model, ultimately obtaining 32-dimensional or 64-dimensional global features.
[0078] In some embodiments of this application, such as Figure 3 As shown, the specific process of inputting each corresponding output feature set into the distribution morphology modeling path to extract distribution features includes: constructing a distribution representation for each corresponding input output feature set to establish a logarithmic histogram and quantile curve; concatenating the logarithmic histogram and quantile curve into a distribution feature vector; inputting the distribution feature vector into a Transformer encoder, which outputs a distribution representation sequence; and performing global pooling and fully connected projection on the output distribution representation sequence to obtain the distribution features.
[0079] Specifically, a distribution representation is constructed for the output feature set corresponding to each input group to establish a logarithmic histogram and quantile curve. The logarithmic histogram describes the proportion of values within a group distributed across different order of magnitude intervals (logarithmic scale), and its specific calculation formula is as follows:
[0080] ;Formula (9)
[0081] in, This indicates taking the absolute value, ensuring that the logarithm is valid; It represents the logarithm to the base 2; it is used to measure the order of magnitude of a numerical value. Indicates the first A logarithmic interval (bucketing) is usually used to divide the range of values into... A range; This indicates an indicator function; it takes the value 1 if the condition within the square brackets is true, and 0 otherwise. This indicates all members within the group. Accumulate each element; This indicates normalization, making the result a proportion rather than a total. Indicates the first The probability of a histogram bucket.
[0082] The specific calculation formula for constructing the quantile curve is as follows:
[0083] ;Formula (10)
[0084] in, Represents random variables Less than or equal to The probability (cumulative distribution function); Indicates a threshold variable; Indicates the quantile level, for example, the value. ; The infimum (minimum upper bound) represents the minimum value that satisfies the condition. value; This represents the numerical value at the corresponding quantile. If Represents the median; if and , representing the 10th percentile and 90th percentile respectively, are used to characterize the tail and range of the distribution.
[0085] The logarithmic histogram and quantile curve established according to formulas (9) and (10) are combined into a distribution feature vector, and the distribution feature vector is input into the Transformer encoder to output the distribution representation sequence. By using the Transformer encoder, the self-attention mechanism can directly learn global dependencies, which is suitable for modeling complex distribution morphological relationships. When the distribution sequence is long (e.g., the histogram has many bins), the Transformer encoder can better characterize the global morphology. Specifically, the distribution feature vector is input into the embedding layer, and the original distribution feature vector is projected into the embedding space to uniformly transform the dimension; the features output from the embedding layer are input into the multi-head self-attention layer to generate query, key and value matrices, and attention is calculated. The outputs of multiple attention heads are concatenated; the output features of multiple attention heads are then subjected to residual connection and layer normalization; the residual connection and layer normalized features are then input into the feedforward network to introduce stronger nonlinear transformation; after multiple transformations, a high-level semantic representation is obtained, thereby outputting the distribution representation sequence.
[0086] The distribution representation sequence is then globally pooled to aggregate the variable-length sequence representation into a fixed-length global vector. After full-connected projection, the pooled global vector is projected onto the target embedding space to output the distribution features.
[0087] In some embodiments of this application, such as Figure 3 As shown, the specific process of fusing the extracted global features and distributed features across modalities to obtain fused features includes: calculating global path weights and distributed path weights based on a linear layer and a sigmoid activation function, respectively, for the input global features and distributed features; normalizing the global path weights and distributed path weights based on a Softmax function to obtain normalized global path weights and distributed path weights; and using the normalized global path weights and distributed path weights to perform weighted fusing of the global features and distributed features to obtain fused features.
[0088] Specifically, the global path weights are first calculated based on the input global features and distribution features using a linear layer and a Sigmoid activation function. and distributed path weights The specific calculation formula is as follows:
[0089] ;Formula (11)
[0090] ;Formula (12)
[0091] in, An embedding vector representing the global features output by the global semantic statistical pathway; An embedding vector representing the distribution characteristics output by the distribution morphology modeling pathway; , The learnable weight matrix maps the input embedding to a scalar or low-dimensional representation. , Indicates the bias term, providing flexible translation adjustment; This indicates that the Sigmoid activation function compresses the result to (0, 1), ensuring that the output can be interpreted as an importance coefficient.
[0092] Based on formulas (11) and (12), a score is calculated for the global semantic statistical pathway and the distribution morphology modeling pathway, respectively. That is, the contribution of the pathway to the current group is calculated. If the weight of the global pathway is greater, it means that the global feature is more important; if the weight of the distribution pathway is greater, it means that the distribution feature is more critical.
[0093] The global and distributed path weights are then normalized using the Softmax function to ensure that the calculated scores of the two paths are converted into probabilistic forms, avoiding excessively large or small weights and ensuring stable fusion. If the statistical characteristics of a group are stable, the normalized global path weights are high, and the model relies more on global statistical features; if the distribution tails of a group are abnormal, the normalized distributed path weights are high, and the model relies more on distribution details. In this way, the fused representation of each group is adaptive, and the model can adaptively decide which type of feature to favor in different groups.
[0094] Finally, the normalized global path weights and distributed path weights are weighted and fused. For example, the fusion is a convex combination to ensure that the output fused features are stable within the tension space of the two information paths, ensuring dynamic balance between global and distributed features, and providing a computational basis for the output accuracy target.
[0095] Based on the obtained fusion features, the corresponding accuracy target for each group is output, as shown in the following formula:
[0096] ;Formula (13)
[0097] in, This represents the weighted fusion embedding vector, which includes global features and distribution features; The output layer function is represented by linear projection (affine transformation). This indicates that the output projection matrix (a learnable parameter) maps the embedding to a scalar; Indicates the bias term, providing numerical translation; Indicates the current layer The The accuracy target for each group.
[0098] According to formula (13), the high-dimensional embedding is transformed into a practically usable precision target value. During training, B_{ℓ,g} is continuously optimizable, but during deployment, it needs to be quantized into discrete levels. The fused information is decoded into control parameters that the hardware can directly use, thus establishing a bridge from features to precision targets, so that the semantic representation obtained from training can directly drive hardware precision control.
[0099] By designing global semantic statistical pathways to model the overall trend and distribution pattern to model the tail and shape, the two are orthogonal. Serial processing would lose information, while parallel processing can ensure complete expression. Furthermore, the contribution of different pathways is analyzed separately, making parameter tuning and visualization more intuitive.
[0100] Step S13: Based on the accuracy target generated by the student model, the prediction result, the reference target generated by the teacher model, and the real label, calculate the task loss, accuracy generation loss, and adversarial loss to construct the total loss function.
[0101] To generate the minimum precision target for each set, an adversarial loss is introduced. Through adversarial training, the precision generation network layer can not only generate low-precision targets but also ensure that the generated precision does not lead to excessive discrepancies between the task output and the teacher model. Specifically, the task loss... It represents the difference between the student model output and the teacher model output. MSE is often used as a metric for task loss, and its goal is to minimize the difference between the student model output and the teacher model output. The specific formula is as follows:
[0102] ;Formula (14)
[0103] in, This represents the prediction result output by the student model; This represents the true label output by the teacher model; This represents the number of training samples.
[0104] Precision generation loss This is used to encourage the generation of lower accuracy targets, reducing computation and energy consumption. This loss function measures the difference between the generated accuracy target and the teacher model's reference target. Its goal is to minimize the difference between the student model's generated accuracy target and the teacher model's reference target, while ensuring that the generated accuracy target is as small as possible; the lower the accuracy, the better. The calculation formula is as follows:
[0105] ;Formula (15)
[0106] in, The accuracy target generated for the student model, i.e., the accuracy corresponding to each operator; This represents the reference target for the teacher model generation; This represents the number of training samples.
[0107] Design to counter loss The goal is to generate low-precision targets through adversarial training, while maintaining the accuracy of the task output close to that of the teacher model. In the adversarial loss, we want the accuracy target to be as low as possible, but without affecting the accuracy of the task output. The calculation formula is as follows:
[0108] ;Formula (16)
[0109] in, Accuracy targets generated for student models; Reference targets generated for the teacher model; It refers to the tolerance for changes in control accuracy, that is, the range of variation of the accuracy target.
[0110] The difference between the accuracy target generated by the student model and the reference target generated by the teacher model is calculated according to formula (16), and then... The value is used to control the range of variation of the precision target, and its goal is to ensure that the precision of the computation task output is not affected while generating low-precision targets.
[0111] According to formula (16), when Less than or equal to The value is 0, at which point the adversarial loss is 0, allowing slight differences without penalty, and encouraging low precision; when Greater than The value is set at which point the adversarial loss value is greater than 0. The larger the gap, the heavier the penalty, preventing excessive reduction in accuracy. This forces the model to move towards lower accuracy as much as possible while ensuring the correctness of the task.
[0112] Based on task loss, accuracy generation loss, and adversarial loss, a total loss function is constructed, with the ultimate goal of minimizing the total loss. The calculation formula is as follows:
[0113] ;Formula (17)
[0114] in, , These are hyperparameters used to balance the contributions of different loss terms and control their relative importance. Larger targets require greater precision to prevent them from moving around randomly. For larger applications, the emphasis is placed on minimizing precision and saving power consumption. Ensure the correctness of the model task itself (classification, regression, etc.); Ensure that the accuracy target is reasonable and does not deviate from the accuracy of the teacher's model; It is used to push the model towards lower accuracy, but there is a threshold limit to avoid excessive reduction in accuracy.
[0115] To further optimize accuracy targets and encourage low-energy and more stable accuracy targets, a regularization term is introduced into the total loss function.
[0116] Step S14: Optimize the student model by backpropagation based on the constructed total loss function to update the parameters of the student model; iterate the training of the student model until convergence to obtain the final student model.
[0117] Step S15: Deploy the final student model to generate the corresponding optimal accuracy target for each group.
[0118] During training, the parameters of the student model's precision generation network layer and ALU computation layer are updated through backpropagation to minimize the total loss. This allows the model to both correctly complete the task and learn to select an appropriate precision target while maintaining correctness. By combining the student model's precision generation network layer and the total loss function, the goal is to generate the minimum precision requirement for each group in each layer, while ensuring that the generated precision does not affect the final task's output precision.
[0119] Finally, through repeated iterative training, the final student model is obtained, which is used to generate the optimal accuracy target for each group and ensure that the student model can minimize energy consumption and computational complexity under limited computing resources, while ensuring that the task accuracy is close to that of the teacher model.
[0120] In some embodiments of this application, the Adam optimizer is used to update the parameters of the student model.
[0121] Furthermore, a validation set is used to evaluate the model and adjust the hyperparameters.
[0122] The accuracy target optimization method for the adaptive variable precision arithmetic logic unit in this application embodiment adopts the variable precision ALU directly participating in model training, and uses the accuracy target of each group in each layer as a learnable parameter. After training, it is directly sent to the ALU to control the calculation accuracy. During deployment, the quantized optimal accuracy target is written into a lookup table and stored in the control status register (CSR) or on-chip SRAM. When performing the calculation of a certain group, the corresponding accuracy parameter is read from this lookup table and the corresponding calculation unit is configured.
[0123] Figure 4 This is a block diagram of a precision target optimization system for adapting variable precision arithmetic logic units provided in an embodiment of this application. Figure 4 As shown, the precision target optimization system 400 adapted to variable precision arithmetic logic units includes:
[0124] The acquisition module 401 is used to acquire the output feature sets of each group in the previous neural network layer;
[0125] The student model and teacher model output module 402 is used to input the corresponding output feature sets of each group into the student model and the pre-trained teacher model respectively; the accuracy generation network layer of the student model generates the corresponding accuracy target based on the corresponding output feature sets of each group, and the ALU calculation layer of the student model performs the calculation task based on the generated accuracy target to generate the prediction result; the teacher model generates the reference target and the true label based on the output feature sets.
[0126] The total loss function construction module 403 is used to calculate the task loss, accuracy generation loss, and adversarial loss based on the accuracy target generated by the student model, the prediction result, the reference target generated by the teacher model, and the real label, so as to construct the total loss function;
[0127] The student model optimization module 404 is used to optimize the student model by backpropagation based on the constructed total loss function, so as to update the parameters of the student model; and iteratively train the student model until convergence to obtain the final student model.
[0128] The model deployment module 405 is used to deploy the final student model and generate the corresponding optimal accuracy target for each group.
[0129] The precision target optimization system for adapting variable precision arithmetic logic units in this application has the following effects: (1) Improved computational efficiency and energy efficiency: By generating dynamic precision targets at the "bit" granularity according to the input characteristics and computational requirements of the task through the model, each computational operation can choose the most suitable precision level, optimize the allocation of computational resources, and improve computational efficiency; for tasks with low precision requirements, the system can reduce the number of computation bits, thereby significantly reducing power consumption; (2) Enhanced adaptability and improved task adaptability: By learning the characteristics of the task (such as data distribution, computational requirements, etc.) through the model, the precision target can be automatically adjusted according to the input characteristics and dynamic changes of different tasks, adaptively generating precision targets, flexibly responding to the precision requirements of different tasks, ensuring a balance between precision and efficiency, and improving the applicability of the system in complex scenarios; (3) Improved the matching degree between precision and task requirements and avoided resource waste: By dynamically adjusting the precision of each computational unit through the model, the actual requirements of the task can be accurately matched, avoiding unnecessary over-adjustment of precision. (3) Ensure that the task will not be executed due to low precision, and also avoid the waste of computing resources due to high precision. This ensures that the task can meet the precision requirements and minimize the consumption of computing resources when it is completed. (4) Reduce the computational overhead and enhance stability: By optimizing the computational efficiency in the precision adjustment process, the computational overhead of the model in precision generation is reduced, ensuring that precision adjustment can be executed in real time in a resource-limited environment. In addition, the stability of the precision adjustment process is significantly improved, avoiding instability caused by over-adjustment of precision and reducing redundant computation. At the same time, an adversarial training mechanism is introduced to further enhance the stability and robustness of precision adjustment, so that the task can maintain consistent output quality at all precision levels. (5) Improve the scalability and adaptability of the system: A flexible and scalable precision adjustment scheme is provided, which can adapt to higher complexity computing tasks and maintain efficient operation in multi-level and large-scale computing. Through flexible precision adjustment methods, it supports the parallel execution of different computing tasks and maintains excellent performance in various complex computing environments.
[0130] It should be understood that the specific process of each module performing the above-mentioned steps has been described in detail in the above method embodiments, and will not be repeated here for the sake of brevity.
[0131] It should also be understood that the module division in the embodiments of this application is illustrative and only represents a logical functional division; in actual implementation, there may be other division methods. Furthermore, the functional modules in the various embodiments of this application can be integrated into a single processor, exist as separate physical entities, or be integrated into a single module. The integrated modules described above can be implemented in hardware or as software functional modules.
[0132] Figure 5 This is a schematic block diagram of the electronic terminal provided in an embodiment of this application. Figure 5 As shown, the electronic terminal 500 includes at least one processor 501, a memory 502, at least one network interface 503, and a user interface 505. The various components in the electronic terminal 500 are coupled together via a bus system 504. It is understood that the bus system 504 is used to implement communication between these components. In addition to a data bus, the bus system 504 also includes a power bus, a control bus, and a status signal bus. However, for clarity, in… Figure 5 The general will label all buses as bus systems.
[0133] The user interface 505 may include a monitor, keyboard, mouse, trackball, clicker, button, touchpad, or touch screen.
[0134] It is understood that memory 502 can be volatile memory or non-volatile memory, or both. Non-volatile memory can be read-only memory (ROM) or programmable read-only memory (PROM), which serves as an external cache. By way of example, but not limitation, many forms of RAM are available, such as static random access memory (SRAM) and synchronous static random access memory (SSRAM). The memories described in the embodiments of this invention are intended to include, but are not limited to, these and any other suitable categories of memory.
[0135] In this embodiment of the invention, the memory 502 is used to store various types of data to support the operation of the electronic terminal 500. Examples of this data include: any executable program for operation on the electronic terminal 500, such as the operating system 5021 and application programs 5022; the operating system 5021 contains various system programs, such as the framework layer, core library layer, driver layer, etc., for implementing various basic services and handling hardware-based tasks. The application program 5022 may contain various applications, such as a media player, browser, etc., for implementing various application services. The methods provided in this embodiment of the invention can be included in the application program 5022.
[0136] The methods disclosed in the above embodiments of the present invention can be applied to processor 501, or implemented by processor 501. Processor 501 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the integrated logic circuit of the hardware in processor 501 or by instructions in the form of software. The processor 501 may be a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Processor 501 can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of the present invention. General-purpose processor 501 may be a microprocessor or any conventional processor, etc. The steps of the accessory optimization method provided in the embodiments of the present invention can be directly reflected as being executed by a hardware decoding processor, or being executed by a combination of hardware and software modules in the decoding processor. The software module may be located in a storage medium, which is located in memory. The processor reads the information in the memory and combines it with its hardware to complete the steps of the aforementioned method.
[0137] In an exemplary embodiment, the electronic terminal 500 may be used by one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), or complex programmable logic devices (CPLDs) to execute the aforementioned method.
[0138] According to the method provided in the embodiments of this application, this application also provides a computer program product, which includes: computer program code, which, when run on a computer, causes the computer to execute... Figures 1 to 3 The method of any of the embodiments shown.
[0139] According to the method provided in the embodiments of this application, this application also provides a computer-readable storage medium storing program code, which, when executed on a computer, causes the computer to perform... Figures 1 to 3 The method of any of the embodiments shown.
[0140] As used in this specification, the terms "component," "module," "system," etc., are used to refer to computer-related entities, hardware, firmware, combinations of hardware and software, software, or software in execution. For example, a component can be, but is not limited to, a process running on a processor, a processor, an object, an executable file, an execution thread, a program, and / or a computer. As illustrated, applications running on computing devices and computing devices can both be components. One or more components may reside in a process and / or an execution thread, and components may be located on a single computer and / or distributed among two or more computers. Furthermore, these components can be executed from various computer-readable media on which various data structures are stored. Components can communicate, for example, via local and / or remote processes based on signals having one or more data packets (e.g., data from two components interacting with another component between a local system, a distributed system, and / or a network, such as the Internet interacting with other systems via signals).
[0141] Those skilled in the art will recognize that the various illustrative logical blocks and steps described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this application.
[0142] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0143] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0144] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0145] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0146] In the above embodiments, the functions of each functional unit can be implemented entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. A computer program product includes one or more computer instructions (programs). When the computer program instructions (programs) are loaded and executed on a computer, all or part of the flow or function according to the embodiments of this application is generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. Computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available media can be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., high-density digital video discs, DVDs), or semiconductor media (e.g., solid-state disks, SSDs, etc.).
[0147] If a function is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0148] In summary, addressing the technical problems of insufficient precision adjustment granularity, inadequate adaptability, and poor matching between precision and task requirements in existing technologies, this invention provides a precision target optimization method, system, medium, terminal, and program product adapted to variable precision arithmetic logic units. Through iterative training, the final student model accurately generates the optimal precision target for each group in each layer of the neural network, enabling dynamic precision adjustment at the "bit" granularity. This achieves finer-grained control and more efficient energy efficiency optimization. Furthermore, it can dynamically adjust the precision target based on the input characteristics and computational requirements of different tasks, ensuring an optimal balance between precision requirements and energy efficiency, thereby enhancing the model's adaptability. Simultaneously, it ensures that the precision of each computational task precisely matches the actual requirements, avoiding unnecessary precision waste or errors caused by excessively low precision, thus improving the matching degree between precision and task requirements. By optimizing the computational efficiency of the precision adjustment algorithm, the computational burden on the model is reduced, ensuring the stability of the precision adjustment process and avoiding instability caused by over-adjustment. Moreover, this invention provides a flexible and scalable precision adjustment method that can adapt to multi-level and highly complex computational tasks, meeting the needs of a wide range of application scenarios. Therefore, this invention not only improves the performance and energy efficiency of variable precision ALUs, but also enhances their adaptability to dynamic computing tasks, providing a more precise and controllable precision adjustment solution for high-performance, low-power computing systems. Thus, this application effectively overcomes the various shortcomings of existing technologies and has high industrial applicability.
[0149] The above embodiments are merely illustrative of the principles and effects of this application and are not intended to limit this application. Any person skilled in the art can modify or alter the above embodiments without departing from the spirit and scope of this application. Therefore, all equivalent modifications or alterations made by those skilled in the art without departing from the spirit and technical concept disclosed in this application should still be covered by the claims of this application.
Claims
1. A method for optimizing the precision target of an adaptable variable-precision arithmetic logic unit, characterized in that, include: Obtain the output feature set of each group in the previous neural network layer; Each corresponding output feature set is input into the student model and the pre-trained teacher model respectively; the accuracy generation network layer of the student model generates a corresponding accuracy target based on each corresponding output feature set, and the ALU calculation layer of the student model performs a calculation task based on the generated accuracy target to generate a prediction result; The teacher model generates reference targets and real labels based on the output feature set; Based on the accuracy target generated by the student model, the prediction results, the reference target generated by the teacher model, and the true labels, the task loss, accuracy generation loss, and adversarial loss are calculated to construct the total loss function; The student model is optimized by backpropagation based on the constructed total loss function to update the parameters of the student model; the student model is trained iteratively until convergence to obtain the final student model. The final student model is then deployed to generate the optimal accuracy target for each group.
2. The precision target optimization method for adapting variable precision arithmetic logic units according to claim 1, characterized in that, The specific process by which the accuracy generation network layer of the student model generates the corresponding accuracy target based on each set of output features includes: Each corresponding output feature set is input into the global semantic statistics pathway to extract global features; simultaneously, each corresponding output feature set is input into the distribution morphology modeling pathway to extract distribution features. The extracted global features and distributed features are fused across modalities to obtain fused features; Based on the obtained fusion features, the corresponding accuracy target for each group is output.
3. The precision target optimization method for adapting variable precision arithmetic logic units according to claim 2, characterized in that, The specific process of inputting each corresponding output feature set into the global semantic statistical pathway to extract global features includes: Based on the corresponding output feature set of each input group, multi-dimensional statistical features are extracted, namely energy characterization features, sparsity features, moment features, gradient sensitivity features, and signal-to-noise ratio features; and the extracted energy characterization features, sparsity features, moment features, gradient sensitivity features, and signal-to-noise ratio features are concatenated into a statistical feature vector. The statistical feature vector is input into a multilayer perceptron with residual connections, and the multilayer perceptron outputs the global features.
4. The precision target optimization method for adapting variable precision arithmetic logic units according to claim 2, characterized in that, The specific process of inputting each corresponding output feature set into the distribution morphology modeling pathway to extract distribution features includes: The corresponding output feature set of each input group is used to construct a distribution representation to establish a logarithmic histogram and quantile curve; and the logarithmic histogram and quantile curve are concatenated to form a distribution feature vector. The distribution feature vector is input into the Transformer encoder, and the Transformer encoder outputs a distribution representation sequence; The output distribution representation sequence is subjected to global pooling and fully connected projection to obtain the distribution features.
5. The precision target optimization method for adapting variable precision arithmetic logic units according to claim 2, characterized in that, The specific process of fusing the extracted global features and the distributed features across modes to obtain the fused features includes: The global path weights and distributed path weights are calculated based on the linear layer and the Sigmoid activation function, respectively, for the input global features and distributed features. The global path weights and distributed path weights are normalized using the Softmax function to obtain normalized global path weights and distributed path weights. The global features and the distributed features are weighted and fused using the normalized global path weights and distributed path weights to obtain the fused features.
6. The precision target optimization method for adapting variable precision arithmetic logic units according to claim 1, characterized in that, The Adam optimizer is used to update the parameters of the student model.
7. A precision target optimization system adapted to variable precision arithmetic logic units, characterized in that, include: The acquisition module is used to acquire the output feature sets of each group in the previous neural network layer; The student model and teacher model output modules are used to input the corresponding output feature sets of each group into the student model and the pre-trained teacher model, respectively; the accuracy generation network layer of the student model generates the corresponding accuracy target based on the corresponding output feature sets of each group, and the ALU calculation layer of the student model performs the calculation task based on the generated accuracy target to generate the prediction result; The teacher model generates reference targets and real labels based on the output feature set; The total loss function construction module is used to calculate the task loss, accuracy generation loss, and adversarial loss based on the accuracy target generated by the student model, the prediction result, the reference target generated by the teacher model, and the true label, so as to construct the total loss function; The student model optimization module is used to optimize the student model through backpropagation based on the constructed total loss function, so as to update the parameters of the student model; the student model is iteratively trained until convergence to obtain the final student model; The model deployment module is used to deploy the final student models and generate the corresponding optimal accuracy target for each group.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1 to 6.
9. A computer program product, characterized in that, The computer program product includes computer program code that, when run on a computer, causes the computer to implement the method as described in any one of claims 1 to 6.
10. An electronic terminal, comprising a memory, a processor, and a computer program stored in the memory, characterized in that, The processor executes the computer program to implement the method as described in any one of claims 1 to 6.
Citation Information
Cited By
Bit allocation method and device for mixed precision quantization model
CN122065884A