Model training method based on distributed system, distributed system, and electronic device

By controlling the training of computing nodes sequentially in a distributed system and using parameters to predict the model, the problem of outdated gradients in asynchronous parallel training is solved, thereby improving the accuracy and speed of model training.

CN120430435BActive Publication Date: 2026-06-02HONOR DEVICE CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
HONOR DEVICE CO LTD
Filing Date
2024-12-30
Publication Date
2026-06-02

Smart Images

  • Figure CN120430435B_ABST
    Figure CN120430435B_ABST
Patent Text Reader

Abstract

A model training method based on a distributed system, a distributed system and an electronic device, relate to the technical field of machine learning. The distributed system comprises a control node and a plurality of computing nodes, and the method is applied to the control node. The control node can control the plurality of computing nodes to perform multi-round iterative training on a target model, and in each round of training, the plurality of computing nodes perform training on the target model in a predetermined order. In the process of training the target model by any one computing node in the Nth round of training, the global parameters of the target model are updated according to the first gradient determined by the computing node based on the first parameters. The first parameters are the global parameters of the target model to be updated by the computing node in the Nth round of training, which are predicted in the (N-1)th round of training. N is a positive integer greater than or equal to 2. The above method can improve the effect of the trained model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of machine learning technology, and in particular to a model training method, a distributed system, and an electronic device based on a distributed system. Background Technology

[0002] In the field of machine learning technology, large amounts of data are typically used for model training to obtain better-performing machine learning models. In this case, distributed systems are commonly used to train models quickly. Asynchronous parallel distributed algorithms are a commonly used model training scheme in the industry.

[0003] However, using asynchronous parallel distributed algorithms for model training is prone to the problem of outdated gradients, leading to poor model performance. Therefore, it is necessary to propose a model training scheme that can improve model performance. Summary of the Invention

[0004] This application provides a model training method, a distributed system, and an electronic device based on a distributed system, which can improve the training effect of the model.

[0005] To achieve the above objectives, the embodiments of this application adopt the following technical solutions:

[0006] Firstly, a model training method based on a distributed system is provided, applied to the control node of the distributed system, which also includes *a* computing nodes, where *a* ≥ 2 and is a positive integer. The control node can control the *a* computing nodes to perform multiple rounds of iterative training on the target model. In each round of training, the *a* computing nodes train the target model once sequentially according to a preset order. That is, training the target model once sequentially by the *a* computing nodes is called one round of training. In one round of training, each computing node trains the target model once. Since there are *a* computing nodes, one round of iterative training includes *a* training iterations. The next computing node is used to train the target model after the previous computing node has trained it. In other words, in one round of *a* training iterations, each training iteration uses only the gradient determined by one computing node to update the global parameters of the target model once. The global parameters to be updated by the next computing node are the global parameters updated based on the gradient determined by the previous computing node in the previous training iteration. One computing node can train the target model once, without waiting for all computing nodes to determine the gradients before updating the global parameters of the target model, resulting in faster model training. Therefore, it can avoid wasting system resources due to excessive training times and save system resources.

[0007] The process of any computing node (worker_i) training the target model in the Nth training round includes: updating the global parameters of the target model based on the first gradient determined by the computing node based on the first parameter; the first parameter is the global parameter of the target model to be updated by the computing node in the Nth training round, predicted in the (N-1)th training round; i is a positive integer greater than or equal to 1, and N ≥ 2 and is a positive integer. This first parameter is close to the actual global parameters of the target model when it is the computing node's turn to train in the Nth training round. Therefore, when it is worker_i's turn to train the target model in the Nth training round, worker_i determines the first gradient based on the first parameter. This first gradient is more closely matched to the actual global parameters to be updated, thus the control node can update the global parameters of the target model more accurately based on the first gradient, thereby improving the accuracy of model training and resulting in a better final trained model.

[0008] In one possible implementation, the first global parameters are the global parameters updated based on the first gradient determined by any computing node worker_i in the Nth training round. The control node can predict the global parameters of the target model to be updated by worker_i in the (N+1)th training round based on the first global parameters, obtaining a second parameter. This second parameter is close to the actual global parameters of the target model when it is worker_i's turn to train in the (N+1)th training round. The control node can send the second parameter to the computing node; the second parameter is used by the computing node to determine the second gradient; the second gradient is used by the control node to update the global parameters of the target model in the (N+1)th training round based on the second gradient. Because the second parameter is close to the actual global parameters of the target model when it is worker_i's turn to train in the (N+1)th training round, the second gradient determined based on the second parameter is more closely matched to the global parameters to be updated by worker_i in the (N+1)th training round. Therefore, the global parameters of the target model can be updated more accurately based on the second gradient, thereby improving the accuracy of model training and resulting in a better-performing final trained model.

[0009] In one possible implementation, a parameter prediction model is configured in the control node. The control node can input a first global parameter into the parameter prediction model to predict the global parameters of the target model to be updated by the computing node in the (N+1)th round of training, thereby obtaining the second parameter.

[0010] In the above scheme, the parameter prediction model has the function or ability to predict the global parameters to be updated for any computing node in the next round of training. Based on this parameter prediction model, the global parameters of the target model to be updated for the computing node in the N+1th round of training can be predicted more accurately and conveniently. This parameter prediction model can be pre-trained or trained step-by-step during the execution of the method in the embodiments of this application; there is no limitation on this.

[0011] In one possible implementation, the parameter prediction model is trained from an initial sample data set; the initial sample data set is obtained in M ​​preliminary iterations prior to the multi-round iterative training; the initial sample data set includes a first sample parameter and a second sample parameter; the first sample parameter is the global parameter updated in the b-th preliminary iteration training; the second sample parameter is the global parameter updated in the b+a-th preliminary iteration training; M > a, b ≥ 1 and b+a ≤ M.

[0012] In the above scheme, before starting multiple rounds of iterative training, sample data—i.e., the initial sample data set—can be obtained through M preliminary iterations of training on 'a' computing nodes. This initial sample data set is based on preliminary iterative training with 'a' computing nodes in the distributed system, thus it is more compatible with the entire distributed system. The parameter prediction model trained based on this initial sample data set is more compatible with the current distributed system, improving the accuracy of global parameter prediction. This, in turn, improves the accuracy of the target model training.

[0013] In one possible implementation, before inputting the first global parameters into the parameter prediction model, the control node can further train the parameter prediction model based on the first global parameters and the second global parameters. The first global parameters are global parameters updated based on the first gradient determined by worker_i in the Nth round of training, and the second global parameters are global parameters updated based on the gradient determined by the computing node in the (N-1)th round of training.

[0014] In the above scheme, during multiple rounds of training, each time the global parameters of the target model are updated (i.e., each time a new global parameter is generated), the control node can update and train the parameter prediction model P based on the new global parameter (such as the first global parameter). That is, during the process of using the parameter prediction model P for global parameter prediction, the parameter prediction model P is progressively updated and optimized, thereby gradually improving the prediction accuracy of the parameter prediction model P, and thus training the target model more accurately.

[0015] In one possible implementation, the control node can input the second global parameter into the parameter prediction model to obtain a third global parameter predicted by the parameter prediction model; determine a loss value based on the difference between the third global parameter and the first global parameter; and adjust the parameter values ​​of the parameter prediction model based on the loss value.

[0016] In the above embodiments, the first global parameter and the second global parameter constitute a sample data group. By calculating the loss value, the parameter prediction model can be updated and trained more quickly and accurately.

[0017] In one possible implementation, during each initial training iteration, the global parameters of the target model are updated based on the gradients determined by each of the a computational nodes.

[0018] In the above scheme, the scheme based on synchronous parallel model training performs M initial iterations of training, which makes the updated global parameters more accurate in each initial iteration. Therefore, it can generate a more accurate initial sample data set, and thus train the parameter prediction model more accurately.

