Model training system, method, storage medium and electronic device

Through the collaborative work of the central processor and the graphics processor, forward gradient propagation and parallel computing are used to solve the problem of low hardware resource utilization in large model training and achieve more efficient resource utilization and training efficiency.

CN118378726BActive Publication Date: 2024-09-20ZHEJIANG LAB
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410830397.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-25
Publication Date
2024-09-20
Estimated Expiration
2044-06-25

AI Technical Summary

Technical Problem

Hardware resource utilization is low when training large models, which increases the difficulty of training and makes it difficult to train large-scale models with limited hardware resources.

Method used

By using the collaborative work of the central processor and the graphics processor in the model training system, forward gradient propagation is used to calculate gradient values ​​and adjust model parameters, reducing storage resource usage, and improving calculations through parallel computing and the use of different precision data formats. Resource utilization.

Benefits of technology

It effectively improves the utilization of hardware resources, reduces the occupation of storage resources, and improves the efficiency of large model training and the utilization of computing resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118378726B
    Figure CN118378726B
Patent Text Reader

Abstract

The present specification discloses a model training system, method, storage medium and electronic device, which can use forward gradient propagation, that is, in the forward propagation process, for the output value of each network layer of the model to be trained and the output value of the network layer above the network layer in the model to be trained, calculate the gradient value of the network layer, and adjust the model parameters of the network layer based on the gradient value of the network layer, so that after the model parameters of each network layer are determined by the central processing unit, the output value of the previous network layer and the gradient value of the network layer can be deleted, thereby effectively reducing the occupancy of storage resources during the training process of the model to be trained.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a model training system, method, storage medium and electronic device. Background Art

[0002] A large model refers to an artificial neural network model with a large number of parameters and strong expressive power, generalization ability, and the ability to handle complex tasks. A large model usually contains hundreds of millions to trillions of parameters. Due to the large scale and high complexity of large models, when training large models, it is necessary to train on large-scale data sets and consume a lot of hardware resources for optimization. Traditional training frameworks are often unable to meet the huge computing requirements required for training large models. Therefore, when training large models, it is necessary to adopt a large model training framework designed specifically for models with billions or even trillions of parameters to effectively support the training of large models.

[0003] Generally speaking, when training large models through a large model training framework, the utilization rate of hardware resources is low, making it impossible to train large-scale models with limited hardware resources, which in turn increases the difficulty of training large models.

[0004] Therefore, how to improve the utilization of hardware resources when training large models is an urgent problem to be solved. Summary of the invention

[0005] This specification provides a model training system, method, storage medium and electronic device to partially solve the above-mentioned problems existing in the prior art.

[0006] This manual adopts the following technical solutions:

[0007] This specification provides a model training system, the model training system comprising: a central processing unit, a graphics processing unit;

[0008] The graphics processor is used to obtain a model building request input by a user, and build a model to be trained according to the model building request, and for each network layer in the model to be trained, determine the network layer above the network layer in the model to be trained as a reference network layer, calculate the gradient value of the network layer according to the output value of the network layer and the output value of the reference network layer, send the gradient value of the network layer to the central processor, and adjust the model parameters of the network layer according to the adjusted model parameters returned by the central processor to obtain the adjusted network layer, and delete the output value of the reference network layer and the gradient value of the network layer;

[0009] The central processing unit is used to adjust the model parameters of the network layer corresponding to the gradient value according to the received gradient value, obtain the adjusted model parameters and return them to the graphics processing unit;

[0010] The graphics processor is used to obtain an adjusted model according to each adjusted network layer, so as to perform a task according to the adjusted model.

[0011] Optionally, the model training system includes: at least two central processing units and at least two graphics processing units, wherein, for each central processing unit, the central processing unit and at least one graphics processing unit constitute a computing node, and for each computing node, the computing node is used to construct at least part of the network layers included in the model to be trained according to the model construction request, and adjust the model parameters of each constructed network layer to obtain adjusted model parameters, so as to obtain the adjusted network layer corresponding to each constructed network layer.

[0012] Optionally, for each computing node, if the computing node is composed of a central processing unit and at least two graphics processing units, each graphics processing unit in the computing node is used to determine the gradient value of the network layer for each network layer constructed by the computing node based on a sample data set matching the graphics processing unit, and send the gradient value of the network layer to the central processing unit in the computing node, and adjust the model parameters of the network layer according to the adjusted model parameters received and returned by the central processing unit to obtain the adjusted network layer, wherein the sample data sets matching different graphics processing units in the computing node are different, and the process of each graphics processing unit determining the output value of at least part of the network layer of the to-be-trained model corresponding to the computing node based on different sample data sets is executed in parallel;

[0013] The central processing unit of the computing node is used to adjust the model parameters of the network layer according to the gradient value of the network layer sent by each graphics processor of the computing node, obtain the adjusted model parameters and return them to each graphics processor of the computing node.

[0014] Optionally, for each computing node, if the computing node is composed of a central processing unit and at least two graphics processing units, each graphics processing unit in the computing node is used to determine the block gradient value of each network layer constructed by the computing node according to the output value of at least part of the neurons in the network layer, and send the block gradient value of the network layer to the central processing unit, and adjust the model parameters of the network layer according to the adjusted model parameters returned by the central processing unit to obtain the adjusted network layer;

