Model training method and device, electronic equipment, storage medium and program product

By building an overall energy consumption prediction model, predicting and optimizing the energy consumption strategy during model training, the problem of high energy consumption and high carbon emissions in artificial intelligence cluster model training is solved, and the training effect with the lowest energy consumption is achieved.

CN118747516APending Publication Date: 2024-10-08SHANGHAI SUIYUAN TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202410845245.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-27
Publication Date
2024-10-08

Smart Images

  • Figure CN118747516A_ABST
    Figure CN118747516A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a model training method and device, electronic equipment, a storage medium and a program product, and the method comprises the steps: obtaining model training energy consumption associated sample data; wherein the model training energy consumption associated sample data comprises model structure sample data, training strategy sample data and average energy consumption sample data; training an overall energy consumption prediction model according to the model training energy consumption associated sample data; wherein the trained overall energy consumption prediction model is used for predicting a training strategy with the lowest energy consumption for the to-be-trained model. According to the technical scheme of the embodiment of the invention, the energy consumption of model training is reduced, and the training cost of the model and the carbon emission in the model training process are greatly reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present invention relate to the field of artificial intelligence technology, and in particular, to a model training method, device, electronic device, storage medium and program product. Background Art

[0002] The development of artificial intelligence technology has achieved tremendous breakthroughs in various fields, among which model training and optimization methods are one of the key links in realizing artificial intelligence applications.

[0003] Using an AI cluster to train a large model consumes a lot of energy, mainly from computing resources, data transmission, storage devices, and cooling systems. For a stable AI cluster, the equipment resources and operation strategies are fixed, so the model training method will affect the energy consumption of the AI ​​cluster.

[0004] In the process of implementing the present invention, the inventors found that when using an artificial intelligence cluster to train a model, the energy consumption of the model training process will be affected by many factors, including model complexity, software and hardware performance, training data scale, distributed training configuration and training skills. Among them, for a model of a given scale, the software and hardware performance and the scale of training data are fixed, so the model complexity, distributed training configuration and training skills will affect the energy consumption of this model training process. In general, the energy consumption generated by the training model includes computing resource energy consumption, data transmission energy consumption, storage device energy consumption and cooling system energy consumption, which is jointly generated by multiple constraints. Theoretically, in a model training scenario, for a fixed model, there is a set of optimal training strategies, including the optimal setting of hyperparameters, the optimal configuration of distributed training and the use of training skills, which can minimize the energy consumption of the overall model training process. Summary of the invention

[0005] The embodiments of the present invention provide a model training method, device, electronic device, storage medium and program product, which are conducive to reducing the energy consumption of model training, significantly reducing the training cost of the model and the carbon emissions of the model training process.

[0006] According to one aspect of the present invention, a model training method is provided, comprising:

[0007] Acquire model training energy consumption-related sample data; wherein the model training energy consumption-related sample data includes model structure sample data, training strategy sample data, and average energy consumption sample data;

[0008] Training the overall energy consumption prediction model based on the energy consumption associated sample data of the model training;

[0009] Among them, the trained overall energy consumption prediction model is used to predict the training strategy with the lowest energy consumption for the training model.

[0010] According to another aspect of the present invention, a model training method is provided, comprising:

[0011] Determine the model structure of the model to be trained, and input the model structure of the model to be trained into the overall energy consumption prediction model; wherein the overall energy consumption prediction model is trained by the model training method described in the first aspect;

[0012] The model structure of the model to be trained is traversed by the overall energy consumption prediction model to calculate the model training prediction energy consumption corresponding to multiple training strategies;

[0013] Select a target training strategy corresponding to the target model training predicted energy consumption, and perform model training on the model to be trained.

[0014] According to another aspect of the present invention, there is provided a model training device, comprising:

[0015] A model training energy consumption associated sample data acquisition module is used to acquire model training energy consumption associated sample data; wherein the model training energy consumption associated sample data includes model structure sample data, training strategy sample data and average energy consumption sample data;

[0016] A first model training module, used for inputting the model training energy consumption associated sample data into the overall energy consumption prediction model to train the overall energy consumption prediction model;

[0017] Among them, the trained overall energy consumption prediction model is used to predict the training strategy with the lowest energy consumption for the training model.

[0018] According to another aspect of the present invention, there is provided a model training device, comprising:

[0019] A model structure input module, used to determine the model structure of the model to be trained, and input the model structure of the model to be trained into the overall energy consumption prediction model; wherein the overall energy consumption prediction model is trained by the model training method described in the first aspect;

[0020] A model training prediction energy consumption calculation module is used to traverse the model structure of the model to be trained through the overall energy consumption prediction model and calculate the model training prediction energy consumption corresponding to multiple training strategies;

[0021] The second model training module is used to select a target training strategy corresponding to the target model training predicted energy consumption, and perform model training on the model to be trained.

[0022] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:

[0023] at least one processor; and

[0024] a memory communicatively connected to the at least one processor; wherein,

[0025] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the model training method described in any embodiment of the present invention.

[0026] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the model training method described in any embodiment of the present invention when executed.

[0027] According to another aspect of the present invention, a computer program product is also provided, including a computer program, which implements the model training method described in any embodiment of the present invention when executed by a processor.

[0028] The embodiment of the present invention obtains model training energy consumption associated sample data including model structure sample data, training strategy sample data and average energy consumption sample data, thereby inputting the model training energy consumption associated sample data into the overall energy consumption prediction model to train the overall energy consumption prediction model. After the overall energy consumption prediction model is trained, the model structure of the model to be trained can be determined, and the model structure of the model to be trained can be input into the overall energy consumption prediction model, so that the overall energy consumption prediction model can traverse the model structure of the model to be trained and calculate the model training predicted energy consumption corresponding to multiple training strategies. When all training strategies correspond to the predicted model training predicted energy consumption, the target training strategy corresponding to the target model training predicted energy consumption can be selected from them, and the model training of the model to be trained can be performed. The above technical solution can solve the existing problem of being unable to predict the energy consumption of the model training process to control the model training energy consumption, and can realize the prediction of the energy consumption data of the model training process, thereby determining the training strategy with the lowest energy consumption based on the predicted energy consumption data, which is conducive to reducing the energy consumption of model training, greatly reducing the training cost of the model and the carbon emissions of the model training process.