[0019] In one possible implementation, during each initial training iteration, the global parameters of the target model are updated based on the gradient determined by any one of the a computing nodes.

[0020] In the above scheme, the scheme based on asynchronous parallel model training performs M initial iterations of training, which can obtain the initial sample data set more quickly, so as to train the parameter prediction model more quickly, and then train the target model (i.e., the main model) based on the parameter prediction model more quickly, thereby improving the training efficiency of the target model.

[0021] In one possible implementation, the control node includes a parameter server. The parameter server is used to determine the computing node used for each training iteration in a training round; the parameter server is also used to, upon receiving the gradient determined by the target computing node, train the target model once based on the gradient determined by the target computing node when it is the target computing node's turn to train the target model; the target computing node is any one of the a computing nodes.

[0022] In the above scheme, the parameter server has been improved so that it not only has the function of updating global parameters, but also the function of predicting global parameters and sequentially controlling multiple computing nodes to train the target model. Based on this improved parameter server, the target model can be trained more efficiently and accurately.

[0023] In one possible implementation, the control node includes a controller and a parameter server. The controller is used to specify the computing node used for each training iteration in a training round. The parameter server is used to train the target model once based on the gradient determined by the computing node specified by the controller.

[0024] The above scheme also improves the parameter server, enabling it to not only update global parameters but also predict them. In this scheme, the controller offloads the function of specifying the computing nodes used in each training round, reducing the load on the parameter server.

[0025] In one possible implementation, during each training round, based on a preset sequence, the controller sends a first control instruction to a first computing node among the a computing nodes, the first control instruction instructing the first computing node to perform one training iteration on the target model; in response to first information returned by the first computing node, a second control instruction is sent to a second computing node, the second control instruction instructing the second computing node to perform one training iteration on the target model; the second computing node is the next computing node after the first computing node among the a computing nodes; the first information indicates that one training iteration of the target model by the first computing node has ended.

[0026] In the above scheme, the controller sends control commands to the computing nodes in a preset order to instruct them to train the model. After each computing node trains the target model once in response to the control command, it can provide feedback to the control node, which can then continue to send control commands to the next computing node to instruct it to train the model once. In this way, the controller enables each computing node to train the target model sequentially in each training round.

[0027] In one possible implementation, after the target model has been trained, media data to be recommended can be determined based on the trained target model, and the media data can be sent to the terminal.

[0028] In the above scheme, the target model trained can be a recommendation model used to recommend media data to the terminal. Because the target model trained in this scheme performs better, it can recommend media data to the terminal more accurately.

[0029] Secondly, this application provides a distributed system including a control node and a computing nodes; the control node is configured to execute the method as described in any of the first aspects above. Exemplarily, the control node includes a memory and one or more processors. When the one or more processors execute the computer instructions, the control node performs the method as described in any of the first aspects above.

[0030] Thirdly, this application provides an electronic device that includes at least a memory and one or more processors. The memory stores computer instructions, which, when executed by the one or more processors, cause the electronic device to perform any of the methods described in the first aspect above.

[0031] Fourthly, this application provides a chip system applied to an electronic device, the chip system including one or more processors, the processors being configured to invoke computer instructions to cause the electronic device to perform any of the methods described in the first aspect above.

[0032] Fifthly, this application provides a computer-readable storage medium including computer instructions that, when executed on an electronic device, cause the electronic device to perform the method described in any of the first aspects above.

[0033] Sixthly, this application provides a computer program product that, when run on a computer, causes the computer to perform any of the methods described in the first aspect above. Attached Figure Description

[0034] Figure 1 A schematic diagram of the architecture of a traditional parameter server-based distributed system provided for embodiments of this application;

[0035] Figure 2 This application provides a schematic diagram illustrating the effect of model training in its embodiments. Figure 1 ;

[0036] Figure 3 A schematic diagram of the expiration gradient provided in the embodiments of this application;

[0037] Figure 4 This is a schematic diagram of the architecture of a distributed system provided in an embodiment of this application;

[0038] Figure 5 A schematic diagram of the principle of the model training method based on a distributed system provided in the embodiments of this application. Figure 1 ;

[0039] Figure 6 This application provides a schematic diagram illustrating the effect of model training in its embodiments. Figure 2 ;

[0040] Figure 7 A schematic diagram of the principle of the model training method based on a distributed system provided in the embodiments of this application. Figure 2 ;

[0041] Figure 8A schematic diagram illustrating the principle of loss value calculation provided in the embodiments of this application;

[0042] Figure 9 This is a schematic diagram of a scenario provided for an embodiment of this application;

[0043] Figure 10 This is a block diagram of the architecture of an electronic device provided in an embodiment of this application. Detailed Implementation

[0044] The technical solutions of the embodiments of this application are described below with reference to the accompanying drawings. In the description of the embodiments of this application, the terminology used in the following embodiments is for the purpose of describing specific embodiments only and is not intended to limit the application. As used in the specification and appended claims of this application, the singular expressions "a," "the," "the," and "this" are intended to also include expressions such as "one or more," unless the context clearly indicates otherwise. It should also be understood that in the following embodiments of this application, "at least one" and "one or more" refer to one or more (including two). The term "and / or" is used to describe the relationship between related objects, indicating that three relationships can exist; for example, A and / or B can represent: A alone, A and B simultaneously, or B alone, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. In the description of the embodiments, unless otherwise stated, "multiple" means two or more.

[0045] References to "one embodiment" or "some embodiments" in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized. The term "connection" includes direct connections and indirect connections, unless otherwise stated. The terms "first," "second," "third," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Therefore, a feature defined with "first," "second," "third," etc., may explicitly or implicitly include one or more of that feature.

[0046] In the embodiments of this application, the words "exemplary," "for example," or "for instance" are used to indicate examples, illustrations, or explanations. Any embodiment or design described as "exemplary," "for example," or "for instance" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or designs. Specifically, the use of the words "exemplary," "for example," or "for instance" is intended to present the relevant concepts in a specific manner.

[0047] This application provides a model training method based on a distributed system. The distributed system includes a control node and *a* computing nodes, where *a* is a positive integer greater than or equal to 2. This method is applied to the control node to improve the performance of the trained model, thereby increasing the accuracy of model processing.

[0048] Distributed systems are used to implement distributed training of models. Computational nodes are responsible for executing the actual training tasks in distributed training; therefore, computational nodes can also be called worker nodes.

[0049] The control node in this embodiment differs from the traditional control node in a distributed system; it is an improved control node. By executing the method in this embodiment using the improved control node, a model with better performance can be trained.

[0050] The machine learning model to be trained is denoted as the target model. Traditionally, the control node is primarily responsible for storing and updating the global parameters of the target model. However, in this embodiment, the control node, in addition to storing and updating the global parameters of the target model, can also control the order in which each computing node updates the global parameters of the target model, mitigating the problems caused by out-of-order updates of model parameters. For example, it alleviates the problem of inaccurate model training and poor model performance due to out-of-order updates of global parameters. Here, global parameters refer to the model parameters shared by all computing nodes (or worker nodes) in a distributed system.

[0051] It should be understood that computing nodes report gradients, thereby updating the global parameters of the target model once, achieving one training iteration of the model. Therefore, the updating of the global parameters of the target model by the computing nodes can also be understood as the computing nodes training the target model. Each update of the global parameters of the target model is equivalent to completing one training iteration of the target model. Therefore, controlling the order in which the computing nodes update the global parameters of the target model can also be called controlling the iterative training of the target model by the computing nodes in sequence.

[0052] In some schemes, the control node may include a parameter server (PS). For ease of understanding, the following will be discussed in conjunction with... Figure 1The architecture of a traditional parameter-based distributed system is illustrated.