[0015] The central processing unit in the computing node is used to adjust the model parameters of the network layer according to the received gradient values ​​of each block of the network layer sent by each graphics processor of the computing node, obtain the adjusted model parameters and return them to each graphics processor of the computing node.

[0016] Optionally, for each computing node, if the computing node is composed of a central processing unit and at least two graphics processing units, each graphics processing unit in the computing node is used to determine the output value of each network layer constructed by the computing node according to the output value of the network layer in the previous layer of the network layer in the model to be trained and the model parameters of the network layer, determine the graphics processor used to determine the gradient value of the next layer of the network layer in the network layer in the model to be trained as the target graphics processor, and transmit the output value of the network layer to the target graphics processor so that the target graphics processor performs the computing task according to the output value of the network layer, and calculate the gradient value of the network layer according to the output value of the network layer and the output value of the network layer in the previous layer of the network layer in the model to be trained, and send the gradient value of the network layer to the central processing unit in the computing node, and adjust the model parameters of the network layer according to the adjusted model parameters returned by the central processing unit to obtain the adjusted network layer.

[0017] Optionally, the central processing unit is used to adjust the model parameters of the network layer corresponding to the gradient value according to the received gradient value and preset statistical data matching the network layer corresponding to the gradient value, obtain the adjusted model parameters and return them to the graphics processor, the statistical data include: momentum value and variance, wherein the momentum value is used to characterize the degree of change of the gradient value during the historical adjustment of the model parameters of the network layer corresponding to the gradient value, and the variance is used to characterize the degree of change of the output value during the historical adjustment of the model parameters of the network layer corresponding to the gradient value.

[0018] Optionally, the central processing unit is used to adjust the preset model parameters of the network layer corresponding to the received gradient value according to the received gradient value to obtain the adjusted model parameters, and perform data conversion on the adjusted model parameters to convert the data format corresponding to the adjusted model parameters into the data format corresponding to the model parameters of the model to be trained stored in the graphics processor, and return the converted adjusted model parameters to the graphics processor, the preset model parameters are the complete model parameters of the model to be trained pre-stored in the central processing unit, and the accuracy of the data format used by the preset model parameters is higher than the accuracy of the data format used by each model parameter of the model to be trained stored in the graphics processor.

[0019] This specification provides a model training method, which is applied to a graphics processor of a model training system, and includes:

[0020] Get the model building request input by the user;

[0021] Building a model to be trained according to the model building request;

[0022] For each network layer in the model to be trained, determine the network layer above the network layer in the model to be trained as the reference network layer, calculate the gradient value of the network layer according to the output value of the network layer and the output value of the reference network layer, and send the gradient value of the network layer to the central processing unit, so that the central processing unit adjusts the model parameters of the network layer corresponding to the gradient value according to the received gradient value, obtains the adjusted model parameters and returns them;

[0023] According to the adjusted model parameters returned by the central processor, the model parameters of the network layer are adjusted to obtain the adjusted network layer, and the output value of the reference network layer and the gradient value of the network layer are deleted;

[0024] According to the adjusted network layer, an adjusted model is obtained, so as to perform a task according to the adjusted model.

[0025] This specification provides a model training method, which is applied to a central processor of a model training system, and includes:

[0026] Receive a gradient value sent by a graphics processor, where the gradient value is calculated by the graphics processor by constructing a model to be trained according to the received model building request, and determining, for each network layer in the model to be trained, a network layer above the network layer in the model to be trained as a reference network layer, according to an output value of the network layer and an output value of the reference network layer;

[0027] According to the gradient value, the model parameters of the network layer corresponding to the gradient value are adjusted to obtain the adjusted model parameters and send them to the graphics processor, so that the graphics processor adjusts the model parameters of the network layer corresponding to the gradient value according to the received adjusted model parameters to obtain the adjusted network layer, and deletes the output value of the reference network layer and the gradient value of the network layer, and obtains the adjusted model according to each adjusted network layer, so as to perform the task according to the adjusted model.

[0028] This specification provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the above-mentioned model training method is implemented.

[0029] This specification provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned model training method when executing the program.

[0030] At least one of the above technical solutions adopted in this specification can achieve the following beneficial effects:

[0031] In the model training system provided in the present specification, the graphics processor is used to obtain a model building request input by a user, and build a model to be trained according to the model building request. For each network layer in the model to be trained, the network layer above the network layer in the model to be trained is determined as a reference network layer, and the gradient value of the network layer is calculated according to the output value of the network layer and the output value of the reference network layer. The gradient value of the network layer is sent to the central processor, and the model parameters of the network layer are adjusted according to the adjusted model parameters returned by the central processor to obtain the adjusted network layer, and the output value of the reference network layer and the gradient value of the network layer are deleted. The central processor is used to adjust the model parameters of the network layer corresponding to the gradient value according to the received gradient value, obtain the adjusted model parameters and return them to the graphics processor, and the graphics processor is used to obtain the adjusted model according to each adjusted network layer, so as to perform tasks according to the adjusted model.