[0029] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0031] Figure 1 is a flow chart of a model training method provided in Embodiment 1 of the present invention;

[0032] Figure 2 is a flow chart of a model training method provided in Embodiment 2 of the present invention;

[0033] Figure 3 It is a flowchart of a model training method provided in Embodiment 2 of the present invention;

[0034] Figure 4 is a flow chart of a model training method provided in Embodiment 3 of the present invention;

[0035] Figure 5 is a schematic diagram of a model training device provided by Embodiment 4 of the present invention;

[0036] Figure 6 is a schematic diagram of a model training device provided in Embodiment 5 of the present invention;

[0037] Figure 7 A schematic diagram of the structure of an electronic device provided in Embodiment 6 of the present invention. DETAILED DESCRIPTION

[0038] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0039] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0040] Embodiment 1

[0041] Figure 1 This is a flow chart of a model training method provided in the first embodiment of the present invention. This embodiment is applicable to the case of using the model training energy consumption associated sample data to train the overall energy consumption prediction model. The method can be executed by a model training device, which can be implemented by software and / or hardware and can generally be integrated in an electronic device. The electronic device can be a server device. As long as it can be used to train the model, the embodiment of the present invention does not limit the specific device type of the electronic device. Accordingly, Figure 1 As shown, the method includes the following operations:

[0042] S110, obtaining sample data associated with model training energy consumption; wherein the sample data associated with model training energy consumption includes model structure sample data, training strategy sample data and average energy consumption sample data.

[0043] The model training energy consumption associated sample data may be sample data used to train the overall energy consumption prediction model. The model structure sample data may be sample data composed of various types of model structure information. The training strategy sample data may be sample data composed of the training strategy used to train the model. The average energy consumption sample data may be sample data composed of the average energy consumption consumed during each model training process.

[0044] In an embodiment of the present invention, before training the overall energy consumption prediction model, sample data for training the overall energy consumption prediction model may be first obtained. The model training energy consumption associated sample data used to train the overall energy consumption prediction model in an embodiment of the present invention may include three types of sample data, namely, model structure sample data, training strategy sample data, and average energy consumption sample data.

[0045] Optionally, the model structure sample data mainly includes various types of model structure information, such as but not limited to the network structure of the model, the number of network layers, and the shape of each layer of the structure. The model structure determines the size of the overall weight parameter of the model and the actual structure. Optionally, the model structure can be a structure composed of each layer of the model network, or the model structure can be a graph structure composed of nodes and connecting edges. As long as it can reflect the characteristics of the model structure, the embodiment of the present invention does not limit the type of model structure.

[0046] Optionally, the training strategy sample data mainly includes the training strategy used to train the model. The training strategy refers to the way to train the model, which can be composed of a series of training parameter configurations. Exemplarily, the training parameters may include but are not limited to the learning rate, batchsize (indicating the number of parameters or data samples passed to the program for training at a single time), the input data length, the regularization parameter, the number of accelerator cards used, the distributed parallel strategy such as data parallelism, pipeline parallelism, tensor parallelism, expert parallelism, the type of distributed communication and the buffer size used, the data type used such as fp32, fp16, tf32, mixed precision and bf16, etc. It may also include the use of reverse recalculation, zero (ZeroRedundancy Optimizer, an optimizer designed to solve the memory bottleneck problem in large-scale distributed training) 1, zero2 and zero3 data parallelism, etc.; the use and proportion of dropout (a regularization technology for neural networks), the type of activation function, the type of position encoding, the use of gradient clipping and its norm, the type of optimizer, the use of gradient accumulation and its number of times, etc.

[0047] In the process of implementing the present invention, the inventors found that the model structure and training strategy will significantly affect the computing resource energy consumption, data transmission energy consumption and storage device energy consumption consumed in the model training process, and thus affect the cooling system energy consumption. For a given model structure, the energy consumption of the training model is determined by the selection of the training strategy. Different training strategies require different computing resources, data transmission and data IO (Input / Output). Therefore, for any model, there can be an optimal set of training strategies to minimize the energy consumption of the training model.

[0048] Therefore, by constructing different model structures and different training strategies, and combining the model structures and training strategies, it is possible to obtain sufficiently rich training samples, and then use the constructed training samples to train the overall energy consumption prediction model. In a specific example, assuming that there are m model structures and p training strategies, an m*p training sample data set size can be obtained, and each training process of the model can be used as a training sample. For a fixed AI cluster, the model structure and training strategy will jointly determine the average energy consumption required for a model training process.

[0049] In a specific example, the types of sample models included in the training samples can be transformer-type models with parameter scales such as 345M, 1B, 2B and 3B. Taking two servers, each server is configured with 8 GPU (Graphics Processing Unit) accelerator cards, and the overall energy consumption prediction model is distributedly trained using the pytorch (an open source Python machine learning library) framework as an example. The overall energy consumption prediction model after training can be used to predict the best training strategy for the transformer-type model with a parameter scale of 15B, so as to minimize the energy consumption of the transformer-type model with a parameter scale of 15B after training.

[0050] In a specific example, the types of sample models included in the training samples can be convolutional neural network models with parameter scales such as 30M, 100M, 345M and 712M. Taking two servers, each server is configured with 8 GPU accelerator cards, and the overall energy consumption prediction model is distributedly trained using the tensorflow (an end-to-end open source machine learning platform) framework as an example, the overall energy consumption prediction model after training can be used to predict the best training strategy for the convolutional neural network model with a parameter scale of 3B, so as to minimize the energy consumption of the convolutional neural network model with a parameter scale of 3B after training.