[0053] Please see Figure 1 Each of the *a* computing nodes (workers) stores a copy of the target model. The target model is the master model to be trained. The data storage system can store *a* data shards. That is, based on the number of computing nodes *a*, the training dataset for the target model can be divided into *a* data shards: data shard 1, data shard 2, ..., data shard *a*. Each computing node corresponds to one data shard. For example, computing node 1 corresponds to data shard 1, and computing node 2 corresponds to data shard 2.

[0054] Each compute node can train the model replica stored in it based on the corresponding data shard. For example, compute node 1 can train the model replica in compute node 1 based on data shard 1, compute node 2 can train the model replica in compute node 2 based on data shard 2, and compute node a can train the model replica in compute node a based on data shard a.

[0055] For each computing node, during model training, the node can receive the global parameters of the target model from the parameter server (PS), calculate the gradient based on the received global parameters, and report the calculated gradient to the PS. The PS can then update the global parameters of the target model based on the reported gradient.

[0056] Distributed training based on parameter servers mainly includes two schemes: (1) synchronous parallel model training; (2) asynchronous parallel model training. The main purpose of distributed training is to update the global parameters of the target model. Therefore, synchronous parallel model training can also be called distributed synchronous update. Asynchronous parallel model training can also be called distributed asynchronous update.

[0057] In the two schemes described above, the way or timing at which the PS updates the global parameters of the target model based on the reported gradients differs. The differences between these two schemes will be described below.

[0058] Synchronous parallel model training (or distributed synchronous update): This refers to the process in which the parameter server (PS) receives gradients reported by all computing nodes, merges them (e.g., by weighted averaging), and updates the global parameters of the target model based on the merged gradients, which is equivalent to completing one training cycle.

[0059] by Figure 1For example, the parameter server PS can distribute the global parameters of the target model to be trained to each computing node. In the d-th training iteration, computing nodes 1 through a will calculate a gradient for the target model based on the latest global parameters distributed by PS, and report their calculated gradients to the parameter server PS.

[0060] After all computing nodes (i.e., *a* computing nodes) have reported gradients, the PS can update the global parameters of the target model based on the acquired gradients. For example, the PS can average the gradients reported by the *a* computing nodes and update the global parameters once based on the averaged gradients, thus obtaining the updated global parameters after the *d*th training iteration. The PS can then distribute the updated global parameters after the *d*th training iteration to the *a* computing nodes. In the *d+1*th training iteration, the *a* computing nodes can calculate the gradients again based on the updated global parameters and report the calculated gradients to the PS, causing the PS to update the global parameters of the target model once, thus obtaining the updated global parameters after the *d+1*th training iteration. This process is repeated iteratively.

[0061] As can be seen from the above, in the synchronous parallel model training scheme, each training session requires updating the global parameters of the target model based on the gradients calculated by all computing nodes. Therefore, PS needs to wait for all computing nodes to finish calculating the gradients before updating the global parameters of the target model.

[0062] Asynchronous parallel model training (or distributed asynchronous update): After each computing node calculates the gradient, it sends it to the parameter server (PS). Upon receiving the gradient from any computing node, the PS can update the global parameters of the target model once, i.e., perform one training iteration, without waiting for gradients from other computing nodes. In other words, the PS updates the global parameters of the target model once every time it receives a gradient calculated by a computing node, i.e., performs one training iteration on the target model.

[0063] Similarly Figure 1 For example, after compute node 1 calculates a gradient based on the latest global parameters issued by PS, it can report this gradient to PS. PS can then update the global parameters once based on the gradient reported by compute node 1, which is equivalent to completing the d-th training iteration. Next, PS receives the gradient calculated by compute node 3, and can update the global parameters once based on the gradient reported by compute node 3, which is equivalent to completing the d+1-th training iteration.

[0064] In some solutions, the processing steps for asynchronous parallel model training are as follows:

[0065] (1.1) worker_i determines the gradient Gi for this training based on the global parameters Wg of the target model.

[0066] Here, worker_i represents the i-th computation node, where i is less than or equal to a and is any positive integer, and a is the total number of computation nodes. Wg is the initial global parameter of the target model in this training, that is, the global parameter before adjustment in this training. It should be understood that Wg also belongs to the global parameters of the target model to be updated in this training.

[0067] The gradient Gi during this training refers to the gradient calculated with respect to the target model during this training process. Specifically, worker_i can calculate the gradient Gi for this training based on the global parameters Wg issued by PS.

[0068] (1.2) worker_i sends gradient Gi to PS.

[0069] (1.3) PS updates the global parameter Wg based on the gradient Gi, and obtains the updated global parameter Wg'.

[0070] For example, PS can update the global parameter Wg according to the following formula:

[0071] Wg'=Wg-l r*Gi.

[0072] Where lr is the learning rate, and Wg' is the global parameter of the target model after being updated in this training.

[0073] (1.4) PS sends the updated global parameter Wg' to worker_i, and worker_i performs the next iteration.

[0074] That is, you can return to steps (1.1) to (1.4) and iterate to train the target model.

[0075] As discussed above, in the asynchronous parallel model training scheme, the PS (Power Controller) does not need to wait for all computing nodes to finish calculating gradients before updating the global parameters of the target model. Instead, any computing node can train the target model once after calculating a gradient, i.e., send the gradient to the PS to request an update of the target model's global parameters. There is no synchronization between the computing nodes, allowing for out-of-order updates of the target model's global parameters (i.e., out-of-order training of the target model).

[0076] Synchronous parallel model training schemes and asynchronous parallel model training schemes each have their own advantages and disadvantages, as shown in Table 1.

[0077] Table 1

[0078]

[0079] As shown in Table 1, because the synchronous parallel model training scheme waits until all computing nodes have calculated the gradients before updating the global parameters of the target model based on these gradients, there are no outdated gradients, resulting in better model performance. However, this also leads to a low model update frequency and slow training speed.

[0080] In asynchronous parallel model training, the computing nodes do not need to wait for each other, resulting in fast training speed. However, outdated gradients are prone to occur, leading to poorer model performance compared to synchronous parallel model training.

[0081] To facilitate a more intuitive understanding of the advantages and disadvantages of synchronous parallel model training schemes versus asynchronous parallel model training schemes, this paper combines... Figure 2 The LOSS curve is illustrated below. The LOSS curve is the curve showing how the value of the model's loss function (i.e., the loss value) changes with the number of iterations or the training time during the training process.

[0082] Please see Figure 2 The horizontal axis represents the training time of the target model, and the vertical axis represents the loss value. Curve 201 is the loss curve for synchronous parallel model training, and curve 202 is the loss curve for asynchronous parallel model training.

[0083] As shown in curves 201 and 202, in the synchronous parallel model training scheme, the target model gradually approaches convergence after training time T1. In the asynchronous parallel model training scheme, the target model gradually approaches convergence after training time T2. Since T2 < T1, the target model converges faster in the asynchronous parallel model training scheme, meaning the training speed is faster.

[0084] Furthermore, it can be intuitively seen from curves 201 and 202 that, in curve 201, the loss value calculated after the target model approaches convergence is smaller. Therefore, the target model trained using the synchronous parallel model training scheme performs better.

[0085] The inventors of this application's embodiments discovered through research that the scheme using asynchronous parallel model training suffers from poor model performance, primarily due to outdated gradients. To facilitate understanding of outdated gradients, the following will, in conjunction with... Figure 3 An illustration is provided for expired gradients.

[0086] Suppose that computation node 1 (worker_1) obtains the global parameter W1 from the PS at time t1. Worker_1 then calculates the gradient G1 based on the global parameter W1. At time t3, worker_1 instructs the PS to update the global parameters based on the gradient G1. That is, worker_1 sends the gradient G1 to the PS, instructing the PS to update the global parameters of the target model based on the gradient G1.