[0032] It can be seen from the above method that by means of forward gradient propagation (i.e., in the forward propagation process, the output value of each network layer of the model to be trained and the output value of the network layer above the network layer in the model to be trained, the gradient value of the network layer is calculated, and the model parameters of the network layer are adjusted based on the gradient value of the network layer), after the model parameters of each network layer are determined by the central processing unit, the output value of the previous network layer and the gradient value of the network layer can be deleted, thereby effectively reducing the occupancy of storage resources during the training process of the model to be trained. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] The drawings described herein are used to provide a further understanding of this specification and constitute a part of this specification. The illustrative embodiments and descriptions of this specification are used to explain this specification and do not constitute an improper limitation on this specification. In the drawings:

[0034] Figure 1 A schematic diagram of a model training system provided in this specification;

[0035] Figure 2 A schematic diagram of the calculation process of the gradient value provided in this specification;

[0036] Figure 3A schematic diagram of the training process of the model to be trained provided in this specification;

[0037] Figure 4 A flowchart of a model training method provided in this specification;

[0038] Figure 5 A flowchart of a model training method provided in this specification;

[0039] Figure 6 A schematic diagram of a model training device provided in this specification;

[0040] Figure 7 A schematic diagram of a model training device provided in this specification;

[0041] Figure 8 A method corresponding to the Figure 4 , Figure 5 Schematic diagram of electronic equipment. DETAILED DESCRIPTION

[0042] In order to make the purpose, technical solutions and advantages of this specification more clear, the technical solutions of this specification will be clearly and completely described below in combination with the specific embodiments of this specification and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of this specification, not all of them. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this specification.

[0043] The technical solutions provided by the embodiments of this specification are described in detail below in conjunction with the accompanying drawings.

[0044] Figure 1 A schematic diagram of a model training system provided in this specification.

[0045] Combination Figure 1 It can be seen that the model training system provided in this specification includes: a central processing unit and a graphics processing unit.

[0046] Among them, when the user needs to build a large model through the above-mentioned model training system and train the constructed large model, the user can send a model building request to the model training system through the terminal device used by the user, so that after the model training system receives the model building request sent by the user, it builds the model to be trained according to the received model building request and trains the model to be trained. The model building request here contains various configuration parameters required to build the model to be trained.

[0047] Of course, the model training system can also obtain a configuration file corresponding to the model to be trained that is pre-configured by the user, and build the model to be trained according to the configuration file, and train the model to be trained.

[0048] Specifically, the graphics processor of the model training system can be used to obtain the model building request input by the user, and build the model to be trained according to the model building request, and then for each network layer in the model to be trained, determine the network layer above the network layer in the model to be trained as the reference network layer, and calculate the gradient value of the network layer according to the output value of the network layer and the output value of the reference network layer, as shown in the following example. Figure 2 shown.

[0049] Figure 2 A schematic diagram of the calculation process of the gradient value provided in this specification.

[0050] Combination Figure 2 It can be seen that the graphics processor can calculate the output value of the network layer based on the output value of the reference network layer and the model parameters of the network layer, and then calculate the gradient value of the reference network layer based on the output value of the reference network layer and the model parameters of the reference network layer, and calculate the gradient value of the network layer based on the gradient value of the reference network layer and the output value of the network layer and the model parameters of the network layer, wherein the method for the graphics processor to calculate the gradient value may be a forward automatic differentiation algorithm.

[0051] Furthermore, after calculating the gradient value of the network layer, the graphics processor can send the gradient value of the network layer to the central processing unit, and adjust the model parameters of the network layer according to the adjusted model parameters returned by the central processing unit to obtain the adjusted network layer, and delete the output value of the reference network layer and the gradient value of the network layer, and obtain the adjusted model based on the adjusted network layers to perform tasks according to the adjusted model.

[0052] The central processing unit of the model training system can be used to adjust the model parameters of the network layer corresponding to the gradient value according to the received gradient value, obtain the adjusted model parameters and return them to the graphics processor.

[0053] From the above content, it can be seen that the model training system can use the forward gradient propagation method (that is, in the forward propagation process, for the output value of each network layer of the model to be trained and the output value of the network layer above the network layer in the model to be trained, the gradient value of the network layer is calculated, and the model parameters of the network layer are adjusted based on the gradient value of the network layer), so that after the model parameters of each network layer are determined by the central processing unit, the output value of the previous network layer and the gradient value of the network layer can be deleted, thereby effectively reducing the occupancy of storage resources during the training process of the model to be trained.

[0054] In addition, the model training system can transfer part of the computing tasks and storage tasks that need to be completed by the graphics processor (that is, the computing tasks and storage tasks for adjusting the model parameters of each network layer of the training model) to the central processing unit to complete, thereby improving the utilization of computing resources.

[0055] In addition, during the process of training each network layer in the model to be trained, the graphics processor can also save the gradient value of each network layer after adjusting the model parameters of each network layer, so that in the process of calculating the gradient value of the next network layer, the gradient value of the network layer can be directly used to avoid repeated calculations, thereby reducing the loss of computing resources while increasing the occupancy of storage resources when training the model to be trained.