[0051] It can be seen that by using a sample model with a small parameter scale to construct a data set of training samples and training the overall energy consumption prediction model through the constructed data set, not only can the training cost be reduced, but also the applicability of the overall energy consumption prediction model can be improved, thereby improving the energy consumption prediction performance of the overall energy consumption prediction model.

[0052] S120, training an overall energy consumption prediction model according to the energy consumption associated sample data of the model training; wherein the trained overall energy consumption prediction model is used as a training strategy for predicting the lowest energy consumption of the training model.

[0053] The overall energy consumption prediction model may be a model that can predict the energy consumption during the model training process. The model to be trained may be a model type to be trained.

[0054] Correspondingly, after the collection and processing of the model training energy consumption associated sample data are completed, the model training energy consumption associated sample data can be used to train the overall energy consumption prediction model. During the training process, the model structure sample data and the training strategy sample data in the model training energy consumption associated sample data can be input into the overall energy consumption prediction model to obtain the energy consumption data predicted by the overall energy consumption prediction model, and the energy consumption data predicted by the overall energy consumption prediction model can be compared with the corresponding average energy consumption sample data to determine the training effect of the overall energy consumption prediction model.

[0055] Correspondingly, when the overall energy consumption prediction model is trained, the accuracy of the overall energy consumption prediction model in predicting the model training energy consumption meets the requirements, and the training strategy with the lowest energy consumption can be predicted for the model to be trained. After the overall energy consumption prediction model predicts the training strategy with the lowest energy consumption for the model to be trained, the predicted training strategy with the lowest energy consumption can be used to train the model to be trained, so that the energy consumption of the model to be trained is the lowest after the training is completed.

[0056] The embodiment of the present invention obtains model training energy consumption associated sample data including model structure sample data, training strategy sample data and average energy consumption sample data, thereby inputting the model training energy consumption associated sample data into the overall energy consumption prediction model to train the overall energy consumption prediction model. The trained overall energy consumption prediction model can be used to predict the training strategy with the lowest energy consumption for the training model, thereby solving the existing problem of being unable to predict the energy consumption of the model training process to control the model training energy consumption, and can realize the energy consumption data of the model training process, thereby determining the training strategy with the lowest energy consumption based on the predicted energy consumption data, which is conducive to reducing the energy consumption of model training, and greatly reducing the training cost of the model and the carbon emissions of the model training process.

[0057] Embodiment 2

[0058] Figure 2 is a flow chart of a model training method provided in Embodiment 2 of the present invention. Figure 3 is a flow chart of a model training method provided by the second embodiment of the present invention. This embodiment is specific based on the above embodiment. In this embodiment, a plurality of specific optional implementation methods are provided for obtaining sample data associated with model training energy consumption and inputting the sample data associated with model training energy consumption into the overall energy consumption prediction model, thereby training the overall energy consumption prediction model. Figure 2 and Figure 3 As shown, the method of this embodiment may include:

[0059] S210, obtaining sample data associated with model training energy consumption; wherein the sample data associated with model training energy consumption includes model structure sample data, training strategy sample data and average energy consumption sample data.

[0060] In an optional embodiment of the present invention, obtaining model training energy consumption associated sample data may include: obtaining model structure original sample data, parsing the model structure original sample data to obtain the number of network layers, network layer structure and network layer shape of the sample model; determining the length of the model structure sample data according to the number of network layers; determining the combination elements of the model structure sample data according to the network layer structure and the network layer shape; wherein the combination elements of the model structure sample data include parameter type and shape size.

[0061] The sample model is a model used to generate sample data associated with model training energy consumption. The model structure original sample data can be the original structure data extracted from each model. The combination elements of the model structure sample data can be the combination parameters of each layer of the model network structure.

[0062] Specifically, after obtaining the original sample data of the model structure of each sample model, the original sample data of the model structure can be parsed to obtain the number of network layers, network layer structure and network layer shape of the sample model. Further, the combination elements constituting the model structure sample data are determined according to the network layer structure and network layer shape of each network layer of the sample model, and the length of the model structure sample data is determined according to the number of network layers of the sample model. Exemplarily, the combination elements of the model structure sample data may include parameter type and shape size. Accordingly, the model structure list corresponding to the model structure sample data generated for a sample model can be: [[parameter type, shape size], ..., [parameter type, shape size]], the length of the list is the number of network layers, and each combination element "[parameter type, shape size]" of the list is the structure and shape of each layer of the network.

[0063] In an optional embodiment of the present invention, the acquisition of model training energy consumption associated sample data may include: acquiring model structure original sample data, parsing the model structure original sample data to obtain training parameters of the sample model; and generating the training strategy sample data according to the training parameters.

[0064] Specifically, the original sample data of the model structure can also be parsed to obtain the training parameters of the sample model, thereby generating the training strategy sample data corresponding to the sample model according to the training parameters of the sample model. Exemplarily, the training strategy sample data can also be in the form of a list, that is, [learning rate, batchsize, input data length, ...] and the like.

[0065] In an optional embodiment of the present invention, the acquisition of model training energy consumption associated sample data may include: acquiring training energy consumption sample data of a sample model corresponding to the original sample data of the model structure; wherein the training energy consumption sample data includes the total training energy consumption and the total number of tokens of the sample model; and calculating the quotient of the total training energy consumption and the total number of tokens to obtain the average energy consumption sample data.

[0066] In order to better measure the energy consumption in each sample model, KW.h / token can be used as the average energy consumption for measurement, that is, the energy required to train each token. Among them, token represents the smallest meaningful unit that the model can understand and generate, and is the basic unit of the model. In other words, the energy consumption consumed by each sample model during the training process can be expressed as: total training energy consumption / total tokens, and the average energy consumption sample data of the sample model is obtained. Optionally, the total training energy consumption can be the total power consumption required for the training process.

[0067] After the above processing, a sample data of model training energy consumption associated with a sample model may be composed of [model structure, training strategy, average energy consumption]. The model structure may be in the form of a list: [[parameter type, shape size], ..., [parameter type, shape size]], and the training strategy may be in the form of a list [learning rate, batchsize, input data length, ...]. The average energy consumption may be the value of KW.h / token calculated for the sample model.