[0087] However, it's possible that computation node 2 (worker_2) also obtains the global parameters W1 from PS, and worker_2 computes them faster than worker_1. Therefore, during the time interval t1 to t3, worker_2 may have already reported the gradient G2 to PS (for example, worker_2 reported the gradient G2 to PS at time t2, instructing PS to update the global parameters based on gradient G2), and PS may have already updated the global parameters of the target model from W1 to W2 based on the gradient G2 reported by worker_2.

[0088] In this scenario, when worker_1 instructs PS to update the global parameters based on gradient G1 at time point t3, the global parameters currently stored in PS to be updated are no longer W1, but have already been updated to W2. Therefore, gradient G1 is outdated for W2, meaning it doesn't match the global parameters W2 to be updated. However, in traditional asynchronous parallel model training schemes, PS will still update the target model's global parameters based on gradient G1, which is equivalent to updating the target model's global parameters based on an outdated gradient, leading to inaccurate model training. This results in a poorly performing model.

[0089] Based on this, this application proposes a model training method based on a distributed system, which is applied to the control node of the distributed system. The distributed system also includes a computing nodes, where a ≥ 2 and is a positive integer.

[0090] In this embodiment, the control node controls the a computing nodes to perform multiple rounds of iterative training on the target model. In each round of training, the a computing nodes sequentially train the target model once according to a preset order.

[0091] It should be understood that a training round in this embodiment does not refer to training the target model once or updating the global parameters of the target model once. In fact, a training round in this embodiment includes *a* training iterations of the target model. In other words, training the target model once by *a* computing nodes in a preset order is equivalent to completing one training round. If *a* computing nodes do not train the target model once in a preset order, it does not constitute a training round in this embodiment. For example, the preliminary iterative training mentioned below does not constitute a training round in this embodiment, but rather preliminary model training performed before starting multiple iterative training rounds.

[0092] After one round of training, in the next round of training, starting again from the first computing node, control a computing nodes to train the target model once in a preset order. The preset order is the same in different rounds of training; that is, in each round of training, control a computing nodes to train the target model once in the same preset order.

[0093] A control node may include a parameter server (PS). In some embodiments, the control node may be the PS itself. In other embodiments, the PS and other devices may be collectively referred to as a control node. For example, the PS and a dedicated controller may be collectively referred to as a control node. The controller may be an electronic device specifically designed to control the execution order of the various computing nodes.

[0094] Please see Figure 4 Taking PS as the control node, in the first round of training, the system will sequentially control each of the a computational nodes to train the target model once, following a preset order: computational node 1 (worker_1) -> computational node 2 (worker_2) -> ... -> computational node a (worker_a). Specifically, PS first controls worker_1 to train the target model once, that is, to update the global parameters of the target model once based on the gradient sent by worker_1. Then, PS controls worker_2 to train the target model once, that is, to update the global parameters of the target model once based on the gradient sent by worker_2. This process continues, controlling each worker to train the target model once, until worker_a is controlled to train the target model once (that is, to update the global parameters of the target model once based on the gradient sent by worker_a), thus completing the first round of training.

[0095] In the second round of training, PS will still control the a computing nodes to train the target model once in the preset order of computing node 1 -> computing node 2 -> ... -> computing node a.

[0096] The target model to be trained on each computing node is the target model trained by the previous computing node. In other words, during each training iteration of the target model on each computing node, the global parameters to be updated for that target model are the global parameters updated by the previous computing node in the previous training iteration. For example, after worker_1 trains the target model once, the global parameters of the target model are W1. Worker_2 trains the target model trained by worker_1; that is, when controlling worker_2 to train the target model, PS will update the global parameters W1 of the target model.

[0097] It should be understood that in two adjacent training rounds, the last computation node in the previous round is the preceding computation node of the first computation node in the next round. Figure 4 For example, computation node 'a' in the first round of training is the previous computation node of computation node 1 in the second round of training. Therefore, in the second round of training, the global parameters of the target model to be updated for computation node 1 are the global parameters updated by computation node 'a' in the first round of training.

[0098] Clearly, unlike the traditional synchronous parallel model training schemes described above, this embodiment does not require waiting for all computing nodes to determine their gradients before updating the global parameters of the target model. Instead, this embodiment controls one computing node to update the target model sequentially; that is, it updates the global parameters of the target model only once using the gradient determined by one computing node. Therefore, compared to the traditional synchronous parallel model training schemes described above, the model training speed is much faster.

[0099] Furthermore, as described above, the scheme in this application embodiment differs from the traditional asynchronous parallel model training scheme. Specifically, in the scheme of this application embodiment, the computing nodes do not train the target model out of order, but rather control each computing node to train the target model sequentially. In addition, compared to the traditional asynchronous parallel model training scheme, this application embodiment also improves upon each training iteration of the target model.

[0100] Specifically, during any training round at any computation node (denoted as worker_i, where i is a positive integer greater than or equal to 1) training the target model, the parameter server PS, upon receiving the gradient reported by worker_i, can predict the global parameters (i.e., the global parameters of the target model) that worker_i needs to update in the next training round. These predicted global parameters are recorded as the predicted parameters. PS can then send the predicted parameters to worker_i. When it's worker_i's turn to train the target model in the next training round, worker_i can determine the gradient based on the predicted parameters and report the determined gradient to PS. PS can then update the global parameters of the target model based on the gradient determined by the predicted parameters.

[0101] from Figure 4 It can be seen that, with Figure 1 Unlike the schemes shown, in this embodiment, the PS not only updates the global parameters based on the gradients reported by the computing nodes, but also, after each update, predicts the global parameters to be updated by the computing node in the next round of training (denoted as the predicted parameters) based on the updated global parameters. The PS sends the predicted parameters to the computing nodes, instead of sending the updated global parameters. Thus, when it is the computing node's turn to train the target model again, the computing node calculates the gradient based on the predicted parameters, and the PS updates the global parameters of the target model based on this gradient.

[0102] In some embodiments, any training round other than the first training round is denoted as the Nth training round, where N ≥ 2 and is a positive integer. The process of any computing node training the target model in the Nth training round includes: updating the global parameters of the target model based on a first gradient determined by the computing node based on a first parameter; the first parameter is the global parameter of the target model to be updated by the computing node in the Nth training round, predicted in the (N-1)th training round; N ≥ 2 and is a positive integer.