[0056] It should be noted that the output value of the first network layer in the model to be trained is calculated based on the sample data input to the model to be trained, and the gradient value of the last network layer in the model to be trained is determined based on the target output value and the actual output value corresponding to the sample data. For ease of understanding, the following is combined with Figure 3 The training process of the model to be trained is described in detail.

[0057] Figure 3 A schematic diagram of the training process of the model to be trained provided in this specification.

[0058] Combination Figure 3It can be seen that for the first network layer of the model to be trained, the network layer can calculate the output value of the network layer based on the sample data input into the model to be trained and the model parameters of the network layer, and calculate the gradient value of the network layer based on the sample data input into the model to be trained and the output value of the network layer, and send the gradient value of the network layer to the central processing unit, so that the central processing unit adjusts the model parameters of the network layer corresponding to the gradient value according to the received gradient value, obtains the adjusted model parameters and returns them to the graphics processor, and the graphics processor can adjust the model parameters of the first network layer according to the adjusted model parameters returned by the central processing unit to obtain the adjusted first network layer.

[0059] Furthermore, the graphics processor can determine, for each network layer except the first network layer and the last network layer in the network layers to be trained, the network layer above the network layer in the model to be trained as a reference network layer, and then calculate the output value of the network layer according to the output value of the reference network layer and the model parameters of the network layer, calculate the gradient value of the reference network layer according to the output value of the reference network layer and the model parameters of the reference network layer, calculate the gradient value of the network layer according to the gradient value of the reference network layer and the output value of the network layer, and send the gradient value of the network layer to the central processing unit, so that the central processing unit adjusts the model parameters of the network layer corresponding to the gradient value according to the received gradient value, obtains the adjusted model parameters and returns them to the graphics processor, and the graphics processor adjusts the model parameters of the network layer according to the adjusted model parameters returned by the central processing unit to obtain the adjusted network layer corresponding to the network layer.

[0060] Furthermore, the graphics processor can calculate the output value of the last network layer in each network layer included in the model to be trained based on the output value of the network layer above the network layer in the model to be trained and the model parameters of the network layer, and then calculate the gradient value of the network layer based on the output value of the network layer and the label value corresponding to the sample data input into the model to be trained, and send the gradient value of the network layer to the central processing unit, so that the central processing unit adjusts the model parameters of the network layer corresponding to the gradient value according to the received gradient value, obtains the adjusted model parameters and returns them to the graphics processor, and the graphics processor can adjust the model parameters of the last network layer according to the adjusted model parameters returned by the central processing unit to obtain the adjusted last network layer.

[0061] Among them, the label value corresponding to the above-mentioned sample data may refer to the actual value corresponding to the sample data determined by manual labeling or other methods. For example, when the model to be trained is an image classification model, the label value corresponding to the sample data may be the probability value that the sample data belongs to different preset classification results.

[0062] In actual application scenarios, in order to speed up the training process of the model to be trained while reducing the occupation of storage resources, data formats with different precisions can also be used in the data processing process of the above-mentioned graphics processor and central processing unit.

[0063] For ease of understanding, the following describes in detail the training process of training a model using data formats with the same precision and the training process of training a model using data formats with two different precisions.

[0064] Specifically, when the model to be trained is trained using the same precision data format, at this time, for each network layer of the model to be trained, after determining the gradient value of the network layer, the graphics processor can send the gradient value of the network layer and the model parameters of the network layer to the central processing unit, so that the central processing unit can receive the gradient value, adjust the model parameters of the network layer, and return the adjusted model parameters.

[0065] Of course, the central processing unit can also obtain a model building request, and according to the model building request, pre-acquire and save the complete model parameters of the model to be trained, and then after receiving the gradient value returned by the image processor, determine the network layer corresponding to the received gradient value, and adjust the model parameters of the network layer corresponding to the received gradient value according to the received gradient value, and return the adjusted model parameters.

[0066] Furthermore, when the model to be trained is trained using data formats of different precisions, the model parameters of the model to be trained can be pre-saved in the central processing unit as preset model parameters. It can be understood that the complete model parameters of the model to be trained can be pre-saved in the central processing unit, and in actual use, the central processing unit can also adjust the preset model parameters of the network layer corresponding to the received gradient value according to the received gradient value to obtain the adjusted model parameters, and perform data conversion on the adjusted model parameters to convert the data format corresponding to the adjusted model parameters into the data format corresponding to the model parameters of the model to be trained stored in the graphics processor, and return the converted adjusted model parameters to the graphics processor.

[0067] The accuracy of the data format used by the above-mentioned preset model parameters is higher than the accuracy of the data format used by each model parameter of the to-be-trained model stored in the graphics processor.

[0068] From the above content, it can be seen that the above-mentioned model training system can adopt a mixed precision method (in the process of calculating the gradient value by the graphics processor, a data format with lower precision is adopted, for example: the fp16 format with 16-bit precision is adopted to reduce the occupation of hardware resources, and in the process of calculating the adjusted model parameters by the central processing unit, a data format with higher precision is adopted, for example: the fp32 format with 16-bit precision is adopted to ensure the accuracy of the calculated adjusted model parameters), while ensuring the accuracy of the calculated adjusted model parameters, reducing the occupation of hardware resources.