[0068] In an optional embodiment of the present invention, after acquiring the model training energy consumption associated sample data, it may also include: when it is determined that the model training energy consumption associated sample data includes continuous values, converting the continuous values ​​into discrete values; and converting the model training energy consumption associated sample data into one-dimensional vector data.

[0069] Optionally, if the model structure sample data and the training strategy sample data are floating point numbers, the floating point numbers can be normalized to dimensionless values ​​in the interval [0,1]. Optionally, the values ​​in the model structure sample data and the training strategy sample data can be regarded as discrete values. If the values ​​in the model structure sample data and the training strategy sample data include continuous values, the bucketing strategy can be used to convert the continuous values ​​into discrete values, and then all discrete values ​​are converted into 1*n vectors using embedding (a method of mapping high-dimensional data to low-dimensional space, usually used to convert discrete, non-continuous data into continuous vector representation) technology.

[0070] S220, extracting features from the model training energy consumption associated sample data through the feature extractor of the overall energy consumption prediction model to obtain a model structure feature vector and a training strategy feature vector.

[0071] The model structure feature vector may be a feature vector obtained by extracting features from the model structure sample data by the overall energy consumption prediction model, and the training strategy feature vector may be a feature vector obtained by extracting features from the training strategy sample data by the overall energy consumption prediction model.

[0072] In an embodiment of the present invention, the model structure of the overall energy consumption prediction model may include a feature extractor. Accordingly, after the model structure sample data and the training strategy sample data of the model training energy consumption associated sample data are input into the overall energy consumption prediction model, the overall energy consumption prediction model may perform feature extraction on the model structure sample data and the training strategy sample data respectively through the feature extractor. Among them, feature extraction on the model structure sample data may obtain a model structure feature vector, and feature extraction on the training strategy sample data may obtain a training strategy feature vector.

[0073] In an optional embodiment of the present invention, the feature extractor of the overall energy consumption prediction model may include a first feature extractor and a second feature extractor; the feature extractor of the overall energy consumption prediction model performs feature extraction on the model training energy consumption associated sample data to obtain a model structure feature vector and a training strategy feature vector, which may include: inputting the model training energy consumption associated sample data into the first feature extractor of the overall energy consumption prediction model, and extracting the first feature vector of the model training energy consumption associated sample data through the first feature extractor; wherein the first feature vector includes the feature vectors of each network layer of the sample model structure and the feature vectors of each configuration of the training parameters; accumulating each of the first feature vectors to obtain a second feature vector; wherein the second feature vector includes the accumulated vector of the feature vectors of each network layer of the sample model structure and the accumulated vector of the feature vectors of each configuration of the training parameters; inputting the second feature vector into the second feature extractor of the overall energy consumption prediction model, and extracting the features of the second feature vector through the second feature extractor to obtain the model structure feature vector and the training strategy feature vector; wherein the second feature extractor may include a model structure feature extractor and a training strategy feature extractor.

[0074] The first feature extractor may be a shared preliminary feature extractor, that is, it is shared for each layer of the model structure and for each configuration of the training strategy. Figure 3The two first feature extractors shown may be the same feature extractors. The second feature extractor may be used to further refine feature extraction of the initially extracted features. The model structure feature extractor may be a second feature extractor, which may be used to further extract refined features from the model structure feature vector. The training strategy feature extractor may also be a second feature extractor, which may be used to further extract refined features from the training strategy feature vector. The first feature vector may be a feature vector obtained by the first feature extractor performing preliminary feature extraction on the model structure sample data and the training strategy sample data. The second feature vector may be a feature vector obtained by accumulating a certain type of first feature vectors.

[0075] In an embodiment of the present invention, the feature extractor of the overall energy consumption prediction model can be a two-stage feature extractor, namely a first feature extractor and a second feature extractor. When the model training energy consumption associated sample data is input into the overall energy consumption prediction model, the model structure sample data and the training strategy sample data in the model training energy consumption associated sample data can be loaded into the high-level cache area of ​​the target chip used to train the overall energy consumption prediction model, and further each training sample in the high-level cache area is moved one by one to the low-level cache area of ​​the target chip, and each training sample in the low-level cache area is moved one by one to the calculation unit of the overall energy consumption prediction model.

[0076] Correspondingly, after the overall energy consumption prediction model receives the model structure sample data and the training strategy sample data, the model structure sample data and the training strategy sample data can be input into the first feature extractor of the overall energy consumption prediction model, so as to extract the first feature vector of the model structure sample data through the first feature extractor to obtain the feature vectors of each network layer of the sample model structure, and extract the first feature vector of the training strategy sample data through the first feature extractor to obtain the feature vectors of each configuration of the training parameters. After the model structure sample data and the training strategy sample data are respectively extracted to the corresponding first feature vectors, the first feature vectors corresponding to the model structure sample data can be accumulated to obtain the second feature vector corresponding to the model structure sample data, and the second feature vector can be the accumulated vector of the feature vectors of each network layer of the sample model structure; and the first feature vectors corresponding to the training strategy sample data can be accumulated to obtain the second feature vector corresponding to the training strategy sample data, and the second feature vector can be the accumulated vector of the feature vectors of each configuration of the training parameters. After obtaining the second feature vector corresponding to the model structure sample data and the training strategy sample data, the second feature vector can be respectively input into the second feature extractor of the overall energy consumption prediction model, such as extracting the features of the second feature vector corresponding to the model structure sample data through the model structure feature extractor to obtain the model structure feature vector, and extracting the features of the second feature vector corresponding to the training strategy sample data through the training strategy feature extractor to obtain the training strategy feature vector.

