Distributed system for machine learning model and method thereof
By dynamically adjusting the amount of training data and the number of gradient accumulation times based on the performance information of computing devices in a distributed system, the problem of cluster performance waste is solved and more efficient machine learning model training is achieved.
Patent Information
- Application Number
- CN202410305117.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-18
- Publication Date
- 2024-08-30
AI Technical Summary
Existing distributed machine learning systems lead to a waste of the total performance of the cluster during the training process and cannot effectively utilize the computing resources of each computing device.
By obtaining its performance information on each computing device, dynamically adjust the training data volume and gradient accumulation times to ensure that each computing device performs different computing tasks during the training process, avoid performance waste, and optimize parameter updates through gradient scaling factors.
Effectively utilize the computing resources of each computing device to improve the overall training efficiency of the distributed system, avoid the waste of cluster performance, and improve the training efficiency of the machine learning model.
Smart Images

Figure CN118567831A
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of artificial intelligence, and more specifically, to a distributed system and method for machine learning models. Background Art
[0002] With the rapid growth of data scale, machine learning is widely used in various fields to mine the value of data. However, in order to perform machine learning, the memory of general physical machines is far from sufficient. Therefore, in practice, it is often necessary to use distributed machine learning systems to complete the training or corresponding estimation of machine learning models. In existing distributed machine learning systems, multiple computing devices usually execute the same training process for the same machine learning model in parallel, which will lead to a waste of the overall performance of the cluster. Summary of the invention
[0003] An exemplary embodiment of the present disclosure is to provide a distributed system and method for a machine learning model, which can solve the problem of total cluster performance waste in a distributed system existing in the prior art.
[0004] According to an exemplary embodiment of the present disclosure, there is provided a distributed system for a machine learning model, comprising: a plurality of computing devices, wherein the same machine learning model is arranged on each computing device; wherein each computing device acquires a quantity of training data corresponding to its own performance information, the plurality of computing devices respectively use the acquired training data to execute the training process of the machine learning model in parallel, and the plurality of computing devices jointly complete the training task of the machine learning model.
[0005] Optionally, each computing device is configured to determine the number of gradient accumulations of the computing device during each execution of the training process of the machine learning model based on performance information of the computing device.
[0006] Optionally, when determining the number of gradient accumulation times, each computing device is configured to: quantify the performance information of the computing device to obtain the performance value of the computing device, and obtain the performance values of other computing devices in the multiple computing devices; take the computing device with the smallest performance value as the device unit, and determine the number of device units corresponding to the multiple computing devices; and determine the number of gradient accumulation times of the computing device based on the performance value of the computing device and the number of the device units.
[0007] Optionally, when determining the number of gradient accumulations, each computing device is configured to: determine an initial number of gradient accumulations of the computing device based on a total data size calculated by the multiple computing devices in a training process, a data size calculated by the computing device in a gradient calculation, and the number of device units; and weight the initial number of gradient accumulations based on a performance value of the computing device to obtain the number of gradient accumulations of the computing device.
[0008] Optionally, each computing device is configured to: obtain first gradient information obtained by each computing device after a corresponding number of gradient accumulations; and update corresponding parameters of the machine learning model based on the first gradient information of each computing device.
[0009] Optionally, when updating the corresponding parameters of the machine learning model, each computing device is configured to: determine the gradient scaling factor of the computing device based on the performance information of the computing device; determine the second gradient information of the computing device based on the first gradient information of the computing device and the gradient scaling factor; obtain the second gradient information of each computing device, and update the parameters of the machine learning model based on the second gradient information of each computing device.
[0010] Optionally, the second gradient information includes multiple second gradients corresponding to each parameter in the machine learning model, wherein each computing device is configured to: for any parameter in the machine learning model, obtain the gradient of any parameter based on the multiple second gradients corresponding to the any parameter from the multiple computing devices and the number of device units.
[0011] Optionally, when determining the gradient scaling factor, each computing device is configured to: quantify performance information of the computing device to obtain a performance value of the computing device; and determine the gradient scaling factor based on the performance value of the computing device.
[0012] Optionally, when determining the performance information, each computing device is configured to: perform matrix multiplication calculations on the computing device and record the calculation time of the computing device; determine the performance information of the computing device based on the calculation time, wherein each computing device performs the same matrix multiplication calculation.
[0013] Optionally, the performance information includes at least one of computing power information, video memory information and communication information.
[0014] According to another exemplary embodiment of the present disclosure, there is provided a method for training a machine learning model using a distributed system, wherein the distributed system includes multiple computing devices, and the same machine learning model is arranged on each computing device, wherein the training method includes: each computing device obtains a number of training data corresponding to its own performance information, the multiple computing devices respectively use the obtained training data to execute the training process of the machine learning model in parallel, and the multiple computing devices jointly complete the training task of the machine learning model.
[0015] Optionally, each computing device determines the number of gradient accumulations of the computing device during each execution of the training process of the machine learning model based on the performance information of the computing device.
[0016] Optionally, when determining the number of gradient accumulation times, each computing device quantifies the performance information of the computing device to obtain a performance value of the computing device, and obtains performance values of other computing devices among the multiple computing devices; taking the computing device with the smallest performance value as a device unit, determining the number of device units corresponding to the multiple computing devices; and determining the number of gradient accumulation times of the computing device based on the performance value of the computing device and the number of device units.
[0017] Optionally, when determining the number of gradient accumulation times, each computing device determines an initial gradient accumulation time of the computing device based on a total data size calculated by the multiple computing devices in a training process, a data size calculated by the computing device in a gradient calculation, and the number of device units; and the initial gradient accumulation time is weighted based on the performance value of the computing device to obtain the gradient accumulation time of the computing device.
[0018] Optionally, each computing device obtains first gradient information obtained by each computing device after a corresponding number of gradient accumulations; and based on the first gradient information of each computing device, updates corresponding parameters of the machine learning model.
[0019] Optionally, when updating the corresponding parameters of the machine learning model, each computing device determines the gradient scaling factor of the computing device based on the performance information of the computing device; determines the second gradient information of the computing device based on the first gradient information of the computing device and the gradient scaling factor; obtains the second gradient information of each computing device, and updates the parameters of the machine learning model based on the second gradient information of each computing device.
[0020] Optionally, the second gradient information includes multiple second gradients corresponding to each parameter in the machine learning model, wherein each computing device obtains the gradient of any parameter in the machine learning model based on the multiple second gradients corresponding to the any parameter from the multiple computing devices and the number of device units.
[0021] Optionally, when determining the gradient scaling factor, each computing device quantifies the performance information of the computing device to obtain a performance value of the computing device; and determines the gradient scaling factor based on the performance value of the computing device.
[0022] Optionally, when determining the performance information, each computing device performs matrix multiplication calculations on the computing device and records the calculation time of the computing device; the performance information of the computing device is determined based on the calculation time, wherein each computing device performs the same matrix multiplication calculations.
[0023] Optionally, the performance information includes at least one of computing power information, video memory information and communication information.
[0024] The present disclosure provides a distributed system and method for machine learning models to at least solve the problems in the above-mentioned related technologies.
[0025] By enabling each computing device to use a different amount of training data for machine learning training based on the performance information of each computing device in the distributed system, the computing resources of each computing device can be effectively utilized, avoiding the waste of the total performance of the cluster. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] The above and other objects and features of the exemplary embodiments of the present invention will become more apparent through the following description in conjunction with the accompanying drawings which exemplarily illustrate the embodiments, in which:
[0027] Figure 1 A block diagram showing a distributed system for machine learning models according to an exemplary embodiment of the present disclosure;
[0028] Figure 2 A flowchart showing a method for training a machine learning model using a distributed system according to an exemplary embodiment of the present disclosure;
[0029] Figure 3 A flowchart showing a method for training a machine learning model using a distributed system according to another exemplary embodiment of the present disclosure is shown;
[0030] Figure 4 A structural schematic diagram of an electronic device applicable to an embodiment of the present disclosure is shown in FIG. DETAILED DESCRIPTION
[0031] The following description with reference to the accompanying drawings is provided to facilitate a comprehensive understanding of the various embodiments of the present disclosure as defined by the claims and their equivalents. This description includes various specific details to facilitate understanding but should be considered as exemplary only. Therefore, one of ordinary skill in the art will recognize that various changes and modifications can be made to the various embodiments described herein without departing from the scope and spirit of the present disclosure. In addition, for the sake of clarity and conciseness, descriptions of well-known functions and structures may be omitted.
[0032] The terms and expressions used in the following specification and claims are not limited to their dictionary meanings, but are merely used by the inventor to enable a clear and consistent understanding of the present disclosure. Therefore, it should be apparent to those skilled in the art that the following description of various embodiments of the present disclosure is provided for illustration purposes only and not for the purpose of limiting the present disclosure as defined in the appended claims and their equivalents.
[0033] It should be understood that the singular forms "a", "an", and "the" may also include plural references unless the context clearly indicates otherwise. Thus, for example, reference to "a component surface" includes reference to one or more such surfaces. When we refer to an element as being "connected" or "coupled" to another element, the one element may be directly connected or coupled to the other element, or the one element and the other element may establish a connection relationship through an intermediate element. In addition, "connected" or "coupled" as used herein may include wireless connection or wireless coupling.
[0034] The term "include" or "may include" refers to the presence of the corresponding disclosed functions, operations or components that can be used in various embodiments of the present disclosure, rather than limiting the presence of one or more additional functions, operations or features. In addition, the term "include" or "have" may be interpreted as indicating certain characteristics, numbers, steps, operations, constituent elements, components or combinations thereof, but should not be interpreted as excluding the possibility of the presence of one or more other characteristics, numbers, steps, operations, constituent elements, components or combinations thereof.
[0035] The term "or" used in various embodiments of the present disclosure includes any of the listed terms and all combinations thereof. For example, "A or B" may include A, may include B, or may include both A and B. When describing multiple (two or more) items, if the relationship between the multiple items is not clearly defined, the multiple items may refer to one, multiple, or all of the multiple items. For example, the description of "parameter A includes A1, A2, A3" may be implemented as parameter A including A1 or A2 or A3, or may be implemented as parameter A including at least two of the three items A1, A2, and A3.
[0036] Unless defined differently, all terms (including technical terms or scientific terms) used in the present disclosure have the same meanings as understood by those skilled in the art described in the present disclosure. Common terms as defined in dictionaries are interpreted as having meanings consistent with the context in the relevant technical field, and should not be interpreted ideally or overly formally unless clearly defined in the present disclosure.
[0037] At least some functions of the device or electronic device provided in the embodiments of the present disclosure can be implemented by an AI model, such as at least one module among multiple modules of the device or electronic device can be implemented by an AI model. Functions associated with AI can be performed by non-volatile memory, volatile memory and processor.
[0038] The processor may include one or more processors. In this case, the one or more processors may be general-purpose processors, such as a central processing unit (CPU), an application processor (AP), etc., or pure graphics processing units, such as a graphics processing unit (GPU), a visual processing unit (VPU), and / or an AI-specific processor, such as a neural processing unit (NPU).
[0039] The one or more processors control the processing of input data according to predefined operating rules or artificial intelligence (AI) models stored in non-volatile memory and volatile memory. The predefined operating rules or artificial intelligence models are provided by training or learning.
[0040] Here, providing by learning means obtaining a predefined operating rule or an AI model with desired characteristics by applying a learning algorithm to a plurality of learning data. The learning can be performed in the device or electronic device itself in which the AI according to the embodiment is executed, and / or can be implemented by a separate server / system.
[0041] The AI model may include multiple neural network layers. Each layer has multiple weight values, and each layer performs neural network calculations by calculating between the input data of the layer (such as the calculation results of the previous layer and / or the input data of the AI model) and the multiple weight values of the current layer. Examples of neural networks include, but are not limited to, convolutional neural networks (CNNs), deep neural networks (DNNs), recurrent neural networks (RNNs), restricted Boltzmann machines (RBMs), deep belief networks (DBNs), bidirectional recurrent deep neural networks (BRDNNs), generative adversarial networks (GANs), and deep Q networks.
[0042] A learning algorithm is a method of using a plurality of learning data to train a predetermined target device (e.g., a robot) to enable, allow, or control the target device to make a determination or prediction. Examples of the learning algorithm include, but are not limited to, supervised learning, unsupervised learning, semi-supervised learning, or reinforcement learning.
[0043] The method provided in the present disclosure may involve one or more technical fields such as speech, language, image, video or data intelligence.
[0044] Optionally, when it comes to the field of speech or language, in a method performed by an electronic device according to the present disclosure, a speech signal as an analog signal can be received via a speech input device (e.g., a microphone), and the speech portion can be converted into computer-readable text using an automatic speech recognition (ASR) model. The user's speech intention can be obtained by interpreting the converted text using a natural language understanding (NLU) model. The ASR model or the NLU model can be an artificial intelligence model. The artificial intelligence model can be processed by an artificial intelligence dedicated processor designed in a hardware structure specified for artificial intelligence model processing. Language understanding is a technology for recognizing and applying / processing human language / text, including, for example, natural language processing, machine translation, dialogue systems, question answering, or speech recognition / synthesis.
[0045] Optionally, when it comes to the field of images or videos, in the method performed by the electronic device according to the present disclosure, output data can be obtained by using image data as input data of an artificial intelligence model. The method of the present disclosure may be related to the field of visual understanding of artificial intelligence technology, which is a technology for recognizing and processing things like human vision, and includes, for example, object recognition, object tracking, image retrieval, human recognition, scene recognition, 3D reconstruction / localization, or image enhancement.
[0046] Optionally, when it comes to the field of intelligent data processing, in the method performed by the electronic device according to the present disclosure, in the inference or prediction stage, an artificial intelligence model can be used to perform predictions by using real-time input data. The processor of the electronic device can perform preprocessing operations on the data to convert it into a form suitable for use as an input to the artificial intelligence model. Inference prediction is a technology for logical reasoning and prediction by determining information, including, for example, knowledge-based reasoning, optimization prediction, preference-based planning or recommendation.
[0047] In the present application, an artificial intelligence model can be obtained by training. Here, "obtained by training" means obtaining a predefined operating rule or artificial intelligence model configured to perform a desired feature (or purpose) by training a basic artificial intelligence model with multiple training data through a training algorithm. The artificial intelligence model may include multiple neural network layers. Each of the multiple neural network layers includes multiple weight values, and the neural network calculation is performed by calculating between the calculation result of the previous layer and the multiple weight values.
[0048] The following describes several optional embodiments to illustrate the technical solutions of the embodiments of the present disclosure and the technical effects produced by the technical solutions of the present disclosure. It should be noted that the following embodiments can refer to, draw on or combine with each other, and the same terms, similar features and similar implementation steps in different embodiments will not be described repeatedly.
[0049] Figure 1 A block diagram of a distributed system for a machine learning model according to an exemplary embodiment of the present disclosure is shown. Figure 1 As shown, the distributed system 1000 for machine learning models according to an exemplary embodiment of the present disclosure includes multiple computing devices (e.g., computing device 1000-1, computing device 1000-2, ..., computing device 1000-n (where n is an integer greater than 1)). For example, the computing device can be implemented by a graphics processing unit (GPU).
[0050] According to an embodiment of the present disclosure, taking into account the heterogeneous device situation, the data set is no longer divided equally among different devices. Instead, appropriate amounts of data are allocated to different computing devices according to the performance information / heterogeneous information (such as computing power, video memory, and communication) of different devices.
[0051] The same machine learning model may be deployed on each of the multiple computing devices.
[0052] Each computing device can determine its own performance information and obtain a corresponding amount of training data from the training data set based on the performance information. For example, a training data set can be divided into a number of training sets corresponding to the number of computing devices according to the ratio between the performance values of each computing device, so that each divided training data has a different number and different data.
[0053] As another example, the distributed system 1000 may include a data distribution device (not shown), which may determine performance information of multiple computing devices respectively, and divide and distribute the training data set to the multiple computing devices based on the performance information. For example, data in the training data set may be distributed to different computing devices in the same proportion according to the computing power of different computing devices.
[0054] Multiple computing devices can respectively use the acquired training data to execute the training process of the machine learning model in parallel, and multiple computing devices jointly complete the training task of the machine learning model.
[0055] As an example, when determining the performance information, the computing device may perform the same matrix multiplication calculation, record its calculation time, and then determine its own performance information based on the calculation time. Each computing device may perform the same matrix multiplication calculation in order to obtain a suitable amount of training data.
[0056] In addition, after determining the performance of the computing device using the above method, for example, the performance information between different computing devices can be further adjusted (such as adjusting the performance ratio between the computing devices) to optimize the overall training efficiency of the distributed system. For example, the performance ratio can be adjusted manually, or preset weights can be applied to different computing devices. In other words, a corresponding amount of training data can be obtained according to the calculated performance information, or after obtaining and adjusting the performance information, a corresponding amount of training data can be obtained according to the adjusted performance information.
[0057] After determining the performance information or performance ratio of each computing device, each computing device can obtain different amounts of data in the training data set in equal proportion.
[0058] As an example, when a distributed system according to an exemplary embodiment of the present disclosure includes two computing devices (such as 1000-1 and 1000-2), based on the computing power of the two computing devices, the two computing devices respectively obtain a portion of data of data set D from a data source (e.g., a data warehouse). For example, the computing power ratio of computing device 1000-1 to computing device 1000-2 is approximately 1:2, computing device 1000-1 obtains 1 / 3 of data set D, computing device 1000-2 obtains 2 / 3 of data set D, and the sum of the data respectively obtained by the two computing devices is the entire data set D. Each computing device trains the same machine learning model in parallel based on the data it obtains. In other words, both computing devices participate in model training based on the data they obtain, and each computing device trains the same machine learning model in parallel based on the data it obtains.
[0059] The training process of the machine learning model can be roughly divided into the forward stage (Forward), the backward stage (Backward), the gradient synchronization stage (all_reduce Gradient) and the parameter update stage (Step). Specifically, the forward stage mainly calculates the output results of the machine learning model and calculates the loss. The backward stage mainly updates the gradient of each parameter in the machine learning model based on the loss. The gradient synchronization stage mainly calculates the average value of the gradient in different computing devices. The parameter update stage mainly updates the parameters of the machine learning model through the gradient. Generally, several rounds of Forward and Backward will be performed during the model training process, that is, several gradient accumulations (Gradient_Accumulation) will be performed.
[0060] For example, the training process of a machine learning model can be represented as:
[0061] (Forward->Backward)*Gradient_Accumulation->all_reduce Gradient->Step
[0062] That is, after each computing device passes through the Forward and Backward of the Gradient_Accumulation round, the gradients of the same model parameters in each computing device are averaged, and then the obtained gradients are used to update the corresponding model parameters.
[0063] In the related art, Gradient_Accumulation of each computing device = TotalBatchSize / MicroBatchSize / num_gpu, and the Gradient_Accumulation of all computing devices is consistent. Wherein, TotalBatchSize represents the total data size calculated by all computing devices in a training process (i.e., a Step), MicroBatchSize represents the data size calculated by a computing device in a gradient calculation (i.e., a Forward->Backward), and num_gpu represents the number of devices of all computing devices.
[0064] According to an embodiment of the present disclosure, in order to further enable a computing device with higher performance to calculate more data, different computing devices may have different gradient accumulation times in each training process.
[0065] Each computing device may determine the number of gradient accumulations during each execution of the training process of the machine learning model based on its performance information. Optionally, in the case of including a data distribution device, the data distribution device may determine the number of gradient accumulations during each execution of the training process of the machine learning model by each computing device based on the performance information of multiple computing devices.
[0066] As an example, for each computing device, the computing device can quantify its own performance information to obtain a performance value, and obtain the performance values of other computing devices in the distributed system from the other computing devices, taking the computing device with the smallest performance value as the device unit, determine the number of device units corresponding to all computing devices in the distributed system, and then determine its own gradient accumulation times based on its own performance value and the determined number of device units.
[0067] For example, a computing device may determine an initial gradient accumulation number of the computing device based on the total data size calculated by all computing devices in a training process, the data size calculated by the computing device in a gradient calculation, and the number of device units, and weight the initial gradient accumulation number based on the performance value of the computing device to obtain the gradient accumulation number of the computing device.
[0068] Specifically, the Gradient_Accumulation of a computing device can be calculated using the following equation (1):
[0069] Gradient_Accumulation=P*TotalBatchSize / MicroBatchSize / HeteroDP(1)
[0070] Among them, P represents the computing power of the computing device, TotalBatchSize represents the total data size calculated by all computing devices in a training process (i.e., one Step), MicroBatchSize represents the data size calculated by the computing device in a gradient calculation (i.e., one Forward->Backward), and HeteroDP represents the number of converted device units.
[0071] For example, assuming that there are two computing devices 1000-1 and 1000-2 in a distributed system, and the computing power ratio is 1:2, which corresponds to the computing power P_1000-1 of computing device 1000-1=1, and the computing power P_1000-2 of computing device 1000-2=2. Then, the device with the lowest computing power is taken as the smallest unit, and according to the computing power ratio, a heterogeneous data parallel group HeteroDP=num_1000-1+2*num_1000-2 is constructed. Among them, num_1000-1 represents the number of computing devices 1000-1, and num_1000-2 represents the number of computing devices 1000-2.
[0072] For example, the computing power ratio of computing device 1000-1 and computing device 1000-2 is about 1:2, then the Gradient_Accumulation on computing device 1000-1: Gradient_Accumulation on computing device 1000-2 may be 1:2.
[0073] By enabling each computing device to perform different times of gradient accumulation during training based on the performance information of each computing device in the distributed system, the computing resources of each computing device can be effectively utilized, thus avoiding the waste of the total performance of the cluster.
[0074] Each computing device may obtain first gradient information after a corresponding number of gradient accumulations, and update corresponding parameters of the machine learning model based on the first gradient information of each computing device. As another example, the distributed system 1000 may also include a parameter server (not shown), which may obtain first gradient information obtained by each computing device after a corresponding number of gradient accumulations, and update corresponding parameters of the machine learning model based on the first gradient information of each computing device.
[0075] In the present disclosure, in order to ensure the consistency of the calculation results, in the gradient synchronization stage, a correlation coefficient may be removed according to the different performance of each computing device so that the overall results are consistent.
[0076] As an example, each computing device may determine a corresponding gradient scaling factor based on its own performance information; determine second gradient information based on the first gradient information and the gradient scaling factor; obtain the second gradient information of each computing device and update the parameters of the machine learning model based on the second gradient information of each computing device. In the present disclosure, the first gradient information may be gradient information without considering the gradient scaling factor, and the second gradient information may be gradient information with considering the gradient scaling factor.
[0077] When determining the gradient scaling factor of the computing device, the computing device may quantify its own performance information to obtain a performance value P, and determine the gradient scaling factor based on the performance value. For example, the gradient scaling factor Gradient_Predivide_Factor = 1 / P.
[0078] By scaling the gradient based on the performance information of each computing device in the distributed system during the gradient synchronization phase, the training results of the machine learning model can be kept consistent.
[0079] The gradient information of a computing device may include multiple gradients corresponding to each parameter in the machine learning model. For example, the gradient information of a computing device may include all gradients corresponding to all parameters of the machine learning model on the computing device. For example, the machine learning model includes parameter A, parameter B, etc., and the corresponding gradient information may include the gradient a corresponding to parameter A, the gradient b corresponding to parameter B, etc. In other words, a computing device obtains the gradient of each parameter after each corresponding number of gradient accumulations. A distributed system includes multiple computing devices, and each computing device itself obtains the gradient of each corresponding parameter.
[0080] For calculating the gradient of a parameter, a computing device may obtain multiple first gradients corresponding to the parameter from multiple computing devices; obtain corresponding multiple second gradients based on the multiple first gradients and the gradient scaling factor; and finally obtain the gradient of the parameter using the multiple second gradients and the number of device units.
[0081] For example, the process of all_reduce Gradient of the present disclosure may be performed as follows:
[0082] 1) For each computing device, Gradient2 = Gradient1 / Gradient_Predivide_Factor, where Gradient1 represents the first gradient, Gradient2 represents the second gradient, and Gradient_Predivide_Factor represents the gradient scaling factor of the computing device;
[0083] 2) For each model parameter, Gradient = all_reduce (Gradient2) / HeteroDP, where all_reduce is the sum of the second gradients corresponding to one parameter in all computing devices, and HeteroDP represents the number of converted device units of all computing devices.
[0084] After obtaining the gradient of each parameter, the corresponding parameter can be updated based on the gradient in the parameter updating stage.
[0085] According to an embodiment of the present disclosure, each computing device may individually calculate its own performance value and the corresponding number of gradient accumulations, gradient scaling factors, etc., or the above functions may be performed by a data distribution device or a parameter server instead. Figure 1 The devices shown are only used to clearly explain the corresponding functions and are not intended to limit Figure 1 Type and quantity of equipment shown.
[0086] The present disclosure is suitable for the training tasks of various machine learning models, especially large-scale deep learning models. When a distributed system with heterogeneous devices is used to train a large number of models, the present disclosure can perform targeted processing on the training tasks of the model based on the performance of different heterogeneous computing devices, thereby avoiding the waste of the total performance of the cluster, and providing a solid foundation for the training of large-scale deep learning models.
[0087] Figure 2 A flowchart of a method for training a machine learning model using a distributed system according to an exemplary embodiment of the present disclosure is shown.
[0088] The distributed system may include multiple computing devices, each of which has the same machine learning model deployed on it.
[0089] In step S201, each computing device obtains a quantity of training data corresponding to its own performance information. For example, after determining its own performance information, each computing device distributes different amounts of data to corresponding computing devices in the same proportion according to the performance ratio of each computing device to perform training in parallel.
[0090] In step S202, multiple computing devices respectively use the acquired training data to execute the training process of the machine learning model in parallel, and the multiple computing devices jointly complete the training task of the machine learning model.
[0091] Each computing device may determine the number of gradient accumulations in each execution of the training process of the machine learning model based on its own performance information. For example, each computing device may perform the same matrix multiplication calculation, record the calculation time, and determine the performance information based on the calculation time. When determining the number of gradient accumulations, each computing device quantifies its own performance information to obtain a performance value, and obtains the performance values of other computing devices; takes the computing device with the smallest performance value as the device unit, and determines the number of device units corresponding to all computing devices; based on its own performance value and the number of device units, determines the corresponding number of gradient accumulations. For example, refer to equation (1) above to calculate the number of gradient accumulations.
[0092] Each computing device can obtain the first gradient information obtained after a corresponding number of gradient accumulations, and update the corresponding parameters of the machine learning model based on the first gradient information of each computing device.
[0093] When updating the corresponding parameters of the machine learning model, each computing device may determine the gradient scaling factor based on the performance information, determine the second gradient information based on the first gradient information and the gradient scaling factor, obtain the second gradient information, and update the parameters of the machine learning model based on the second gradient information of each computing device. For example, the model parameters may be updated with reference to the all_reduce Gradient process above, thereby effectively utilizing the computing resources of each computing device, avoiding the waste of the overall performance of the cluster, and improving training efficiency.
[0094] Figure 3 A flowchart of a method for training a machine learning model using a distributed system according to another exemplary embodiment of the present disclosure is shown.
[0095] Reference Figure 3 In step S301, each computing device in the distributed system may read its own configuration information, such as a corresponding amount of training data, hardware configuration, and software configuration.
[0096] In step S302, each computing device calculates its own heterogeneous parameters, such as computing power, number of gradient accumulations, gradient scaling factors, etc.
[0097] In step S303, each computing device performs a training process and determines whether the training is completed.
[0098] If the training is completed, the process ends; otherwise, in step S304, each computing device determines whether the corresponding number of gradient accumulations Gradient_Accumulation has been iterated.
[0099] If the corresponding number of gradient accumulations has been iterated, then in step S305 , the computing device may scale the gradient information obtained after the corresponding number of gradient accumulations has been executed according to the gradient scaling factor Gradient_Predivide_Factor, and in step S306 , perform gradient synchronization and update parameters.
[0100] If there is no gradient accumulation number corresponding to the iteration, then in step S307, the data of the previous iteration is obtained, and in step S308, a forward phase and a backward phase operation (forward-backward) are performed to obtain the gradient information of this iteration. In step S309, the number of iterations is increased by 1, and step S304 is performed again until the corresponding gradient accumulation number is reached.
[0101] Figure 4 FIG. 2 shows a schematic diagram of the structure of an electronic device to which the embodiment of the present disclosure is applicable. Figure 4 As shown, Figure 4 The electronic device 4000 shown includes: a processor 4001 and a memory 4003. The processor 4001 and the memory 4003 are connected, such as through a bus 4002. Optionally, the electronic device 4000 may also include a transceiver 4004, which can be used for data interaction between the electronic device and other electronic devices, such as data transmission and / or data reception. It should be noted that in actual applications, each of the processor 4001, the memory 4003 and the transceiver 4004 is not limited to one, and the structure of the electronic device 4000 does not constitute a limitation on the embodiments of the present disclosure. Optionally, the electronic device may be a first network node, a second network node or a third network node.
[0102] Processor 4001 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. It may implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the disclosure of the present invention. Processor 4001 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.
[0103] The bus 4002 may include a path to transmit information between the above components. The bus 4002 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus 4002 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0104] The memory 4003 may be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, or an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory) or other optical disk storage, optical disk storage (including compressed optical disk, laser disk, optical disk, digital versatile disk, Blu-ray disk, etc.), magnetic disk storage media, other magnetic storage devices, or any other medium that can be used to carry or store computer programs and can be read by a computer, without limitation herein.
[0105] The memory 4003 is used to store computer programs or executable instructions for executing the embodiments of the present disclosure, and the execution is controlled by the processor 4001. The processor 4001 is used to execute the computer programs or executable instructions stored in the memory 4003 to implement the steps shown in the above method embodiments.
[0106] An embodiment of the present disclosure provides a computer-readable storage medium having a computer program or instructions stored thereon. When the computer program or instructions are executed by at least one processor, the steps and corresponding contents of the aforementioned method embodiment can be executed or implemented.
[0107] The embodiments of the present disclosure also provide a computer program product, including a computer program, which can implement the steps and corresponding contents of the aforementioned method embodiments when executed by a processor.
[0108] The terms "first", "second", "third", "fourth", "1", "2", etc. (if any) in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than that shown or described in the text.
[0109] It should be understood that, although the flowchart of the embodiment of the present disclosure indicates each operation step by arrows, the implementation order of these steps is not limited to the order indicated by the arrows. Unless clearly stated herein, in some implementation scenarios of the embodiment of the present disclosure, the implementation steps in each flowchart can be executed in other orders according to demand. In addition, some or all of the steps in each flowchart may include multiple sub-steps or multiple stages based on the actual implementation scenario. Some or all of these sub-steps or stages can be executed at the same time, and each sub-step or stage in these sub-steps or stages can also be executed at different times. In scenarios with different execution times, the execution order of these sub-steps or stages can be flexibly configured according to demand, and the embodiment of the present disclosure does not limit this.
[0110] The above text and drawings are provided only as examples to help readers understand the present disclosure. They are not intended and should not be interpreted as limiting the scope of the present disclosure in any way. Although certain embodiments and examples have been provided, based on the contents disclosed herein, it is obvious to those skilled in the art that the embodiments and examples shown can be changed without departing from the scope of the present disclosure, and other similar implementation means based on the technical ideas of the present disclosure are adopted, which also fall within the protection scope of the embodiments of the present disclosure.
Claims
1. A distributed system for a machine learning model, comprising: A plurality of computing devices, wherein the same machine learning model is deployed on each computing device; Among them, each computing device obtains a quantity of training data corresponding to its own performance information, and the multiple computing devices respectively use the obtained training data to execute the training process of the machine learning model in parallel, and the multiple computing devices jointly complete the training task of the machine learning model.
2. The distributed system according to claim 1, wherein: Each computing device is configured to determine the number of gradient accumulations of the computing device during each execution of the training process of the machine learning model based on the performance information of the computing device.
3. The distributed system according to claim 2, wherein: When determining the number of gradient accumulations, each computing device is configured to: quantifying the performance information of the computing device to obtain a performance value of the computing device, and obtaining performance values of other computing devices among the multiple computing devices; Taking the computing device with the smallest performance value as the device unit, determining the number of device units corresponding to the plurality of computing devices; The number of gradient accumulation times of the computing device is determined based on the performance value of the computing device and the number of the device units.
4. The distributed system according to claim 3, wherein: When determining the number of gradient accumulations, each computing device is configured to: Determining an initial gradient accumulation number of the computing device based on a total data size calculated by the plurality of computing devices in one training process, a data size calculated by the computing device in one gradient calculation, and the number of the device units; The initial gradient accumulation times are weighted based on the performance value of the computing device to obtain the gradient accumulation times of the computing device.
5. A distributed system according to any one of claims 2 to 4, wherein: Each computing device is configured to: Acquire first gradient information obtained by each computing device after a corresponding number of gradient accumulations; Based on the first gradient information of each computing device, the corresponding parameters of the machine learning model are updated.
6. The distributed system according to claim 5, wherein: When updating corresponding parameters of the machine learning model, each computing device is configured to: determining a gradient scaling factor of the computing device based on performance information of the computing device; determining second gradient information of the computing device based on the first gradient information of the computing device and the gradient scaling factor; Obtain the second gradient information of each computing device, and update the parameters of the machine learning model based on the second gradient information of each computing device.
7. The distributed system according to claim 6, wherein: The second gradient information includes a plurality of second gradients corresponding to each parameter in the machine learning model, Wherein, each computing device is configured as: For any parameter in the machine learning model, a gradient of the parameter is obtained based on a plurality of second gradients corresponding to the parameter from the plurality of computing devices and the number of the device units.
8. The distributed system according to claim 6, wherein: In determining the gradient scaling factor, each computing device is configured to: quantifying the performance information of the computing device to obtain a performance value of the computing device; The gradient scaling factor is determined based on a performance value of the computing device.
9. The distributed system according to claim 1, wherein: In determining the performance information, each computing device is configured to: Performing a matrix multiplication calculation on the computing device and recording a calculation time of the computing device; determining performance information of the computing device based on the computing time, Each of the computing devices performs the same matrix multiplication calculation.
10. A method for training a machine learning model using a distributed system, wherein: The distributed system includes multiple computing devices, each of which is equipped with a same machine learning model. Wherein, the training method comprises: Each computing device acquires a quantity of training data corresponding to its own performance information, and the multiple computing devices respectively use the acquired training data to execute the training process of the machine learning model in parallel, and the multiple computing devices jointly complete the training task of the machine learning model.