[0069] In actual application scenarios, since the above-mentioned models to be trained are usually large models with a large parameter scale, using only a single computing device (for example: a single graphics processor, a single central processing unit) often cannot meet the computing requirements required for training large models.

[0070] Therefore, the above-mentioned model training system may include at least two central processing units and at least two graphics processing units, wherein, for each central processing unit, the central processing unit and at least one graphics processing unit constitute a computing node, and for each computing node, the computing node is used to construct at least part of the network layers included in the model to be trained according to the model construction request, and adjust the model parameters of each constructed network layer to obtain the adjusted model parameters, so as to obtain the adjusted network layer corresponding to each constructed network layer.

[0071] It can be seen from the above content that the model training system can include a computing cluster, which is composed of at least one computing node, wherein each computing node is composed of a central processing unit and at least one graphics processing unit, and for each computing node, the computing node can only train part of the network layer of the model to be trained.

[0072] For example: Assume that the model to be trained has three network layers, where the first network layer can be deployed in computing node one, the second network layer can be deployed in computing node two, and the third network layer can be deployed in computing node three, thereby avoiding the situation where a single computing device is unable to meet the hardware resource requirements for training a large model.

[0073] For another example: suppose the model to be trained has five network layers, where the first and second network layers can be deployed in computing node one, the third network layer can be deployed in computing node two, and the fourth and fifth network layers can be deployed in computing node three.

[0074] It should be noted that when different network layers of the model to be trained are deployed on different computing nodes, since there is a training dependency between the network layers (for example, when training the second network layer of the model to be trained, the output value of the first network layer of the model to be trained is required to be used for training), at this time, the computing node deployed with the previous network layer can calculate the output value required for the next network layer, and then send the output value to the computing node where the next network layer is located through the network communication method between computing nodes, so that the computing node where the next network layer is located does not have to wait for the model parameters of the previous network layer to be adjusted before adjusting the model parameters of the next network layer, thereby effectively improving the training efficiency of the model to be trained. In other words, when the computing node deployed with the previous network layer can calculate the output value required for the next network layer, it can send the output value to the computing node where the next network layer is located through the network communication method between computing nodes, so that the overall process of the computing node where the next network layer is located adjusting the model parameters for the next network layer and the process of the computing node where the previous network layer is deployed calculating the gradient value of the previous network layer and adjusting the model parameters of the previous network layer are executed in parallel.

[0075] Specifically, for each computing node, if the computing node is composed of a central processing unit and at least two graphics processing units, each graphics processing unit in the computing node is used to determine the output value of each network layer constructed by the computing node according to the output value of the network layer in the model to be trained and the model parameters of the network layer, determine the graphics processing unit used to determine the gradient value of the next network layer in the network layer in the model to be trained as the target graphics processing unit, and transmit the output value of the network layer to the target graphics processing unit so that the target graphics processing unit performs the computing task according to the output value of the network layer, and while the target graphics processing unit performs the computing task according to the output value of the network layer, calculate the gradient value of the network layer according to the output value of the network layer and the output value of the network layer in the model to be trained, and send the gradient value of the network layer to the central processing unit in the computing node, and adjust the model parameters of the network layer according to the adjusted model parameters returned by the central processing unit to obtain the adjusted network layer.

[0076] In addition, since large models have large-scale model parameters, a large amount of sample data is required when training large models. Therefore, in order to improve the efficiency of training the model to be trained, for each computing node, the network layer deployed in the computing node can be trained using different sample data through the multiple graphics processors contained in the computing node.

[0077] Specifically, when a computing node includes two or more graphics processors, each graphics processor in the computing node is used to determine the gradient value of each network layer constructed by the computing node based on a sample data set matching the graphics processor, and send the gradient value of the network layer to the central processing unit in the computing node, and adjust the model parameters of the network layer according to the adjusted model parameters returned by the central processing unit to obtain the adjusted network layer, wherein, different sample data sets matching different graphics processors in the computing node, the process of each graphics processor determining the output value and gradient value of at least part of the network layer of the model to be trained corresponding to the computing node based on different sample data sets is executed in parallel, and the central processing unit of the computing node is used to adjust the model parameters of the network layer according to the gradient value of the network layer sent by each graphics processor of the computing node, obtain the adjusted model parameters and return them to each graphics processor of the computing node.

[0078] Of course, each graphics processor in the computing node can also be used to determine the block gradient value of each network layer constructed by the computing node according to the output value of at least part of the neurons in the network layer, and send the block gradient value of the network layer to the central processing unit, and adjust the model parameters of the network layer according to the adjusted model parameters returned by the central processing unit to obtain the adjusted network layer. The central processing unit in the computing node is used to adjust the model parameters of the network layer according to the block gradient values ​​of the network layer sent by each graphics processor of the computing node, obtain the adjusted model parameters and return them to each graphics processor of the computing node.

[0079] It can be seen from the above content that, for each computing node, the computing node can improve the efficiency of training the network layer of the model to be trained deployed on the computing node through two different methods, that is, for each computing node, the computing node can use different sample data sets through each image processor to train the network layer of the model to be trained deployed on the computing node, and each image processor can calculate the output value of each neuron in the network layer of the model to be trained deployed on the computing node in parallel. These two methods can be used separately or together.