[0077] In a specific example, for the model structure sample data, the parameter type and shape size of each layer of the sample model can be spliced ​​into a 1*2n vector, and then a multi-layer neural network is used as the first feature extractor of the overall energy consumption prediction model. The first feature extractor is a shared feature extractor for all sample model structure network layers. Using the first feature extractor, feature extraction is performed on the spliced ​​vector of each layer of the sample model into a 1*n first feature vector, and then the first feature vector of each layer is accumulated into a 1*n second feature vector. Then another multi-layer neural network is used as a model structure feature extractor to further extract features from the second feature vector of the model structure sample data to obtain a 1*n model structure feature vector.

[0078] In a specific example, for the training strategy sample data, the training strategy can be a list composed of multiple training parameter configurations, each training parameter element in the list is a configuration, and each configuration is a 1*n embedding vector. Similarly, the multi-layer neural network used in the above-mentioned model structure sample data can be used as the first feature extractor, and the first feature extractor is a shared feature extractor for the training parameters in all sample models. The first feature extractor is used to extract features from each configuration into a 1*n first feature vector, and then the first feature vector of each configuration is accumulated into a 1*n second feature vector. Then, a multi-layer neural network different from the model structure feature extractor is used as a training strategy feature extractor to further extract features from the second feature vector of the training strategy sample data to obtain a 1*n training strategy feature vector.

[0079] S230, fusing the model structure feature vector and the training strategy feature vector to obtain a fused feature vector.

[0080] Accordingly, after obtaining the model structure feature vector of the model structure sample data and the training strategy feature vector of the training strategy sample data, in order to facilitate the subsequent data processing flow, the model structure feature vector and the training strategy feature vector can be fused to obtain a fused feature vector. Optionally, the fusion can be performed by feature splicing, or by other applicable methods. The embodiment of the present invention does not limit the specific fusion method of the model structure feature vector and the training strategy feature vector.

[0081] Optional, such as Figure 3As shown in the figure, the overall energy consumption prediction model can use the cross attention mechanism to fully integrate the model structure feature vector and the training strategy feature vector, and finally form a 1*n fusion feature vector. The calculation process of the cross attention mechanism can be: let the model structure feature vector X1 be 1*n, the training strategy feature vector X2 be 1*n, generate the query vector Q according to the model structure feature vector, and set the corresponding attention parameter W Q , generate the key vector K and value vector V according to the training strategy feature vector, and set the corresponding attention parameter W K and W V , then the query vector Q is X1*W Q , the key vector K is X2*W K , the value vector V is X2*W V , the fused feature vector is: softmax(Q*K T / n 0.5 )*V (Softmax function converts a real vector into a probability distribution). Q , W K and W V is the parameter to be trained, and T represents the matrix transpose. The cross attention mechanism can better integrate the characteristics of the model structure and training strategy.

[0082] S240, inputting the fused feature vector into the energy consumption prediction model based on the fused feature vector of the overall energy consumption prediction model to obtain the predicted average energy consumption.

[0083] The predicted average energy consumption may be the average energy consumption consumed in the sample model training process obtained by an energy consumption prediction model based on the fused feature vector according to the fused feature vector prediction.

[0084] In an embodiment of the present invention, the model structure of the overall energy consumption prediction model may also include an energy consumption prediction model based on a fused feature vector, which is mainly used for energy consumption prediction. After the overall energy consumption prediction model obtains a fused feature vector formed by fusing the model structure feature vector and the training strategy feature vector, the fused feature vector can be input into the energy consumption prediction model based on the fused feature vector, so that the fused feature vector is parsed and processed by the energy consumption prediction model based on the fused feature vector to obtain a set of predicted average energy consumption corresponding to the model structure sample data and the training strategy sample data.

[0085] S250, calculating the loss value between the predicted average energy consumption and the average energy consumption sample data, and updating the model parameters of the overall energy consumption prediction model according to the loss value.

[0086] S260, determine whether the overall energy consumption prediction model has been trained, if so, execute S270, otherwise, return to execute S210.

[0087] Optionally, the energy consumption prediction model based on the fused feature vector can adopt a multi-layer neural network or other machine learning models. After the energy consumption prediction model based on the fused feature vector predicts the predicted average energy consumption according to the fused feature vector, the mean square error loss function can be used to calculate the loss value loss between the actual average energy consumption and the predicted average energy consumption. When it is determined that the loss value between the actual average energy consumption and the predicted average energy consumption does not meet the training requirements, the back propagation algorithm is used to update the model parameters of the overall energy consumption prediction model, including multi-level feature extractors, cross-attention mechanisms, and model parameters involved in the energy consumption prediction model based on the fused feature vector.

[0088] S270, the overall energy consumption prediction model training is completed.

[0089] Optionally, determining whether the training of the overall energy consumption prediction model is completed may be performed by determining whether the overall energy consumption prediction model has reached a set number of training times, or determining whether the loss value between the actual average energy consumption and the predicted average energy consumption has reached a set value or tends to a stable value. The embodiment of the present invention does not limit the specific method for determining whether the training of the overall energy consumption prediction model is completed.

[0090] The above technical solution proposes a model training method that takes energy consumption into consideration. The data set is constructed by using different model structures and different training strategies to enable the overall energy consumption prediction model to extract the model structure feature vector and the training strategy feature vector based on the data set, and fuse the model structure feature vector and the training strategy feature vector to obtain a fused feature vector. Finally, the energy consumption prediction model based on the fused feature vector in the overall energy consumption prediction model is trained according to the fused feature vector, so that the energy consumption prediction model based on the fused feature vector has the ability to predict the average energy consumption required for model training. The trained overall energy consumption prediction model can be used to predict the training strategy with the lowest energy consumption for the model to be trained, which is conducive to reducing the energy consumption of model training, greatly reducing the training cost of the model and the carbon emissions of the model training process.

[0091] Embodiment 3

[0092] Figure 4 This is a flow chart of a model training method provided in the third embodiment of the present invention. This embodiment is applicable to the case where the overall energy consumption prediction model that has been trained is used to determine the training strategy with the lowest energy consumption for the training model. The method can be executed by a model training device, which can be implemented by software and / or hardware, and can generally be integrated in an electronic device. The electronic device can be a terminal device or a server device. As long as it can run the energy consumption data of the overall energy consumption prediction model pre-model training, the embodiment of the present invention does not limit the specific device type of the electronic device. Accordingly, Figure 4 As shown, the method includes the following operations:

[0093] S310, determining a model structure of a model to be trained, and inputting the model structure of the model to be trained into an overall energy consumption prediction model.

[0094] The overall energy consumption prediction model is obtained by training using the model training method described in Example 1 or Example 2.

[0095] In an embodiment of the present invention, the trained overall energy consumption prediction model can be carried in the target hardware device for operation. When it is necessary to predict the energy consumption data corresponding to each training strategy for the model to be trained, the model structure of the model to be trained can be determined and the model structure of the model to be trained can be input into the overall energy consumption prediction model.

[0096] S320, using the overall energy consumption prediction model to traverse the model structure of the model to be trained and calculate the model training prediction energy consumption corresponding to multiple training strategies.

[0097] Among them, the model training predicted energy consumption, that is, the average energy consumption calculated by the overall energy consumption prediction model for the model structure and training strategy of the model to be trained, can reflect the energy consumption data required to train the model to be trained using the training strategy.

[0098] Since the model structure of the model to be trained is a fixed known quantity, the overall energy consumption prediction model can combine the model structure of the model to be trained with each training strategy after receiving the model structure of the model to be trained, so as to traverse and calculate the model training prediction energy consumption corresponding to multiple training strategies for the model to be trained. It can be understood that each group of training strategies can predict a model training prediction energy consumption, and the model training prediction energy consumption corresponding to each training strategy may be the same or different.

[0099] S330, selecting a target training strategy corresponding to the target model training predicted energy consumption, and performing model training on the model to be trained.

[0100] Among them, the target model training prediction energy consumption can be the model training prediction energy consumption with the lowest value.

[0101] Correspondingly, after the overall energy consumption prediction model traverses the model structure of the model to be trained and calculates the model training prediction energy consumption corresponding to multiple training strategies, it can screen out the target model training prediction energy consumption with the lowest value from each model training prediction energy consumption, and determine the target training strategy corresponding to the predicted target model training prediction energy consumption, so as to use the target training strategy to train the model to be trained, so that the energy consumption value consumed by the model to be trained after the training is completed is the lowest.

[0102] The above-mentioned method of determining the training strategy for model adaptation by considering energy consumption can be applied to different artificial intelligence acceleration cards, training frameworks and algorithm models.

[0103] The embodiment of the present invention obtains model training energy consumption associated sample data including model structure sample data, training strategy sample data and average energy consumption sample data, thereby inputting the model training energy consumption associated sample data into the overall energy consumption prediction model to train the overall energy consumption prediction model. After the overall energy consumption prediction model is trained, the model structure of the model to be trained can be determined, and the model structure of the model to be trained can be input into the overall energy consumption prediction model, so that the overall energy consumption prediction model can traverse the model structure of the model to be trained and calculate the model training predicted energy consumption corresponding to multiple training strategies. When all training strategies correspond to the predicted model training predicted energy consumption, the target training strategy corresponding to the target model training predicted energy consumption can be selected from them, and the model training of the model to be trained can be performed. The above technical solution can solve the existing problem of being unable to predict the energy consumption of the model training process to control the model training energy consumption, and can realize the prediction of the energy consumption data of the model training process, thereby determining the training strategy with the lowest energy consumption based on the predicted energy consumption data, which is conducive to reducing the energy consumption of model training, greatly reducing the training cost of the model and the carbon emissions of the model training process.

[0104] In the technical solution of the present disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information are in compliance with the relevant laws and regulations and do not violate public order and good morals.

[0105] It should be noted that any arrangement and combination of the technical features in the above embodiments also falls within the protection scope of the present invention.

[0106] Embodiment 4

[0107] Figure 5 is a schematic diagram of a model training device provided by Embodiment 4 of the present invention, such as Figure 5 As shown, the device includes: a model training energy consumption associated sample data acquisition module 410 and a first model training module 420, wherein:

[0108] The model training energy consumption associated sample data acquisition module 410 is used to acquire the model training energy consumption associated sample data; wherein the model training energy consumption associated sample data includes model structure sample data, training strategy sample data and average energy consumption sample data;

[0109] A first model training module 420, configured to input the model training energy consumption associated sample data into the overall energy consumption prediction model to train the overall energy consumption prediction model;

[0110] Among them, the trained overall energy consumption prediction model is used to predict the training strategy with the lowest energy consumption for the training model.

[0111] The embodiment of the present invention obtains model training energy consumption associated sample data including model structure sample data, training strategy sample data and average energy consumption sample data, thereby inputting the model training energy consumption associated sample data into the overall energy consumption prediction model to train the overall energy consumption prediction model. The trained overall energy consumption prediction model can be used to predict the training strategy with the lowest energy consumption for the training model, thereby solving the existing problem of being unable to predict the energy consumption of the model training process to control the model training energy consumption, and can realize the energy consumption data of the model training process, thereby determining the training strategy with the lowest energy consumption based on the predicted energy consumption data, which is conducive to reducing the energy consumption of model training, and greatly reducing the training cost of the model and the carbon emissions of the model training process.

[0112] Optionally, the model training energy consumption associated sample data acquisition module 410 is also used to: acquire the original sample data of the model structure, parse the original sample data of the model structure to obtain the number of network layers, network layer structure and network layer shape of the sample model; determine the length of the model structure sample data according to the number of network layers; determine the combination elements of the model structure sample data according to the network layer structure and the network layer shape; wherein the combination elements of the model structure sample data include parameter type and shape size.

[0113] Optionally, the model training energy consumption associated sample data acquisition module 410 is also used to: acquire original sample data of the model structure, parse the original sample data of the model structure to obtain training parameters of the sample model; and generate the training strategy sample data according to the training parameters.