[0103] Specifically, for any computation node worker_i, in the (N-1)th training round, after the control node (e.g., PS) updates the global parameters of the target model based on the gradient reported by worker_i, the control node can predict the global parameters to be updated by worker_i in the Nth training round based on the updated global parameters, denoted as the first parameter. Then, during the training of the target model by worker_i in the Nth training round, worker_i can determine the first gradient based on this first parameter and report it to the control node. The control node can then update the global parameters of the target model based on this first gradient. Since this first parameter is close to the global parameters to be updated by worker_i in the Nth training round (i.e., the actual global parameters of the target model when it is worker_i's turn to train the target model in the Nth training round), using the first gradient determined by the first parameter can update the global parameters of the target model more accurately.

[0104] It should be understood that in the first round of training, when each computing node updates the target model, since the global parameters predicted in the previous round of training are not yet available, each computing node can determine the gradient based on the updated global parameters issued by the PS and report it to the PS. For any computing node worker_i, in the first round of training, the PS predicts the global parameters (i.e., the predicted parameters) to be updated by worker_i in the second round of training based on the global parameters reported by worker_i, and sends the predicted parameters to worker_i. This allows worker_i to determine the gradient based on the predicted parameters when updating the target model in the second round of training. In other words, starting from the second round of training, each computing node can determine the gradient based on the predicted parameters, and this gradient is used to update the global parameters of the target model.

[0105] In some examples, a parameter prediction model P is deployed in the PS. This parameter prediction model P has the function or ability to predict the global parameters to be updated for any computing node worker_i in the next round of training. The PS can predict the global parameters to be updated for worker_i in the next round of training based on the parameter prediction model P. The parameter prediction model P can be pre-trained or trained stepwise during the execution of the methods in the embodiments of this application. In other words, the parameter prediction model P can be used while simultaneously optimizing its training; detailed schemes will be described below. In other examples, the PS can also use statistical analysis algorithms or other methods to predict the global parameters to be updated for worker_i in the next round of training, without limitation.

[0106] For ease of understanding, combined with Figure 5 This section illustrates a single training iteration of the target model. Please refer to [link / reference]. Figure 5In the (N-1)th training round, computing node 1, computing node 2, ..., computing node a each train the target model once in sequence. After computing node a completes its training of the target model in the (N-1)th training round, the training begins in the Nth round. In the Nth training round, starting again from computing node 1, each computing node continues to train the target model once in sequence. For ease of distinction, in... Figure 5 In the diagram, arrows used to illustrate the sequential training of each computing node in the (N-1)th round of training are represented by solid lines, while arrows used to illustrate the sequential training of each computing node in the Nth round of training are represented by dashed lines.

[0107] It should be understood that the processing principle for each computing node to train the target model is the same. Figure 5 The following explanation uses computing node 1 as an example, and will not elaborate on the training of the target model by all computing nodes.

[0108] In the (N-1)th training round, when it's the turn of computation node 1 to train the target model, computation node 1 determines the gradient and reports it to the PS. For simplicity, the gradient determined by computation node 1 in the (N-1)th training round is denoted as the gradient determined in the (N-1)th training round. This does not mean that the gradient calculated by computation node 1 represents the gradient of the entire (N-1)th training round. In fact, each computation node in the (N-1)th training round will calculate the gradient in turn, thus training the target model once for each round.

[0109] like Figure 5 As shown, the PS updates the global parameters of the target model once based on the gradient determined in the (N-1)th training round reported by computing node 1. The PS can predict the global parameters to be updated for computing node 1 in the Nth training round based on the updated global parameters. The predicted global parameters to be updated for computing node 1 in the Nth training round can be denoted as the predicted parameters (i.e., the first parameters).

[0110] The PS can send the predicted parameters to computation node 1. Then, in the Nth training iteration, when computation node 1 trains the target model again, it can determine the gradient based on the predicted parameters. Again, for simplicity, the gradient determined by computation node 1 in the Nth training iteration is denoted as the gradient determined in the Nth training iteration. Computation node 1 can report the gradient determined in the Nth training iteration to the PS. The PS can then update the global parameters of the target model based on the gradient determined in the Nth training iteration.

[0111] In some embodiments, for any computing node worker_i, the global parameters updated based on the gradient determined in the Nth training round can be denoted as the first global parameters. In the Nth training round, the control node can predict the global parameters of the target model to be updated by worker_i in the (N+1)th training round based on the first global parameters, thus obtaining the second parameters. The control node can then send these second parameters to worker_i.

[0112] The second parameter is used by the computation node to determine the second gradient; the second gradient is used by the control node to update the global parameters of the target model based on the second gradient in the (N+1)th training round. That is, worker_i can determine the second gradient based on the second parameter and report the second gradient to the control node. It should be understood that worker_i can report the second gradient either before it is worker_i's turn to update the global parameters of the target model again in the (N+1)th training round, or after it is worker_i's turn to update the global parameters of the target model again in the (N+1)th training round, without limitation. In the case that worker_i updates the global parameters of the target model again in the (N+1)th training round, PS updates the global parameters of the target model based on the second gradient to achieve one training of the target model.

[0113] As discussed above, in traditional asynchronous parallel model training schemes, if gradient aging occurs, the gradient determined by the computation node (i.e., the outdated gradient) will not match the actual global parameters of the target model that need to be updated, leading to inaccurate model training. In the scheme described above, the global parameters to be updated by worker_i in the next training round are predicted in advance. These predicted parameters are close to the actual global parameters of the target model when it is worker_i's turn to train in the next round. Therefore, when it is worker_i's turn to train the target model in the next round, worker_i determines the gradient based on these predicted parameters. Compared to traditional asynchronous parallel model training schemes, the gradient determined based on these predicted parameters is more closely matched to the actual global parameters that need to be updated. Therefore, PS can update the global parameters of the target model more accurately based on the gradient determined by the predicted parameters, thereby improving the accuracy of model training. The solution in this application embodiment alleviates the problem of expired gradients to a certain extent or reduces the probability of generating expired gradients, improves the accuracy of each model training, and approximately achieves the model effect achieved by the synchronous parallel model training solution, thereby improving the final trained model effect.

[0114] In summary, the method in this application embodiment can maintain a fast training speed and achieve good model performance, showing significant improvement compared to both traditional asynchronous parallel model training schemes and traditional synchronous parallel model training schemes.

[0115] Please see Figure 6 Curve 201 is the loss curve for synchronous parallel model training, and curve 202 is the loss curve for asynchronous parallel model training. Curve 203 is the loss curve using the scheme in this embodiment. As can be seen from curve 203, when using the scheme in this embodiment for model training, the loss value is relatively small when the target model is close to convergence, and the target model can reach a near-convergence state in a relatively short time. Therefore, using the scheme in this embodiment can achieve a good convergence of the target model while maintaining a relatively fast training speed.

[0116] The following will describe the application scenarios of the methods in the embodiments of this application.

[0117] The method described in this application can be applied to scenarios such as data recommendation and image classification.

[0118] Taking a data recommendation scenario as an example, after the target model is trained using the method in this embodiment, the target model is used to recommend media data to the terminal, for example, to push advertising data (also called advertising content) to the terminal. Advertising data can be data or content in formats such as text or images. The sample data used to train the target model is sample media data.

[0119] The method described in this application embodiment allows for faster training of a target model (i.e., a recommendation model) with better recommendation performance, resulting in more accurate media data and improved user experience. Furthermore, it avoids wasting system resources due to excessive training iterations and reduces system resource waste caused by inaccurate or invalid recommendations.

[0120] It should be understood that the methods in this application embodiment are not limited to data recommendation scenarios and can be applied to any scenario that requires processing using a machine learning model. For example, the method can also be applied to image classification scenarios. The target model trained by the method in this application embodiment can be an image classification model. The sample data used to train the target model are sample images. The target model trained using the method in this application embodiment can be used to more accurately identify objects in images. For example, in a face recognition scenario, the target model trained by the method in this application embodiment can more accurately identify faces in images, improving the accuracy of face recognition. Furthermore, the face recognition results can be sent to a terminal device to instruct the terminal device to unlock or perform payment processing, etc.

[0121] The solutions in the embodiments of this application are described below with reference to the accompanying drawings.

[0122] As mentioned above, the control node can control a computing nodes to perform multiple rounds of iterative training on the target model. The control node can control a computing nodes to perform multiple rounds of iterative training on the target model based on either method 1 or method 2.

[0123] Method 1

[0124] The control node may include a parameter server (PS). The parameter server controls a number of computing nodes to perform multiple rounds of iterative training on the target model. In each training round, the parameter server determines the computing nodes used for each training iteration. Thus, in each training round, the parameter server controls the a computing nodes to train the target model sequentially according to a preset order.

[0125] Specifically, after receiving the parameters sent by the parameter server, any one of the a computing nodes will calculate the gradient based on the parameters sent by the parameter server and report the gradient to the parameter server.

[0126] The difference between this method and traditional asynchronous parallel model training schemes lies in the fact that in traditional schemes, the parameter server immediately updates the global parameters of the target model upon receiving a gradient reported by a computing node. In Method 1, after receiving a gradient reported by any one of the a computing nodes (hereinafter referred to as the target computing node for ease of description), the parameter server checks whether it is the target computing node's turn to train the target model. If it is not the target computing node's turn, the parameter server can leave it alone until it is the target computing node's turn to train the target model. Then, the parameter server can train the target model once based on the gradient determined by the target computing node. In this way, in one round of training, the parameter server can control the a computing nodes to train the target model once in a preset order.

[0127] It should be understood that after the previous computing node of the target computing node has trained the target model, it can be determined that it is the turn of the target computing node to train the target model once. In each training session of the target computing node, the global parameters to be updated for the target model are the global parameters updated by the previous computing node in the previous training.

[0128] In a training round, the previous computation node is the preceding computation node adjacent to the target computation node according to a preset order. In two adjacent training rounds, the last computation node in the previous round is the previous computation node of the first computation node in the next round. For a detailed description of the previous computation node, please refer to the description above.

[0129] In some embodiments, the specific steps of controlling a computing nodes to train the target model once sequentially according to a preset order based on the parameter server are as follows:

[0130] (2.1): When it is worker_i's turn to train the target model in this round of training, worker_i determines the gradient Gi for this training based on the global parameters Wg of the target model.

[0131] Here, worker_i represents the i-th computation node, where i is less than or equal to a and is any positive integer, and a is the total number of computation nodes. Wg is the initial global parameter of the target model in this training, that is, the global parameter before adjustment in this training. It should be understood that Wg also belongs to the global parameters of the target model to be updated in this training.

[0132] The gradient Gi during this training refers to the gradient calculated with respect to the target model during this training process. Specifically, worker_i can calculate the gradient Gi for this training based on the global parameters Wg issued by PS.

[0133] (2.2): worker_i sends gradient Gi to PS.

[0134] (2.3): After training the target model once for each of worker_0 to worker_i-1, PS updates the global parameter Wg based on the gradient Gi, and obtains the updated global parameter Wg'.

[0135] For example, PS can update the global parameter Wg according to the following formula:

[0136] Wg'=Wg-l r*Gi.

[0137] Where lr is the learning rate, and Wg' is the global parameter of the target model after being updated in this training.

[0138] (2.4): PS predicts the global parameter Wp to be updated in the next training round of worker_i based on the updated global parameter Wg', and sends Wp to worker_i, and worker_i performs the next iteration.

[0139] That is, you can return to steps (2.1) to (2.4) and repeat this process iteratively to train the target model.

[0140] In some embodiments, in step (2.4), PS can input the updated global parameter Wg' into the parameter prediction model P to predict Wp. For example, PS can predict Wp according to the following formula:

[0141] Wp = P(Wg'); where P represents the parametric prediction model.

[0142] In some examples, besides using the parametric prediction model P to predict Wp, the parameters of the parametric prediction model P can also be updated based on the updated global parameters Wg', thus performing an update training of the parametric prediction model P. This is equivalent to performing an update training of the parametric prediction model P based on the new global parameters after each training update. The specific processing of updating and training the parametric prediction model P is described below and will not be detailed here.

[0143] Method 2

[0144] The control node may include a parameter server and a controller. The control node includes a controller and a parameter server. The controller specifies the computing nodes used for each training iteration in a training round. The parameter server trains the target model once based on the gradients determined by the computing nodes specified by the controller. That is, in Method 2, the controller is responsible for determining the execution order of each computing node, while the parameter server is responsible for updating and predicting global parameters. This division of labor reduces the load on the parameter server to some extent.

[0145] Specifically, in each training round, the controller sends a first control command to the first computing node (one of the a computing nodes) in a preset order. The first control command instructs the first computing node to train the target model once. The first computing node trains the target model once in response to the first control command. For details of this training of the target model, please refer to the description above. For example, the first computing node can determine the gradient and report it to the parameter server, allowing the parameter server to update the global parameters of the target model based on the gradient and obtain the predicted parameters issued by the parameter server.

[0146] After the first computing node completes one training iteration of the target model, it sends a first message to the controller. This first message indicates that the first computing node has finished training the target model.

[0147] The controller can respond to the first information returned by the first computing node and continue to send a second control command to the second computing node. The second control command instructs the second computing node to perform one training iteration on the target model. The second computing node is the next computing node after the first computing node among the a computing nodes. Thus, the second computing node will perform one training iteration on the target model. After completing one training iteration on the target model, the second computing node will also send feedback to notify the controller that the training iteration on the target model by the second computing node has ended.

[0148] The controller continues sending control commands to the next computing node, and so on, until it controls the last computing node to train the target model once, which is equivalent to completing one round of training. Then, the controller can control the first of the 'a' computing nodes to train the target model again, thus starting a new round of training. This cycle is repeated to control 'a' computing nodes to perform multiple rounds of iterative training on the target model.

[0149] As discussed above, the parameter server PS can predict global parameters based on the parameter prediction model P. Specifically, for each computing node, after the control node updates the global parameters based on the gradient determined by that computing node in the current training round, it can call the parameter prediction model to predict the global parameters of the target model to be updated by that computing node in the next training round. That is, for any computing node worker_i, the control node can input the global parameters updated by worker_i in the current training round into the parameter prediction model P to predict the global parameters updated by worker_i when it is worker_i's turn to train the target model again in the next training round.

[0150] For example, the global parameters updated based on the gradient determined by worker_i in the Nth training round can be denoted as the first global parameters. In the Nth training round, the control node (e.g., PS) can input the first global parameters into the parameter prediction model P, and use the parameter prediction model P to predict the global parameters of the target model to be updated by worker_i in the (N+1)th training round, thus obtaining the second parameters.

[0151] In some embodiments, the parameter prediction model P can be a pre-trained model.

[0152] In some examples, the parameter prediction model P may be a model pre-trained before executing the method in the embodiments of this application. For example, a sample data set may be prepared in advance, which can be referred to as the preset sample data set. Before executing the method in the embodiments of this application, the control node may train the parameter prediction model P based on the preset sample data set.

[0153] In other examples, the parameter prediction model P can also be a model trained using an initial sample data set obtained through multiple (e.g., M) preliminary iterations of training using the method described in this application. That is, this initial sample data set is not pre-prepared but is obtained based on preliminary iterative training with *a* computing nodes in a distributed system. Therefore, it is more compatible with the entire distributed system, and the parameter prediction model trained based on this initial sample data set is more compatible with the current distributed system, improving the accuracy of global parameter prediction. This, in turn, improves the accuracy of the target model training.

[0154] Specifically, before controlling the a computing nodes to perform multiple rounds of iterative training on the target model, the control node can control the a computing nodes to perform M preliminary iterative training iterations, thereby obtaining multiple initial sample data sets. These initial sample data sets include first sample parameters and second sample parameters; the first sample parameters are the global parameters updated in the b-th preliminary iterative training iteration; the second sample parameters are the global parameters updated in the (b+a)-th preliminary iterative training iteration; M > a, b ≥ 1, and b+a ≤ M. It should be understood that each preliminary iterative training iteration in the M preliminary iterative training iterations is used to update the global parameters of the target model once.

[0155] The control node can train a parameter prediction model P based on multiple initial sample data sets. Then, the control node controls a computing nodes to perform multiple rounds of iterative training on the target model. In each round of training, while each computing node is training the target model, it uses the parameter prediction model to predict the global parameters of the target model to be updated in the next round of training.

[0156] In some embodiments, the control node can use the above-described synchronous parallel model training scheme to perform M preliminary iterations of training. In each preliminary iteration, the control node can update the global parameters of the target model based on the gradients determined by each of the a computing nodes. That is, after all a computing nodes have reported their determined gradients, the control node can update the global parameters of the target model once based on the gradients reported by all computing nodes, completing one preliminary iteration of training. In this embodiment, performing M preliminary iterations of training based on the synchronous parallel model training scheme makes the updated global parameters more accurate in each preliminary iteration, thus generating a more accurate initial sample data set, and consequently training the parameter prediction model more accurately.

[0157] In some embodiments, the control node can use the asynchronous parallel model training scheme described above to perform M initial iterations of training. In each initial iteration, the control node can update the global parameters of the target model based on the gradient determined by any one of the a computational nodes. The a computational nodes can update the global parameters of the target model independently. Each time the control node receives a gradient reported by a computational node, it updates the global parameters of the target model, completing one initial iteration of training. In this embodiment, performing M initial iterations of training based on the asynchronous parallel model training scheme can obtain the initial sample data set more quickly, facilitating faster training of the parameter prediction model, and thus enabling faster training of the target model (i.e., the main model) based on the parameter prediction model, thereby improving the training efficiency of the target model.

[0158] In some embodiments, after obtaining the trained parameter prediction model P, the parameter prediction model P can be updated and trained during multiple rounds of training. For example, during multiple rounds of training, each time the global parameters of the target model are updated (i.e., each time a new global parameter is generated), the control node can update and train the parameter prediction model P based on the new global parameters. That is, during the process of using the parameter prediction model P for global parameter prediction, the parameter prediction model P is progressively updated and optimized, enabling the parameter prediction model P to capture the most recent changes in the global parameters, thereby gradually improving the prediction accuracy of the parameter prediction model P, and thus training the target model more accurately.

[0159] Specifically, for a computing node `worker_i`, the global parameters updated based on the gradient determined by `worker_i` in the Nth training round (i.e., the first gradient) are denoted as the first global parameters, and the global parameters updated based on the gradient determined by `worker_i` in the (N-1)th training round are denoted as the second global parameters. The first and second global parameters constitute a set of sample data, for example, denoted as the first sample data set. The control node can perform an update training of the parameter prediction model based on these first and second global parameters.

[0160] As mentioned above, the number of training iterations in one round of training is equal to the number of computing nodes. With *a* computing nodes, one round of training consists of *a* training iterations. If we accumulate the number of iterations across multiple rounds, then for any computing node *worker_i*, the global parameters to be updated in the next round based on the gradient determined by *worker_i* are the global parameters after *a* training iterations. Similarly, the global parameters updated based on the gradient determined by *worker_i* in the previous round of training are the global parameters before *a* training iterations.

[0161] Please see Figure 7Taking compute node 1 as an example, the global parameters updated once based on the gradient determined by compute node 1 in the Nth training round is denoted as the cth training round. Then, the training of the target model again by compute node 1 in the N+1th training round is the c+ath training round. PS updates the global parameters of the target model based on the gradient determined by compute node 1 in the cth training round. The updated global parameters can be denoted as the global parameters after the cth training round (i.e., the global parameters updated in the cth training round). PS no longer directly sends the global parameters after the cth training round to compute node 1, but instead inputs the global parameters after the cth training round to the parameter prediction model P, so that the parameter prediction model P predicts the global parameters to be updated in the c+ath training round. Since each compute node is controlled to train the target model once in sequence in this embodiment, the c+ath training round is precisely the turn of compute node 1 to train the target model. Therefore, the predicted global parameters to be updated in the c+ath training round are the predicted global parameters to be updated by compute node 1 in the N+1th training round.

[0162] exist Figure 7 For simplicity, the predicted global parameters to be updated in the (c+a)th training iteration can be denoted as the predicted parameters. The parameter prediction model P can send the predicted global parameters to be updated in the (c+a)th training iteration to computation node 1. In the (c+a)th training iteration, computation node 1 retrains the target model and can directly use the predicted parameters to determine the gradient, which can be denoted as the gradient determined in the (c+a)th training iteration. Computation node 1 can then send the gradient determined in the (c+a)th training iteration to the PS, allowing the PS to update the global parameters of the target model based on this gradient.

[0163] In addition, PS can perform an update training on the parameter prediction model P based on the global parameters after the c-th training and the global parameters after the ca-th training (i.e., the updated global parameters in the ca-th training). This allows the parameter prediction model P to capture the most recent changes in the global parameters, improving the subsequent prediction accuracy of the parameter prediction model P. For example, the global parameters after the c-th training can be the first global parameters, and the global parameters after the ca-th training can be the second global parameters.

[0164] In some embodiments, training the parameter prediction model based on the first global parameter and the second global parameter includes: inputting the second global parameter into the parameter prediction model to obtain a third global parameter predicted by the parameter prediction model; determining a loss value based on the difference between the third global parameter and the first global parameter; and adjusting the parameter values ​​of the parameter prediction model based on the loss value.

[0165] Please see Figure 8The first global parameter can be Wc, which is the global parameter after the c-th training iteration. The second global parameter can be Wc-a, which is the global parameter after the ca-th training iteration. Wc and Wc-a have the same dimension after being converted to vectors. For example... Figure 8 As shown, both can be 6-dimensional vectors. It should be understood that the 6-dimensional vector is only used to indicate that Wc and Wc-a have the same dimensions after vectorization; it is not necessarily limited to 6-dimensional vectors. The parameter prediction model P can use a three-layer fully connected network, which has low computational cost and will not cause a performance bottleneck for the parameter server PS. In other examples, the parameter prediction model P can also be a network with other layers; this is not limited.

[0166] The parameter prediction model P can predict the global parameters after training 'a' (i.e., predict the global parameters after training 'c') based on the global parameters Wc-a after training 'ca', thus obtaining Wp. The parameter prediction model P can calculate the loss value based on the difference between Wc and Wp. For example, the parameter prediction model P can be based on the loss function Loss:|Wc-Wp. 2 Find the loss value between Wc and Wp, and then adjust the parameter values ​​of the parameter prediction model P based on the loss value.

[0167] In some embodiments, taking the scenario of recommending media data as an example, the method in the embodiments of this application is illustrated. The training set used to train the target model for pushing media data to the terminal is a sample media dataset. For example, the media data can be advertising data in formats such as text or images.

[0168] The sample media dataset can be divided into *a* media data segments, denoted as media data segment 1...media data segment a (e.g., ...). Figure 9 (As shown). The target model to be trained is a model used to push media data to the terminal.

[0169] Please see Figure 9 A control node, such as parameter server 901, can control the a computing nodes to perform multiple rounds of iterative training on the target model. In each round of training, the a computing nodes train the target model sequentially according to a preset order. Specifically, the process of any computing node (work_i) training the target model in the Nth round of training includes: the computing node (work_i) receiving the predicted parameters (i.e., the predicted global parameters, see the description above) from parameter server 901, calculating the gradient based on the predicted parameters and the corresponding media data in media data segment 1, and sending the gradient to parameter server 901. Parameter server 901 can update the global parameters of the target model based on the reported gradient. This achieves accurate training of the target model.

[0170] Parameter server 901 can predict the global parameters to be updated for computation node (work_i) in the next training round based on the updated global parameters after the Nth training round, and then distribute the predicted global parameters to computation node (work_i). For example, parameter server 901 can use the parameter prediction model to predict the global parameters to be updated for computation node (work_i) in the next training round. When it is computation node (work_i)'s turn to train the target model in the next training round, computation node (work_i) determines the gradient based on the distributed predicted parameters and reports it to parameter server 901. Parameter server 901 can then update the global parameters of the target model based on the reported gradient.

[0171] Thus, after multiple rounds of training, a recommendation model 902 can be quickly trained, which can accurately push media data to the terminal 903. It should be understood that the trained recommendation model 902 can be deployed on a server or other device (not shown in the figure), and this is not limited. Based on the trained recommendation model 902, media data to be recommended can be determined; and the media data can be sent to the terminal 903. For example, the recommended media data can be displayed in the notification bar 9031 on the terminal 903.

[0172] This application provides a distributed system including a control node and a computing nodes; the control node is used to execute the various functions or steps in the above method embodiments. Exemplarily, the control node includes a memory and one or more processors. When the one or more processors execute the computer instructions, the control node performs the method as described in any of the first aspects above.

[0173] It should be understood that both the control node and the computing node described above are electronic devices. For example, the electronic device may be a server or a terminal. This application does not impose any special limitations on the specific form of the electronic device.

[0174] Figure 10 This is a structural block diagram of an electronic device provided in an embodiment of this application. The structure illustrated in this embodiment does not constitute a specific limitation on the electronic device. In other embodiments, the electronic device may include... Figure 10 It may contain more or fewer components, or combine some components, or separate some components, or arrange the components differently. The components shown in the diagram may be implemented in hardware, software, or a combination of software and hardware.

[0175] like Figure 10As shown, the electronic device may include a processor 1010, a memory 1020, and a communication module 1030. The processor 1010 can be used to read and execute computer-readable instructions. Optionally, the processor 1010 may also include a controller, an arithmetic logic unit (ALU), and registers. The controller is primarily responsible for instruction decoding and issuing control signals for the operations corresponding to the instructions. The ALU is primarily responsible for storing register operands and intermediate operation results temporarily stored during instruction execution. Registers are high-speed storage components with limited storage capacity, which can be used to temporarily store instructions, data, and addresses.

[0176] In specific implementations, the hardware architecture of processor 1010 can be an application-specific integrated circuit (ASIC) architecture, a microprocessor without interlocked piped stages (MIPS) architecture, an ARM (advanced RISC machines) architecture, or a net processor (NP) architecture, etc.

[0177] The memory 1020 is coupled to the processor 1010 and is used to store various software programs and / or multiple sets of instructions. In this embodiment, the resolution testing method of the electronic device can be implemented not only by integrating it into a processor of the electronic device, but also by storing it in the memory of the electronic device as program code. The processor of the electronic device can then call the code stored in the memory of the electronic device to execute the above method.

[0178] In a specific implementation, the memory 1020 may include high-speed random access memory, and may also include non-volatile memory, such as one or more disk storage devices, flash memory devices, or other non-volatile solid-state storage devices. The memory 1020 may store an operating system, such as uCOS, VxWorks, RTLinux, or other embedded operating systems.

[0179] The communication module 1030 can be used to establish communication connections between electronic devices and other communication terminals via a network, and to send and receive data via the network. For example, when the electronic device is a control node, it can establish a connection with a computing node through the communication module 1030 to receive gradients from the computing node and, after updating the global parameters, send the updated global parameters back to the computing node.

[0180] This application also provides a chip system applied to an electronic device. The chip system includes one or more processors, which are used to invoke computer instructions to cause the electronic device to perform the functions or steps described in the above method embodiments.

[0181] This application also provides a computer-readable storage medium including computer instructions that, when executed on the electronic device, cause the electronic device to perform the various functions or steps described in the method embodiments.

[0182] This application also provides a computer program product that, when run on a computer, causes the computer to perform the functions or steps described in the above method embodiments.

[0183] Through the above description of the embodiments, those skilled in the art can clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0184] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another apparatus, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0185] The units described as separate components may or may not be physically separate. A component shown as a unit can be one or more physical units; that is, it can be located in one place or distributed in multiple different locations. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0186] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0187] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, essentially or in other words, the parts that contribute to the prior art, or all or part of the technical solutions, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0188] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A model training method based on a distributed system, characterized in that, The control node is applied to the distributed system, which also includes a computing nodes, where a ≥ 2 and is a positive integer. The control node includes a parameter server, and the computing node includes electronic devices; the method includes: The system controls the a computing nodes to perform multiple rounds of iterative training on the target model. In each round of training, the system controls the a computing nodes to train the target model once in a preset order. The control node is used to determine the computing nodes used for each training session in a round of training. The process of controlling any computing node to train the target model in the Nth round of training includes: The control node receives the first gradient determined based on the first parameter uploaded by the computing node, and updates the global parameters of the target model based on the first gradient; the first parameter is the global parameter of the target model to be updated by the computing node in the Nth round of training, which is predicted by the control node in the N-1th round of training; N≥2 and is a positive integer.