[0080] When the above two methods are used simultaneously, the computing node can determine each graphics processor group from each graphics processor, and for each graphics processor group, the graphics processor group contains at least two graphics processors, and the graphics processor group is used to determine the gradient value of the network layer based on the sample data set matching the graphics processor group, and send the gradient value of the network layer to the central processing unit in the computing node, and for each graphics processor in the graphics processor group, the graphics processor can, for each network layer deployed on the computing node, determine the block gradient value of the network layer according to the output value of at least part of the neurons in the network layer, and send the block gradient value of the network layer to the central processing unit, wherein the sample data contained in the sample data set matching different graphics processor groups is different, and for each graphics processor group, each graphics processor in the graphics processor group is used to determine the output value of at least part of the neurons in the network layer where the model to be trained is deployed on the computing node and determine the block gradient value of the network layer corresponding to this part of the neurons.

[0081] From the above content, it can be seen that the forward gradient propagation method can be used, that is, in the forward propagation process, for the output value of each network layer of the model to be trained and the output value of the network layer above the network layer in the model to be trained, the gradient value of the network layer is calculated, and the model parameters of the network layer are adjusted based on the gradient value of the network layer. In this way, after the model parameters of each network layer are determined by the central processing unit, the output value of the previous network layer and the gradient value of the network layer can be deleted, thereby effectively reducing the occupancy of storage resources during the training process of the model to be trained.

[0082] For ease of understanding, the following will describe in detail the method performed by the graphics processor during the training of the large model through the above-mentioned model training system. Figure 4 shown.

[0083] Figure 4 A flow chart of a model training method provided in this specification includes the following steps:

[0084] S401: Obtain a model building request input by a user.

[0085] S402: Construct a model to be trained according to the model construction request.

[0086] S403: For each network layer in the model to be trained, determine the network layer above the network layer in the model to be trained as the reference network layer, calculate the gradient value of the network layer according to the output value of the network layer and the output value of the reference network layer, and send the gradient value of the network layer to the central processing unit, so that the central processing unit adjusts the model parameters of the network layer corresponding to the gradient value according to the received gradient value, obtains the adjusted model parameters and returns them.

[0087] S404: According to the adjusted model parameters received and returned by the central processor, the model parameters of the network layer are adjusted to obtain the adjusted network layer, and the output value of the reference network layer and the gradient value of the network layer are deleted.

[0088] S405: Obtain an adjusted model according to the adjusted network layer, so as to perform a task according to the adjusted model.

[0089] In addition, this specification also describes in detail the method performed by the central processor during the training of the large model by the above-mentioned model training system, as follows: Figure 5 shown.

[0090] Figure 5 A flow chart of a model training method provided in this specification includes the following steps:

[0091] S501: receiving a gradient value sent by a graphics processor, wherein the gradient value is calculated by the graphics processor by constructing a model to be trained according to a received model building request, and determining, for each network layer in the model to be trained, a network layer above the network layer in the model to be trained as a reference network layer, according to an output value of the network layer and an output value of the reference network layer.

[0092] S502: adjusting the model parameters of the network layer corresponding to the gradient value according to the gradient value, obtaining the adjusted model parameters and sending them to the graphics processor, so that the graphics processor adjusts the model parameters of the network layer corresponding to the gradient value according to the received adjusted model parameters to obtain the adjusted network layer, and deletes the output value of the reference network layer and the gradient value of the network layer, and obtains an adjusted model according to each adjusted network layer, so as to perform tasks according to the adjusted model.

[0093] The above are one or more implementation model training methods of this specification. Based on the same idea, this specification also provides a corresponding model training device, such as Figure 6 , Figure 7 shown.

[0094] Figure 6 A schematic diagram of a model training device provided in this specification includes:

[0095] An acquisition module 601 is used to acquire a model building request input by a user;

[0096] A construction module 602 is used to construct a model to be trained according to the model construction request;

[0097] A determination module 603 is used to determine, for each network layer in the model to be trained, a network layer above the network layer in the model to be trained as a reference network layer, calculate a gradient value of the network layer according to an output value of the network layer and an output value of the reference network layer, and send the gradient value of the network layer to a central processing unit, so that the central processing unit adjusts the model parameters of the network layer corresponding to the gradient value according to the received gradient value, obtains the adjusted model parameters and returns them;

[0098] An adjustment module 604 is used to adjust the model parameters of the network layer according to the adjusted model parameters returned by the central processor to obtain the adjusted network layer, and delete the output value of the reference network layer and the gradient value of the network layer;

[0099] The execution module 605 is used to obtain an adjusted model according to the adjusted network layer, so as to perform a task according to the adjusted model.

[0100] Figure 7 A schematic diagram of a model training device provided in this specification includes:

[0101] The receiving module 701 is used to receive a gradient value sent by a graphics processor, wherein the gradient value is calculated by the graphics processor when constructing a model to be trained according to the received model construction request, and determining, for each network layer in the model to be trained, a network layer above the network layer in the model to be trained as a reference network layer, according to an output value of the network layer and an output value of the reference network layer;

