A model parallel training method and device
By determining the master node and extended computing node set of the pipeline parallel unit in the distributed heterogeneous cluster, the problem of low efficiency of large-scale neural network model training on the distributed heterogeneous cluster is solved, and efficient distributed parallel training is achieved, reducing the cost of training. cost.
Patent Information
- Application Number
- CN202410845072.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-27
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2044-06-27
AI Technical Summary
The efficiency of distributed parallel training of large-scale neural network models on existing distributed heterogeneous clusters is low, resulting in poor cost savings.
By forming a cluster set in a distributed heterogeneous cluster, determine the master node of the pipeline parallel unit, and expand the computing node set according to the master node and communication distance to ensure that the total computing node memory meets the memory requirements of the neural network model, using tensor Parallel strategies for training.
It improves the efficiency of distributed parallel training of models under distributed heterogeneous clusters, reduces hardware procurement and operating costs, and achieves efficient training of large-scale neural network models.
Smart Images

Figure CN118410859B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a model parallel training method and device, and also to an electronic device, a non-transitory computer-readable storage medium and a computer program product. Background Art
[0002] In recent years, with the rapid development of information technology, various neural network models have been widely used in the field of artificial intelligence. In order to further improve the accuracy and generalization of neural network models, the usual practice is to increase the scale of neural network models and data sets. However, as the scale of model parameters increases, the model effect is also gradually improving, but it also brings greater challenges to the training framework. In this case, a single central processing unit (CPU) or a single graphics processing unit (GPU) cannot meet the computing device requirements of large-scale neural network models. The use of efficient distributed parallel training methods to implement model training can help researchers train large-scale neural network models on thousands of GPU computing nodes or even more computing nodes. At the same time, in order to meet different model training requirements, various series of GPU computing devices have been developed and designed. With the development of these computing devices, more hardware options have been brought to the market. Enterprises will purchase multiple models of computing devices according to the needs of different periods. The models of each computing device are different, and the number of computing devices that can be carried by different servers is also different, resulting in the construction of distributed heterogeneous clusters with various topological structures. In this case, if efficient distributed parallel training of large-scale neural network models can be implemented on distributed heterogeneous clusters based on different computing devices, a lot of costs will be saved. However, the existing distributed parallel training of large-scale neural network models implemented on distributed heterogeneous clusters has poor efficiency. Therefore, how to design a more efficient model parallel training solution has become a technical problem that needs to be solved urgently. Summary of the invention
[0003] The present invention provides a model parallel training method to solve the defect that the model parallel training scheme in the prior art has high limitations and leads to poor efficiency of distributed parallel training.
[0004] The present invention provides a model parallel training method, comprising:
[0005] Obtain multiple cluster sets formed between computing nodes in a distributed heterogeneous cluster;
[0006] Determine the master node of each pipeline parallel unit according to the cluster set; wherein the pipeline parallel unit is a computing unit divided based on a pipeline parallel manner, and each pipeline parallel unit corresponds to at least one network layer in the training neural network model;
[0007] Expanding the computing nodes of the pipeline parallel unit according to the communication distance between the main node of the pipeline parallel unit and the computing node, and determining the computing node set of the pipeline parallel unit;
[0008] When the total amount of memory of the computing node set is greater than or equal to the target amount of memory required by the pipeline parallel unit to train at least one network layer, the neural network model is trained based on the computing node set to obtain a target neural network model.
[0009] According to a model parallel training method provided by the present invention, the computing nodes of the pipeline parallel unit are expanded according to the communication distance between the main node of the pipeline parallel unit and the computing node to determine the computing node set of the pipeline parallel unit, which specifically includes:
[0010] Taking the master node of the pipeline parallel unit as a reference node, determining the communication distances between the master node and other computing nodes in the corresponding cluster set in the distributed heterogeneous cluster except the master node;
[0011] Compare and analyze the communication distances between the other computing nodes except the master node in the corresponding cluster set in the distributed heterogeneous cluster and the master node, and determine the computing node with the shortest communication distance with the master node among the other computing nodes;
[0012] Each time the computing node set of the pipeline parallel unit is expanded, a computing node with the smallest communication distance is selected from the other computing nodes and added to the corresponding computing node set of the pipeline parallel unit, until the total amount of memory in the computing node set of the pipeline parallel unit is greater than or equal to the target memory amount required for the pipeline parallel unit to train at least one network layer, thereby obtaining the computing node set of the pipeline parallel unit.
[0013] According to a model parallel training method provided by the present invention, before expanding the computing nodes of the pipeline parallel unit according to the communication distance between the main node of the pipeline parallel unit and the computing node, it also includes:
[0014] Determine the shortest path connecting the main nodes of each of the pipeline parallel units;
[0015] The arrangement order of the main nodes in the shortest path is used as the pipeline parallel order; wherein each main node is the first computing node of a pipeline parallel stage in the corresponding pipeline parallel unit; the pipeline parallel order is the arrangement order of the main nodes of the pipeline parallel unit.
[0016] According to a model parallel training method provided by the present invention, each time the computing node set of the pipeline parallel unit is expanded, a computing node with the smallest communication distance is selected from the other computing nodes to be added to the computing node set of the corresponding pipeline parallel unit, specifically comprising:
[0017] The main nodes of each of the pipeline parallel units are selected in turn according to the pipeline parallel order, and according to the communication distances between the other computing nodes except the main node in the corresponding cluster set and the main nodes of each of the pipeline parallel units selected in turn, a computing node with the shortest communication distance is selected from the other computing nodes except the main node in the corresponding cluster set each time and added to the computing node set of the pipeline parallel unit corresponding to the main node selected in turn.
[0018] According to a model parallel training method provided by the present invention, the step of obtaining a plurality of cluster sets formed between computing nodes in a distributed heterogeneous cluster includes:
[0019] Obtaining the communication distance between computing nodes in the distributed heterogeneous cluster; wherein the distributed heterogeneous cluster includes multiple computing nodes;
[0020] Based on the communication distances between the computing nodes, clustering is performed on the computing nodes in the distributed heterogeneous cluster to obtain a plurality of cluster sets.
[0021] According to a model parallel training method provided by the present invention, determining the master node of each pipeline parallel unit according to the cluster set specifically includes:
[0022] Determine the central node of the cluster set based on the video memory value of the computing node in the cluster set and the centrality of the computing node in the cluster set;
[0023] The central node of each cluster set is used as the main node of each corresponding pipeline parallel unit.
[0024] According to a model parallel training method provided by the present invention, the method of determining the central node of the cluster set based on the video memory value of the computing node in the cluster set and the centrality of the computing node in the cluster set specifically includes:
[0025] Obtaining the video memory value and the first weight value of the computing node in the cluster set;
[0026] Obtaining the centrality and the second weight value of the computing node in the cluster set;
[0027] Based on the video memory value and the first weight value of the computing node in the cluster set, the centrality of the computing node in the cluster set and the second weight value, the score value of each computing node in the cluster set is calculated, and the computing node with the highest score value is determined as the central node of the cluster set.
[0028] According to a model parallel training method provided by the present invention, after obtaining the computing node set of the pipeline parallel unit, it also includes:
[0029] In the case that the last master node selected in sequence according to the pipeline parallel order does not meet the preset memory condition, according to the Zero-Pole distributed storage method and in the reverse pipeline parallel order, reverse adjustment is performed starting from selecting the last master node, and the computing node set of the pipeline parallel unit is expanded according to the communication distance between the last master node and the computing node to meet the minimum memory requirement, until the total memory of all computing nodes in each pipeline parallel unit is greater than or equal to the minimum memory requirement, the dynamic adjustment is determined to be successful, and the tensor parallel strategy within the pipeline parallel unit is determined, and the memory resources of the computing nodes are allocated based on the tensor parallel strategy to train the neural network model and obtain the target neural network model.
[0030] According to a model parallel training method provided by the present invention, when the total amount of memory of the computing node set is greater than or equal to the target amount of memory required by the pipeline parallel unit to train at least one network layer, the neural network model is trained based on the computing node set to obtain a target neural network model. The method specifically includes: when the total amount of memory of all computing nodes in the computing node set is greater than or equal to the target amount of memory required by the pipeline parallel unit to train at least one network layer, determining that the tensor parallel strategy within the pipeline parallel unit is to use an average partitioning method to distribute the length corresponding to the divided computing tensor according to the proportion of the remaining memory resources of each computing node in the computing node set, so as to train the neural network model in a tensor parallel manner to obtain a target neural network model.
[0031] According to a model parallel training method provided by the present invention, it also includes: when the total memory amount of all computing nodes in the computing node set is less than the target memory amount required for the pipeline parallel unit to train the at least one network layer, a zero-pole distributed storage method is used to store the model parameters of the pipeline parallel unit respectively on different computing nodes in the computing node set, and the tensor parallel strategy in the pipeline parallel unit is determined to use an average division method to distribute the length corresponding to the divided computing tensor according to the proportion of the remaining memory resources of each computing node in the computing node set, so as to obtain the target neural network model through tensor parallel training of the neural network model.
[0032] According to a model parallel training method provided by the present invention, after selecting the last master node for reverse order adjustment according to the zero-pole distributed storage method and in the reverse pipeline parallel order, and expanding the computing node set of the pipeline parallel unit according to the communication distance between the last master node and the computing node, the method further includes:
[0033] If the last computing node set is adjusted in reverse order and it is determined that the minimum memory requirement is not met, the dynamic adjustment is determined to have failed, and an early warning message of insufficient computing resources is generated.
[0034] The present invention also provides a model parallel training device, comprising:
[0035] A cluster set obtaining unit, used to obtain multiple cluster sets formed between computing nodes in a distributed heterogeneous cluster;
[0036] A master node determination unit, used to determine the master node of each pipeline parallel unit according to the cluster set; wherein the pipeline parallel unit is a computing unit divided based on a pipeline parallel manner, and each pipeline parallel unit corresponds to at least one network layer in the training neural network model;
[0037] A master node expansion unit, used to expand the computing nodes of the pipeline parallel unit according to the communication distance between the master node of the pipeline parallel unit and the computing node, and determine the computing node set of the pipeline parallel unit;
[0038] A parallel resource allocation processing unit is used to train the neural network model based on the computing node set to obtain a target neural network model when the total memory amount of the computing node set is greater than or equal to the target memory amount required by the pipeline parallel unit to train at least one network layer.
[0039] According to a model parallel training device provided by the present invention, the cluster set obtaining unit is specifically used for:
[0040] Obtaining the communication distance between computing nodes in the distributed heterogeneous cluster; wherein the distributed heterogeneous cluster includes multiple computing nodes;
[0041] Based on the communication distances between the computing nodes, clustering is performed on the computing nodes in the distributed heterogeneous cluster to obtain a plurality of cluster sets.
[0042] According to a model parallel training device provided by the present invention, the master node determination unit is specifically used for:
[0043] Determine the central node of the cluster set based on the video memory value of the computing node in the cluster set and the centrality of the computing node in the cluster set;
[0044] The central node of each cluster set is used as the main node of each corresponding pipeline parallel unit.
[0045] According to a model parallel training device provided by the present invention, the central node of the cluster set is determined based on the video memory value of the computing node in the cluster set and the centrality of the computing node in the cluster set, specifically including:
[0046] Obtaining the video memory value and the first weight value of the computing node in the cluster set;
[0047] Obtaining the centrality and the second weight value of the computing node in the cluster set;
[0048] Based on the video memory value and the first weight value of the computing node in the cluster set, the centrality of the computing node in the cluster set and the second weight value, the score value of each computing node in the cluster set is calculated, and the computing node with the highest score value is determined as the central node of the cluster set.
[0049] According to a model parallel training device provided by the present invention, the master node expansion unit is specifically used for:
[0050] Taking the master node of the pipeline parallel unit as a reference node, determining the communication distances between the master node and other computing nodes in the corresponding cluster set in the distributed heterogeneous cluster except the master node;
[0051] Compare and analyze the communication distances between the other computing nodes except the master node in the corresponding cluster set in the distributed heterogeneous cluster and the master node, and determine the computing node with the shortest communication distance with the master node among the other computing nodes;
[0052] Each time the computing node set of the pipeline parallel unit is expanded, a computing node with the smallest communication distance is selected from the other computing nodes and added to the corresponding computing node set of the pipeline parallel unit, until the total amount of memory in the computing node set of the pipeline parallel unit is greater than or equal to the target memory amount required for the pipeline parallel unit to train at least one network layer, thereby obtaining the computing node set of the pipeline parallel unit.
[0053] According to a model parallel training device provided by the present invention, before expanding the computing nodes of the pipeline parallel unit according to the communication distance between the main node of the pipeline parallel unit and the computing node, it also includes:
[0054] Identify pipeline parallel sequential units for:
[0055] Determine the shortest path connecting the main nodes of each of the pipeline parallel units;
[0056] The arrangement order of the main nodes in the shortest path is used as the pipeline parallel order; wherein each main node is the first computing node of a pipeline parallel stage in the corresponding pipeline parallel unit; the pipeline parallel order is the arrangement order of the main nodes of the pipeline parallel unit.
[0057] According to a model parallel training device provided by the present invention, each time the computing node set of the pipeline parallel unit is expanded, a computing node with the smallest communication distance is selected from the other computing nodes to be added to the computing node set of the corresponding pipeline parallel unit, specifically comprising:
[0058] The main nodes of each of the pipeline parallel units are selected in turn according to the pipeline parallel order, and according to the communication distances between the other computing nodes except the main node in the corresponding cluster set and the main nodes of each of the pipeline parallel units selected in turn, a computing node with the shortest communication distance is selected from the other computing nodes except the main node in the corresponding cluster set each time and added to the computing node set of the pipeline parallel unit corresponding to the main node selected in turn.
[0059] According to a model parallel training device provided by the present invention, after obtaining the computing node set of the pipeline parallel unit, it also includes:
[0060] Dynamically resized into units for:
[0061] In the case that the last master node selected in sequence according to the pipeline parallel order does not meet the preset memory condition, according to the Zero-Pole distributed storage method and in the reverse pipeline parallel order, reverse adjustment is performed starting from selecting the last master node, and the computing node set of the pipeline parallel unit is expanded according to the communication distance between the last master node and the computing node to meet the minimum memory requirement, until the total memory of all computing nodes in each pipeline parallel unit is greater than or equal to the minimum memory requirement, the dynamic adjustment is determined to be successful, and the tensor parallel strategy within the pipeline parallel unit is determined, and the memory resources of the computing nodes are allocated based on the tensor parallel strategy to train the neural network model and obtain the target neural network model.
[0062] According to a model parallel training device provided by the present invention, the parallel resource allocation processing unit is specifically used for:
[0063] When the total memory amount of all computing nodes in the computing node set is greater than or equal to the target memory amount required by the pipeline parallel unit to train at least one network layer, the tensor parallel strategy within the pipeline parallel unit is determined to be to use an average partitioning method to distribute the length corresponding to the divided computing tensor according to the proportion of the remaining memory resources of each computing node in the computing node set, so as to train the neural network model in a tensor parallel manner and obtain the target neural network model.
[0064] According to a model parallel training device provided by the present invention, the parallel resource allocation processing unit is specifically used for: when the total memory amount of all computing nodes in the computing node set is less than the target memory amount required for the pipeline parallel unit to train the at least one network layer, the model parameters of the pipeline parallel unit are stored in different computing nodes of the computing node set by using a zero-pole distributed storage method, and the tensor parallel strategy within the pipeline parallel unit is determined to be an average division method to allocate the length corresponding to the divided computing tensor according to the proportion of the remaining memory resources of each computing node in the computing node set, so as to obtain the target neural network model through tensor parallel training of the neural network model.
[0065] According to a model parallel training device provided by the present invention, after selecting the last master node for reverse order adjustment according to the zero-pole distributed storage method and in the reverse pipeline parallel order, and expanding the computing node set of the pipeline parallel unit according to the communication distance between the last master node and the computing node, the device further includes:
[0066] Early warning unit, used for:
[0067] If the last computing node set is adjusted in reverse order and it is determined that the minimum memory requirement is not met, the dynamic adjustment is determined to have failed, and an early warning prompt message of insufficient computing resources is generated.
[0068] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the model parallel training method as described in any one of the above items when executing the program.
[0069] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the model parallel training method as described in any of the above items.
[0070] The present invention also provides a computer program product, including a computer program, characterized in that when the computer program is executed by a processor, the model parallel training method as described in any of the above items is implemented.
[0071] The model parallel training method provided by the present invention determines the main node of each pipeline parallel unit through the cluster set formed between the computing nodes in the distributed heterogeneous cluster; the pipeline parallel unit is a computing unit divided based on the pipeline parallel method, and each pipeline parallel unit corresponds to at least one network layer in the training neural network model; the computing node set of the pipeline parallel unit is expanded according to the main node and the communication distance of the pipeline parallel unit to determine the computing node set; when the total memory of the computing node set is greater than or equal to the target memory amount required for the pipeline parallel unit to train at least one network layer, the neural network model is trained based on the computing node set; it can realize the distributed parallel training of large-scale neural network models on the distributed heterogeneous cluster based on different hardware devices, and effectively improves the distributed parallel training efficiency of the model under the distributed heterogeneous cluster. BRIEF DESCRIPTION OF THE DRAWINGS
[0072] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0073] Figure 1 This is one of the flow charts of the model parallel training method provided by the present invention.
[0074] Figure 2 This is the second flow chart of the model parallel training method provided by the present invention.
[0075] Figure 3It is a schematic diagram of the layout and device distribution of a distributed heterogeneous cluster in the model parallel training method provided by the present invention.
[0076] Figure 4 It is a schematic diagram of the distributed heterogeneous cluster topology relationship and memory size in the model parallel training method provided by the present invention.
[0077] Figure 5 It is a structural schematic diagram of the model parallel training device provided by the present invention.
[0078] Figure 6 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0079] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0080] Combine the following Figure 1-Figure 6 The model parallel training method and device of the present invention are described, and its embodiments are described in detail.
[0081] Based on the model parallel training method described in the present invention, the embodiments are described in detail below. Figure 1 As shown, it is one of the flow charts of the model parallel training method provided by the present invention, and the specific implementation process includes the following steps:
[0082] Step 101: Obtain multiple cluster sets formed between computing nodes in a distributed heterogeneous cluster.
[0083] In the specific implementation process of this step, it is necessary to send the same sample data between the computing nodes of the distributed heterogeneous cluster based on a preset test program, obtain the average sending and receiving time between any two computing nodes, and take the derivative of the average sending and receiving time as the communication distance between the two computing nodes. Furthermore, the communication distance between the computing nodes in the distributed heterogeneous cluster can be obtained. Among them, the distributed heterogeneous cluster includes multiple computing nodes. Based on the communication distance between the computing nodes, the computing nodes in the distributed heterogeneous cluster are pre-clustered to obtain multiple cluster sets.
[0084] It should be noted that if Figure 2As shown, before executing this step, it is also necessary to calculate the number of network layers L and the total amount of memory required MM of the entire neural network model in advance according to the trained neural network model (such as the Transformer model structure). Then, the user specifies the initial pipeline parallel value (i.e., Pip_size), that is, the initial pipeline parallel value represents the initial pipeline parallel size, corresponding to splitting the neural network model into the number of copies corresponding to the pipeline parallel value (such as 4 copies). The initial pipeline parallel value can be set to the number of network layers L of the neural network model. Then calculate the video memory size M_pip required for each pipeline parallel unit. The present invention adopts Zero distributed video memory technology, which can store the intermediate parameter variables of the partial parameter calculation of the neural network model on different graphics cards respectively, and then synchronize them from other graphics cards when the calculation is required. Under the condition of a certain communication time, smaller video memory resources can be used to complete the calculation. When the video memory resources of the distributed heterogeneous cluster are limited, consider using this technology. It is also necessary to calculate the minimum video memory value M_pip_min required for each pipeline parallel unit and the memory M_pip_weight required for some parameters of the neural network model (such as network weight parameters) and their intermediate parameter variables. In addition, it is also necessary to obtain the relevant parameters of the distributed heterogeneous cluster, send the same size of data between each computing unit (i.e., computing node) through the test program, and calculate the average sending and receiving time T between any two computing nodes. The derivative V of the average sending and receiving time T is taken as the communication distance between the two computing nodes. The topological relationship formed by the communication distance and the computing node forms a weighted undirected connection graph G. The video memory value M of each computing node is also obtained by the test program or manual input method. The computing unit or computing node can be a GPU or DTU on a board. For example, the number of network layers L=12 of the entire model can be calculated based on the trained neural network model structure, and the total amount of memory required MM=1200G. Then the user specifies the initial pipeline parallel value Pip_size=4. At this time, the pipeline parallel divided for the network layer number L=12 is 4 pipeline parallels, that is, 1 pipeline parallel corresponds to 3 network layers, that is, the number of network layers trained corresponding to the pipeline parallel unit is 3. Then calculate the video memory size M_pip=300G required for each pipeline parallel unit. The minimum memory value required for each pipeline parallel unit is M_pip_min=200G, and the memory required for some parameters of the neural network model and its intermediate parameter variables is M_pip_weight=20. In addition, in obtaining the relevant parameters of the distributed heterogeneous cluster, the topology and memory value of each computing node are obtained through testing and manual input methods. The specific topology structure is as follows Figure 4 shown.
[0085] In the pre-clustering process described in this step, based on the obtained weighted undirected connection graph G, a clustering algorithm such as K_means can be used to represent the distance of the computing nodes with the communication distance, and all computing nodes in the distributed heterogeneous cluster can be clustered into Pip_size classes, and the i-th cluster set is recorded as C(i). It should be noted that the initial pipeline parallelism value is equal to the number of cluster sets (for example, 4), and the initial pipeline parallelism value is used to represent the number of pipeline parallelisms, and each pipeline parallelism unit corresponds to a cluster set.
[0086] For example, all computing nodes (i.e., computing devices such as GPUs and DTUs) in a distributed heterogeneous cluster are clustered into four categories based on communication distance. The generated cluster sets are: C(1), C(2), C(3), and C(4). Among them, 1_A_1, 2_A_1, 2_E_1, 3_A_1, etc. are all computing nodes.
[0087] C(1)={1_A_1,…,1_A_4,1_B_1,…,1_B_4}.
[0088] C(2)={2_A_1,…,2_A_4,2_B_1, 2_B_2, 2_C_1, 2_C_2, 2_D_1, 2_D_2}.
[0089] C(3)={2_E_1,…,2_E_8,2_F_1,2_F_1,2_G_1,2_G_2}.
[0090] C(4)={3_A_1,…,3_A_8,3_B_1}.
[0091] Step 102: determine the master node of each pipeline parallel unit according to the cluster set; wherein the pipeline parallel unit is a computing unit divided based on a pipeline parallel manner, and each pipeline parallel unit corresponds to at least one network layer in the training neural network model.
[0092] During the implementation of this step, the central node of the cluster set can be determined based on the video memory value of the computing node in the cluster set and the centrality of the computing node in the cluster set; each central node of the cluster set is used as the main node of each corresponding pipeline parallel unit. Specifically, the video memory value and the first weight value of the computing node in the cluster set are obtained, and the centrality and the second weight value of the computing node in the cluster set are obtained; based on the video memory value and the first weight value of the computing node in the cluster set, the centrality and the second weight value of the computing node in the cluster set, the score value of each computing node in the cluster set is calculated, and the computing node with the highest score value is determined as the central node of the cluster set.
[0093] Specifically, in the process of determining the central node, the central node can be selected based on pre-clustering. For all computing nodes in the cluster set, the memory size (i.e., memory value) of each computing node and its centrality in the operator (i.e., cluster set) are considered to calculate the score value and select the master node of the pipeline parallel (pipeline parallel unit). Different scoring election methods can be set according to the characteristics of different distributed heterogeneous clusters. The present invention adopts the weighted average method of the two, i.e., score=weight1 Centrality + weight Memory occupancy rate. The computing node with the highest score in the calculation result is selected as the master node P(i) of the pipeline parallel unit. Wherein, score is the score value, weight1 is the second weight value, and weight is the first weight value. The memory occupancy rate can be determined based on the video memory size or video memory value.
[0094] Combined with the example in step 101, with score = 0.7 Centrality +0.3 Taking memory occupancy as an example, the master nodes selected for the four pipeline parallel units can be: 1_A_2, 2_A_4, 2_E_3, 3_A_3. Among them, the centrality is used to indicate the degree of clustering the central point of the cluster set, which can be expressed by the communication distance, which can be specifically determined by existing technology calculation, and will not be described in detail here.
[0095] Step 103: Expand the computing node set of the pipeline parallel unit according to the communication distance between the main node of the pipeline parallel unit and the computing node, and determine the computing node set of the pipeline parallel unit.
[0096] During the implementation of this step, it is first necessary to determine the pipeline parallel unit corresponding to the training of the entire neural network model; wherein, there are at least two pipeline parallel units corresponding to the training of the entire neural network model. Taking the main node of the pipeline parallel unit as the reference node, determine the communication distance between the other computing nodes except the main node in the corresponding cluster set in the distributed heterogeneous cluster and the main node. Among them, the computing nodes in the computing node set of the pipeline parallel unit are all obtained from the corresponding cluster set; there is a one-to-one correspondence between the pipeline parallel unit and the cluster set. Compare and analyze the communication distances between the other computing nodes except the main node in the corresponding cluster set in the distributed heterogeneous cluster and the main node, and determine the computing node with the shortest communication distance with the main node among the other computing nodes. Each time the computing node set of the pipeline parallel unit is expanded, a computing node with the smallest communication distance is selected from the other computing nodes and added to the corresponding computing node set of the pipeline parallel unit, until the total amount of memory in the computing node set of the pipeline parallel unit is greater than or equal to the target memory amount required for the pipeline parallel unit to train at least one network layer, triggering the stop of expanding the computing node set of the pipeline parallel unit to obtain the computing node set of the pipeline parallel unit.
[0097] Specifically, for the computing node set Set(i) of different pipeline parallel units. Each determined central node P(i) should be the first element of the computing node set (i.e., the first computing node). Then, taking the master node (i.e., the central node) as the reference node, each time a computing node with the closest communication distance to the master node is selected in the entire distributed heterogeneous cluster and included in the computing node set. Its memory is added to the total memory of the computing node set, and the computing node is removed from the distributed heterogeneous cluster. The above process is performed sequentially until the total memory of the computing node set Set(i) is greater than or equal to the required memory M_pip, and then the expansion is stopped. That is, starting from the pipeline parallel starting node (e.g., the first master node of the four pipeline parallel units), the computing node set Set(i) of each pipeline parallel stage (i.e., pipeline parallel unit) is determined sequentially. If the memory requirements of each pipeline stage can be met until the last pipeline node (e.g., the last master node of the four pipeline parallel units), the distributed parallel pipeline parallel node allocation is completed. Pipeline parallelism is to divide each network layer of the trained model into different parts and run them on different computing nodes.
[0098] For example, determine the computing node set Set(i) of different pipeline parallel units. First, starting from the main node of Pipline_1:1_A_2, the computing nodes added in sequence are 1_A_1, 1_A_3, 1_A_4, 1_B_1, 1_B_2, 1_B_3, 1_B_4, so far the total memory (i.e. the total memory of all computing nodes in the computing node set) is 320G greater than 300G (i.e. the target memory required for the pipeline parallel unit to train the at least one network layer) and the expansion is ended. Then, starting from the main node of Pipline_2:2_A_4, in sequence, 2_A_3, 2_A_1, 2_A_2, 2_B_1, 2_B_2, 2_C_1, 2_C_2, so far the total memory (i.e. the total memory of all computing nodes in the computing node set) is 320G greater than 300G and the expansion is ended, and 2_D_1 and 2_D_2 in the original cluster set are left. Next, starting from the main node of Pipline_3:2_E_3, the following are 2_E_4, 2_E_2, 2_E_1, 2_E_5, 2_E_6, 2_E_7, 2_E_8, 2_F_1, 2_F_2, 2_G_1, 2_G_2, 2_D_1, 2_D_2. The total memory is 320G, which is greater than 300G. The expansion ends, and 2_D_1 and 2_D_2 in cluster set C(2) are expanded to this computing node set. Finally, starting from the main node of Pipline_4:3_A_3, the following are 3_A_4, 3_A_1, 3_A_2, 3_A_5, 3_A_6, 3_A_7, 3_A_8. The total memory is 320G, which is greater than 300G. The expansion ends, and 3_B_1 in the original cluster set is left unused.
[0099] In the process of expanding the computing nodes of the pipeline parallel unit, if the computing node set added to a certain pipeline parallel stage is the master node of other pipeline parallel stages, the computing node set of the other pipeline parallel stages is re-determined as the master node according to the election method, that is, a new master node is re-selected from the remaining computing nodes in the computing node set of the other pipeline parallel stage until the last computing node is left in the computing node set of the other pipeline parallel stage. When all computing nodes in a certain pre-clustering set are selected as elements of other computing node sets, all remaining computing nodes in the distributed heterogeneous cluster that do not participate in the expansion of the computing node set need to be re-clustered and the above process is repeated. This method allows the master node of each pipeline parallel unit to be determined according to the clustering set each time the computing nodes of the pipeline parallel unit are expanded, so as to continue to perform the expansion operation of the computing nodes of the pipeline parallel unit, thereby improving the stability of determining the computing node set of the pipeline parallel unit.
[0100] In addition, it should be noted that before the computing nodes of the pipeline parallel unit are expanded according to the communication distance between the main node of the pipeline parallel unit and the computing node, it also includes: performing a multi-node shortest path analysis based on the communication distance between the main nodes of each pipeline parallel unit to determine the shortest path connecting the main nodes of each pipeline parallel unit; using the arrangement order of the main nodes in the shortest path as the pipeline parallel order; wherein each main node is the first computing node of a pipeline parallel stage in the corresponding pipeline parallel unit.
[0101] In the process of determining the pipeline parallel order, for the selected Pip_size main nodes, according to the communication distance between them, combined with the shortest path algorithm of multiple computing nodes, a shortest path connecting these main nodes is found, and a node arrangement order corresponding to the shortest path is used as the sorting order of the pipeline parallel stage, and each computing node corresponds to a stage of the pipeline parallel stage. For example, for the selected Pip_size main nodes, according to the communication distance between them, combined with the shortest path algorithm of multiple nodes, the pipeline parallel order obtained is: Pipline_1:1_A_2, Pipline_2:2_A_4, Pipline_3:2_E_3, Pipline_4:3_A_3.
[0102] Correspondingly, according to the communication distances between the other computing nodes and the main node, a computing node with the shortest communication distance is selected from the other computing nodes each time to be added to the computing node set of the pipeline parallel unit. The corresponding specific implementation process includes: selecting the main nodes of each of the pipeline parallel units in sequence according to the pipeline parallel order, and according to the communication distances between the other computing nodes and the main nodes of each of the pipeline parallel units selected in sequence, selecting a computing node with the shortest communication distance from the other computing nodes each time to be added to the computing node set of the pipeline parallel unit corresponding to the master node selected in sequence.
[0103] Step 104: When the total memory amount of the computing node set is greater than or equal to the target memory amount required by the pipeline parallel unit to train at least one network layer, train the neural network model based on the computing node set to obtain a target neural network model.
[0104] In the embodiment of the present invention, in order to fully utilize the memory of the computing node set and improve the robustness of training the neural network model, the memory allocation can also be dynamically adjusted. Specifically, after selecting the main nodes of each of the pipeline parallel units in sequence according to the pipeline parallel order, and according to the communication distances between the other computing nodes and the main nodes of each of the pipeline parallel units selected in sequence, each time a computing node with the shortest communication distance is selected from the other computing nodes to be added to the computing node set of the pipeline parallel unit corresponding to the master node selected in sequence, if the last main node selected in sequence according to the pipeline parallel order does not meet the preset memory condition, according to the zero-pole distributed storage method and in the reverse pipeline parallel order, reverse adjustment is performed starting from selecting the last main node, and the computing node set of the pipeline parallel unit is expanded according to the communication distance between the last main node and the computing node, so as to meet the minimum memory requirement, until the total memory amount of all computing nodes in each pipeline parallel unit is greater than or equal to the minimum memory requirement, it is determined that the dynamic adjustment is successful, and the tensor parallel strategy in the pipeline parallel unit is determined, and the memory resources of the computing nodes are allocated based on the tensor parallel strategy to train the neural network model and obtain the target neural network model. By dynamically adjusting the reverse order, the memory of the computing node set can be fully utilized to improve the robustness of training the neural network model.
[0105] During the dynamic adjustment process, if the last master node does not meet the memory requirements, it is necessary to use ZERO distributed memory technology to reduce dependence on memory resources. Starting from the last master node, reverse the order of the pipeline parallelism and follow the center point expansion method to meet the minimum memory requirements until the total memory of the node set in each pipeline parallel stage is greater than the minimum memory M_pip_min, and the dynamic adjustment is completed. If the minimum memory requirements are still not met when adjusting in reverse order to the last process set, that is, the first node set of the pipeline, it means that the automatic setting of the parallel strategy has failed and more computing resources need to be added. In addition, during the dynamic adjustment process, by detecting that each last pipeline node can meet the memory requirements, there is no need for dynamic adjustment, and the process parallelization is automatically allocated.
[0106] In the case where the total memory of all computing nodes in the computing node set is greater than or equal to the target memory required by the pipeline parallel unit to train at least one network layer, the complete model parameters of the pipeline parallel unit are stored on the computing nodes, and the tensor parallel strategy in the pipeline parallel unit is determined to be an average partitioning method to distribute the length corresponding to the divided computing tensor according to the proportion of the remaining memory resources of each computing node, so as to obtain the target neural network model through tensor parallel training of the neural network model. According to the zero-pole distributed storage method and in the reverse pipeline parallel order, reverse adjustment is performed starting from selecting the last master node, and the computing node set of the pipeline parallel unit is expanded according to the communication distance between the last master node and the computing node, and it also includes: if the reverse adjustment is to the last computing node set, if it is determined that the minimum memory requirement is not met, it is determined that the dynamic adjustment fails, and an early warning prompt message of insufficient computing resources is generated.
[0107] The present invention detects each pipeline parallel stage in turn and sets a tensor parallel strategy. The tensor parallel strategy in the pipeline parallel stage is mainly divided into the following situations:
[0108] If the number of nodes n(i) of the pipeline parallel set set(i) is 1, that is, only one computing node can meet the resources required for parallelism. In this case, tensor parallelism is not required, and the computing node directly calculates. The pipeline parallel set is the computing node set of the pipeline parallel unit. For example: for the Pipline_1 stage and the Pipline_2 stage: the number of computing nodes is greater than 1, and the memory value of each computing node is greater than 20G, so the ZERO distributed storage technology is not used, and tensor parallelism is directly performed according to the average partitioning method.
[0109] If the number of computing nodes n(i) of the pipeline parallel set set(i) is greater than 1, but the total memory of the entire computing node set is less than M_pip, or there is a computing node with small memory that is insufficient to store the corresponding neural network weight parameter M_pip_weight of the pipeline parallel stage. In this case, ZERO distributed video memory technology is used to store the parameters separately in each computing node (such as GPU). At this time, the tensor parallel strategy allocates the size of the divided weight parameters and the length corresponding to the calculation tensor according to the proportion of memory. For example, for the Pipline_3 stage: the number of computing nodes is greater than 1, tensor parallelism is required, and there is a situation where the memory of a single computing node is less than 20G. In this case, ZERO distributed storage technology (i.e., zero-level distributed storage method) is required to split the model parameters and store them in each computing node. At the same time, storage and tensor parallelism are performed according to the memory ratio, and the ratio is: 2_E_3: 1, 2_E_4: 1, 2_E_2: 1, 2_E_1: 1, 2_E_5: 1, 2_E_6: 1, 2_E_7: 1, 2_E_8: 1, 2_F_1: 1, 2_F_2: 1, 2_G_1: 1, 2_G_2: 1, 2_D_1: 2, 2_D_2: 2. The memory described in the present invention is GPU memory (i.e., video memory or video memory capacity).
[0110] If the number of computing nodes n(i) of the pipeline parallel set set(i) is greater than 1, and the memory resources of each computing node are large enough to store all the parameters of the entire pipeline parallel stage and the memory required for intermediate parameter variables, there is still memory space for calculation. At this time, the ZERO distributed video memory technology is no longer used, but the complete parameters of the pipeline stage are stored on each computing node. The tensor parallel strategy is to allocate the length corresponding to the divided calculation tensor according to the proportion of remaining memory. For the Pipline_4 stage, the same as the Pipline_1 stage, the average division method is used for tensor parallelism.
[0111] Among them, Pipline_1 stage, Pipline_2 stage, Pipline_3 stage, and Pipline_4 stage are all different pipeline parallel stages.
[0112] In the case where the total memory amount of all computing nodes in the computing node set is less than the target memory amount required for the pipeline parallel unit to train the at least one network layer, a zero-pole distributed storage method is adopted to store the model parameters of the pipeline parallel unit on different computing nodes respectively, and the tensor parallel strategy within the pipeline parallel unit is determined to adopt an average partitioning method to distribute the length corresponding to the divided computing tensor according to the proportion of the remaining memory resources of each computing node, so as to train the neural network model through tensor parallelism and obtain the target neural network model.
[0113] like Figure 3 As shown, a server and different computing nodes (such as GPU / DTU) in a distributed heterogeneous cluster, all servers in each computer room are connected by a switch, and the switch is connected to a shared local area network. In the process of obtaining multiple cluster sets formed between computing nodes in a distributed heterogeneous cluster, it is necessary to first obtain the communication distance between computing nodes in the distributed heterogeneous cluster; wherein the distributed heterogeneous cluster includes multiple computing nodes; based on the distance of the communication between the computing nodes, the computing nodes in the distributed heterogeneous cluster are clustered to obtain multiple cluster sets, for example: computing nodes 1_A_4 GPU and 1_B_4 GPU in computer room one form a cluster set; computing nodes 2_A_4 GPU, 2_B_2 GPU, 2_C_2 GPU, 2_D_2 GPU, 2_E_8 DTU, 2_F_2DTU, 2_G_4 DTU in computer room two form a cluster set; computing nodes 3_A_8 GPU and 3_B_1 GPU in computer room three form a cluster set.
[0114] Based on the Megatron framework, the present invention designs a method for automatically setting parallel strategies for heterogeneous clusters, so as to achieve the purpose of using heterogeneous clusters to carry out pre-training model training; at the same time, users do not need to pay attention to specific parallel technologies, which greatly reduces the threshold of use. The present invention can help researchers to carry out large-scale neural network model training based on heterogeneous distributed clusters. Heterogeneous clusters can be different types of computing devices (such as GPU / DTU, etc.) or different server topologies. The present invention can provide an automated distributed parallel strategy that does not require researchers to have a very professional understanding of the principles of distribution, improves the efficiency of distributed layout, and reduces the complexity of distributed training implementation. By using logical communication time as a measure of distance, pre-clustering and other technologies are used to perceive the node set suitable for tensor parallelism and the node set suitable for pipeline parallelism, thereby guiding the distributed parallel scheme. At the same time, relevant graph algorithms such as the shortest path are used to determine the node order of pipeline parallelism.
[0115] The model parallel training method provided by the present invention determines the main node of each pipeline parallel unit through the cluster set formed between the computing nodes in the distributed heterogeneous cluster; the pipeline parallel unit is a computing unit divided based on the pipeline parallel method, and each pipeline parallel unit corresponds to at least one network layer in the training neural network model; the computing node set of the pipeline parallel unit is expanded according to the main node and the communication distance of the pipeline parallel unit to determine the computing node set; when the total memory of the computing node set is greater than or equal to the target memory amount required for the pipeline parallel unit to train at least one network layer, the neural network model is trained based on the computing node set; it can realize the distributed parallel training of large-scale neural network models on the distributed heterogeneous cluster based on different hardware devices, and effectively improves the distributed parallel training efficiency of the model under the distributed heterogeneous cluster.
[0116] The model parallel training device provided by the present invention is described below. The model parallel training device described below and the model parallel training method described above can be referred to in correspondence with each other. Figure 5 As shown, it is a schematic diagram of the structure of the model parallel training device provided by the present invention. The model parallel training device of the present invention specifically includes the following parts:
[0117] The cluster set obtaining unit 501 is used to obtain multiple cluster sets formed between computing nodes in a distributed heterogeneous cluster.
[0118] The master node determination unit 502 is used to determine the master node of each pipeline parallel unit according to the cluster set; wherein the pipeline parallel unit is a computing unit divided based on a pipeline parallel manner, and each pipeline parallel unit corresponds to at least one network layer in the training neural network model.
[0119] The master node expansion unit 503 is used to expand the computing nodes of the pipeline parallel unit according to the communication distance between the master node of the pipeline parallel unit and the computing node, and determine the computing node set of the pipeline parallel unit.
[0120] The parallel resource allocation processing unit 504 is used to train the neural network model based on the computing node set to obtain the target neural network model when the total memory amount of the computing node set is greater than or equal to the target memory amount required by the pipeline parallel unit to train at least one network layer.
[0121] According to a model parallel training device provided by the present invention, the cluster set obtaining unit is specifically used for:
[0122] Obtaining the communication distance between computing nodes in the distributed heterogeneous cluster; wherein the distributed heterogeneous cluster includes multiple computing nodes;
[0123] Based on the communication distances between the computing nodes, clustering is performed on the computing nodes in the distributed heterogeneous cluster to obtain a plurality of cluster sets.
[0124] According to a model parallel training device provided by the present invention, the master node determination unit is specifically used for:
[0125] Determine the central node of the cluster set based on the video memory value of the computing node in the cluster set and the centrality of the computing node in the cluster set;
[0126] The central node of each cluster set is used as the main node of each corresponding pipeline parallel unit.
[0127] According to a model parallel training device provided by the present invention, the central node of the cluster set is determined based on the video memory value of the computing node in the cluster set and the centrality of the computing node in the cluster set, specifically including:
[0128] Obtaining the video memory value and the first weight value of the computing node in the cluster set;
[0129] Obtaining the centrality and the second weight value of the computing node in the cluster set;
[0130] Based on the video memory value and the first weight value of the computing node in the cluster set, the centrality of the computing node in the cluster set and the second weight value, the score value of each computing node in the cluster set is calculated, and the computing node with the highest score value is determined as the central node of the cluster set.
[0131] According to a model parallel training device provided by the present invention, the master node expansion unit is specifically used for:
[0132] Taking the master node of the pipeline parallel unit as a reference node, determining the communication distances between the master node and other computing nodes in the corresponding cluster set in the distributed heterogeneous cluster except the master node;
[0133] Compare and analyze the communication distances between the other computing nodes except the master node in the corresponding cluster set in the distributed heterogeneous cluster and the master node, and determine the computing node with the shortest communication distance with the master node among the other computing nodes;
[0134] Each time the computing node set of the pipeline parallel unit is expanded, a computing node with the smallest communication distance is selected from the other computing nodes and added to the corresponding computing node set of the pipeline parallel unit, until the total amount of memory in the computing node set of the pipeline parallel unit is greater than or equal to the target memory amount required for the pipeline parallel unit to train at least one network layer, thereby obtaining the computing node set of the pipeline parallel unit.
[0135] According to a model parallel training device provided by the present invention, before expanding the computing nodes of the pipeline parallel unit according to the communication distance between the main node of the pipeline parallel unit and the computing node, it also includes:
[0136] Identify pipeline parallel sequential units for:
[0137] Determine the shortest path connecting the main nodes of each of the pipeline parallel units;
[0138] The arrangement order of the main nodes in the shortest path is used as the pipeline parallel order; wherein each main node is the first computing node of a pipeline parallel stage in the corresponding pipeline parallel unit; the pipeline parallel order is the arrangement order of the main nodes of the pipeline parallel unit.
[0139] According to a model parallel training device provided by the present invention, each time the computing node set of the pipeline parallel unit is expanded, a computing node with the smallest communication distance is selected from the other computing nodes to be added to the computing node set of the corresponding pipeline parallel unit, specifically comprising:
[0140] The main nodes of each of the pipeline parallel units are selected in turn according to the pipeline parallel order, and according to the communication distances between the other computing nodes except the main node in the corresponding cluster set and the main nodes of each of the pipeline parallel units selected in turn, a computing node with the shortest communication distance is selected from the other computing nodes except the main node in the corresponding cluster set each time and added to the computing node set of the pipeline parallel unit corresponding to the main node selected in turn.
[0141] According to a model parallel training device provided by the present invention, after obtaining the computing node set of the pipeline parallel unit, it also includes:
[0142] Dynamically resized into units for:
[0143] In the case that the last master node selected in sequence according to the pipeline parallel order does not meet the preset memory condition, according to the Zero-Pole distributed storage method and in the reverse pipeline parallel order, reverse adjustment is performed starting from selecting the last master node, and the computing node set of the pipeline parallel unit is expanded according to the communication distance between the last master node and the computing node to meet the minimum memory requirement, until the total memory of all computing nodes in each pipeline parallel unit is greater than or equal to the minimum memory requirement, the dynamic adjustment is determined to be successful, and the tensor parallel strategy within the pipeline parallel unit is determined, and the memory resources of the computing nodes are allocated based on the tensor parallel strategy to train the neural network model and obtain the target neural network model.
[0144] According to a model parallel training device provided by the present invention, the parallel resource allocation processing unit is specifically used for:
[0145] When the total memory amount of all computing nodes in the computing node set is greater than or equal to the target memory amount required by the pipeline parallel unit to train at least one network layer, the tensor parallel strategy within the pipeline parallel unit is determined to be to use an average partitioning method to distribute the length corresponding to the divided computing tensor according to the proportion of the remaining memory resources of each computing node in the computing node set, so as to train the neural network model in a tensor parallel manner and obtain the target neural network model.
[0146] According to a model parallel training device provided by the present invention, the parallel resource allocation processing unit is specifically used for: when the total memory amount of all computing nodes in the computing node set is less than the target memory amount required for the pipeline parallel unit to train the at least one network layer, the model parameters of the pipeline parallel unit are stored in different computing nodes of the computing node set by using a zero-pole distributed storage method, and the tensor parallel strategy within the pipeline parallel unit is determined to be an average division method to allocate the length corresponding to the divided computing tensor according to the proportion of the remaining memory resources of each computing node in the computing node set, so as to obtain the target neural network model through tensor parallel training of the neural network model.
[0147] According to a model parallel training device provided by the present invention, after selecting the last master node for reverse order adjustment according to the zero-pole distributed storage method and in the reverse pipeline parallel order, and expanding the computing node set of the pipeline parallel unit according to the communication distance between the last master node and the computing node, the device further includes:
[0148] Early warning unit, used for:
[0149] If the last computing node set is adjusted in reverse order and it is determined that the minimum memory requirement is not met, the dynamic adjustment is determined to have failed, and an early warning message of insufficient computing resources is generated.
[0150] The model parallel training device provided by the present invention determines the main node of each pipeline parallel unit through the cluster set formed between the computing nodes in the distributed heterogeneous cluster; the pipeline parallel unit is a computing unit divided based on the pipeline parallel method, and each pipeline parallel unit corresponds to at least one network layer in the training neural network model; the computing node set of the pipeline parallel unit is expanded according to the main node and the communication distance of the pipeline parallel unit to determine the computing node set; when the total memory of the computing node set is greater than or equal to the target memory amount required for the pipeline parallel unit to train at least one network layer, the neural network model is trained based on the computing node set; it can realize distributed parallel training of large-scale neural network models on distributed heterogeneous clusters based on different hardware devices, and effectively improves the distributed parallel training efficiency of the model under the distributed heterogeneous cluster.
[0151] Figure 6 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 6 As shown, the electronic device (i.e., electronic device) may include: a processor (processor) 601, a communication interface (Communications Interface) 604, a memory (memory) 602, and a communication bus 603, wherein the processor 601, the communication interface 604, and the memory 602 communicate with each other through the communication bus 603. The processor 601 may call the logic instructions in the memory 602 to execute the model parallel training method, which includes: obtaining multiple cluster sets formed between computing nodes in a distributed heterogeneous cluster; determining the master node of each pipeline parallel unit according to the cluster set; wherein the pipeline parallel unit is a computing unit divided based on a pipeline parallel manner, and each pipeline parallel unit corresponds to at least one network layer in the training neural network model; expanding the computing nodes of the pipeline parallel unit according to the communication distance between the master node of the pipeline parallel unit and the computing node, and determining the computing node set of the pipeline parallel unit; when the total memory amount of all computing nodes in the computing node set is greater than or equal to the target memory amount required for the pipeline parallel unit to train the at least one network layer, training the neural network model based on the computing node set to obtain the target neural network model.
[0152] In addition, the logic instructions in the above-mentioned memory 602 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0153] On the other hand, the present application also provides a computer program product, which includes a computer program, which can be stored on a computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the model parallel training method provided by the above methods, and the method includes: obtaining multiple cluster sets formed between computing nodes in a distributed heterogeneous cluster; determining the main node of each pipeline parallel unit according to the cluster set; wherein the pipeline parallel unit is a computing unit divided based on a pipeline parallel manner, and each pipeline parallel unit corresponds to at least one network layer in a training neural network model; the computing nodes of the pipeline parallel unit are expanded according to the communication distance between the main node of the pipeline parallel unit and the computing node, and the computing node set of the pipeline parallel unit is determined; when the total memory amount of all computing nodes in the computing node set is greater than or equal to the target memory amount required for the pipeline parallel unit to train the at least one network layer, the neural network model is trained based on the computing node set to obtain the target neural network model.
[0154] On the other hand, the present application also provides a computer-readable storage medium, which includes a stored program, wherein the program executes the model parallel training method provided by the above methods when it is run, and the method includes: obtaining multiple cluster sets formed between computing nodes in a distributed heterogeneous cluster; determining the main node of each pipeline parallel unit according to the cluster set; wherein the pipeline parallel unit is a computing unit divided based on a pipeline parallel manner, and each pipeline parallel unit corresponds to at least one network layer in a training neural network model; the computing nodes of the pipeline parallel unit are expanded according to the communication distance between the main node of the pipeline parallel unit and the computing node, and the computing node set of the pipeline parallel unit is determined; when the total memory amount of all computing nodes in the computing node set is greater than or equal to the target memory amount required for the pipeline parallel unit to train the at least one network layer, the neural network model is trained based on the computing node set to obtain the target neural network model.
[0155] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0156] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0157] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A model parallel training method, characterized in that: include: Obtain multiple cluster sets formed between computing nodes in a distributed heterogeneous cluster; Determine the master node of each pipeline parallel unit according to the cluster set; wherein the pipeline parallel unit is a computing unit divided based on a pipeline parallel manner, and each pipeline parallel unit corresponds to at least one network layer in the training neural network model; The computing nodes of the pipeline parallel unit are expanded according to the communication distance between the main node of the pipeline parallel unit and the computing node, and the computing node set of the pipeline parallel unit is determined; in the process of expanding the computing nodes of the pipeline parallel unit, if the computing node set added to the pipeline parallel stage is the main node of other pipeline parallel stages, the computing node set of the other pipeline parallel stages is re-determined as the main node according to the election method, and a new main node is re-selected from the remaining computing nodes in the computing node set of the other pipeline parallel stages until the last computing node is left in the computing node set of the other pipeline parallel stages; when all computing nodes in the pre-clustering set are selected as elements of other computing node sets, all remaining computing nodes in the distributed heterogeneous cluster that have not participated in the expansion of the computing node set need to be re-clustered; When the total amount of memory of the computing node set is greater than or equal to the target amount of memory required by the pipeline parallel unit to train the at least one network layer, training the neural network model based on the computing node set to obtain a target neural network model; After obtaining the computing node set of the pipeline parallel unit, it also includes: when the last master node selected in sequence according to the pipeline parallel order does not meet the preset memory condition, according to the zero-pole distributed storage method and in the reverse pipeline parallel order, reverse adjustment is performed starting from selecting the last master node, and the computing node set of the pipeline parallel unit is expanded according to the communication distance between the last master node and the computing node to meet the minimum memory requirement, until the total memory of all computing nodes in each pipeline parallel unit is greater than or equal to the minimum memory requirement, it is determined that the dynamic adjustment is successful, and the tensor parallel strategy in the pipeline parallel unit is determined, and the memory resources of the computing nodes are allocated based on the tensor parallel strategy to train the neural network model and obtain the target neural network model.
2. The method according to claim 1, characterized in that The step of expanding the computing nodes of the pipeline parallel unit according to the communication distance between the main node of the pipeline parallel unit and the computing node to determine the computing node set of the pipeline parallel unit specifically includes: Taking the master node of the pipeline parallel unit as a reference node, determining the communication distances between the master node and other computing nodes in the corresponding cluster set in the distributed heterogeneous cluster except the master node; Compare and analyze the communication distances between the other computing nodes except the master node in the corresponding cluster set in the distributed heterogeneous cluster and the master node, and determine the computing node with the shortest communication distance with the master node among the other computing nodes; Each time the computing node set of the pipeline parallel unit is expanded, a computing node with the smallest communication distance is selected from the other computing nodes and added to the corresponding computing node set of the pipeline parallel unit, until the total amount of memory in the computing node set of the pipeline parallel unit is greater than or equal to the target memory amount required for the pipeline parallel unit to train at least one network layer, thereby obtaining the computing node set of the pipeline parallel unit.
3. The method according to claim 2, characterized in that Before expanding the computing nodes of the pipeline parallel unit according to the communication distance between the main node of the pipeline parallel unit and the computing node, the method further includes: Determine the shortest path connecting the main nodes of each of the pipeline parallel units; The arrangement order of the main nodes in the shortest path is used as the pipeline parallel order; wherein each main node is the first computing node of a pipeline parallel stage in the corresponding pipeline parallel unit; the pipeline parallel order is the arrangement order of the main nodes of the pipeline parallel unit.
4. The method according to claim 3, characterized in that: Each time the computing node set of the pipeline parallel unit is expanded, a computing node with the smallest communication distance is selected from the other computing nodes to be added to the computing node set of the corresponding pipeline parallel unit, specifically including: Selecting the master node of each of the pipeline parallel units in sequence according to the pipeline parallel order, and calculating the communication distance between the master nodes of each of the pipeline parallel units selected in sequence and other computing nodes except the master node in the corresponding cluster set; Each time, a computing node with the smallest communication distance is selected from other computing nodes in the corresponding cluster set except the master node and added to the computing node set of the corresponding pipeline parallel unit of the master node selected in sequence.
5. The method according to claim 1, characterized in that The step of obtaining a plurality of cluster sets formed between computing nodes in a distributed heterogeneous cluster includes: Obtaining the communication distance between computing nodes in the distributed heterogeneous cluster; wherein the distributed heterogeneous cluster includes multiple computing nodes; Based on the communication distances between the computing nodes, clustering is performed on the computing nodes in the distributed heterogeneous cluster to obtain a plurality of cluster sets.
6. The method according to claim 1, characterized in that Determining the master node of each pipeline parallel unit according to the cluster set specifically includes: Determine the central node of the cluster set based on the video memory value of the computing node in the cluster set and the centrality of the computing node in the cluster set; The central node of each cluster set is used as the main node of each corresponding pipeline parallel unit.
7. The method according to claim 6, characterized in that The determining the central node of the cluster set based on the video memory value of the computing node in the cluster set and the centrality of the computing node in the cluster set specifically includes: Obtaining the video memory value and the first weight value of the computing node in the cluster set; Obtaining the centrality and the second weight value of the computing node in the cluster set; Based on the video memory value and the first weight value of the computing node in the cluster set, the centrality of the computing node in the cluster set and the second weight value, the score value of each computing node in the cluster set is calculated, and the computing node with the highest score value is determined as the central node of the cluster set.
8. The method according to claim 1, characterized in that: The step of training the neural network model based on the computing node set to obtain the target neural network model specifically includes: When the total memory amount of all computing nodes in the computing node set is greater than or equal to the target memory amount required by the pipeline parallel unit to train at least one network layer, the tensor parallel strategy within the pipeline parallel unit is determined to be to use an average partitioning method to distribute the length corresponding to the divided computing tensor according to the proportion of the remaining memory resources of each computing node in the computing node set, so as to train the neural network model in a tensor parallel manner and obtain the target neural network model.
9. The method according to claim 1, characterized in that: Also includes: In the case where the total memory amount of all computing nodes in the computing node set is less than the target memory amount required for the pipeline parallel unit to train the at least one network layer, a zero-pole distributed storage method is adopted to store the model parameters of the pipeline parallel unit respectively on different computing nodes in the computing node set, and the tensor parallel strategy in the pipeline parallel unit is determined to adopt an average partitioning method to distribute the length corresponding to the divided computing tensor according to the proportion of the remaining memory resources of each computing node in the computing node set, so as to train the neural network model through tensor parallelism and obtain the target neural network model.
10. The method according to claim 8, characterized in that According to the zero-level distributed storage method and in the reverse pipeline parallel order, reverse order adjustment is performed starting from selecting the last master node, and after the computing node set of the pipeline parallel unit is expanded according to the communication distance between the last master node and the computing node, the method further includes: If the last computing node set is adjusted in reverse order and it is determined that the minimum memory requirement is not met, the dynamic adjustment is determined to have failed, and an early warning message of insufficient computing resources is generated.
11. A model parallel training device, characterized in that: include: A cluster set obtaining unit, used to obtain multiple cluster sets formed between computing nodes in a distributed heterogeneous cluster; A master node determination unit, used to determine the master node of each pipeline parallel unit according to the cluster set; wherein the pipeline parallel unit is a computing unit divided based on a pipeline parallel manner, and each pipeline parallel unit corresponds to at least one network layer in the training neural network model; A master node expansion unit is used to expand the computing nodes of the pipeline parallel unit according to the communication distance between the master node of the pipeline parallel unit and the computing node, and determine the computing node set of the pipeline parallel unit; in the process of expanding the computing nodes of the pipeline parallel unit, if the computing node set added to the pipeline parallel stage is the master node of other pipeline parallel stages, then the computing node set of the other pipeline parallel stages is re-determined according to the election method, and a new master node is re-selected from the remaining computing nodes in the computing node set of the other pipeline parallel stages until the last computing node is left in the computing node set of the other pipeline parallel stages; when all computing nodes in the pre-clustering set are selected as elements of other computing node sets, all remaining computing nodes in the distributed heterogeneous cluster that have not participated in the expansion of the computing node set need to be re-clustered; A parallel resource allocation processing unit, configured to train the neural network model based on the computing node set to obtain a target neural network model when the total memory amount of the computing node set is greater than or equal to the target memory amount required by the pipeline parallel unit to train the at least one network layer; After obtaining the computing node set of the pipeline parallel unit, it also includes: dynamically adjusting into units, used for: when the last master node selected in sequence according to the pipeline parallel order does not meet the preset memory condition, according to the zero-pole distributed storage method and in the reverse pipeline parallel order, starting from selecting the last master node, reverse adjustment is performed, and the computing node set of the pipeline parallel unit is expanded according to the communication distance between the last master node and the computing node to meet the minimum memory requirement, until the total memory of all computing nodes in each pipeline parallel unit is greater than or equal to the minimum memory requirement, it is determined that the dynamic adjustment is successful, and the tensor parallel strategy in the pipeline parallel unit is determined, and the memory resources of the computing nodes are allocated based on the tensor parallel strategy to train the neural network model and obtain the target neural network model.
12. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, it implements the model parallel training method as described in any one of claims 1 to 10.
13. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, it implements the model parallel training method as described in any one of claims 1 to 10.
14. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, it implements the model parallel training method as described in any one of claims 1 to 10.