2. The method according to claim 1, characterized in that, The global parameters updated based on the first gradient are used as the first global parameters; In the Nth round of training, the method further includes: Based on the first global parameters, predict the global parameters of the target model to be updated in the computing node during the N+1th round of training, and obtain the second parameters; The second parameter is sent to the computing node; the second parameter is used by the computing node to determine the second gradient; the second gradient is used by the control node to update the global parameters of the target model based on the second gradient in the N+1th training round.

3. The method according to claim 2, characterized in that, The control node is equipped with a parameter prediction model; The step of predicting the global parameters of the target model to be updated in the computing node during the (N+1)th round of training based on the first global parameters, to obtain the second parameters, includes: The first global parameter is input into the parameter prediction model to obtain the second parameter.

4. The method according to claim 3, characterized in that, The parameter prediction model is trained from the initial sample data set; The initial sample data set was obtained in the M preliminary iterations of training prior to the multiple rounds of iterative training. The initial sample data set includes a first sample parameter and a second sample parameter; the first sample parameter is the global parameter updated in the b-th initial iteration training; the second sample parameter is the global parameter updated in the b+a-th initial iteration training. M>a, b≥1 and b+a≤M.

5. The method according to claim 3 or 4, characterized in that, Before inputting the first global parameter into the parameter prediction model, the method further includes: The parameter prediction model is trained based on the first global parameter and the second global parameter; the second global parameter is the global parameter updated by the gradient determined by the computing node in the (N-1)th round of training.