[0102] The adjustment module 702 is used to adjust the model parameters of the network layer corresponding to the gradient value according to the gradient value, obtain the adjusted model parameters and send them to the graphics processor, so that the graphics processor adjusts the model parameters of the network layer corresponding to the gradient value according to the received adjusted model parameters to obtain the adjusted network layer, and deletes the output value of the reference network layer and the gradient value of the network layer, and obtains the adjusted model according to each adjusted network layer, so as to perform tasks according to the adjusted model.

[0103] This specification also provides a computer-readable storage medium, which stores a computer program, which can be used to execute the above Figure 4 , Figure 5 A model training method provided.

[0104] This manual also provides Figure 8 The one shown corresponds to Figure 4 , Figure 5 A schematic diagram of the electronic device. Figure 8 As mentioned above, at the hardware level, the electronic device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory, and may also include other hardware required for the business. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to achieve the above Figure 1 The model training method described. Of course, in addition to the software implementation, this specification does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc., that is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.

[0105] For the improvement of a technology, it can be clearly distinguished whether it is a hardware improvement (for example, improvement of the circuit structure of diodes, transistors, switches, etc.) or a software improvement (improvement of the method flow). However, with the development of technology, many improvements of the method flow today can be regarded as direct improvements of the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that the improvement of a method flow cannot be implemented with a hardware entity module. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. Designers can "integrate" a digital system on a PLD by programming themselves, without having to ask chip manufacturers to design and make dedicated integrated circuit chips. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented by "logic compiler" software, which is similar to the software compiler used when developing and writing programs, and the original code before compilation must also be written in a specific programming language, which is called hardware description language (HDL). There is not only one kind of HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed ​​Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that it is only necessary to program the method flow slightly in the above-mentioned hardware description languages ​​and program it into the integrated circuit, and then it is easy to obtain the hardware circuit that implements the logic method flow.

[0106] The controller may be implemented in any suitable manner, for example, the controller may take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (such as software or firmware) executable by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller may also be implemented as part of the control logic of the memory. It is also known to those skilled in the art that, in addition to implementing the controller in a purely computer-readable program code manner, the controller may be implemented in the form of a logic gate, a switch, an application-specific integrated circuit, a programmable logic controller, and an embedded microcontroller by logically programming the method steps. Therefore, such a controller may be considered as a hardware component, and the devices for implementing various functions included therein may also be considered as structures within the hardware component. Or even, the devices for implementing various functions may be considered as both software modules for implementing the method and structures within the hardware component.

[0107] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.

[0108] For the convenience of description, the above device is described in various units according to their functions. Of course, when implementing this specification, the functions of each unit can be implemented in the same or multiple software and / or hardware.

[0109] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems, or computer program products. Therefore, this specification may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0110] This specification is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of this specification. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0111] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0112] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0113] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0114] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0115] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0116] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0117] It should be understood by those skilled in the art that the embodiments of this specification may be provided as methods, systems or computer program products. Therefore, this specification may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0118] This specification may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. This specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.

[0119] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0120] The above description is only an embodiment of the present specification and is not intended to limit the present specification. For those skilled in the art, the present specification may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present specification shall be included in the scope of the claims of the present specification.

Claims

1. A model training system, characterized in that: The model training system includes: a central processing unit and a graphics processing unit; The graphics processor is used to obtain a model building request input by a user, and build a model to be trained according to the model building request, and for each network layer in the model to be trained, determine the network layer above the network layer in the model to be trained as a reference network layer, calculate the gradient value of the network layer according to the output value of the network layer and the output value of the reference network layer, send the gradient value of the network layer to the central processor, and adjust the model parameters of the network layer according to the adjusted model parameters returned by the central processor to obtain the adjusted network layer, and delete the output value of the reference network layer and the gradient value of the network layer; The central processing unit is used to adjust the model parameters of the network layer corresponding to the gradient value according to the received gradient value and the preset statistical data matching the network layer corresponding to the gradient value, obtain the adjusted model parameters and return them to the graphics processor, the statistical data includes: momentum value and variance, wherein the momentum value is used to characterize the degree of change of the gradient value during the historical adjustment of the model parameters of the network layer corresponding to the gradient value, and the variance is used to characterize the degree of change of the output value during the historical adjustment of the model parameters of the network layer corresponding to the gradient value; The graphics processor is used to obtain an adjusted model according to each adjusted network layer, so as to perform a task according to the adjusted model.

2. The model training system according to claim 1, characterized in that: The model training system includes: at least two central processing units and at least two graphics processing units, wherein, for each central processing unit, the central processing unit and at least one graphics processing unit constitute a computing node, and for each computing node, the computing node is used to construct at least part of the network layers included in the model to be trained according to the model construction request, and adjust the model parameters of each constructed network layer to obtain the adjusted model parameters, so as to obtain the adjusted network layer corresponding to each constructed network layer.