[0114] Optionally, the model training energy consumption associated sample data acquisition module 410 is also used to: obtain the training energy consumption sample data of the sample model corresponding to the original sample data of the model structure; wherein the training energy consumption sample data includes the total training energy consumption and the total number of tokens of the sample model; calculate the quotient of the total training energy consumption and the total number of tokens to obtain the average energy consumption sample data.

[0115] Optionally, the above-mentioned device may also include a model training energy consumption associated sample data conversion module, which is used to: when it is determined that the model training energy consumption associated sample data includes continuous values, convert the continuous values ​​into discrete values; and convert the model training energy consumption associated sample data into one-dimensional vector data.

[0116] Optionally, the first model training module 420 is used to: perform feature extraction on the model training energy consumption associated sample data through the feature extractor of the overall energy consumption prediction model to obtain a model structure feature vector and a training strategy feature vector; fuse the model structure feature vector and the training strategy feature vector to obtain a fused feature vector; input the fused feature vector into the energy consumption prediction model based on the fused feature vector of the overall energy consumption prediction model to obtain the predicted average energy consumption; calculate the loss value between the predicted average energy consumption and the average energy consumption sample data, and update the model parameters of the overall energy consumption prediction model according to the loss value; return to execute the operation of obtaining the model training energy consumption associated sample data until it is determined that the training of the overall energy consumption prediction model is completed.

[0117] Optionally, the feature extractor of the overall energy consumption prediction model includes a first feature extractor and a second feature extractor; the first model training module 420 is used to: input the model training energy consumption associated sample data into the first feature extractor of the overall energy consumption prediction model, and extract the first feature vector of the model training energy consumption associated sample data through the first feature extractor; wherein the first feature vector includes the feature vectors of each network layer of the sample model structure and the feature vectors of each configuration of the training parameters; accumulate each of the first feature vectors to obtain a second feature vector; wherein the second feature vector includes the accumulated vector of the feature vectors of each network layer of the sample model structure and the accumulated vector of the feature vectors of each configuration of the training parameters; input the second feature vector into the second feature extractor of the overall energy consumption prediction model, and extract the features of the second feature vector through the second feature extractor to obtain the model structure feature vector and the training strategy feature vector; wherein the second feature extractor includes a model structure feature extractor and a training strategy feature extractor.

[0118] The above-mentioned model training device can execute the model training method provided in the first or second embodiment of the present invention, and has the functional modules and beneficial effects corresponding to the execution method. For technical details not described in detail in this embodiment, please refer to the model training method provided in the first or second embodiment of the present invention.

[0119] Embodiment 5

[0120] Figure 6 is a schematic diagram of a model training device provided in Embodiment 5 of the present invention, such as Figure 6 As shown, the device includes: a model structure input module 510, a model training prediction energy consumption calculation module 520 and a second model training module 530, wherein:

[0121] A model structure input module 510 is used to determine the model structure of the model to be trained, and input the model structure of the model to be trained into the overall energy consumption prediction model; wherein the overall energy consumption prediction model is trained by the model training method described in Example 1 or Example 2;

[0122] A model training prediction energy consumption calculation module 520 is used to traverse the model structure of the model to be trained through the overall energy consumption prediction model and calculate the model training prediction energy consumption corresponding to multiple training strategies;

[0123] The second model training module 530 is used to select a target training strategy corresponding to the target model training predicted energy consumption, and perform model training on the model to be trained.

[0124] The embodiment of the present invention obtains model training energy consumption associated sample data including model structure sample data, training strategy sample data and average energy consumption sample data, thereby inputting the model training energy consumption associated sample data into the overall energy consumption prediction model to train the overall energy consumption prediction model. After the overall energy consumption prediction model is trained, the model structure of the model to be trained can be determined, and the model structure of the model to be trained can be input into the overall energy consumption prediction model, so that the overall energy consumption prediction model can traverse the model structure of the model to be trained and calculate the model training predicted energy consumption corresponding to multiple training strategies. When all training strategies correspond to the predicted model training predicted energy consumption, the target training strategy corresponding to the target model training predicted energy consumption can be selected from them, and the model training of the model to be trained can be performed. The above technical solution can solve the existing problem of being unable to predict the energy consumption of the model training process to control the model training energy consumption, and can realize the prediction of the energy consumption data of the model training process, thereby determining the training strategy with the lowest energy consumption based on the predicted energy consumption data, which is conducive to reducing the energy consumption of model training, greatly reducing the training cost of the model and the carbon emissions of the model training process.

[0125] The above-mentioned model training device can execute the model training method provided in the third embodiment of the present invention, and has the functional modules and beneficial effects corresponding to the execution method. For technical details not described in detail in this embodiment, please refer to the model training method provided in the third embodiment of the present invention.

[0126] Embodiment 6

[0127] Figure 7A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.

[0128] like Figure 7 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0129] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0130] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The processor 11 executes the various methods and processes described above, such as a model training method.

[0131] In some embodiments, the model training method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the model training method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to execute the model training method in any other suitable manner (e.g., by means of firmware).

[0132] Optionally, the model training method may include: obtaining sample data associated with model training energy consumption; wherein the sample data associated with model training energy consumption includes model structure sample data, training strategy sample data and average energy consumption sample data; training an overall energy consumption prediction model based on the sample data associated with model training energy consumption; wherein the trained overall energy consumption prediction model is used to predict the training strategy with the lowest energy consumption for the model to be trained.

[0133] Optionally, the model training method may include: determining the model structure of the model to be trained, and inputting the model structure of the model to be trained into the overall energy consumption prediction model; wherein the overall energy consumption prediction model is trained by the model training method described in Example 1 or Example 2; traversing the model structure of the model to be trained by the overall energy consumption prediction model to calculate the model training predicted energy consumption corresponding to multiple training strategies; selecting the target training strategy corresponding to the target model training predicted energy consumption, and performing model training on the model to be trained.

[0134] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0135] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0136] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0137] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).

[0138] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0139] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.

[0140] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.

[0141] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.

Claims