6. The method according to claim 5, characterized in that, The step of training the parameter prediction model based on the first global parameters and the second global parameters includes: The second global parameter is input into the parameter prediction model to obtain the third global parameter predicted by the parameter prediction model; The loss value is determined based on the difference between the third global parameter and the first global parameter; Based on the loss value, adjust the parameter values ​​of the parameter prediction model.

7. The method according to claim 4, characterized in that, In each initial iteration of training, the global parameters of the target model are updated based on the gradients determined by each of the a computing nodes. or, In each initial training iteration, the global parameters of the target model are updated based on the gradient determined by any one of the a computing nodes.

8. The method according to any one of claims 1-7, characterized in that, The parameter server is also used to train the target model once based on the gradient determined by the target computing node after receiving the gradient determined by the target computing node, when it is the turn of the target computing node to train the target model once; the target computing node is any one of the a computing nodes.

9. The method according to any one of claims 1-7, characterized in that, The control node further includes a controller, which is used to specify the computing node used for each training session in a training round; the parameter server is used to train the target model once based on the gradient determined by the computing node specified by the controller.

10. The method according to claim 9, characterized in that, The step of training the target model once per training round by the a computing nodes in a preset order includes: In each round of training, the controller sends a first control instruction to the first computing node among the a computing nodes in a preset order. The first control instruction is used to instruct the first computing node to train the target model once. In response to the first information returned by the first computing node, a second control command is sent to the second computing node, the second control command being used to instruct the second computing node to perform one training operation on the target model; the second computing node is the next computing node after the first computing node among the a computing nodes; the first information is used to indicate that one training operation of the first computing node on the target model has been completed.

11. The method according to any one of claims 1-10, characterized in that, The method further includes: Based on the trained target model, determine the media data to be recommended; The media data is sent to the terminal.

12. A distributed system, characterized in that, The distributed system includes a control node and a computing nodes; the control node is used to execute the method as described in any one of claims 1-11.

13. An electronic device, characterized in that, The electronic device includes at least a memory and one or more processors; the memory is used to store computer instructions, which, when executed by the one or more processors, cause the electronic device to perform the method as described in any one of claims 1-11.

14. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes computer instructions that, when executed on an electronic device, cause the electronic device to perform the method as described in any one of claims 1-11.

15. A computer program product, characterized in that, When the computer program product is run on a computer, it causes the computer to perform the method as described in any one of claims 1-11.