3. The model training system according to claim 2, characterized in that: For each computing node, if the computing node is composed of a central processing unit and at least two graphics processing units, each graphics processing unit in the computing node is used to determine the gradient value of the network layer for each network layer constructed by the computing node based on a sample data set matching the graphics processing unit, and send the gradient value of the network layer to the central processing unit in the computing node, and adjust the model parameters of the network layer according to the adjusted model parameters returned by the central processing unit to obtain the adjusted network layer, wherein the sample data sets matching different graphics processing units in the computing node are different, and the process of each graphics processing unit determining the output value of at least part of the network layer of the to-be-trained model corresponding to the computing node based on different sample data sets is executed in parallel; The central processing unit of the computing node is used to adjust the model parameters of the network layer according to the gradient value of the network layer sent by each graphics processor of the computing node, obtain the adjusted model parameters and return them to each graphics processor of the computing node.

4. The model training system according to claim 2, characterized in that: For each computing node, if the computing node is composed of a central processing unit and at least two graphics processing units, each graphics processing unit in the computing node is used to determine the block gradient value of each network layer constructed by the computing node according to the output value of at least part of the neurons in the network layer, and send the block gradient value of the network layer to the central processing unit, and adjust the model parameters of the network layer according to the adjusted model parameters returned by the central processing unit to obtain the adjusted network layer; The central processing unit in the computing node is used to adjust the model parameters of the network layer according to the received gradient values ​​of each block of the network layer sent by each graphics processor of the computing node, obtain the adjusted model parameters and return them to each graphics processor of the computing node.

5. The model training system according to claim 2, characterized in that: For each computing node, if the computing node is composed of a central processing unit and at least two graphics processing units, each graphics processing unit in the computing node is used to determine the output value of each network layer constructed by the computing node according to the output value of the network layer in the previous layer of the network layer in the model to be trained and the model parameters of the network layer, determine the graphics processing unit used to determine the gradient value of the next layer of the network layer in the network layer in the model to be trained as the target graphics processing unit, and transmit the output value of the network layer to the target graphics processing unit so that the target graphics processing unit performs the computing task according to the output value of the network layer, and calculate the gradient value of the network layer according to the output value of the network layer and the output value of the network layer in the previous layer of the network layer in the model to be trained, and send the gradient value of the network layer to the central processing unit in the computing node, and adjust the model parameters of the network layer according to the adjusted model parameters returned by the central processing unit to obtain the adjusted network layer.

6. The model training system according to claim 1, characterized in that: The central processing unit is used to adjust the preset model parameters of the network layer corresponding to the received gradient value according to the received gradient value to obtain the adjusted model parameters, and perform data conversion on the adjusted model parameters to convert the data format corresponding to the adjusted model parameters into the data format corresponding to the model parameters of the model to be trained stored in the graphics processor, and return the converted adjusted model parameters to the graphics processor, the preset model parameters are the complete model parameters of the model to be trained pre-stored in the central processing unit, and the accuracy of the data format used by the preset model parameters is higher than the accuracy of the data format used by each model parameter of the model to be trained stored in the graphics processor.

7. A model training method, characterized in that: The method is applied to a graphics processor of a model training system, and the method comprises: Get the model building request input by the user; Building a model to be trained according to the model building request; For each network layer in the model to be trained, determine the network layer above the network layer in the model to be trained as the reference network layer, calculate the gradient value of the network layer according to the output value of the network layer and the output value of the reference network layer, and send the gradient value of the network layer to a central processor, so that the central processor adjusts the model parameters of the network layer corresponding to the gradient value according to the received gradient value and the preset statistical data matching the network layer corresponding to the gradient value, obtains the adjusted model parameters and returns them, and the statistical data includes: momentum value and variance, wherein the momentum value is used to characterize the degree of change of the gradient value during the historical adjustment of the model parameters of the network layer corresponding to the gradient value, and the variance is used to characterize the degree of change of the output value during the historical adjustment of the model parameters of the network layer corresponding to the gradient value; According to the adjusted model parameters returned by the central processor, the model parameters of the network layer are adjusted to obtain the adjusted network layer, and the output value of the reference network layer and the gradient value of the network layer are deleted; According to the adjusted network layer, an adjusted model is obtained, so as to perform a task according to the adjusted model.

8. A model training method, characterized in that: The method is applied to a central processor of a model training system, and the method comprises: Receive a gradient value sent by a graphics processor, where the gradient value is calculated by the graphics processor by constructing a model to be trained according to the received model building request, and determining, for each network layer in the model to be trained, a network layer above the network layer in the model to be trained as a reference network layer, according to an output value of the network layer and an output value of the reference network layer; According to the received gradient value and the preset statistical data matching the network layer corresponding to the gradient value, the model parameters of the network layer corresponding to the gradient value are adjusted to obtain the adjusted model parameters and return them to the graphics processor, so that the graphics processor adjusts the model parameters of the network layer corresponding to the gradient value according to the received adjusted model parameters to obtain the adjusted network layer, and deletes the output value of the reference network layer and the gradient value of the network layer, and obtains the adjusted model according to each adjusted network layer, so as to perform tasks according to the adjusted model, and the statistical data include: momentum value and variance, wherein the momentum value is used to characterize the degree of change of the gradient value during the historical adjustment process of the model parameters of the network layer corresponding to the gradient value, and the variance is used to characterize the degree of change of the output value during the historical adjustment process of the model parameters of the network layer corresponding to the gradient value.

9. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method described in any one of claims 7 to 8 is implemented.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method described in any one of claims 7 to 8 is implemented.