1. A model training method, characterized in that: include: Acquire model training energy consumption-related sample data; wherein the model training energy consumption-related sample data includes model structure sample data, training strategy sample data, and average energy consumption sample data; Training the overall energy consumption prediction model based on the energy consumption associated sample data of the model training; Among them, the trained overall energy consumption prediction model is used to predict the training strategy with the lowest energy consumption for the training model.

2. The method according to claim 1, characterized in that The step of obtaining the model training energy consumption-related sample data includes: Obtaining original sample data of the model structure, parsing the original sample data of the model structure, and obtaining the number of network layers, network layer structure, and network layer shape of the sample model; Determine the length of the model structure sample data according to the number of network layers; Determine the combination element of the model structure sample data according to the network layer structure and the network layer shape; The combination elements of the model structure sample data include parameter type and shape size.

3. The method according to claim 1, characterized in that The step of obtaining the model training energy consumption-related sample data includes: Obtaining original sample data of the model structure, parsing the original sample data of the model structure, and obtaining training parameters of the sample model; The training strategy sample data is generated according to the training parameters.

4. The method according to claim 1, characterized in that: The step of obtaining the model training energy consumption-related sample data includes: Obtain training energy consumption sample data of the sample model corresponding to the original sample data of the model structure; wherein the training energy consumption sample data includes the total training energy consumption of the sample model and the total number of semantic unit tokens; The quotient of the total training energy consumption and the total number of tokens is calculated to obtain the average energy consumption sample data.

5. The method according to any one of claims 1 to 4, characterized in that: After obtaining the sample data associated with the model training energy consumption, the method further includes: In the case where it is determined that the model training energy consumption associated sample data includes a continuous value, converting the continuous value into a discrete value; The energy consumption associated sample data for model training is converted into one-dimensional vector data.

6. The method according to claim 5, characterized in that The step of inputting the model training energy consumption associated sample data into the overall energy consumption prediction model to train the overall energy consumption prediction model includes: The feature extractor of the overall energy consumption prediction model performs feature extraction on the model training energy consumption associated sample data to obtain a model structure feature vector and a training strategy feature vector; Fusing the model structure feature vector and the training strategy feature vector to obtain a fused feature vector; Inputting the fused feature vector into the energy consumption prediction model based on the fused feature vector of the overall energy consumption prediction model to obtain the predicted average energy consumption; Calculating a loss value between the predicted average energy consumption and the average energy consumption sample data, and updating a model parameter of the overall energy consumption prediction model according to the loss value; Return to execute the operation of obtaining sample data associated with model training energy consumption until it is determined that the training of the overall energy consumption prediction model is completed.

7. The method according to claim 6, characterized in that The feature extractor of the overall energy consumption prediction model includes a first feature extractor and a second feature extractor; The feature extractor of the overall energy consumption prediction model extracts features of the model training energy consumption associated sample data to obtain a model structure feature vector and a training strategy feature vector, including: Input the model training energy consumption associated sample data into the first feature extractor of the overall energy consumption prediction model, and extract the first feature vector of the model training energy consumption associated sample data through the first feature extractor; wherein the first feature vector includes the feature vectors of each network layer of the sample model structure and the feature vectors of each configuration of the training parameters; Accumulating the first feature vectors to obtain a second feature vector; wherein the second feature vector includes the accumulated vector of the feature vectors of each network layer of the sample model structure and the accumulated vector of the feature vectors of each configuration of the training parameters; Inputting the second feature vector into the second feature extractor of the overall energy consumption prediction model, extracting the features of the second feature vector through the second feature extractor, and obtaining the model structure feature vector and the training strategy feature vector; Among them, the second feature extractor includes a model structure feature extractor and a training strategy feature extractor.

8. A model training method, characterized in that: include: Determine the model structure of the model to be trained, and input the model structure of the model to be trained into the overall energy consumption prediction model; wherein the overall energy consumption prediction model is trained by the model training method described in any one of claims 1 to 7; The model structure of the model to be trained is traversed by the overall energy consumption prediction model to calculate the model training prediction energy consumption corresponding to multiple training strategies; Select a target training strategy corresponding to the target model training predicted energy consumption, and perform model training on the model to be trained.

9. A model training device, characterized in that: include: A model training energy consumption associated sample data acquisition module is used to acquire model training energy consumption associated sample data; wherein the model training energy consumption associated sample data includes model structure sample data, training strategy sample data and average energy consumption sample data; A first model training module, used for inputting the model training energy consumption associated sample data into the overall energy consumption prediction model to train the overall energy consumption prediction model; Among them, the trained overall energy consumption prediction model is used to predict the training strategy with the lowest energy consumption for the training model.

10. A model training device, characterized in that: include: A model structure input module, used to determine the model structure of the model to be trained, and input the model structure of the model to be trained into the overall energy consumption prediction model; wherein the overall energy consumption prediction model is trained by the model training method described in any one of claims 1 to 7; A model training prediction energy consumption calculation module is used to traverse the model structure of the model to be trained through the overall energy consumption prediction model and calculate the model training prediction energy consumption corresponding to multiple training strategies; The second model training module is used to select a target training strategy corresponding to the target model training predicted energy consumption, and perform model training on the model to be trained.

11. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the model training method described in any one of claims 1-7, or execute the model training method described in claim 8.

12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, which are used to enable a processor to implement the model training method described in any one of claims 1 to 7, or execute the model training method described in claim 8 when executed.

13. A computer program product comprising a computer program / instructions, wherein: When the computer program / instructions are executed by a processor, the model training method described in any one of claims 1 to 7 is implemented, or the model training method described in claim 8 is executed.

Citation Information

Patent Citations

  • Energy consumption prediction network training method, device, energy consumption prediction method, device and computer equipment

    CN113408802A

  • Network model optimization method and device, computer equipment and storage medium

    CN113642702A

  • Method and device for adjusting AI computing power hardware computing resource allocation according to base station energy consumption

    CN117255396A

  • Method and apparatus for performing distributed training on deep learning model, device and storage medium

    US20220374713A1

  • Resource usage prediction for deep learning model

    US20230035451A1