WO2023123275A1 - 确定分布式训练算法框架配置方法、装置及系统 - Google Patents

确定分布式训练算法框架配置方法、装置及系统 Download PDF

Info

Publication number
WO2023123275A1
WO2023123275A1 PCT/CN2021/143339 CN2021143339W WO2023123275A1 WO 2023123275 A1 WO2023123275 A1 WO 2023123275A1 CN 2021143339 W CN2021143339 W CN 2021143339W WO 2023123275 A1 WO2023123275 A1 WO 2023123275A1
Authority
WO
WIPO (PCT)
Prior art keywords
training
dtaf
configuration
module
candidate
Prior art date
Application number
PCT/CN2021/143339
Other languages
English (en)
French (fr)
Inventor
林嘉树
孙伟高
张克终
伍玮翔
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to PCT/CN2021/143339 priority Critical patent/WO2023123275A1/zh
Priority to CN202180098682.2A priority patent/CN117396851A/zh
Publication of WO2023123275A1 publication Critical patent/WO2023123275A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]

Definitions

  • the embodiments of the present application relate to the field of artificial intelligence, and more specifically, to a method, device and system for determining the configuration of a distributed training algorithm framework.
  • the distributed training method can effectively reduce the computing pressure and storage pressure of neural network model training, but because distributed training requires a large amount of information communication, the completion time of distributed training is limited to a certain extent by the communication cost in the training process.
  • the first module may be a modular technology module
  • the hyperparameters may be parameters that determine the performance of the modular technology module itself, for example, learning rate, iteration parameters, and the like.
  • different technical modules for distributed training are modularized, the obtained candidate DTAF configuration is used for model training, and the training completion time of the candidate DTAF configuration is fed back, and the training is completed according to the candidate DTAF configuration Time and the training completion time of the original first DTAF configuration to determine whether to update the original first DTAF configuration, forming a closed-loop process of DTAF configuration self-adaptation.
  • the optimal distributed training algorithm framework configuration can be flexibly and automatically searched without expert experience.
  • the initial DTAF configuration is used as an input of the search algorithm, and the DTAF configuration obtained after searching for a preset search time is determined as a candidate DTAF configuration.
  • the preset search time can be understood as the search time that takes the initial DTAF configuration as the starting point of the search algorithm to obtain candidate DTAF configurations, that is, within the preset search time, with the initial DTAF configuration as the starting point of the search algorithm, it can be obtained
  • candidate DTAF configurations that is, within the preset search time, with the initial DTAF configuration as the starting point of the search algorithm, it can be obtained
  • the last second DTAF configuration is determined as a candidate DTAF configuration.
  • the method further includes: performing multiple iterative updates to the first DTAF configuration, and the iterative update includes: using the first DTAF configuration as an input of a search algorithm, and performing a random search to obtain a new candidate DTAF Configuration; distribute new candidate DTAF configuration to iterative processor, to obtain new second training time, new second training time is the corresponding training completion time of new candidate DTAF configuration; According to new second training time and first During training time, determine whether to update the first DTAF configuration.
  • the optimized DTAF configuration is updated through multiple iterations, and the quality of the optimized DTAF configuration can be improved.
  • the search algorithm includes a Markov Chain Monte Carlo MCMC method.
  • the first asynchronous training selection block is the asynchronous training selection block of the internal training cycle of the working node.
  • the asynchronous training of the internal training cycle of the working node is enabled, that is, the internal training cycle of the working node , different iterative processors can perform asynchronous training.
  • the second asynchronous training selection block is an asynchronous training selection block for an external training cycle between different working nodes, and when the candidate DTAF configuration includes the second asynchronous training selection block, the external training cycle between different working nodes is enabled
  • Asynchronous training of that is, iterative processors between different worker nodes can perform asynchronous training.
  • the modularized asynchronous training selection block makes it possible to automatically select whether to include the asynchronous training selection block in the process of determining the candidate DTAF configuration, instead of artificially deciding whether to use synchronous training or asynchronous training.
  • Asynchronous training can reduce synchronization During training, wait for the idle implementation of Straggler to improve the utilization rate of computing power.
  • the second module further includes a backpropagation random freeze module, and the backpropagation random freeze module is used to stop the backpropagation calculation.
  • a device for determining the configuration of a distributed training algorithm framework is provided, the device is applied to a data processor, and the device includes an acquisition module, an allocation module, and a determination module: the acquisition module is used to obtain a candidate distributed training algorithm framework DTAF configuration, the candidate DTAF configuration includes at least one first module and at least one hyperparameter corresponding to each first module; the allocation module is used to assign the candidate DTAF configuration to the iterative processor, and the candidate DTAF configuration is used for the iterative processor to perform Model training; the acquisition module is also used to obtain the second training time, and the second training time is the corresponding training time based on the candidate DTAF configuration to complete the model training; the determination module is used to determine whether to Updating the first DTAF configuration, wherein the first training time is the training time corresponding to the completion of model training based on the first DTAF configuration.
  • the first module may be a modular technology module
  • the hyperparameters may be parameters that determine the performance of the modular technology module itself, for example, learning rate, iteration parameters, and the like.
  • completing the model training based on the candidate DTAF configuration can be understood as that the model to be trained is trained according to the first module in the candidate DTAF configuration and the hyperparameters corresponding to the first module.
  • the device further includes an updating module, if the second training time is less than the first training time, the updating module is used to update the candidate DTAF configuration to the first DTAF configuration; if the second training time is greater than or Equal to the first training time, the determining module is used to determine not to update the first DTAF configuration.
  • the obtaining module is specifically configured to use the first DTAF configuration as an input of a search algorithm to obtain a candidate DTAF configuration; wherein the search algorithm is used to search the search space, wherein the search space includes at least A second module and at least one hyperparameter corresponding to each second module, and at least one first module is obtained by searching from at least one second module.
  • the obtaining module is specifically configured to, when the first DTAF configuration is an initial DTAF configuration, use a DTAF configuration obtained after a preset search time search as a candidate DTAF configuration.
  • the preset search time can be understood as the search time that takes the initial DTAF configuration as the starting point of the search algorithm to obtain candidate DTAF configurations, that is, within the preset search time, with the initial DTAF configuration as the starting point of the search algorithm, it can be obtained
  • candidate DTAF configurations that is, within the preset search time, with the initial DTAF configuration as the starting point of the search algorithm, it can be obtained
  • the last second DTAF configuration is determined as a candidate DTAF configuration.
  • the DTAF configuration after the preset search time search is determined as the candidate DTAF configuration, which can improve the accuracy of the initial determination of the candidate DTAF configuration, thereby reducing the number of iterations to obtain the optimized DTAF configuration , and improve the quality of optimized DTAF configurations.
  • the device further includes a search module: the update module is further configured to perform multiple iterative updates to the first DTAF configuration, and the iterative update includes: the search module is configured to use the first DTAF configuration as a search algorithm The input of is to perform a random search, so that the acquisition module obtains a new candidate DTAF configuration; the distribution module is also used to assign a new candidate DTAF configuration to the iterative processor, so as to obtain a new second training time, a new second training time Configure the corresponding training completion time for the new candidate DTAF; the determination module is also used to determine whether to update the first DTAF configuration according to the new second training time and the first training time.
  • the update module is further configured to perform multiple iterative updates to the first DTAF configuration, and the iterative update includes: the search module is configured to use the first DTAF configuration as a search algorithm The input of is to perform a random search, so that the acquisition module obtains a new candidate DTAF configuration; the distribution module is also used to assign
  • the first asynchronous training selection block is the asynchronous training selection block of the internal training cycle of the working node.
  • the asynchronous training of the internal training cycle of the working node is enabled, that is, the internal training cycle of the working node , different iterative processors can perform asynchronous training.
  • the second module further includes a backpropagation random freeze module, and the backpropagation random freeze module is used to stop the backpropagation calculation.
  • the second module further includes a new optimizer module, and the new optimizer module is used to update the local model parameters of the working nodes.
  • the gradient vector after the Powerball function can accelerate the entire training process.
  • a system for determining the configuration of a distributed training algorithm framework includes a data processor and an iterative processor: the data processor is used to obtain a candidate distributed training algorithm framework DTAF configuration, and the candidate DTAF configuration includes at least one At least one hyperparameter corresponding to the first module group and each first module group; the data processor is used to assign the candidate DTAF configuration to the iterative processor, and the candidate DTAF configuration is used for the iterative processor to perform model training; the data processor is used to, from The iteration processor obtains the second training time, and the second training time is the training time corresponding to completing the model training based on the candidate DTAF configuration; the data processor is used to determine whether to update the first DTAF configuration according to the second training time and the first training time, Wherein, the first training time is the training time corresponding to the completion of model training based on the first DTAF configuration.
  • the data processor may be a central processing unit CPU, and the iteration processor may be an image processor GPU, or an embedded neural network processor NPU.
  • the first module may be a modular technology module
  • the hyperparameters may be parameters that determine the performance of the modular technology module itself, for example, learning rate, iteration parameters, and the like.
  • completing the model training based on the candidate DTAF configuration can be understood as that the model to be trained is trained according to the first module in the candidate DTAF configuration and the hyperparameters corresponding to the first module.
  • different technical modules for distributed training are modularized, the obtained candidate DTAF configuration is used for model training, and the training completion time of the candidate DTAF configuration is fed back, and the training is completed according to the candidate DTAF configuration Time and the training completion time of the original first DTAF configuration to determine whether to update the original first DTAF configuration, forming a closed-loop process of DTAF configuration self-adaptation.
  • the optimal distributed training algorithm framework configuration can be flexibly and automatically searched without expert experience.
  • the data processor is specifically configured to use the first DTAF configuration as an input of a search algorithm to obtain a candidate DTAF configuration; wherein the search algorithm is used to search a search space, wherein the search space includes At least one second model group and at least one hyperparameter corresponding to each second model group, and at least one first model group is obtained by searching from at least one second model group.
  • the second module is the technology module to be used for the candidate DTAF configuration.
  • the preset search time can be understood as the search time that takes the initial DTAF configuration as the starting point of the search algorithm to obtain candidate DTAF configurations, that is, within the preset search time, with the initial DTAF configuration as the starting point of the search algorithm, it can be obtained
  • candidate DTAF configurations that is, within the preset search time, with the initial DTAF configuration as the starting point of the search algorithm, it can be obtained
  • the last second DTAF configuration is determined as a candidate DTAF configuration.
  • the iterative processor performs an internal training cycle of working nodes and an external training cycle between different working nodes according to the candidate DTAF configuration.
  • the iterative processor is specifically configured to, according to the third module in the candidate DTAF configuration and at least one hyperparameter in the third module, perform a training cycle inside the working node to obtain the local Model gradient: passing the local model gradient of the working node to the data processor; the data processor is specifically used to obtain updated local model parameters according to the local model gradient of the working node.
  • the third module is a technical module that performs a training cycle inside the working node.
  • the iterative processor can pass the local model gradient to the data processor through the bus.
  • the data processors of different working nodes are used to transfer the updated local model parameters to the respective iterative processors of different working nodes; the iterative processors of different working nodes are used to update the updated Any one of the iterative processors of different working nodes is used to pass the reduced local model parameters to any one of the data processors of different working nodes, so as to update the global model parameters.
  • any one of the iterative processors of different working nodes is used to transmit the reduced local model parameters to the data processor in the parameter server, so as to update the global model parameters.
  • the communication frequency in the distributed training process can be greatly reduced, thereby improving the training efficiency.
  • the second module includes a first asynchronous training selection block
  • the first asynchronous training selection block is used to enable the asynchronous training of the training loop inside the working node
  • the first asynchronous training selection block includes staleness-sensitive knowledge module, distance perception module or global momentum module.
  • the first asynchronous training selection block is the asynchronous training selection block of the internal training cycle of the working node.
  • the asynchronous training of the internal training cycle of the working node is enabled, that is, the internal training cycle of the working node , different iterative processors can perform asynchronous training.
  • the second module further includes a second asynchronous training selection block, the second asynchronous training selection block is used to enable the asynchronous training mode of the external training cycle between different working nodes, the second asynchronous training Choice blocks include staleness-aware modules, distance-aware modules, or global momentum modules.
  • the modularized asynchronous training selection block makes it possible to automatically select whether to include the asynchronous training selection block in the process of determining the candidate DTAF configuration, instead of artificially deciding whether to use synchronous training or asynchronous training.
  • Asynchronous training can reduce synchronization During training, wait for the idle implementation of Straggler to improve the utilization rate of computing power.
  • the new optimizer module is a Powerball base optimizer set.
  • the gradient vector after the Powerball function can accelerate the entire training process.
  • Fig. 4 is a schematic diagram of the types of distributed training methods provided by the embodiment of the present application.
  • Fig. 5 is a schematic diagram of a configuration method for determining a distributed training algorithm framework provided by an embodiment of the present application
  • FIG. 7 is a flow chart of another method for determining the configuration of the distributed training algorithm framework according to the embodiment of the present application.
  • Fig. 8 is a flow chart of the internal cycle of a working node in the embodiment of the present application.
  • FIG. 9 is a schematic diagram of the protocol method provided by the embodiment of this application.
  • FIG. 10 is a schematic diagram of an apparatus for configuring a frame of a determined distributed training algorithm provided by an embodiment of the present application.
  • deep learning is a learning technique based on deep neural network algorithms.
  • the deep learning model includes an input layer, a hidden layer, and an output layer, which use multiple nonlinear transformations to process data.
  • a neural network is a behavioral feature that imitates animal neural networks. This network relies on the complexity of the system to achieve the purpose of processing information by adjusting the interconnection relationship between a large number of internal nodes.
  • a deep neural network can be understood as a neural network with multiple hidden layers, and the "multiple” here has no special metric. Theoretically speaking, a model with more parameters has a higher complexity and a greater “capacity”, which means that it can complete more complex learning tasks. Training the deep neural network is the process of learning the weight matrix, and its ultimate goal is to obtain the weight matrix of all layers of the trained deep neural network (the weight matrix is the weight of each layer of neurons in the deep learning model).
  • FIG. 1 is a schematic block diagram of a deep learning model 100 provided by an embodiment of the present application.
  • the deep learning model 100 may include an input layer 110 , a hidden layer 120 and an output layer 130 .
  • the hidden layer 120 includes n (n is greater than 1) layers of neurons as an example for illustration.
  • each of the input layer 110, output layer 130, and hidden layer 120 includes one or more neurons.
  • the input layer 110 includes two neurons
  • each of the n layers in the hidden layer 120 includes three neurons
  • the output layer 130 includes one neuron as an example for illustration.
  • the deep learning model 100 shown in FIG. 1 may be a fully connected neural network, or a convolutional neural network (CNN).
  • CNN convolutional neural network
  • the deep learning model 100 is a fully connected neuron network model.
  • the deep learning model 100 is a CNN model.
  • the deep learning model 100 may include forward propagation (forward propagation, FP) calculation and back propagation (back propagation, BP) calculation.
  • forward propagation forward propagation
  • BP back propagation
  • the training data such as the pixel information of the input image
  • the training data is used as the input (i 1 , i 2 ) of the input layer 110 of the deep learning model 100 .
  • the input of the input layer 110 may output a prediction result from the output layer 130 after passing through multiple neurons in the hidden layer 120 .
  • each layer of neurons in the hidden layer 120 corresponds to a weight matrix.
  • the product of the input of the input layer 110 and the weight matrix of the neurons of the first layer is used as the input of the neurons of the first layer of the hidden layer 120, and the input of the neurons of the first layer of the hidden layer 120 passes through the neurons of the first layer
  • the activation function (for example, it can be a sigmoid function) then outputs the output value of a layer 1 neuron.
  • the product of the output value of the neuron in the first layer of the hidden layer 120 and the weight matrix of the neuron in the second layer is used as the input of the neuron in the second layer of the hidden layer 120 .
  • a prediction result is finally output from the output layer 130 .
  • weight values in these weight matrices need to be corrected in a large amount of training in practical applications, and each weight matrix formed by the weight values obtained through training can extract pixel information from the image to be inferred input by the user, thereby helping the deep learning model 100 Perform correct inference on the image to be inferred.
  • the weight matrix of each layer in the deep learning model 100 can be updated according to the difference between the current predicted value and the prior knowledge (of course, there is usually an initialization process before the first update , which is to initialize the weight matrix corresponding to each layer of neurons in the hidden layer 120 of the deep learning model 100).
  • the error BP algorithm is used to correct the weight parameter size of the weight matrix in the deep learning model 100 in the process of training the deep learning model 100, so that the error loss of the deep learning model 100 becomes smaller and smaller.
  • BP calculation is an error-led reverse movement, aiming to obtain the optimal model parameters, that is, the weight matrix of neurons in each layer.
  • BP calculation can calculate the error E between the output prediction value o 1 and the prior knowledge.
  • the weight parameters in the weight matrix of neurons in each layer of the deep learning model 100 can be corrected according to the error E.
  • the correction to the weight parameters may be to calculate the gradients of the weight parameters in the weight matrix respectively, and the gradient may be to calculate derivatives of the weight parameters in the weight matrix by using a loss.
  • the above-mentioned deep learning model 100 training process (including FP calculation process and BP calculation process) can be completed in a training system including at least one working node.
  • the at least one working node may be at least one model training server.
  • the distributed training system of the deep learning model 100 and the types of distributed training methods will be described below with reference to FIGS. 2 to 4 .
  • FIG. 2 is a schematic structural diagram of a distributed training system 200 for a deep learning model 100 provided by an embodiment of the present application.
  • the distributed training system 200 shown in FIG. 2 may include a model training server 210 , a model training server 220 , a model training server 230 , a parameter server 240 , and a cloud storage 250 .
  • the distributed training system 200 may include at least one model training server, where one model training server may serve as a working node.
  • one model training server may serve as a working node.
  • three model training servers are taken as examples in FIG. 2 for illustration.
  • the structure of the model training server 220 and the model training server 230 is similar to that of the model training server 210 , and the model training server 210 will be described in detail below.
  • It includes: at least one processor, a memory 213 , an input and output interface 214 , a communication interface 215 , and a bus 216 .
  • At least one processor may be connected to the memory 213 .
  • the memory 213 can be used to store the program code and training data.
  • the memory 213 may be an internal storage unit of at least one processor, or an external storage unit independent of at least one processor, or may include a storage unit internal to at least one processor and an external storage unit independent of at least one processor. Parts of the storage unit.
  • the memory 213 can be a solid state disk (solid state drive, SSD), also can be a hard disk drive (hard disk drive, HDD), can also be a read-only memory (read-only memory, ROM), random access memory (random access memory) , RAM) etc.
  • SSD solid state drive
  • HDD hard disk drive
  • ROM read-only memory
  • RAM random access memory
  • the at least one processor can obtain program codes and training data from the memory 213 and train the deep learning model 100 .
  • at least one processor can perform iterative calculations according to the program code and training data (for example, perform FP calculations and BP calculations as shown in Figure 1), and in the distributed training system 200, the BP calculation
  • the gradients of the weight parameters in the obtained weight matrix are sent (push) to the parameter server 240 .
  • At least one processor may include two types of processors. Wherein, one type of processor includes at least one data processor 211 , and the other type of processor includes at least one iterative processor 212 .
  • the data processor 211 can be a central processing unit (central processing unit, CPU)
  • the iterative processor 212 can be an embedded neural network processor (neural-network process units, NPU), and can also be an image Processor (graphics processing unit, GPU).
  • the model training server 210 may also include a bus 216 .
  • the memory 213 , the input/output interface 214 , and the communication interface 215 may be connected to at least one processor (for example, the data processor 211 and the iterative processor 212 ) through the bus 216 .
  • the bus 216 may be a peripheral component interconnect standard (peripheral component interconnect, PCI) bus or an extended industry standard architecture (extended industry standard architecture, EISA) bus or the like.
  • PCI peripheral component interconnect
  • EISA extended industry standard architecture
  • the bus 216 can be divided into address bus, data bus, control bus and so on. For ease of representation, only one line is used in FIG. 2 , but it does not mean that there is only one bus or one type of bus.
  • It includes: at least one data processor 241 , a memory 243 , an input and output interface 244 , a communication interface 245 , and a bus 246 .
  • the parameter storage space in the memory 243 may store gradients of weight parameters sent by the model training server 210 , the model training server 220 , and the model training server 230 respectively.
  • At least one data processor 241 may be connected to the memory 243, and the data processor 241 may be, for example, a CPU. At least one data processor 241 can obtain the gradients sent by the model training server 210, the model training server 220, and the model training server 230 respectively from the memory 243, process the multiple gradients pushed by multiple model training servers through the processor, and can The gradient average value after processing is stored in the memory 243 . As an example, at least one data processor 241 may perform weighted average calculation on multiple gradients pushed by multiple model training servers, and store the average value of the gradients in the memory 243 .
  • the data processor 241 in the parameter server 240 calculates the average value of the gradient during one iteration, in the calculation of FP in the next iteration, it is necessary to correct the second time FP according to the average value of the gradient.
  • the weight matrix is iterated, and the weight matrix is stored in the parameter storage space of the memory 243 for the model training server 210, the model training server 220, and the model training server 230 to use in the next round of training.
  • the parameter server 240 may further include an iterative processor 242, and the iterative processor 242 may run the deep learning model 100 therein.
  • the iterative processor 242 may be an NPU or a GPU.
  • the system 200 may further include a cloud storage 250 .
  • the cloud storage 250 can serve as an external storage on which the user can store program codes and training data.
  • the model training server 210 at least one processor can first store the program code and data stored in the cloud storage 250 in the storage 213 during operation, so that at least one process can obtain the program code and training from the storage 213. data, and the deep learning model 100 can be trained according to the program code and training data.
  • the data stored in the cloud storage 250 may be the training data of the model, the prior knowledge corresponding to the training data, and the weight matrix corresponding to the neurons of each layer in the hidden layer 120 of each model 100 initial value, etc.
  • Distributed training methods can be implemented in two ways, namely data parallelization and model parallelization.
  • Data parallelization is to divide the training data of the deep learning model into different subsets and assign them to different working nodes in the distributed training system. Each working node has a copy of the deep learning model. Training is performed on worker nodes.
  • Model parallelization is to divide the architecture of the deep learning model into different working nodes to realize the distribution of training.
  • the method for determining the structure of the distributed training algorithm proposed in the embodiment of the application can be applied to the distributed training of data parallelization, and can also be applied to the distributed training of model parallelization. This application does not limit this. For the sake of illustration, the following The scenario of distributed training with data parallelization is taken as an example to illustrate.
  • Figure 4 shows two data-parallel distributed training methods, namely a synchronous training method and an asynchronous training method.
  • the two distributed training methods shown in FIG. 4 can both be applied to the distributed training structure shown in FIG. 2 .
  • the synchronous training method and the asynchronous training method will be specifically described below in conjunction with FIG. 4 .
  • Figure 4 (a) is a synchronous distributed training method.
  • the training data is divided into multiple subsets.
  • training is performed on different working nodes at the same time to obtain different gradients and send them to the parameter server.
  • the parameter server waits for all the working nodes to return the gradients, then reduces the different gradients (allreduce), updates the model parameters according to the reduced gradients, and sends the updated parameters to different working nodes. Similar to the first iteration, multiple iterations are performed.
  • the abscissa represents time t
  • the ordinate represents different working nodes
  • different working nodes can be different model training servers in Figure 2, and different working nodes process multiple subsets.
  • different working nodes 1 perform model training at the same time t1 at the same time.
  • working node 1 takes the longest time to train and calculate the gradient, and does not transmit its own gradient to the parameter server until time t2.
  • the parameter The server needs to wait until the gradients of all working nodes are passed to itself before starting gradient reduction.
  • (b) in Figure 4 is an asynchronous distributed training method.
  • the training data is divided into multiple subsets, and different working nodes independently calculate their own gradients.
  • the parameter server obtains the gradient transmitted by a certain working node, it immediately updates the model parameters.
  • the updated model parameters are transmitted to the working node, different working nodes perform multiple iterations.
  • the gradient is transmitted to the parameter server, and the parameter server immediately updates the model parameters according to the gradient of the working node 1, and transmits the updated parameters to the working node 1 for the gradient of the second iteration starting from time t'3 calculate.
  • Gradient calculation and model parameter update are performed independently between different working nodes.
  • asynchronous training method is only applicable to the distributed training system 200 deployed centrally.
  • Round One round means one forward propagation and one backpropagation of all training samples.
  • the BERT model is a self-encoding language model that can extract relational features in sentences at the same time, and can extract relational features at multiple levels to fully reflect sentence semantics.
  • the model has many parameters and a large model, and a large amount of training data is required for training.
  • ResNet50 50-layer residual network
  • the residual network model is a convolutional neural network. This model is easy to optimize and can improve accuracy by increasing considerable depth. This model also requires a large amount of training data. The training computation of the BERT model is much larger than that of the ResNet50 model.
  • Distributed training can alleviate the running pressure and storage pressure of large model and large data set model training on a single device, but the communication between different devices undertaking distributed training tasks affects the completion time of distributed training.
  • the parameter server needs to wait for all the working nodes to return their respective gradients, and then perform gradient reduction, that is, the working node (straggler) with the slowest training speed determines the
  • the update speed of the iterative model parameters affects the completion time of the distributed training of the entire model.
  • the number of communications between different devices undertaking distributed training tasks and the communication cost of each communication also affect the completion time of distributed training.
  • the technical means to speed up the convergence speed of the model is mainly to use layer-wise adaptive methods, for example, layer-wise adaptive learning rate scaling (layer-wise adaptive rate scaling, LARS) and layer-wise adaptive moments for batch (LAMB).
  • LARS layer-wise adaptive learning rate scaling
  • LAMB layer-wise adaptive moments for batch
  • a model parameter synchronization between different working nodes is performed to reduce the frequency of communication between different working nodes, that is, to reduce the number of communications between different devices.
  • QSGD quantized stochastic gradient descent
  • topK elements top K elements
  • the embodiment of the present application provides a method, device and system for determining the configuration of the distributed training algorithm framework to solve the above problems.
  • the solution of the embodiment of the present application will be described in detail below with reference to FIG. 5 to FIG. 10 .
  • FIG. 5 is a schematic diagram of a method for configuring a framework for determining a distributed training algorithm provided by an embodiment of the present application.
  • FIG. 5 will be described in detail below.
  • the data processor obtains a candidate distributed training algorithm framework (distributed training algorithm framework, DTAF) configuration, where the candidate DTAF configuration includes at least one first module and at least one hyperparameter corresponding to each first module.
  • DTAF distributed training algorithm framework
  • the distributed training algorithm framework configuration includes modular distributed training technology modules and/or technology blocks, and hyperparameters corresponding to technology modules and/or technology blocks, for example, standard forward propagation modules, standard inverse Direct propagation module, gradient quantization compression module, etc.
  • standard forward propagation modules for example, standard forward propagation modules, standard inverse Direct propagation module, gradient quantization compression module, etc.
  • standard inverse Direct propagation module for example, standard inverse Direct propagation module
  • gradient quantization compression module etc.
  • the first DTAF configuration is used as an input of the search algorithm to obtain candidate DTAF configurations; wherein the search algorithm is used to search the search space, wherein the search space includes at least one second module and each At least one hyperparameter corresponding to the second module group, at least one first module group is obtained by searching from at least one second module group.
  • the first DTAF configuration may be an initial DTAF configuration, or a DTAF configuration of a previous round of distributed model training, which is not limited in this embodiment of the present application.
  • the second module is the technology module to be used for the candidate DTAF configuration.
  • obtaining a candidate DTAF configuration can be understood as a DTAF configuration generated according to the first module searched in the search space and at least one corresponding hyperparameter.
  • the at least one second module included in the search space can be understood as a modular technology module, and each technology module can realize the same function or different functions.
  • N second modules in at least one second module can form the first technical block, N is a positive integer, wherein the second modules belonging to the first technical block can be used to realize the same function.
  • the search space can be understood as including two dimensions, the first dimension is at least one second module, and the other dimension is the hyperparameters corresponding to each second module.
  • the second module can be used in the first DTAF configuration, or not used in the first DTAF configuration.
  • the first module used in the candidate DTAF configuration and the hyperparameters corresponding to each first module are searched out from the search space through a search algorithm.
  • the data processor allocates the candidate DTAF configuration to an iterative processor, where the candidate DTAF configuration is used by the iterative processor to perform model training.
  • the data processor acquires a second training time, where the second training time is the training time corresponding to the completion of model training based on the candidate DTAF configuration.
  • the data processor determines whether to update the first DTAF configuration according to the second training time and the first training time acquired in S530, wherein the first training time is the training time corresponding to the completion of model training based on the first DTAF configuration.
  • the candidate DTAF configuration is updated to the first DTAF configuration; when the second training time is greater than or equal to the first training time, the first DTAF configuration is not updated .
  • the first DTAF configuration is used as an input of the search algorithm to directly obtain candidate DTAF configurations.
  • the first DTAF configuration C is not updated, and based on the first DTAF configuration, the MCMC search algorithm is used to perform a random search in the search space to generate New candidate DTAF configuration.
  • the specific implementation method can be to transform the cost function into a probability function, such as formula (1):
  • is a constant
  • p(C) is the target distribution of candidate DTAF configurations obtained by taking the first DTAF configuration as the input of the MCMC search algorithm.
  • the candidate DTAF configuration C * is less likely to achieve the target distribution than the original first DTAF configuration C, that is, p(C * ) ⁇ p(C)
  • the candidate DTAF configuration C * also has a chance to be retained, and the candidate DTAF The probability that configuration C * is retained is p(C * )/p(C) ⁇ 1.
  • UCB can be viewed as a weighted sum of predicted value and uncertainty. When the weights are small, UCB can easily help select samples with lower expected values. When the value of the acquisition function is large, it is more likely to select samples with greater uncertainty.
  • acquisition functions such as expected improvement (EI), probability of improvement (PI), entropy search (ES), and Thompson sampling (TS), among others. Extensive research has shown that combinations of several acquisition functions are also possible. To summarize, BO builds an initial surrogate model using a set of randomly sampled datasets.
  • the model distributed training using the candidate DTAF configuration is mainly divided into two-dimensional loops, which are the internal loop of S631 working nodes and the loop between different working nodes in S632.
  • one working node corresponds to one model training server
  • the iterative processor in one working node may include M cards
  • the iterative processor is a GPU, that is, M GPUs.
  • each GPU has the same training model, and each GPU performs model training according to different training data, where M is a positive integer, for example, M can be 4, 8 or 16, This application is not limited to this.
  • forward propagation can be standard forward propagation (normal forward propagation, normal FP), or forward propagation based on random elimination (forward propagation with dropout, FP with Dropout), or Other forward propagation schemes are not limited in this embodiment of the present application.
  • the training model is backpropagated in the iterative processor according to the error between the prediction result in S6311 and the prior knowledge, and the gradient of the weight parameters of different model layers is calculated.
  • backpropagation can be standard backpropagation (normal backward propagation, normal BP) or random frozen backpropagation (backward propagation with randomly freeze, BP with randomly freeze) or other reverse propagation.
  • normal backward propagation normal BP
  • random frozen backpropagation backward propagation with randomly freeze, BP with randomly freeze
  • the direction propagation scheme is not limited in this embodiment of the present application.
  • the random freeze backpropagation will be described in detail later, and will not be repeated here.
  • the gradient reduction can be all reduce, no reduce, pushsum reduce, etc., which is not limited in this application.
  • Gradient reduction can also be called gradient aggregation, or gradient integration.
  • the different protocol modes will be described in detail later with reference to FIG. 10 , and details are not repeated here.
  • the data processor locally updates the model parameters according to the reduced gradient.
  • the data processor updates the model parameters locally according to the gradient after this internal loop S6313 specification and the local model parameters of the previous internal loop
  • steps S6311 to S6315 may perform asynchronous training on different internal working nodes.
  • different iterative processors do not perform asynchronous training. That is, when the gradient reduction method in S6313 is other than no reduction method, inside the working node, different iterative processors can perform asynchronous training, that is, the candidate DTAF configuration includes the asynchronous training selection of the internal training cycle of the working node block and its hyperparameters.
  • asynchronous training selection block of the internal training cycle of the working node may also be called the first asynchronous training selection block, and may have other names, which are not limited in this embodiment of the present application.
  • the outer loop between different working nodes is after the inner loop on a single working node ends, and the steps executed by the data processor can be executed by the data processor of the parameter server, or by any specified A data processor of a worker node to execute.
  • the data processor of the parameter server it is the data processor of the parameter server to execute; for a distributed training system with decentralized deployment, you can arbitrarily specify a certain working node, that is, the data in a certain model training server
  • the processor performs the execution, which is not limited in this embodiment of the present application.
  • the external loop between different working nodes to update the global model parameters may include the following steps:
  • GPU as an iterative processor as an example
  • their respective GPUs used for model parameter reduction among different work nodes are GPU1 of work node 1, work GPU2 on node 2, GPU1 on worker node 3, and GPU2 on worker node 4.
  • the number of GPUs in different working nodes here is just an example, and may be any GPU in the working node, which is not limited in this embodiment of the present application.
  • the data processor calculates the momentum of different working nodes, so as to correct the update direction of model parameters on different working nodes.
  • the data processor calculates and updates this external cycle according to the momentums of different working nodes calculated in the last external cycle, the model parameters after S6321 reduction in the last external cycle, and the model parameters after S6321 reduction in this external cycle.
  • Cycle the momentum of different working nodes, the specific update formula (4) is as follows:
  • parent_monen(j-1) is the momentum of different working nodes calculated in the last outer loop
  • reduce_param(j) is the model parameter after S6321 reduction in this outer loop
  • reduce_param(j-1) is the last outer loop
  • the data processor updates the global model parameters according to the momentums of different working nodes updated in S6322.
  • the data processor updates the global model parameters according to the global model parameters updated in the last external loop and the momentums of different working nodes after S6322 update in this external loop, and the specific update formula is as follows:
  • parent_param(j) param_update(parent_param(j-1),parent_momen(j)) (5)
  • parent_param(j-1) is the global model parameter updated in the last external loop
  • parent_momen(j) is the momentum of different working nodes after S6322 update in this external loop.
  • steps S631 to S6324 may perform asynchronous training among different working nodes.
  • the iterative processors between different working nodes do not perform asynchronous training. That is, when the protocol mode in S6321 is other than no protocol, iterative processors between different working nodes can perform asynchronous training, that is, the candidate DTAF configuration includes the external training cycle between different working nodes Asynchronous training modules and their hyperparameters.
  • asynchronous training selection block of the outer training cycle between different working nodes may also be called a second asynchronous training selection block, and may have other names, which are not limited in this embodiment of the present application.
  • the second asynchronous training selection block as a technical block to be selected in the external training cycle between different working nodes, may be in the candidate DTAF configuration or not in the candidate DTAF configuration , which depends on how the local model parameters of different working nodes are reduced during the external loop between different working nodes. That is, when the candidate DTAF configuration includes the second asynchronous training selection block, the asynchronous training of the outer training loop between different working nodes is enabled, that is, the iterative processors between different working nodes can perform asynchronous training.
  • asynchronous training selection block makes it possible to automatically select whether to include the asynchronous training selection block in the process of determining the candidate DTAF configuration, instead of artificially deciding whether to use synchronous training or asynchronous training.
  • Asynchronous training can reduce the idle time of waiting for Straggler in synchronous training and improve Computing power utilization.
  • the communication frequency in the distributed training process can be greatly reduced, thereby improving the training efficiency.
  • Figure 8 only shows some technical modules or technical blocks that can be used for candidate DTAF configurations during the internal training cycle of the working node.
  • other technical modules or technology blocks that can be used for candidate DTAF configurations
  • the blocks are embodied in the embodiments of the present application by way of example.
  • the forward propagation module in S6311 can be a standard forward propagation module, a standard forward propagation module, or other forward propagation modules based on random elimination. This application implements Examples are not limited to this.
  • the backpropagation module in S6312 may be a standard backpropagation module, or other backpropagation modules such as a random frozen backpropagation module, which is not limited in this embodiment of the present application.
  • Random freezing backpropagation is to randomly select a layer in the neural network as the starting layer to start and stop backpropagation, and stop the gradient calculation and parameter update during the backpropagation process between this layer and the transmission layer, thereby reducing the backpropagation. It increases the training throughput while propagating the amount of computation, thereby accelerating the training speed of the neural network.
  • the hyperparameter of the random freezing backpropagation technology module is a probability value ⁇ , and the probability value ⁇ determines whether random freezing is enabled. If the candidate DTAF configuration includes the random freezing backpropagation technology module and its hyperparameter probability value ⁇ , when the candidate DTAF configuration is used for model training, the random freezing of a certain layer in the model is enabled with the probability ⁇ , then from this A layer starts to stop the backpropagation calculation between this layer and the transmission layer, and updates the parameters of each layer that have been backpropagated; if the random freezing is not enabled with the probability of 1- ⁇ , then the backpropagation of any neural network layer is not Make any changes to Propagation.
  • S6317 can also be performed.
  • Different GPUs on the iterative processor will perform gradient quantization and compression on the gradients obtained by back propagation in S6312, so as to reduce the difference between different GPUs on the iterative processor after S6312. Gradient communication data volume.
  • the modular gradient quantization compression module can be marked stochastic gradient descent (sign stochastic gradient descent, SignSGD), 1-bit stochastic gradient descent (1-bit stochastic gradient descent, 1-bit SGD), Other gradient quantization compression modules such as ternary gradients (TernGrad), quantized stochastic gradient descent (QSGD), etc., are not limited in this embodiment of the present application.
  • SignSGD compresses each element in the gradient vector to 0 or 1; SignSGD compresses each element in the gradient vector to -1 or 1; TernGrad compresses each element in the gradient vector to -1, 0 or 1; QSGD compresses each element in the gradient vector to several numerical values specified by humans, and its compression ratio can be changed by humans.
  • the hyperparameters of the modular gradient quantization compression module and the gradient sparsification compression module meet the requirement that the model training accuracy can vary within an acceptable range. Therefore, it can also be applied to model training that is sensitive to gradient accuracy.
  • All-reduce, all-reduce is the process of adding and averaging the gradients of all devices at the gradient synchronization point of all devices.
  • the traditional full protocol is that each device transmits the gradient generated by itself to other devices, so that each device can calculate the average value of the gradient by itself.
  • device A completes the process of adding and averaging the gradients of all devices by obtaining the gradients generated on device B, device C, and device D.
  • the ring full protocol is that each device divides the gradient generated by itself into n parts on average, each device is connected in a ring, and each device transfers its own k-th gradient to the next device at the same time , will receive the gradient of the k-1th share from the previous device, so as to obtain the gradient of 1/n of each device, so as to realize the effect of adding and averaging the gradients of all devices.
  • the Pushsum protocol is that each device only transmits its own gradient to some devices at a time, and after multiple transmissions, the gradient of each device is transmitted to all other devices. As shown in (c) of FIG. 9 , the gradient of device A is only transmitted to device B, device C and device E, and the gradient of device B is only transmitted to device D, device E and device F. Although only some of the devices obtain gradient information in each communication, as the number of communications increases, the gradients of all devices are communicated among all devices. This protocol can reduce the communication traffic of the gradient and ensure that the accuracy of the model does not decrease during the distributed training process.
  • the internal momentum calculation of the S6318 working node can also be performed.
  • Child_momen(i) momen_update(child_momen(i-1),grad(i)) (5)
  • child_momen(i-1) is the internal momentum of the working node in the last internal cycle
  • grad(i) is the internal gradient of the working node after the reduction by S6313 in this internal cycle.
  • the S6314 data processor performs local update of the model parameters according to the momentum of the current internal cycle S6318 and the local model parameters of the previous internal cycle, and the specific formula (6) is as follows:
  • Child_param(i) param_update(child_param(i-1),child_momen(i)) (6)
  • child_param(i-1) is the local model parameter of the last internal cycle
  • child_momen(i) is the momentum of this internal cycle.
  • the update of the local model parameters can be performed from two dimensions, namely, the type of the basic optimizer and the setting of the basic optimizer.
  • the modular basic optimizer type can be any one or more of the following types: stochastic gradient descent (SGD), adaptive momentum estimation (adaptive moment estimation, Adam), LAMB, adaptive gradient ( adaptive gradient, AdaGrad), limited-memory broyden fletcher Goldfarb shanno (L-BFGS), Nesterov accelerated adaptive moment estimation (Nadm), adaptive momentum gradient Descent (adaptive moment gradient descent, AMSGrad), root mean square propagation (root mean square propagation, RMSProp), Delta adaptive gradient (adaptive gradient delta, AdaDelta).
  • SGD stochastic gradient descent
  • adaptive momentum estimation adaptive moment estimation
  • Adam adaptive moment estimation
  • LAMB adaptive gradient
  • AdaGrad adaptive gradient
  • L-BFGS limited-memory broyden fletcher Goldfarb shanno
  • Nesterov accelerated adaptive moment estimation Nedm
  • adaptive momentum gradient Descent adaptive moment gradient descent, AMSGrad
  • root mean square propagation root mean square propagation, RMSProp
  • Delta adaptive gradient adaptive gradient delta, AdaDe
  • the modular base optimizer settings can be any one or more of the following types: Powerball, Nesterov momentum (Nesterov momentum), weight delay (weight decay), L1/L2-Norm, dynamic batch Size (dynamic batch size), momentum (momentum), learning rate schedule (learning rate schedule), learning rate decay (learning rate decay), warm-up learning rate (learning rate warm up).
  • the Powerball basic optimizer setting can also be called a new optimizer module.
  • the Powerball function in the Powerball basic optimizer setting can act on the gradient vector.
  • the variables in the function ⁇ is set to be greater than 0 and less than 1, so in this case, the value of the element whose absolute value is less than 1 in the gradient vector will be increased, and the value of the element whose absolute value is greater than 1 will be decreased, thereby changing the size of the entire gradient vector and direction.
  • the gradient vector after the Powerball function can accelerate the entire training process.
  • the intensity of the Powerball function is controlled by ⁇ , and the smaller the ⁇ , the greater the intensity of the effect.
  • the asynchronous training selection technology block may include multiple technical modules for reducing gradient lag during asynchronous training, or model parameter version lag during asynchronous training.
  • the staleness aware module obtain the staleness ⁇ k of the current iteration through simple calculation, and punish the staleness ⁇ k during the parameter update process, so as to reduce the effect of staleness on the asynchronous training accuracy.
  • gap aware module Compared with the staleness aware module, the gap aware module calculates a distance G k to replace the staleness ⁇ k , and then makes a penalty for the distance G k when updating the momentum, It can reduce the impact on asynchronous training accuracy similar to the staleness aware module.
  • the total momentum module is a combination of explicit momentum and implicit momentum, and the total momentum can be calculated by the corresponding formula.
  • the smaller the full momentum module the stronger the generalization of the asynchronous training algorithm, that is, the higher the accuracy of the model on the verification data set.
  • the full momentum is measured in real time, so that the full momentum can always be kept at a small level.
  • the full momentum module can improve the generalization accuracy of the asynchronous training algorithm.
  • the local model parameter reduction method of different working nodes is the same as the gradient reduction method in S6313 in the inner loop, so details are not described here. For details, refer to the previous description. The difference is that for the outer loop, the model parameters are reduced, while for the inner loop, the gradient is reduced.
  • the outer loop may also have an asynchronous training option technical block, wherein the asynchronous training option technical block may include similar technical modules as those included in S6316 in the inner loop.
  • the asynchronous training option technical block may include similar technical modules as those included in S6316 in the inner loop.
  • the above content is a description of the method for configuring the framework of the determined distributed training algorithm in the embodiment of the present application.
  • the apparatus for configuring the framework of the determined distributed training algorithm in the embodiment of the present application will be described below with reference to FIG. 10 . It should be understood that the device described below can execute the method of the aforementioned embodiment of the present application. In order to avoid unnecessary repetition, repeated descriptions are appropriately omitted when introducing the device of the embodiment of the present application below.
  • FIG. 10 is a schematic diagram of a configuration device for determining a distributed training algorithm framework provided by an embodiment of the present application.
  • the obtaining module 1030 is used to obtain the candidate DTAF configuration of the distributed training algorithm framework, the candidate DTAF configuration includes at least one first module and at least one hyperparameter corresponding to each first module; the distribution module 1020 is used to distribute the candidate DTAF configuration For the iterative processor, the candidate DTAF configuration is used for the iterative processor to perform model training; the acquisition module is also used to obtain the second training time, and the second training time is the training time corresponding to the model training based on the candidate DTAF configuration; the determination module 1040 uses Therefore, it is determined whether to update the first DTAF configuration according to the second training time and the first training time, wherein the first training time is the training time corresponding to the completion of model training based on the first DTAF configuration.
  • the device may also include an updating module 1050, if the second training time is less than the first training time, the updating module 1050 is used to update the candidate DTAF configuration to the first DTAF configuration; if the second training time is greater than or equal to the first training time A training time, the determining module 1040 is configured to determine not to update the first DTAF configuration.
  • an updating module 1050 if the second training time is less than the first training time, the updating module 1050 is used to update the candidate DTAF configuration to the first DTAF configuration; if the second training time is greater than or equal to the first training time A training time, the determining module 1040 is configured to determine not to update the first DTAF configuration.
  • the obtaining module is specifically configured to use the first DTAF configuration as an input of a search algorithm to obtain a candidate DTAF configuration; wherein the search algorithm is used to search a search space, wherein the search space includes at least one second module At least one hyperparameter corresponding to each second model group, at least one first model group is obtained by searching from at least one second model group.
  • a “module” may be a software program, a hardware circuit or a combination of both to realize the above functions.
  • the hardware circuitry may include application specific integrated circuits (ASICs), electronic circuits, processors (such as shared processors, dedicated processors, or group processors) for executing one or more software or firmware programs. etc.) and memory, incorporating logic, and/or other suitable components to support the described functionality.
  • ASICs application specific integrated circuits
  • processors such as shared processors, dedicated processors, or group processors for executing one or more software or firmware programs. etc.
  • memory incorporating logic, and/or other suitable components to support the described functionality.

Abstract

本申请提供了一种确定分布式训练算法框架配置方法、装置及系统。该方法包括:获得候选分布式训练算法框架DTAF配置,将候选DTAF配置用于模型训练,并反馈候选DTAF配置的训练完成时间,根据候选DTAF配置的训练完成时间和原第一DTAF配置的训练完成时间,来确定是否对原第一DTAF配置进行更新,形成DTAF配置自适应的闭环过程。在无需专家经验的前提下,可以灵活地自动搜索最优的分布式训练算法框架配置。

Description

确定分布式训练算法框架配置方法、装置及系统 技术领域
本申请实施例涉及人工智能领域,并且更具体地,涉及一种确定分布式训练算法框架配置方法、装置及系统。
背景技术
人工智能(artificial intelligence,AI)是利用数字计算机或者数字计算机控制的机器模拟、延伸和扩展人的智能,感知环境、获取知识并使用知识获得最佳结果的理论、方法、技术及应用系统。换句话说,人工智能是计算机科学的一个分支,它企图了解智能的实质,并生产出一种新的能以人类智能相似的方式做出反应的智能机器。人工智能领域的研究包括机器人,自然语言处理,计算机视觉,决策与推理,人机交互,推荐与搜索,AI基础理论等。
在人工智能领域,通过对神经网络模型进行训练能够得到性能较优的目标神经网络模型以执行各种数据处理工作。大模型和大数据集的神经网络模型训练可以使得模型的表征能力更强,然而这对运算设备计算能力和存储能力是一种挑战。此时,分布式训练技术的产生就是为了降低神经网络模型训练的运算压力和存储压力。
分布式训练方法可以有效降低神经网络模型训练的运算压力和存储压力,但是由于分布式训练需要进行大量的信息通讯,分布式训练的完成时间在一定程度上受限于训练过程中的通信成本。目前,有很多从不同角度来减少训练中的通信成本的分布式训练方法,但是这些方法多为正交,需要基于专家经验来确定比较合适的分布式训练方法。因此,如何灵活地确定分布式训练算法框架配置是一个亟待解决的问题。
发明内容
本申请实施例提供一种确定分布式训练算法框架配置方法、装置及系统,可以对分布式训练算法框架配置进行自适应地确定,在无需专家经验的前提下获得最优的训练策略。
第一方面,提供了一种确定分布式训练算法框架配置的方法,该方法由数据处理器执行,该方法包括:获得候选分布式训练算法框架DTAF配置,候选DTAF配置包括至少一个第一模组和每个第一模组对应的至少一个超参数;分配候选DTAF配置给迭代处理器,候选DTAF配置用于迭代处理器进行模型训练;获取第二训练时间,第二训练时间为基于候选DTAF配置完成模型训练对应的训练时间;根据第二训练时间和第一训练时间,确定是否更新第一DTAF配置,其中,第一训练时间为基于第一DTAF配置完成模型训练对应的训练时间。
示例性地,数据处理器可以为中央处理单元CPU,迭代处理器可以是图像处理器GPU,还可以是嵌入式神经网络处理器NPU。
应理解,第一模组可以为模块化的技术模组,超参数可以为决定模块化技术模组自身性能的参数,例如,学习率,迭代参数等。
其中,基于候选DTAF配置完成模型训练可以理解为待训练的模型是根据候选DTAF配置中的第一模组以及第一模组对应的超参数完成的训练。
在本申请实施例中,将不同的用于分布式训练的技术模组模块化,将获得的候选DTAF配置用于模型训练,并反馈候选DTAF配置的训练完成时间,根据候选DTAF配置的训练完成时间和原第一DTAF配置的训练完成时间,来确定是否对原第一DTAF配置进行更新,形成DTAF配置自适应的闭环过程。这样,在无需专家经验的前提下,可以灵活地自动搜索最优的分布式训练算法框架配置。
在一种可能的实现方式中,根据第二训练时间和第一训练时间,确定是否更新第一DTAF配置包括:如果第二训练时间小于第一训练时间,将候选DTAF配置更新为第一DTAF配置;如果第二训练时间大于或等于第一训练时间,确定不更新第一DTAF配置。
在一种可能的实现方式中,获得候选分布式训练算法DTAF配置包括:将第一DTAF配置作为搜索算法的输入,以获得候选DTAF配置;其中,搜索算法用于对搜索空间进行搜索,其中,搜索空间包括至少一个第二模组和每个第二模组对应的至少一个超参数,至少一个第一模组为从至少一个第二模组中搜索获得的。
应理解,第二模组是待用于候选DTAF配置的技术模组。
在一种可能的实现方式中,当第一DTAF配置为初始DTAF配置时,将初始DTAF配置作为搜索算法的输入,将经过预设搜索时间搜索之后得到的DTAF配置,确定为候选DTAF配置。
其中,预设搜索时间可以理解为以初始DTAF配置为搜索算法的起点,为获得候选DTAF配置经历的搜索时间,也就是在预设搜索时间内,以初始DTAF配置为搜索算法为起点,可以获得多个第二DTAF配置,将最后一个第二DTAF配置确定为候选DTAF配置。
在本申请实施例中,根据初始DTAF配置,经过预设搜索时间搜索之后的DTAF配置确定为候选DTAF配置,可以提高初次确定候选DTAF配置的准确性,从而减少为获得优化的DTAF配置的迭代次数,并且提高优化的DTAF配置的质量。
在一种可能的实现方式中,该方法还包括:对第一DTAF配置进行多次迭代更新,迭代更新包括:将第一DTAF配置作为搜索算法的输入,进行随机搜索,以获得新的候选DTAF配置;分配新的候选DTAF配置给迭代处理器,以获得新的第二训练时间,新的第二训练时间为新的候选DTAF配置对应的训练完成时间;根据新的第二训练时间和第一训练时间,确定是否更新第一DTAF配置。
在本申请实施例中,经过多次迭代更新后的优化的DTAF配置,可以提高优化的DTAF配置的质量。
在一种可能的实现方式中,搜索算法包括马尔科夫链蒙特卡洛MCMC方法。
在一种可能的实现方式中,第二模组包括第一异步训练选择块,第一异步训练选择块用于使能工作节点内部的训练循环的异步训练,第一异步训练选择块包括陈旧性感知模组、距离感知模组或者全局动量模组。
应理解,第一异步训练选择块为工作节点内部训练循环的异步训练选择块,当候选 DTAF配置中包括第一异步训练选择块时,使能工作节点内部训练循环的异步训练,即工作节点内部,不同迭代处理器可以进行异步训练。
在一种可能的实现方式中,第二模组还包括第二异步训练选择块,第二异步训练选择块用于使能不同工作节点之间的迭代的异步训练方式,第二异步训练选择块包括陈旧性感知模组、距离感知模组或者全局动量模组。
应理解,第二异步训练选择块为不同工作节点之间的外部训练循环的异步训练选择块,当候选DTAF配置中包括第二异步训练选择块时,使能不同工作节点之间的外部训练循环的异步训练,即不同工作节点之间的迭代处理器可以进行异步训练。
在本申请实施例中,模块化的异步训练选择块,使得在确定候选DTAF配置过程中,可以自动选择是否包括异步训练选择块,而非人为决定是同步训练还是异步训练,异步训练可以减少同步训练中等待Straggler的空闲实现,提高算力的利用率。
在一种可能的实现方式中,第二模组还包括反向传播随机冻结模组,反向传播随机冻结模组用于停止反向传播计算。
在本申请实施例中,模块化的随机冻结反向传播,可以在减少反向传播计算量的同时提高训练吞吐量,进而加速神经网络训练速度。
在一种可能的实现方式中,第二模组还包括新型优化器模组,新型优化器模组用于更新工作节点内部的本地模型参数。
应理解,新型优化器模组可以为Powerball基础优化器设置。
在本申请实施例中,经过Powerball函数作用后的梯度向量能够加速整个训练过程。
第二方面,提供了一种确定分布式训练算法框架配置的装置,该装置应用于数据处理器,该装置包括获取模块、分配模块以及确定模块:获取模块用于,获得候选分布式训练算法框架DTAF配置,候选DTAF配置包括至少一个第一模组和每个第一模组对应的至少一个超参数;分配模块用于,分配候选DTAF配置给迭代处理器,候选DTAF配置用于迭代处理器进行模型训练;获取模块还用于,获取第二训练时间,第二训练时间为基于候选DTAF配置完成模型训练对应的训练时间;确定模块用于,根据第二训练时间和第一训练时间,确定是否更新第一DTAF配置,其中,第一训练时间为基于第一DTAF配置完成模型训练对应的训练时间。
示例性地,数据处理器可以为中央处理单元CPU,迭代处理器可以是图像处理器GPU,还可以是嵌入式神经网络处理器NPU。
应理解,第一模组可以为模块化的技术模组,超参数可以为决定模块化技术模组自身性能的参数,例如,学习率,迭代参数等。
其中,基于候选DTAF配置完成模型训练可以理解为待训练的模型是根据候选DTAF配置中的第一模组以及第一模组对应的超参数完成的训练。
在本申请实施例中,将不同的用于分布式训练的技术模组模块化,将获得的候选DTAF配置用于模型训练,并反馈候选DTAF配置的训练完成时间,根据候选DTAF配置的训练完成时间和原第一DTAF配置的训练完成时间,来确定是否对原第一DTAF配置进行更新,形成DTAF配置自适应的闭环过程。这样,在无需专家经验的前提下,可以灵活地自动搜索最优的分布式训练算法框架配置。
在一种可能的实现方式中,该装置还包括更新模块,如果第二训练时间小于第一训练 时间,更新模块用于,将候选DTAF配置更新为第一DTAF配置;如果第二训练时间大于或等于第一训练时间,确定模块用于,确定不更新第一DTAF配置。
在一种可能的实现方式中,获取模块具体用于,将第一DTAF配置作为搜索算法的输入,以获得候选DTAF配置;其中,搜索算法用于对搜索空间进行搜索,其中,搜索空间包括至少一个第二模组和每个第二模组对应的至少一个超参数,至少一个第一模组为从至少一个第二模组中搜索获得的。
应理解,第二模组是待用于候选DTAF配置的技术模组。
在一种可能的实现方式中,获取模块具体用于,当第一DTAF配置为初始DTAF配置时,将经过预设搜索时间搜索之后得到的DTAF配置,作为候选DTAF配置。
其中,预设搜索时间可以理解为以初始DTAF配置为搜索算法的起点,为获得候选DTAF配置经历的搜索时间,也就是在预设搜索时间内,以初始DTAF配置为搜索算法为起点,可以获得多个第二DTAF配置,将最后一个第二DTAF配置确定为候选DTAF配置。
在本申请实施例中,根据初始DTAF配置,经过预设搜索时间搜索之后的DTAF配置确定为候选DTAF配置,可以提高初次确定候选DTAF配置的准确性,从而减少为获得优化的DTAF配置的迭代次数,并且提高优化的DTAF配置的质量。
在一种可能的实现方式中,该装置还包括搜索模块:更新模块还用于,对第一DTAF配置进行多次迭代更新,迭代更新包括:搜索模块用于,将第一DTAF配置作为搜索算法的输入,进行随机搜索,以使获取模块获得新的候选DTAF配置;分配模块还用于,分配新的候选DTAF配置给迭代处理器,以获得新的第二训练时间,新的第二训练时间为新的候选DTAF配置对应的训练完成时间;确定模块还用于,根据新的第二训练时间和第一训练时间,确定是否更新第一DTAF配置。
在本申请实施例中,经过多次迭代更新后的优化的DTAF配置,可以提高优化的DTAF配置的质量。
在一种可能的实现方式中,搜索算法包括马尔科夫链蒙特卡洛MCMC方法。
在一种可能的实现方式中,第二模组包括第一异步训练选择块,第一异步训练选择块用于使能工作节点内部训练循环的异步训练,第一异步训练选择块包括陈旧性感知模组、距离感知模组或者全局动量模组。
应理解,第一异步训练选择块为工作节点内部训练循环的异步训练选择块,当候选DTAF配置中包括第一异步训练选择块时,使能工作节点内部训练循环的异步训练,即工作节点内部,不同迭代处理器可以进行异步训练。
在一种可能的实现方式中,第二模组还包括第二异步训练选择块,第二异步训练选择块用于使能不同工作节点之间的外部训练循环的异步训练,第二异步训练选择块包括陈旧性感知模组、距离意识模组或者全局动量模组。
应理解,第二异步训练选择块为不同工作节点之间的外部训练循环的异步训练选择块,当候选DTAF配置中包括第二异步训练选择块时,使能不同工作节点之间的外部训练循环的异步训练,即不同工作节点之间的迭代处理器可以进行异步训练。
在本申请实施例中,模块化的异步训练选择块,使得在确定候选DTAF配置过程中,可以自动选择是否包括异步训练选择块,而非人为决定是同步训练还是异步训练,异步训 练可以减少同步训练中等待Straggler的空闲实现,提高算力的利用率。
在一种可能的实现方式中,第二模组还包括反向传播随机冻结模组,反向传播随机冻结模组用于停止反向传播计算。
在本申请实施例中,模块化的随机冻结反向传播,可以在减少反向传播计算量的同时提高训练吞吐量,进而加速神经网络训练速度。
在一种可能的实现方式中,第二模组还包括新型优化器模组,新型优化器模组用于更新工作节点本地模型参数。
应理解,新型优化器模组可以为Powerball基础优化器设置。
在本申请实施例中,经过Powerball函数作用后的梯度向量能够加速整个训练过程。
第三方面,提供了一种确定分布式训练算法框架配置的系统,该系统包括数据处理器和迭代处理器:数据处理器用于,获得候选分布式训练算法框架DTAF配置,候选DTAF配置包括至少一个第一模组和每个第一模组对应的至少一个超参数;数据处理器用于,分配候选DTAF配置给迭代处理器,候选DTAF配置用于迭代处理器进行模型训练;数据处理器用于,从迭代处理器获取第二训练时间,第二训练时间为基于候选DTAF配置完成模型训练对应的训练时间;数据处理器用于,根据第二训练时间和第一训练时间,确定是否更新第一DTAF配置,其中,第一训练时间为基于第一DTAF配置完成模型训练对应的训练时间。
示例性地,数据处理器可以为中央处理单元CPU,迭代处理器可以是图像处理器GPU,还可以是嵌入式神经网络处理器NPU。
应理解,第一模组可以为模块化的技术模组,超参数可以为决定模块化技术模组自身性能的参数,例如,学习率,迭代参数等。
其中,基于候选DTAF配置完成模型训练可以理解为待训练的模型是根据候选DTAF配置中的第一模组以及第一模组对应的超参数完成的训练。
在本申请实施例中,将不同的用于分布式训练的技术模组模块化,将获得的候选DTAF配置用于模型训练,并反馈候选DTAF配置的训练完成时间,根据候选DTAF配置的训练完成时间和原第一DTAF配置的训练完成时间,来确定是否对原第一DTAF配置进行更新,形成DTAF配置自适应的闭环过程。这样,在无需专家经验的前提下,可以灵活地自动搜索最优的分布式训练算法框架配置。
在一种可能的实现方式中,数据处理器具体用于:如果第二训练时间小于第一训练时间,数据处理器将候选DTAF配置更新为第一DTAF配置;如果第二训练时间大于或等于第一训练时间,数据处理器确定不更新第一DTAF配置。
在一种可能的实现方式中,数据处理器具体用于,将第一DTAF配置作为搜索算法的输入,以获得候选DTAF配置;其中,搜索算法用于对搜索空间进行搜索,其中,搜索空间包括至少一个第二模组和每个第二模组对应的至少一个超参数,至少一个第一模组为从至少一个第二模组中搜索获得的。
应理解,第二模组是待用于候选DTAF配置的技术模组。
在一种可能的实现方式中,数据处理器用于,当第一DTAF配置为初始DTAF配置时,将经过预设搜索时间搜索之后得到的DTAF配置,作为候选DTAF配置。
其中,预设搜索时间可以理解为以初始DTAF配置为搜索算法的起点,为获得候选 DTAF配置经历的搜索时间,也就是在预设搜索时间内,以初始DTAF配置为搜索算法为起点,可以获得多个第二DTAF配置,将最后一个第二DTAF配置确定为候选DTAF配置。
在本申请实施例中,根据初始DTAF配置,经过预设搜索时间搜索之后的DTAF配置确定为候选DTAF配置,可以提高初次确定候选DTAF配置的准确性,从而减少为获得优化的DTAF配置的迭代次数,并且提高优化的DTAF配置的质量。
在一种可能的实现方式中,数据处理器还用于对第一DTAF配置进行多次迭代更新,迭代更新包括:将第一DTAF配置作为搜索算法的输入,进行随机搜索,以获得新的候选DTAF配置;分配新的候选DTAF配置,以获得新的第二训练时间,新的第二训练时间为新的候选DTAF配置对应的训练完成时间;根据新的第二训练时间和第一训练时间,确定是否更新第一DTAF配置。
在本申请实施例中,经过多次迭代更新后的优化的DTAF配置,可以提高优化的DTAF配置的质量。
在一种可能的实现方式中,搜索算法包括马尔科夫链蒙特卡洛MCMC方法。
在一种可能的实现方式中,迭代处理器根据候选DTAF配置,进行工作节点内部训练循环和不同工作节点之间外部训练循环。
在一种可能的实现方式中,迭代处理器具体用于,根据候选DTAF配置中的第三模组和第三模组中至少一个超参数,在工作节点内部进行训练循环,以获得工作节点本地模型梯度;将工作节点的本地模型梯度传递给数据处理器;数据处理器具体用于,根据工作节点的本地模型梯度,获得更新后的本地模型参数。
应理解,第三模组为在工作节点内部进行训练循环的技术模组。
需要说明的是,在工作节点内部,迭代处理器可以通过总线将本地模型梯度传递给数据处理器。
在一种可能的实现方式中,不同工作节点的数据处理器用于,分别将更新后的本地模型参数传递给不同工作节点各自对应的迭代处理器;不同工作节点的迭代处理器用于,对更新后的本地模型参数进行规约;不同工作节点的迭代处理器中的任意一个用于,将规约后的本地模型参数传递给不同工作节点的数据处理器中的任意一个,以进行全局模型参数的更新。
在一种可能的实现方式中,不同工作节点的迭代处理器中的任意一个用于,将规约后的本地模型参数传递给参数服务器中的数据处理器,以进行全局模型参数的更新。
应理解,不同工作节点之间的参数传递可以通过工作节点的通信接口来实现。
在本申请实施例中,通过内外循环的双层递归机制,结合自适应DTAF配置寻优,可以大大降低分布式训练过程中的通信频率,从而提高训练效率。
在一种可能的实现方式中,第二模组包括第一异步训练选择块,第一异步训练选择块用于使能工作节点内部的训练循环的异步训练,第一异步训练选择块包括陈旧性感知模组、距离感知模组或者全局动量模组。
应理解,第一异步训练选择块为工作节点内部训练循环的异步训练选择块,当候选DTAF配置中包括第一异步训练选择块时,使能工作节点内部训练循环的异步训练,即工作节点内部,不同迭代处理器可以进行异步训练。
在一种可能的实现方式中,第二模组还包括第二异步训练选择块,第二异步训练选择块用于使能不同工作节点之间的外部训练循环的异步训练方式,第二异步训练选择块包括陈旧性感知模组、距离感知模组或者全局动量模组。
应理解,第二异步训练选择块为不同工作节点之间的外部训练循环的异步训练选择块,当候选DTAF配置中包括第二异步训练选择块时,使能不同工作节点之间的外部训练循环的异步训练,即不同工作节点之间的迭代处理器可以进行异步训练。
在本申请实施例中,模块化的异步训练选择块,使得在确定候选DTAF配置过程中,可以自动选择是否包括异步训练选择块,而非人为决定是同步训练还是异步训练,异步训练可以减少同步训练中等待Straggler的空闲实现,提高算力的利用率。
在一种可能的实现方式中,第二模组还包括反向传播随机冻结模组,反向传播随机冻结模组用于停止反向传播计算。
在本申请实施例中,模块化的随机冻结反向传播,可以在减少反向传播计算量的同时提高训练吞吐量,进而加速神经网络训练速度。
在一种可能的实现方式中,第二模组还包括新型优化器模组,新型优化器模组用于更新工作节点本地模型参数。
应理解,新型优化器模组为Powerball基础优化器设置。
在本申请实施例中,经过Powerball函数作用后的梯度向量能够加速整个训练过程。
第四方面,提供一种计算机可读介质,该计算机可读介质存储用于设备执行的程序代码,该程序代码包括用于执行第一方面中的任意一种实现方式中的方法。
第五方面,提供一种确定装置,包括处理器与数据接口,处理器通过数据接口读取存储器上存储的指令,执行上述第一方面中的任意一种实现方式中的方法。
可选地,作为一种实现方式,还可以包括存储器,存储器中存储有指令,处理器用于执行存储器上存储的指令,当指令被执行时,处理器用于执行第一方面中的任意一种实现方式中的方法。
附图说明
图1是本申请实施例提供的一种深度学习模型示意图;
图2是本申请实施例提供的一种分布式训练系统示意性结构图;
图3是本申请实施例提供的另一种分布式训练系统示意性结构图;
图4是本申请实施例提供的分布式训练方法种类示意图;
图5是本申请实施例提供的一种确定分布式训练算法框架配置方法示意图;
图6是本申请实施例的一种确定分布式训练算法框架配置方法流程图;
图7是本申请实施例的另一种确定分布式训练算法框架配置方法流程图;
图8是本申请实施例的一种工作节点内部循环工作流程图;
图9是本申请实施例提供的规约方式示意图;
图10是本申请实施例提供的一种确定分布式训练算法框架配置装置示意图。
具体实施方式
下面将结合附图,对本申请实施例中的技术方案进行描述。
在AI领域中,深度学习是一种基于深层次的神经网络算法的学习技术。深度学习模型包括输入层、隐含层、输出层,其使用多重非线性变换对数据进行处理。
应理解,神经网络是一种模仿动物神经网络行为特征,这种网络依靠系统的复杂程度,通过调整内部大量节点之间相互连接的关系,从而达到处理信息的目的。
还应理解,深层次的神经网络(深度学习模型)可以理解为具有多个隐含层的神经网络,这里的“多个”并没有特别的度量标准。理论上而言,参数越多的模型复杂度越高,“容量”也就越大,也就意味着它能完成更复杂的学习任务。训练深度神经网络的也就是学习权重矩阵的过程,其最终目的是得到训练好的深度神经网络的所有层的权重矩阵(该权重矩阵为深度学习模型每一层神经元上的权重)。
下面结合图1,对应用于本申请实施例的一种可能的深度学习模型的训练过程进行详细描述。
图1是本申请实施例提供的一种深度学习模型100的示意性框图。深度学习模型100可以包括输入层110,隐含层120以及输出层130。
应理解,本申请实施例中以隐含层120包括n(n大于1)层神经元作为示例进行说明。
还应理解,输入层110、输出层130以及隐含层120中的每一层包括一个或多个神经元。图1中以输入层110包括两个神经元、隐含层120中的n层中的每一层均包括三个神经元、输出层130包括一个神经元为例进行说明。
图1所示的深度学习模型100可以是全连接的神经网络,也可以是卷积神经网络(convolutional neural network,CNN)。在每一层的所有神经元与下一层的所有神经元连接(每一层的每一个神经元上的权重w均不为0)的情况下,该深度学习模型100是一个全连接的神经网络模型。在每一层的所有神经元不与下一层的所有神经元连接(每一层的每一个神经元上的权重w部分为0)的情况下,该深度学习模型100是一个CNN模型。
参见图1,在深度学习模型100中可以包括前向传播(forward propagation,FP)计算和反向传播(back propagation,BP)计算。
在FP计算的过程中,获取训练数据,例如输入图像的像素信息,将训练数据作为深度学习模型100输入层110的输入(i 1,i 2)。输入层110的输入可以在经过隐含层120中的多个神经元之后,从输出层130输出一个预测结果。具体的,隐含层120中的每一层神经元都对应有一个权重矩阵。输入层110的输入与第1层神经元的权重矩阵的乘积作为隐含层120的第1层神经元的输入,该隐含层120的第1层神经元的输入经过第1层神经元中的激活函数(例如,可以是sigmoid函数)之后输出一个第1层神经元的输出值。隐含层120的第1层神经元的输出值与第2层神经元的权重矩阵的乘积作为隐含层120的第2层神经元的输入。同理,以此类推,最终从输出层130输出一个预测结果。
这些权重矩阵中的权重值在实际应用中需要在大量的训练中得到修正,通过训练得到的权重值形成的各个权重矩阵可以从用户输入的待推理图像中提取像素信息,从而帮助深度学习模型100对该待推理图像进行正确的推理。
在训练有监督的深度学习模型100的过程中,希望深度学习模型100的输出层130输出的预测值o 1尽可能的接近训练数据的先验知识(prior knowledge),先验知识也被称为真实值(ground truth),一般包括由人提供的训练数据对应的预测结果。所以可以通过比 较当前的预测值和先验知识,再根据两者之间的差异情况来更新深度学习模型100中每一层的权重矩阵(当然,在第一次更新之前通常会有初始化的过程,即为初始化深度学习模型100的隐含层120的各层神经元对应的权重矩阵)。并采用误差BP算法在训练深度学习模型100的过程中修正深度学习模型100中权重矩阵的权重参数大小,使得深度学习模型100的误差损失越来越小。
具体地,FP计算过程中产生的预测值和先验知识间可能会有误差,如果输出的预测值大于先验知识,可以调整权重矩阵中的权重参数,使得输出的预测值低一些。如果输出的预测值小于先验知识,可以调整权重矩阵中的权重参数,使得输出的预测值高一些。BP计算是以误差为主导的反向运动,旨在得到最优的模型参数,也即各层神经元的权重矩阵。
在一次迭代过程中,BP计算可以计算输出的预测值o 1以及先验知识之间的误差E。并可以沿着输出层130、隐含层120、输入层110的方向,根据误差E修正深度学习模型100中每一层神经元的权重矩阵中的权重参数。具体地,对权重参数的修正可以是分别计算出权重矩阵中的权重参数的梯度,该梯度可以是用损失对权重矩阵中的权重参数求导数。
本申请实施例中上述深度学习模型100训练过程(包括FP计算过程以及BP计算过程)可以在包括至少一个工作节点的训练系统中完成。该至少一个工作节点可以是至少一个一个模型训练服务器。下面将结合图2至图4,对深度学习模型100的分布式训练系统以及分布式训练方法的种类进行描述。
一般而言,神经网络模型的精度随着训练数据量增加而上升。但是数据量的增加使得计算负荷变大,因此针对神经网络模型的分布式训练方法应运而生。分布式训练方法旨在通过采用多个工作节点来增加计算资源,并通过多个工作节点对训练的模型进行迭代,以提升神经网络模型训练速度。应理解,本申请实施例中以神经网络模型中的深度学习模型为例进行说明,本申请实施例提出的确定分布式训练算法框架配置方法还可以应用于其他神经网络模型,对此不作限制。
图2是本申请实施例提供的一种深度学习模型100的分布式训练系统200的示意性结构图。图2所示的分布式训练系统200中可以包括模型训练服务器210、模型训练服务器220、模型训练服务器230、参数服务器240、云存储器250。
参见图2,分布式训练系统200可以包括至少一个模型训练服务器,其中,一个模型训练服务器可以作为一个工作节点。为了便于描述,图2中以三个模型训练服务器作为示例进行说明。模型训练服务器220以及模型训练服务器230的结构与模型训练服务器210类似,下面对模型训练服务器210进行详细描述。
(1)模型训练服务器210:
包括:至少一个处理器、存储器213、输入输出接口214、通信接口215、总线216。
其中,至少一个处理器可以与存储器213连接。该存储器213可以用于存储该程序代码和训练数据。该存储器213可以是至少一个处理器内部的存储单元,也可以是与至少一个处理器独立的外部存储单元,还可以是包括与至少一个处理器内部的存储单元和与至少一个处理器独立的外部存储单元的部件。
存储器213可以是固态硬盘(solid state drive,SSD),也可以是硬盘驱动器(hard disk drive,HDD),还可以是只读存储器(read-only memory,ROM)、随机存取存储器(random access memory,RAM)等。
该至少一个处理器可以从存储器213获取程序代码以及训练数据,并对深度学习模型100进行训练。作为示例而非限定,至少一个处理器可以根据程序代码以及训练数据进行迭代计算(例如,进行如图1所示的FP计算以及BP计算),还可以在分布式训练系统200中,将BP计算出的权重矩阵中的权重参数的梯度发送(push)至参数服务器240。
具体的,至少一个处理器可以包括两类处理器。其中,一类处理器包括至少一个数据处理器211,另一类处理器包括至少一个迭代处理器212。作为一个示例而非限定,数据处理器211可以是中央处理单元(central processing unit,CPU),迭代处理器212可以是嵌入式神经网络处理器(neural-network process units,NPU),也可以是图像处理器(graphics processing unit,GPU)。
其中,迭代处理器212中运行有深度学习模型100,并在对深度学习模型100进行BP计算中,计算出每一层的神经元的权重矩阵中权重参数的梯度。数据处理器211可以用于将BP计算出的梯度发送(push)至参数服务器240。
可选的,模型训练服务器210还可以包括总线216。其中,存储器213、输入输出接口214、通信接口215可以通过总线216与至少一个处理器(例如,数据处理器211、迭代处理器212)连接。总线216可以是外设部件互连标准(peripheral component interconnect,PCI)总线或扩展工业标准结构(extended industry standard architecture,EISA)总线等。所述总线216可以分为地址总线、数据总线、控制总线等。为便于表示,图2中仅用一条线表示,但并不表示仅有一根总线或一种类型的总线。
(2)参数服务器240:
包括:至少一个数据处理器241、存储器243、输入输出接口244、通信接口245、总线246。
其中,存储器243中的参数存储空间可以存储有模型训练服务器210、模型训练服务器220、模型训练服务器230分别发送的权重参数的梯度。
至少一个数据处理器241可以与存储器243连接,数据处理器241例如可以是CPU。至少一个数据处理器241可以从存储器243中获取模型训练服务器210、模型训练服务器220、模型训练服务器230分别发送的梯度,对多个模型训练服务器通过处理器push的多个梯度进行处理,并可以将处理之后的梯度平均值存储至存储器243。作为一个示例,至少一个数据处理器241可以对多个模型训练服务器分别push的多个梯度进行加权平均计算,并将梯度平均值存储至存储器243。
需要说明的是,本申请实施例在一次迭代过程中,参数服务器240中的数据处理器241计算出梯度平均值之后,在下次迭代中FP计算中,还需要根据该梯度平均值修正第下次迭代中权重矩阵,并将该权重矩阵存入存储器243的参数存储空间以供模型训练服务器210、模型训练服务器220、模型训练服务器230在下轮训练中使用。
可选的,在一些实施例中,参数服务器240中还可以包括迭代处理器242,该迭代处理器242中可以运行有深度学习模型100。作为一个示例,迭代处理器242可以是NPU,也可以是GPU。
(3)云存储器250:
可选,在一些实施例中,系统200还可以包括云存储器250。云存储器250可以作为外部存储器,用户可以将程序代码和训练数据存储在该外部存储器上。以模型训练服务器 210为例,至少一个处理器在运行过程中,可以先将云存储器250中存储的程序代码和数据存储在存储器213中,以便于至少一个处理可以从存储器213获取程序代码以及训练数据,并可以根据程序代码和训练数据对深度学习模型100进行训练。
需要说明的是,云存储器250中存储的数据可以是模型的训练数据、该训练数据相对应的先验知识以及各个模型100的隐含层120中的每一层的神经元所对应的权重矩阵的初始值等。
应理解,图2所示的分布式训练系统200包括参数服务器,为中心化部署的分布式训练系统,分布式训练系统还可以为去中心化部署的,图3是本申请实施例提供的另一种深度学习模型100的分布式训练系统300的示意性结构图。图3所示的分布式训练系统300中可以包括模型训练服务器310、模型训练服务器320、模型训练服务器330和云存储器340。
去中心化分布式训练系统300中可以包括多个模型训练服务器,以模型训练服务器310为例来具体说明。
模型训练服务器310不同于分布式训练系统200中的模型训练服务器210的地方在于,第一,数据处理器311的功能更加丰富,例如可以根据其他模型训练服务器的梯度,来更新模型参数,因此,在去中心化部署的分布式训练系统300中不需要参数服务器去整合规约不同模型训练服务器传送的梯度,来更新模型参数;第二,存储器还具有参数存储空间。模型训练服务器310其他部分和图2中的模型训练服务器210相同。
分布式训练方法可以通过两种方式实现,分别是数据并行化和模型并行化。
(1)数据并行化
数据并行化是将深度学习模型的训练数据分成不同子集,分配给分布式训练系统中的不同的工作节点上,每个工作节点具有该深度学习模型的副本,不同子集分别在各自对应的工作节点上进行训练。
(2)模型并行化
模型并行化是将深度学习模型的架构切分到不同的工作节点上来实现训练的分布化。
本申请实施例中提出的确定分布式训练算法结构方法可以应用于数据并行化的分布式训练,还可以应用于模型并行化的分布式训练,本申请对此不作限制,为了便于说明,以下以数据并行化的分布式训练的场景为例进行说明。
图4示出了两种数据并行分布式训练方法,分别是同步训练方法和异步训练方法。图4所示的两种分布式训练方法均可以应用于图2所示的分布式训练结构,下面将结合图4分别具体说明同步训练方法和异步训练方法。
(1)同步训练方法
图4的(a)为同步分布式训练方法,训练数据被分为多个子集,在第一次迭代过程中,同时在不同的工作节点上进行训练,获得不同的梯度,传送给参数服务器,参数服务器等待所有工作节点传回梯度后将不同的梯度进行规约(allreduce),并根据规约后的梯度对模型参数进行更新,并将更新后的参数发送给不同的工作节点。和第一次迭代类似地,进行多次迭代。
示例性地,如图4的(a)所示,横坐标表示时间t,纵坐标表示不同的工作节点,其中,不同的工作节点可以为图2中不同的模型训练服务器,不同工作节点分别处理多个子 集。在第一次迭代过程中,不同的工作节点1在相同的时刻t1同时进行模型训练,其中,工作节点1训练计算梯度的时间最久,到时刻t2才将自己的梯度传送给参数服务器,参数服务器需要等到所有工作节点的梯度传给自己之后,才开始进行梯度规约。随后,从时刻t2至时刻t3,参数服务器将来自不同工作节点的梯度进行规约以及模型参数更新,并将更新后的模型参数发送给不同的工作节点。从时刻t3开始,不同的工作节点开始新的迭代过程,进行多次迭代。
(2)异步训练方法
图4的(b)为异步分布式训练方法,训练数据被分为多个子集,不同的工作节点独立计算各自的梯度,参数服务器获得某个工作节点传送的梯度之后,立即进行模型参数的更新,在将更新后的模型参数传送给该工作节点,不同工作节点进行多次迭代。
示例性地,如图4的(b)所示,横坐标表示时间,纵坐标表示不同的工作节点,不同工作节点也可以为图2中所示的不同的模型训练服务器,不同工作节点根据各自处理训练数据子集的速度,将每次迭代获得的梯度传回给参数服务器。以工作节点1为例,在第一次迭代过程中,工作节点1从时刻t’1开始根据分配给工作节点1的训练数据子集进行模型训练,在时刻t’2第一次迭代训练结束,得到对应的梯度。随后,将该梯度传送给参数服务器,参数服务器立即根据工作节点1的梯度进行模型参数更新,并将更新后的参数传送给工作节点1,用于从时刻t’3开始第二次迭代的梯度计算。不同工作节点之间是独立进行梯度计算和模型参数更新。
需要注意的是,异步训练方法仅适用于中心化部署的分布式训练系统200。
为了便于理解本申请的技术方案,下面将对本申请涉及的概念做简要介绍。
(1)轮次(epoch):一个轮次表示所有训练样本的一次正向传播和一次反向传播。
(2)批大小(batch size):每批用于训练的样本数量。
(3)迭代(iteration):完成一次时期所需要的批数量。
(4)BERT(bidirectional encoder representations from transformers)模型:BERT模型是一种自编码语言模型,可以同时提取句子中的关系特征,并且能在多个不同层次提取关系特征,进而全面反映句子语义。该模型参数多、模型大,在进行训练时需要大量训练数据。
(5)ResNet50(50-layer residual network)模型:残差网络模型是一种卷积神经网络,该模型容易优化并且能够通过增加相当的深度来提高准确率,该模型也需要大量的训练数据,BERT模型的训练计算量远大于ResNet50模型的训练计算量。
分布式训练可以缓解大模型和大数据集模型训练在单个设备上的运行压力和存储压力,但是承担分布式训练任务的不同设备之间的通信,影响着分布式训练的完成时间。
例如,对于同步分布式训练中的参数服务器而言,参数服务器需要等待所有的工作节点都传回各自的梯度,再进行梯度规约,也就是训练速度最慢的工作节点(straggler)决定了此次迭代的模型参数的更新速度,进而影响了整个模型分布式训练的完成时间。
再例如,承担分布式训练任务的不同设备之间的通信次数以及每次通信的通信成本,也影响着分布式训练的完成时间。
目前,针对分布式训练完成时间受训练速度最慢的工作节点的问题,加快模型的收敛速度的技术手段主要是使用分层自适应的方法,例如,分层自适应学习率缩放(layer-wise  adaptive rate scaling,LARS)和分层自适应动量(layer-wise adaptive moments for batch,LAMB)。LARS优化器通过在模型的各层使能不同大小的学习率,使得整个训练即使在大的batch size上依然可以快速收敛,来减少分布式训练的完成时间。然而当batch size增加到一定大小之后,LARS优化器的表现陷入瓶颈。此时,LAMB优化器通过在模型的各层使能不同大小的动量,在保证训练精度的同时,又提高了训练速度,使得整个训练可以快速收敛,来减少分布式训练的完成时间。
目前,还有很多从减少不同设备之间的通信次数的角度,或者从降低不同设备之间的通信成本的角度的分布式训练方法,来实现减少分布式训练的完成时间。
例如,立足于减少通信次数的角度的方法有本地随机梯度下降(local stochastic gradient descent,LocalSGD)或者慢动量(slow momentum,SlowMo)等方法,这两种方法是工作节点内部通过多次迭代参数更新之后,再进行不同工作节点之间的一次模型参数同步,来减少不同工作节点之间的通信频率,也就是减少不同设备之间的通信次数。
再例如,立足于降低通信成本的角度的方法有量化随机梯度下降(quantized stochastic gradient descent,QSGD)或者前K元素法(topK elements)等方法,通过对梯度向量进行量化或者稀疏化来减少单次通信的通信量,从而降低单次的通信成本。
上述不同的分布式训练方法都是从不同的角度来减少分布式训练的时间,每种分布式训练方法都有各自的优点,也有各自的缺点。
例如,对于SlowMo而言,通过减少不同工作节点之间的通信次数,可以有效降低整体的训练时间,但是SlowMo只支持同步分布式训练下的数据并行,并不支持异步训练,此外,SlowMo只支持人为选择基础优化器(例如,对于BERT模型选择LAMB优化器,对于ResNet50模型选择LARS优化器),不能自动寻找最优的优化器。
目前还有一种兼容多种训练方式的深度学习分布式训练方法,是通过GPU的数量和工作节点的数量,来判断是进行分布式训练还是进行传统训练,当进行分布式训练时,通过人为方式确定参数,进而根据确定的参数选择采用Tensorflow或者Horovod中提供的并行策略。这种方法依然需要依靠专家经验判断,不能自动寻找最优的分布式训练配置。
由于上述方法都是从不同角度实现减少分布式训练时间的目标,都有各自的优点和缺点,但是不同的方法是正交的,即不同的方法是独立存在的。因此,如何对分布式训练算法框架进行自适应地确定,以获得在无需专家经验的前提下最优的训练策略是一个亟待解决的问题。
本申请实施例提供了一种确定分布式训练算法框架配置方法、装置及系统,用于解决上述问题,下面将结合图5至图10对本申请实施例的方案进行详细说明。
图5是本申请实施例提供的一种确定分布式训练算法框架配置方法示意图,下面将对图5进行详细说明。
S510,数据处理器,获得候选分布式训练算法框架(distributed training algorithm framework,DTAF)配置,候选DTAF配置包括至少一个第一模组和每个第一模组对应的至少一个超参数。
应理解,分布式训练算法框架配置包括模块化的分布式训练技术模组和/或技术块,以及技术模组和/或技术块对应的超参数,例如,标准前向传播模组、标准反向传播模组、梯度量化压缩模组等。后续将结合图8和图9举例说明技术模组和技术块。
作为一种可能的实现方式,将第一DTAF配置作为搜索算法的输入,以获得候选DTAF配置;其中,搜索算法用于对搜索空间进行搜索,其中,搜索空间包括至少一个第二模组和每个第二模组对应的至少一个超参数,至少一个第一模组为从至少一个第二模组中搜索获得的。
应理解,第一DTAF配置可以是初始DTAF配置,也可以是上一轮分布式模型训练的DTAF配置,本申请实施例对此不作限定。
应理解,第二模组是待用于候选DTAF配置的技术模组。
应理解,获得候选DTAF配置可以理解为根据在搜索空间中搜索得到的第一模组及其对应的至少一个超参数生成的DTAF配置。
搜索空间包括的至少一个第二模组可以理解为模块化的技术模组,每个技术模组可以实现相同的功能或者不同的功能。当至少一个第二模组中的N个第二模组可以组成第一技术块时,N为正整数其中,属于第一技术块的第二模组可以用于实现相同的功能。
需要说明的是,搜索空间可以理解为包括两个维度的内容,第一个维度是至少一个第二模组,另一个维度是每个第二模组对应的超参数。其中,第二模组是可以用于第一DTAF配置,也可以不用于第一DTAF配置。通过搜索算法从搜索空间中搜索出用于候选DTAF配置中的第一模组和每个第一模组对应的超参数。
需要说明的是,超参数是决定技术模组自身性能的参数,例如可以是学习率、迭代次数等。
作为一种可能实现的方式,搜索算法可以是马尔科夫链蒙特卡洛(Markov chain Monte Carlo,MCMC)方法,也可以是贝叶斯优化(Bayesian Optimization)方法,还可以是其他搜索算法,本申请实施例对此不作限制,后面将结合图6对MCMC搜索算法的使用进行详细说明。
S520,数据处理器分配所述候选DTAF配置给迭代处理器,其中,候选DTAF配置用于迭代处理器进行模型训练。
需要说明的是,S510确定的候选DTAF配置分配给不同的工作节点,用于不同工作节点的模型训练。例如,候选DTAF配置分配给四个工作节点,这四个工作节点都会获得相同的候选DTAF配置,并按照候选DTAF配置中包括的第一模组和第一模组对应的超参数,进行模型训练。
S530,数据处理器获取第二训练时间,第二训练时间为基于候选DTAF配置完成模型训练对应的训练时间。
其中,基于候选DTAF配置完成模型训练可以理解为待训练的模型是根据候选DTAF配置中的第一模组以及第一模组对应的超参数完成的训练。
需要说明的是,第二训练时间用于更新第一DTAF配置。
S540,数据处理器根据S530获取的第二训练时间和第一训练时间,确定是否更新第一DTAF配置,其中,第一训练时间为基于第一DTAF配置完成模型训练对应的训练时间。
作为一种可能实现的方式,当第二训练时间小于第一训练时间时,将候选DTAF配置更新为第一DTAF配置;当第二训练时间大于或等于第一训练时间,不更新第一DTAF配置。
作为一种可能实现的方式,当第二训练时间小于第一训练时间,但两者比较接近时, 也可以不更新所述第一DTAF配置,将未更新的第一DTAF配置作为下次搜索候选DTAF配置的起点。
本申请实施例中将不同的用于分布式训练的技术模块化,通过搜索算法获得候选DTAF配置,将候选DTAF配置用于模型训练,并反馈候选DTAF配置的训练完成时间,根据候选DTAF配置的训练完成时间和原第一DTAF配置的训练完成时间,来确定是否对原第一DTAF配置进行更新,形成DTAF配置自适应的闭环过程。这样,在无需专家经验的前提下,可以灵活地自动搜索最优的分布式训练算法框架配置。
下面将结合图6至图9对确定分布式训练算法框架配置方法进行详细说明,图6给出了本申请实施例的一种确定分布式训练算法框架配置方法流程图。
需要说明的是,本申请实施例中的确定分布式训练算法框架配置方法可以在CPU上实现,不同分布式训练系统中是通过不同的CPU来实现的。例如,对于中心化部署的分布式训练系统200而言,参数服务器240中的CPU(也就是数据处理器241)可以用于实现本申请实施例中的确定分布式训练算法框架配置方法;对于去中心化的分布式部署系统300而言,可以指定任意一个模型训练服务器中的CPU(例如,数据处理器311)用于实现本申请实施例中的确定分布式训练算法框架配置方法。本申请对此不做限制。下面使用中心化部署的分布式训练系统200为例来具体说明确定分布式训练算法框架配置方法。
需要说明的是,图6至图9的流程图中,全圆角矩形框为在数据处理器上执行的步骤,矩形框为迭代处理器上执行的步骤,半圆角半直角的矩形框为数据处理器和迭代处理器存在交互的步骤。此说明仅为了便于理解本申请的实施例,对本申请实施例的方案没有限定作用。
作为一种可能的实现方式,S610,数据处理器确定搜索空间,搜索空间包括至少一个待用于候选分布式训练框架的第二模组和第二模组对应的至少一个超参数。
应理解,S610中的搜索空间和S510中的搜索空间相同,搜索空间包括的技术模组,或者N个技术模组组成的技术块,可用于候选DTAF配置,也可以不用于候选DTAF配置。换句话说,技术模组技术块都具有“可拔插”的性能,可以根据搜索算法来确定哪些技术模组和技术块可以组成一个候选DTAF配置,用于后续的模型训练。
S620,数据处理器,将第一DTAF配置作为搜索算法的输入,在搜索空间中进行搜索,以获得候选DTAF配置。
需要说明的是,第一DTAF配置可以是上一轮DTAF配置迭代更新后的第一DTAF配置,也可以是初始DTAF配置。本申请实施例对此不作限制。
作为一种可能实现的方式,将第一DTAF配置作为搜索算法的输入,直接获得候选DTAF配置。
具体地,将第一DTAF配置作为搜索算法的输入,在搜索空间中进行随机搜索,以获得候选DTAF配置。也就是,如果根据相同的第一DTAF配置,在搜索空间中进行搜索,由于每次搜索是一个随机过程,因此每次搜索生成的候选DTAF配置是不同的。
作为一种可能实现的方式,如果第一DTAF配置是初始DTAF配置,将所述初始DTAF配置作为所述搜索算法的输入,将经过预设搜索时间搜索之后得到的DTAF配置,确定为所述候选DTAF配置。
需要说明的是,在第一DTAF配置迭代更新搜索过程中,初始DTAF配置中的多个技 术模组和每个技术模组对应的超参数可以是随机确定的,也可以是人为根据经验确定的,本申请对此不作限制。需要说明的是,本申请仅在确定初始DTAF配置时,可以通过专家经验人为确定,DTAF配置寻优过程都是自动进行的。
需要说明的是,由于初始DTAF配置可以是随机确定的,如果将以随机确定的初始DTAF配置作为搜索算法的输入,将在搜索空间中的搜索得到的第一个DTAF配置作为候选DTAF配置,那么,经过该候选DTAF配置进行模型训练得到的训练结果可能较差,例如训练时间很长,这不利于最优DTAF配置的搜索。因此,如果将经过预设搜索时间搜索之后得到的DTAF配置作为候选DTAF配置,那么可以减少最优DTAF搜索时间和寻优的迭代次数。
示例性地,搜索算法可以是MCMC。具体地,根据MCMC算法以初始DTAF配置为搜索起点,经过预设搜索时间之后,可以获得一系列的第二DTAF配置包括C 0,C 1,C 2,…,C n,n为正整数,其中,C 0是根据初始DTAF配置得到的,C 1是根据C 0得到的,C 2是根据C 1得到的,以此类推。每个第二DTAF配置包括待通过MCMC进行搜索的多个技术模组和每个技术模组对应的超参数。将C n确定为候选DTAF配置。将经过预设搜索时间搜索之后得到的DTAF配置确定为所述候选DTAF配置,还可以理解为候选DTAF配置是经过预设搜索时间之后,符合MCMC搜索算法中初始搜索的评价指标的DTAF配置。
S630,数据处理器将候选DTAF配置分配给迭代处理器,迭代处理器使用候选DTAF配置进行模型训练,以获得候选DTAF配置对应的第二训练时间,并将第二训练时间反馈给数据处理器。
示例性地,如果分布式训练系统中有四个模型训练服务器,也就是有四个工作节点,分别是工作节点1、工作节点2、工作节点3和工作节点4。这四个工作节点中的迭代处理器都会获得相同的候选DTAF配置。根据该候选DTAF配置完成模型训练后,生成相应的候选DTAF配置训练完成时间,也就是第二训练时间。
作为一种可能实现的方式,不同工作节点的迭代处理器可以依次反馈不同候选DTAF配置对应的训练完成时间。应理解,反馈方式可以有多种,本申请对此不作限制。
S640,数据处理器,根据第二训练时间和第一训练时间,确定是否更新第一DTAF配置。
根据第二训练时间和第一训练时间,利用MCMC来确定是否更新第一DTAF配置的具体的算法如下:
for迭代次数=1to有限次数:
使用随机步长从第一DTAF配置C生成候选DTAF配置C *
if cost(C *)<cost(C):
用C *替换C
else:
用概率函数exp(α·(cost(C)-cost(C *)))替换C
end if
end for
返回最好的配置C。
应理解,上述内容为具体算法框架流程的文字性说明。
其中,cost()表示使用一个DTAF配置完成模型训练的成本函数,也就是训练完成时间。其中,候选DTAF配置记为C *,候选DTAF配置对应的模型训练完成时间为第二训练时间,记为cost(C *),上一轮利用搜索算法更新的第一DTAF配置,记为C,其对应的模型训练完成时间为第一训练时间,记为cost(C),例如,在第一DTAF配置迭代更新搜索过程开始时,C可以是初始DTAF配置。
作为一种可能实现的方式,当第二训练时间小于第一训练时间时,将候选DTAF配置C *更新为第一DTAF配置C。
作为一种可能实现的方式,当第二训练时间大于或等于第一训练时间时,不更新第一DTAF配置C,并且基于第一DTAF配置,利用MCMC搜索算法在搜索空间进行随机搜索,以生成新的候选DTAF配置。
具体实现方式可以为,将成本函数转化为概率函数,如公式(1):
p(C)∝e -β·cost(C)      (1)
其中,β为常数,p(C)是以第一DTAF配置为MCMC搜索算法的输入,获得的候选DTAF配置的目标分布。
具体地,使用Metropolis-Hastings算法生成马尔可夫链来具体实现对候选的配置是接收还是拒绝。首先,确定第一DTAF配置C(例如,初始DTAF配置),并从建议分布(proposal distribution)q(C|C *)中生成候选DTAF配置C *。如果该候选DTAF配置被接受,C *将代替原第一DTAF配置C成为新的第一DTAF配置,否则,候选DTAF配置C *被拒绝,最后基于原第一DTAF配置C,生成新的候选DTAF配置。重复此过程,直到达到预先设定的次数为止。
作为一种可能实现的方式,如果上述建议分布是对称的,即q(C|C *)=q(C *|C),则候选DTAF配置C *的验收标准满足公式(2),将公式(1)代入公式(2):
Figure PCTCN2021143339-appb-000001
公式(2)提供了MCMC算法的一种直观解释。观察以上公式可以看到,通过接受或拒绝候选DTAF配置C *,使得更新后的第一DTAF配置逐渐收敛到目标分布p(C)。如果候选DTAF配置C *相比于原第一DTAF配置C实现目标分布的可能性更大,即p(C *)>p(C),则候选DTAF配置C *被接受为目标分布的实现,即将满足条件的C *替换原原第一DTAF配置C。如果候选DTAF配置C *相比于原第一DTAF配置C实现目标分布的可能性小,即p(C *)≤p(C),候选DTAF配置C *也还有机会被保留,该候选DTAF配置C *被保留的的概率为为p(C *)/p(C)≤1。
作为另一种可能实现的方式,搜索算法可以是贝叶斯优化(Bayesian optimization,BO)。贝叶斯优化是优化评估成本高昂的黑盒函数的一种技术,是一种基于高斯过程(Gaussian process)和贝叶斯定理的参数优化方法,能保证显著的自动化寻优,从而可以大大提高设计质量和人力生产力。核函数是高斯过程的核心概念,这决定高斯过程的基本性质。核函数在高斯过程中生成一个协方差矩阵(covariance matrix)来衡量任意两个点之间的相关性,透过评估不同输入点之间的关系,将这种关系反映到后续的样本位置上,用于预测后续未知点的值。常用的核函数包括高斯核函数,线性核函数等。这方法已应用于众多应用设计 中,提高效率。贝叶斯优化需要在每一次迭代时选取一个最佳观测值,这是贝叶斯优化的关键问题。关于贝叶斯优化的大量数学原理,包括采集函数,这里可以使用比较常用的上置信边界(upper confidence bound,UCB)作为采集函数,UCB定义满足公式(3):
UCB(x)=m(x)+κσ(x)      (3)
其中m(x)和σ(x)分别是高斯过程的预测因子和不确定性因子,κ是平衡开发和勘探的参数。UCB可被视为预测值和不确定性的加权和值。当权重较小时,UCB很容易帮助选择预期值较低的样本。当获取函数的值较大时,它更有可能选择不确定性较大的样本。还有许多其他可用的采集函数,例如预期改进(expected improvement,EI)、改进概率(probability of improvement,PI)、熵搜索(entropy search,ES)和汤普森采样(Thompson sampling,TS)等。广泛的研究已经证明,由几个采集函数组成的组合也是可以的。总括来说,BO使用一组随机抽样的数据集构建初始代理模型。通过利用预测均值和不确定性估计,采集函数选择具有最大适应度值的作为下一个推荐点,以增量细化代理模型。经过一定次数的迭代,将在理论保证的情况下达到全局最优。本申请实施例还可以使用其他搜索算法,对此不作限制。
本申请实施例中将不同的用于分布式训练的技术模块化,通过搜索算法获得候选DTAF配置,将候选DTAF配置用于模型训练,并反馈候选DTAF配置的训练完成时间,根据候选DTAF配置的训练完成时间和原第一DTAF配置的训练完成时间,来确定是否对原第一DTAF配置进行更新,形成DTAF配置自适应的闭环过程。这样,可以无需专家经验的前提下,灵活地自动搜索最优的分布式训练算法框架配置,获得最优的优化和通信策略组合。
图7是本申请实施例的另一种确定分布式训练算法框架配置方法流程图。图7是对S630步骤的进一步详细说明。
需要说明的是,S630,使用候选DTAF配置进行模型分布式训练主要分为两个维度的循环,分别是S631工作节点内部循环和S632不同工作节点之间循环。
S631,工作节点进行内部循环,以更新本地模型参数。
需要说明的是,每个工作节点根据候选DTAF配置中包括的技术模组和技术模组对应的超参数,进行内部训练循环,以更新工作节点上本地模型参数或者由技术模组组成的技术块,
其中,一个工作节点对应一个模型训练服务器,一个工作节点中的迭代处理器可以包括M张卡,当迭代处理器为GPU时,也就是M个GPU。对于数据并行的分布式训练而言,每个GPU上都有相同的训练模型,每个GPU根据不同的训练数据进行模型训练,其中M为正整数,例如,M可以为4、8或者16,本申请对此不作限制。
需要说明的是,工作节点的内部循环还可以称为子循环,本申请实施例对名称不作限制。S631工作节点进行内部循环,以更新本地模型参数可以包括如下步骤:
S6311,训练模型在迭代处理器中根据训练数据进行前向传播,训练得到预测结果。
作为一种可能实现的方式,前向传播可以是标准前向传播(normal forward propagation,normal FP),也可以是基于随机剔除的前向传播(forward propagation with dropout,FP with Dropout),还可以是其他前向传播方案,本申请实施例对此不作限制。
S6312,训练模型在迭代处理器中根据S6311中预测结果和先验知识之间的误差,进 行反向传播,计算不同模型层权重参数的梯度。
作为一种可能实现的方式,反向传播可以是标准反向传播(normal backward propagation,normal BP)也可以是随机冻结反向传播(backward propagation with randomly freeze,BP with randomly freeze)还可以是其他反向传播方案,本申请实施例对此不作限制。后续将对随机冻结反向传播进行详细描述,在此不作赘述。
S6313,对工作节点内部不同迭代处理器上的梯度,进行梯度规约。
作为一种可能实现的方式,梯度规约可以为全规约(all reduce)、无规约(no reduce)和推和规约(pushsum reduce)等,本申请对此不做限制。梯度规约还可以称为梯度聚合,或者梯度整合。后续将结合图10对不同规约方式进行详细描述,在此不作赘述。
S6314,数据处理器根据规约后的梯度,对模型参数进行本地更新。
作为一种可能实现的方式,数据处理器根据本次内部循环S6313规约后的梯度和上一次内部循环的本地模型参数,对模型参数进行本地更新
需要说明的是,S6314中使用的技术模组将在图8中具体说明,在此不作赘述。
S6315,将S6311至S6314的步骤在工作节点内部迭代i次,其中i为正整数。
可选的,S6316,步骤S6311至S6315可以在工作节点内部不同上进行异步训练。
作为一种可能实现的方式,当S6313中的梯度规约方式为无规约,那么工作节点内部,不同迭代处理器不进行异步训练。也就是,当S6313中的梯度规约方式为除无规约以外的其他规约方式时,工作节点内部,不同迭代处理器可以进行异步训练,也就是候选DTAF配置中包括工作节点内部训练循环的异步训练选择块及其超参数。
应理解,工作节点内部训练循环的异步训练选择块还可以称为第一异步训练选择块,还可以有其他名称,本申请实施例对此不作限制。
需要说明的是,在获得候选DTAF配置时,第一异步训练选择块作为一种工作节点内部训练循环待选择的技术块,可以在候选DTAF配置中,也可以不在候选DTAF配置中,这取决于工作节点内部梯度规约的方式。也就是,当候选DTAF配置中包括第一异步训练选择块时,使能工作节点内部训练循环的异步训练,即工作节点内部,不同迭代处理器可以进行异步训练。
上述内容详细介绍了每个工作节点内部的训练循环的具体步骤,后续将结合图8对在每个工作节点内部循环中,可用于候选DTAF配置的技术模组和技术块进行详细说明。下面将继续结合图7对S632不同工作节点间进行训练循环的步骤进行详细说明。
S632,不同工作节点之间的外部训练循环,以更新全局模型参数。
需要说明的是,不同工作节点之间的外部循环是在单个工作节点上的内部循环结束之后,使用数据处理器执行的步骤可以是通过参数服务器的数据处理器去执行,也可以是通过任意指定的一个工作节点的数据处理器去执行。例如,对于中心化部署的分布式训练系统,是参数服务器的数据处理器去执行;对于去中心化部署的分布式训练系统,可以任意指定某一个工作节点,即某一个模型训练服务器中的数据处理器去执行,本申请实施例对此不作限制。
需要说明的是,不同工作节点之间的外部循环还可以称为父循环,本申请实施例对名称不作限制。S632不同工作节点之间的外部循环,以更新全局模型参数可以包括如下步骤:
S6321,不同工作节点上的迭代处理器根据S631获取的不同工作节点i次内部循环后的本地模型参数,对不同工作节点的本地模型参数进行规约。
作为一种可能实现的方式,在S6321中的参数规约方式和S6313中的梯度规约方式类似,可以有多种,例如全规约、无规约和pushsum reduce等,本申请对此不做限制。不同工作节点模型参数规约还可以称为不同工作节点模型参数聚合,或者不同工作节点模型参数整合。
作为一种可能实现的方式,不同工作节点的迭代处理器中的任意一个迭代处理器作为不同工作节点之间的本地模型参数规约的设备。本申请实施例对迭代处理器中用于不同工作节点之间的模型参数规约的迭代处理器不作限定。
示例性地,以迭代处理器为GPU为例,如果在分布式训练中有四个工作节点,它们各自的用于不同工作节点之间的模型参数规约的GPU分别为工作节点1的GPU1、工作节点2的GPU2、工作节点3的GPU1和工作节点4的GPU2。此处不同工作节点中的GPU编号仅是示例作用,可以为任意一个在工作节点中的GPU,本申请实施例对此不作限制。
S6322,数据处理器计算不同工作节点的动量,以修正不同工作节点上模型参数更新的方向。
示例性地,数据处理器根据上一次外部循环计算得到的不同工作节点的动量、上一次外部循环中S6321规约后的模型参数和本次外部循环中S6321规约后的模型参数,计算更新本次外部循环不同工作节点的动量,具体的更新公式(4)如下:
Figure PCTCN2021143339-appb-000002
其中,parent_monen(j-1)为上一次外部循环计算得到的不同工作节点的动量,reduce_param(j)为本次外部循环中S6321规约后的模型参数,reduce_param(j-1)为上一次外部循环中S6321规约后的模型参数。
S6323,数据处理器根据S6322更新后的不同工作节点的动量,进行全局模型参数更新。
示例性地,数据处理器根据上一次外部循环更新的全局模型参数和本次外部循环中S6322更新后的不同工作节点的动量,进行全局模型参数更新,具体更新公式如下:
parent_param(j)=param_update(parent_param(j-1),parent_momen(j))   (5)
其中,parent_param(j-1)为上一次外部循环更新的全局模型参数,parent_momen(j)为本次外部循环中S6322更新后的不同工作节点的动量。
S6324,将S631至S6323的步骤外部迭代j次,其中j为正整数。
可选的,S6325,步骤S631至S6324可以在不同工作节点之间进行异步训练。
作为一种可能实现的方式,当S6321中的不同工作节点的本地模型参数方式的规约方式为无规约,那么不同工作节点之间的迭代处理器不进行异步训练。也就是,当S6321中的规约方式为除无规约以外的其他规约方式,不同工作节点之间的迭代处理器可以进行异步训练,也就是候选DTAF配置中包括不同工作节点之间的外部训练循环的异步训练模组及其超参数。
应理解,不同工作节点之间的外部训练循环的异步训练选择块还可以称为第二异步训练选择块,还可以有其他名称,本申请实施例对此不作限制。
需要说明的是,在获得候选DTAF配置时,第二异步训练选择块作为一种不同工作节点之间的外部训练循环待选择的技术块,可以在候选DTAF配置中,也可以不在候选DTAF配置中,这取决于不同工作节点之间外部循环时,不同工作节点的本地模型参数的规约方式。也就是,当候选DTAF配置中包括第二异步训练选择块时,使能不同工作节点之间的外部训练循环的异步训练,即不同工作节点之间的迭代处理器可以进行异步训练。
在本申请实施例中,不同工作节点将各自本地更新后的模型参数反馈给数据处理器进行外部循环,以更新全局模型参数,这个过程可以是同步进行,也可以是异步训练,S6325中模块化的异步训练选择块,使得在确定候选DTAF配置过程中,可以自动选择是否包括异步训练选择块,而非人为决定是同步训练还是异步训练,异步训练可以减少同步训练中等待Straggler的空闲实现,提高算力的利用率。
在本申请实施例中,通过内外循环的双层递归机制,结合自适应DTAF配置寻优,可以大大降低分布式训练过程中的通信频率,从而提高训练效率。
下面将结合图8具体说明图7中每个工作节点内部循环中,可用于候选DTAF配置的技术模组和技术块,图8是本申请实施例的一种工作节点内部循环工作流程图。
图8中的工作节点内部循环的工作流程和图7中的工作节点内部循环工作流程类似,下面将结合图9说明模块化的技术模组的具体内容,以及可选的内部循环步骤。
需要说明的是,图8中仅示出了在工作节点内部训练循环过程中,部分可用于候选DTAF配置的技术模组或者技术块,为了简洁,其他可用于候选DTAF配置的技术模组或者技术块以举例的形式在本申请实施例中体现出来。
S6311中的正向传播模组可以是标准前向传播模组,也可以是标准前向传播模组,也可以是基于随机剔除的前向传播模组等其他前向传播模组,本申请实施例对此不作限制。
S6312中的反向传播模组可以是标准反向传播模组,也可以是随机冻结反向传播模组等其他反向传播模组,本申请实施例对此不作限制。
随机冻结反向传播是通过随机选取神经网络中的一层作为开始停止反向传播的开始层,停止该层和传输层之间的反向传播过程中的梯度计算和参数更新,从而在减少反向传播计算量的同时提高训练吞吐量,进而加速神经网络训练速度。
示例性地,随机冻结反向传播技术模组的超参数是概率值ε,概率值ε决定了是否使能随机冻结。如果候选DTAF配置中包括随机冻结反向传播技术模组及其超参数概率值ε,在使用该候选DTAF配置进行模型训练时,以概率ε使能模型中某一层的随机冻结,则从这一层开始停止该层和传输层之间的反向传播计算,并更新已经经过反向传播的各层参数;如果以1-ε的概率不使能随机冻结,则不对任何神经网络层的反向传播做任何改变。
可选的,在S6312和S6313中间,还可以进行S6317,迭代处理器上不同GPU将各自在S6312反向传播获得的梯度,进行梯度量化压缩,以降低S6312之后迭代处理器上不同GPU之间的梯度的通信数据量。
作为一种可能实现的方式,模块化的梯度量化压缩模组可以是标记随机梯度下降(sign stochastic gradient descent,SignSGD)、1比特随机梯度下降(1-bit stochastic gradient descend,1-bit SGD),三元梯度法(ternary gradients,TernGrad)、量化随机梯度下降(quantized  stochastic gradient descent,QSGD)等其他梯度量化压缩模组,本申请实施例对此不作限制。
示例性地,SignSGD会把梯度向量中的每个元素压缩为0或者1;SignSGD将梯度向量中的每个元素压缩为-1或者1;TernGrad将梯度向量中的每个元素压缩为-1,0或者1;QSGD将梯度向量中的每个元素压缩为人为指定的几个数值大小,其压缩率可由人进行改变。
可选的,和梯度量化压缩功能相似,同样可以降低S6312之后反馈给数据处理器的梯度的通信数据量的方法是梯度稀疏化压缩方法。在本申请中可以将梯度稀疏化压缩方法模块化,也就是变成搜索空间中的第二模组,用于后续的搜索以确定候选DTAF配置。
在本申请实施例中,模块化的梯度量化压缩模组和梯度稀疏化压缩模组的超参数满足模型训练精度在可接受范围内变动的要求。因此,也可以适用于对梯度精度敏感的模型训练。
S6313中的梯度规约模组有多种,也就是多种梯度同步通信方式,下面将结合图9进行详细介绍,图9是本申请实施例提供的规约方式示意图。
全规约,全规约是在所有设备梯度同步点将所有设备的梯度相加求平均的过程,全规约有两种,分别是传统全规约和环全规约(ring all-reduce),如图9所示。
如图9的(a)所示,传统全规约是每个设备将自身产生的梯度传递给其他设备,从而每个设备可以自行计算出梯度平均值。例如,设备A通过获得设备B、设备C以及设备D上产生的梯度,完成所有设备梯度相加求平均的过程。
如图9的(b)所示,环全规约是每个设备将自身产生的梯度平均分成n份,每个设备环状连接,每个设备将自身第k份梯度传递给下一个设备的同时,会收到来自上一个设备的第k-1份的梯度,以此获得每个设备1/n的梯度,从而实现所有设备梯度相加求平均的效果。例如,有四个设备产生四个不同的梯度,每个设备的梯度都平均分为四份,在第1次环状传递中,设备A的第1份梯度传递给设备B,设备B的第2份梯度传递给设备C,设备C的第3份梯度传递给设备D,设备D的第4份梯度传递给梯度A,在第2次环状传递中,设备A的第4份梯度传递给设备B,设备B的第1份梯度传递给设备C,设备C的第2份梯度传递给设备D,设备D的第3份梯度传递给梯度A,以此类推,直到每个设备上都有不同设备平分的梯度。
Pushsum规约是将每个设备一次只将自己的梯度传递给部分设备,经过多次传递,使得每个设备的梯度传递给所有的其他设备。如图9的(c)所示,设备A的梯度仅传递给设备B、设备C和设备E,设备B的梯度仅传递给设备D、设备E和设备F。虽然每次通信只有部分设备获得了梯度信息,但是随着通信次数的增加,所有设备的梯度均在所有设备之间完成了通信。这种规约方式可以减少梯度的通信量并且能保证分布式训练过程中模型的精度不减。
无规约就是所有设备之间的梯度都不进行信息的交换,也就是如图9的(d)所示,每个设备之间都无通信。
需要说明的是,对于工作节点内部循环而言,所有设备为每个工作节点上不同GPU上产生的梯度。
可选的,在S6313和S6314之间,还可以进行S6318工作节点内部动量计算。
示例性地,根据本次内部循环中S6313进行规约后的工作节点内部的梯度,和上一次 内部循环中工作节点内部动量,更新获得本次内部循环中工作节点内部动量,以修正工作节点内部本地模型参数更新的方向,具体公式(5)如下:
child_momen(i)=momen_update(child_momen(i-1),grad(i))    (5)
其中,child_momen(i-1)为上一次内部循环中工作节点内部动量,grad(i)为本次内部循环中S6313进行规约后的工作节点内部的梯度。
可选的,S6314数据处理器根据本次内部循环S6318的动量和上一次内部循环的本地模型参数,对模型参数进行本地更新,具体公式(6)如下:
child_param(i)=param_update(child_param(i-1),child_momen(i))    (6)
其中,child_param(i-1)为上一次内部循环的本地模型参数,child_momen(i)为本次内部循环的动量。
应理解,本地模型参数的更新可以从两个维度去执行,分别是基础优化器类型和基础优化器的设置。
S63141,模块化的基础优化器类型可以是如下类型中任意一种或多种:随机梯度下降(stochastic gradient descent,SGD)、自适应动量估计(adaptive moment estimation,Adam)、LAMB、自适应梯度(adaptive gradient,AdaGrad)、有限内存的拟牛顿优化(limited-memory broyden fletcher Goldfarb shanno,L-BFGS)、内斯特罗夫加速自适应动量估计(Nesterov accelerated adaptive moment estimation,Nadm)、自适应动量梯度下降(adaptive moment gradient descent,AMSGrad)、均方根传播(root mean square propagation,RMSProp)、Delta自适应梯度(adaptive gradient delta,AdaDelta)。本申请实施例对优化器类型不作限制。
S63142,模块化的基础优化器设置可以是如下类型中的任意一种或多种:Powerball、内斯特罗夫动量(Nesterov momentum)、权重延迟(weight decay)、L1/L2-Norm、动态批大小(dynamic batch size)、动量(momentum)、学习率调度(learning rate schedule)、学习率衰退(learning rate decay)、预热学习率(learning rate warm up)。
其中,Powerball基础优化器设置还可以称为新型优化器模组,Powerball基础优化器设置中的Powerball函数可以作用在梯度向量上将Powerball函数应用于基础优化器类型为SGD时,将函数中的变量γ设置为大于0小于1,所以在这种情况下,梯度向量中绝对值小于1的元素值将得到增大,绝对值大于1的元素值将得到减小,从而改变整个梯度向量的大小和方向。Powerball函数作用后的梯度向量能够加速整个训练过程。Powerball函数作用的强度由γ控制,γ越小作用强度越大。
可选的,在S6316中,异步训练选择技术块中可以包括多个技术模组,用于减少异步训练过程中的梯度滞后,或者异步训练过程中模型参数版本滞后。
例如,陈旧性感知(staleness aware)模组:通过简单的计算得到当前迭代的stalenessτ k,并在参数更新过程中对stalenessτ k进行惩罚,从而起到减少staleness对异步训练精度影响的效果。
例如,距离感知(gap aware)模组:和staleness aware模组相比,gap aware模组计算出来一个距离G k去代替陈旧性τ k,然后在更新momentum的时候对距离G k做出惩罚,可以起到和staleness aware模组相似的减少对异步训练精度影响的效果。
再例如,全动量(total momentum)模组:全动量是合并了显动量(explicitmomentum)和非显动量(implicit momentum),总动量可以通过相应的公式计算获得。全动量模组越 小,则异步训练算法的泛化性越强,也就是使得模型在验证数据集上的精度越高。通过自动调节负反馈结构调节训练过程中的学习率大小,实时测量全动量,使得全动量总可以保持在较小的水平。全动量模组可以提升异步训练算法泛化性精度。
需要说明的是,在异步训练选择技术块中还可以包括其他技术模组,本申请对此不作限制。
以上结合图8和图9对本申请实施例中S631工作节点内部训练循环中的技术模组和技术块以及可选的内部循环步骤做了详细说明,对于S632不同工作节点之间的外部循环而言,部分技术模组和技术块和S631中的类似。
示例性地,对于外部循环中的S6321而言,不同工作节点的本地模型参数规约的方法和内部循环中的S6313中的梯度规约方法的种类相同,在此不做赘述,详情参考此前描述。不同点在于,对于外部循环而言,规约的是模型参数,而对于内部循环而言,规约的是梯度。
示例性地,对于外部循环中的S6325而言,外部循环也可以有异步训练选项技术块,其中,异步训练选项技术块可以包括和内部循环中的S6316中包括的类似的技术模组。为了简洁,在此不作赘述。
上述内容是对本申请实施例的确定分布式训练算法框架配置方法的描述,下面结合图10对本申请实施例的确定分布式训练算法框架配置装置进行说明。应理解,下面描述的装置能够执行前述本申请实施例的方法,为了避免不必要的重复,下面在介绍本申请实施例的装置时适当省略重复的描述。
图10是本申请实施例提供的一种确定分布式训练算法框架配置装置示意图,图10所示的确定DTAF配置装置1000可以包括分配模块1020、获取模块1030、确定模块1040和更新模块1050。
获取模块1030用于,获得分布式训练算法框架候选DTAF配置,候选DTAF配置包括至少一个第一模组和每个第一模组对应的至少一个超参数;分配模块1020用于,分配候选DTAF配置给迭代处理器,候选DTAF配置用于迭代处理器进行模型训练;获取模块还用于,获取第二训练时间,第二训练时间为基于候选DTAF配置完成模型训练对应的训练时间;确定模块1040用于,根据第二训练时间和第一训练时间,确定是否更新第一DTAF配置,其中,第一训练时间为基于第一DTAF配置完成模型训练对应的训练时间。
可选地,该装置还可以包括更新模块1050,如果第二训练时间小于第一训练时间,更新模块1050用于,将候选DTAF配置更新为第一DTAF配置;如果第二训练时间大于或等于第一训练时间,确定模块1040用于,确定不更新第一DTAF配置。
可选地,获取模块具体用于,将第一DTAF配置作为搜索算法的输入,以获得候选DTAF配置;其中,搜索算法用于对搜索空间进行搜索,其中,搜索空间包括至少一个第二模组和每个第二模组对应的至少一个超参数,至少一个第一模组为从至少一个第二模组中搜索获得的。
可选地,获取模块具体用于,当第一DTAF配置为初始DTAF配置时,将经过预设搜索时间搜索之后得到的DTAF配置,作为候选DTAF配置。
可选地,该装置还可以包括搜索模块1010,更新模块还用于,对第一DTAF配置进行多次迭代更新,迭代更新包括:搜索模块用于,将第一DTAF配置作为搜索算法的输入, 进行随机搜索,以使获取模块获得新的候选DTAF配置;分配模块还用于,分配新的候选DTAF配置给迭代处理器,以获得新的第二训练时间,新的第二训练时间为新的候选DTAF配置对应的训练完成时间;确定模块还用于,根据新的第二训练时间和第一训练时间,确定是否更新第一DTAF配置。
需要说明的是,上述模块是从功能逻辑上的划分,并非限定上述模块必须是独立的硬件单元。这里的术语“模块”可以通过软件和/或硬件形式实现,对此不作具体限定。
例如,“模块”可以是实现上述功能的软件程序、硬件电路或二者结合。所述硬件电路可能包括应用特有集成电路(application specific integrated circuit,ASIC)、电子电路、用于执行一个或多个软件或固件程序的处理器(例如共享处理器、专有处理器或组处理器等)和存储器、合并逻辑电路和/或其它支持所描述的功能的合适组件。
因此,在本申请的实施例中描述的各示例的模块,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。
本申请实施例的确定分布式训练算法框架配置系统架构可以是图2或者图3所示的任意一种,详细系统架构可参考图2的相关描述,为了简洁,在此不作赘述。该系统包括数据处理器和迭代处理器。
数据处理器用于,获得候选分布式训练算法框架DTAF配置,候选DTAF配置包括至少一个第一模组和每个第一模组对应的至少一个超参数;数据处理器用于,分配候选DTAF配置给迭代处理器,候选DTAF配置用于迭代处理器进行模型训练;数据处理器用于,从迭代处理器获取第二训练时间,第二训练时间为基于候选DTAF配置完成模型训练对应的训练时间;数据处理器用于,根据第二训练时间和第一训练时间,确定是否更新第一DTAF配置,其中,第一训练时间为基于第一DTAF配置完成模型训练对应的训练时间。
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统、装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
在本申请所提供的几个实施例中,应该理解到,所揭露的系统、装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。
所述功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。

Claims (35)

  1. 一种确定分布式训练算法框架配置的方法,其特征在于,所述方法由数据处理器执行,所述方法包括:
    获得候选分布式训练算法框架DTAF配置,所述候选DTAF配置包括至少一个第一模组和每个所述第一模组对应的至少一个超参数;
    分配所述候选DTAF配置给迭代处理器,所述候选DTAF配置用于所述迭代处理器进行模型训练;
    获取第二训练时间,所述第二训练时间为基于所述候选DTAF配置完成模型训练对应的训练时间;
    根据所述第二训练时间和第一训练时间,确定是否更新第一DTAF配置,其中,所述第一训练时间为基于所述第一DTAF配置完成模型训练对应的训练时间。
  2. 如权利要求1所述的方法,其特征在于,所述根据所述第二训练时间和第一训练时间,确定是否更新所述第一DTAF配置包括:
    如果所述第二训练时间小于所述第一训练时间,将所述候选DTAF配置更新为所述第一DTAF配置;
    如果所述第二训练时间大于或等于所述第一训练时间,确定不更新所述第一DTAF配置。
  3. 如权利要求1或2所述的方法,其特征在于,所述获得候选DTAF配置包括:
    将所述第一DTAF配置作为搜索算法的输入,以获得所述候选DTAF配置;
    其中,所述搜索算法用于对搜索空间进行搜索,其中,所述搜索空间包括至少一个第二模组和每个所述第二模组对应的至少一个超参数,所述至少一个第一模组为从所述至少一个第二模组中搜索获得的。
  4. 如权利要求3所述的方法,其特征在于,所述将所述第一DTAF配置作为搜索算法的输入,获得所述候选DTAF配置包括:
    当所述第一DTAF配置为初始DTAF配置时,将所述初始DTAF配置作为所述搜索算法的输入,将经过预设搜索时间搜索之后得到的DTAF配置,确定为所述候选DTAF配置。
  5. 如权利要求3或4所述的方法,其特征在于,所述方法还包括:
    对所述第一DTAF配置进行多次迭代更新,所述迭代更新包括:
    将所述第一DTAF配置作为所述搜索算法的输入,进行随机搜索,以获得新的候选DTAF配置;
    分配所述新的候选DTAF配置给所述迭代处理器,以获得新的第二训练时间,所述新的第二训练时间为所述新的候选DTAF配置对应的训练完成时间;
    根据所述新的第二训练时间和所述第一训练时间,确定是否更新所述第一DTAF配置。
  6. 如权利要求3至5任一项所述的方法,其特征在于,所述搜索算法包括马尔科夫链蒙特卡洛MCMC方法。
  7. 如权利要求3至6任一项所述的方法,其特征在于,所述第二模组包括第一异步 训练选择块,所述第一异步训练选择块用于使能工作节点内部的训练循环的异步训练,所述第一异步训练选择块包括陈旧性感知模组、距离感知模组或者全局动量模组。
  8. 如权利要求3至7任一项所述的方法,其特征在于,所述第二模组还包括第二异步训练选择块,所述第二异步训练选择块用于使能不同工作节点之间的外部训练循环的异步训练,所述第二异步训练选择块包括陈旧性感知模组、距离感知模组或者全局动量模组。
  9. 如权利要求3至8任一项所述的方法,其特征在于,所述第二模组还包括反向传播随机冻结模组,所述反向传播随机冻结模组用于停止反向传播计算。
  10. 如权利要求3至9任一项所述的方法,其特征在于,所述第二模组还包括新型优化器模组,所述新型优化器模组用于更新工作节点内部的本地模型参数。
  11. 一种确定分布式训练算法框架配置的装置,其特征在于,所述装置应用于数据处理器,所述装置包括获取模块、分配模块以及确定模块:
    所述获取模块用于,获得候选分布式训练算法框架DTAF配置,所述候选DTAF配置包括至少一个第一模组和每个所述第一模组对应的至少一个超参数;
    所述分配模块用于,分配所述候选DTAF配置给迭代处理器,所述候选DTAF配置用于所述迭代处理器进行模型训练;
    所述获取模块还用于,获取第二训练时间,所述第二训练时间为基于所述候选DTAF配置完成模型训练对应的训练时间;
    所述确定模块用于,根据所述第二训练时间和第一训练时间,确定是否更新第一DTAF配置,其中,所述第一训练时间为基于所述第一DTAF配置完成模型训练对应的训练时间。
  12. 如权利要求11所述的装置,其特征在于,所述装置还包括更新模块,:
    如果所述第二训练时间小于所述第一训练时间,所述更新模块用于,将所述候选DTAF配置更新为所述第一DTAF配置;
    如果所述第二训练时间大于或等于所述第一训练时间,所述确定模块用于,确定不更新所述第一DTAF配置。
  13. 如权利要求11或12所述的装置,其特征在于,
    所述获取模块具体用于,将所述第一DTAF配置作为搜索算法的输入,以获得所述候选DTAF配置;
    其中,根据所述搜索算法用于对搜索空间进行搜索,其中,所述搜索空间包括至少一个第二模组和每个所述第二模组对应的至少一个超参数,所述至少一个第一模组为从所述至少一个第二模组中搜索获得的。
  14. 如权利要求13所述的装置,其特征在于,所述获取模块具体用于,当所述第一DTAF配置为初始DTAF配置时,将经过预设搜索时间搜索之后得到的DTAF配置,作为所述候选DTAF配置。
  15. 如权利要求13或14所述的装置,其特征在于,所述装置还包括搜索模块:
    所述更新模块还用于,对所述第一DTAF配置进行多次迭代更新,所述迭代更新包括:
    所述搜索模块用于,将所述第一DTAF配置作为所述搜索算法的输入,进行随机搜索,以使所述获取模块获得新的候选DTAF配置;
    所述分配模块还用于,分配所述新的候选DTAF配置给所述迭代处理装置,以获得新的第二训练时间,所述新的第二训练时间为所述新的候选DTAF配置对应的训练完成时间;
    所述确定模块还用于,根据所述新的第二训练时间和所述第一训练时间,确定是否更新所述第一DTAF配置。
  16. 如权利要求13至15任一项所述的装置,其特征在于,所述搜索算法包括马尔科夫链蒙特卡洛MCMC方法。
  17. 如权利要求13至16任一项所述的装置,其特征在于,所述第二模组包括第一异步训练选择块,所述第一异步训练选择块用于使能工作节点内部训练循环的异步训练,所述第一异步训练选择块包括陈旧性感知模组、距离感知模组或者全局动量模组。
  18. 如权利要求13至17任一项所述的装置,其特征在于,所述第二模组还包括第二异步训练选择块,所述第二异步训练选择块用于使能不同工作节点之间的外部训练循环的异步训练,所述第二异步训练选择块包括陈旧性感知模组、距离意识模组或者全局动量模组。
  19. 如权利要求13至18任一项所述的装置,其特征在于,所述第二模组还包括反向传播随机冻结模组,所述反向传播随机冻结模组用于停止反向传播计算。
  20. 如权利要求13至19任一项所述的装置,其特征在于,所述第二模组还包括新型优化器模组,所述新型优化器模组用于更新工作节点内部本地模型参数。
  21. 一种确定分布式训练算法框架配置的系统,其特征在于,所述系统包括数据处理器和迭代处理器:
    所述数据处理器用于,获得候选分布式训练算法框架DTAF配置,所述候选DTAF配置包括至少一个第一模组和每个所述第一模组对应的至少一个超参数;
    所述数据处理器用于,分配所述候选DTAF配置给所述迭代处理器,所述候选DTAF配置用于所述迭代处理器进行模型训练;
    所述数据处理器用于,从所述迭代处理器获取第二训练时间,所述第二训练时间为基于所述候选DTAF配置完成模型训练对应的训练时间;
    所述数据处理器用于,根据所述第二训练时间和第一训练时间,确定是否更新第一DTAF配置,其中,所述第一训练时间为基于所述第一DTAF配置完成模型训练对应的训练时间。
  22. 如权利要求21所述的系统,其特征在于,所述数据处理器具体用于:
    如果所述第二训练时间小于所述第一训练时间,所述数据处理器将所述候选DTAF配置更新为所述第一DTAF配置;
    如果所述第二训练时间大于或等于所述第一训练时间,所述数据处理器确定不更新所述第一DTAF配置。
  23. 如权利要求21或22所述的系统,其特征在于,所述数据处理器具体用于:
    将所述第一DTAF配置作为搜索算法的输入,以获得所述候选DTAF配置;
    其中,所述搜索算法用于对搜索空间进行搜索,其中,所述搜索空间包括至少一个第二模组和每个所述第二模组对应的至少一个超参数,所述至少一个第一模组为从所述至少一个第二模组中搜索获得的。
  24. 如权利要求23所述的系统,其特征在于,所述数据处理器具体用于:
    当所述第一DTAF配置为初始DTAF配置时,将经过预设搜索时间搜索之后得到的DTAF配置,作为所述候选DTAF配置。
  25. 如权利要求23或24所述的系统,其特征在于,
    所述数据处理器还用于对所述第一DTAF配置进行多次迭代更新,所述迭代更新包括:
    将所述第一DTAF配置作为所述搜索算法的输入,进行随机搜索,以获得新的候选DTAF配置;
    分配所述新的候选DTAF配置,以获得新的第二训练时间,所述新的第二训练时间为所述新的候选DTAF配置对应的训练完成时间;
    根据所述新的第二训练时间和所述第一训练时间,确定是否更新所述第一DTAF配置。
  26. 如权利要求23至25任一项所述的系统,其特征在于,所述搜索算法包括马尔科夫链蒙特卡洛MCMC方法。
  27. 如权利要求21至26任一项所述的系统,其特征在于,
    所述迭代处理器用于,根据所述候选DTAF配置,进行工作节点内部训练循环和不同工作节点之间外部训练循环。
  28. 如权利要求27所述的系统,其特征在于,所述迭代处理器具体用于:
    根据所述候选DTAF配置中的第三模组和所述第三模组中至少一个超参数,在工作节点内部进行训练循环,以获得工作节点本地模型梯度;
    将所述工作节点的本地模型梯度传递给所述数据处理器;
    所述数据处理器,根据所述工作节点的本地模型梯度,获得更新后的本地模型参数。
  29. 如权利要求28所述的系统,其特征在于,
    所述不同工作节点的数据处理器用于,分别将所述更新后的本地模型参数传递给所述不同工作节点各自对应的迭代处理器;
    所述不同工作节点的迭代处理器用于,对所述更新后的本地模型参数进行规约;
    所述不同工作节点的迭代处理器中的任意一个用于,将规约后的本地模型参数传递给所述不同工作节点的数据处理器中的任意一个,以进行全局模型参数的更新。
  30. 如权利要求21至29任一项所述的系统,其特征在于,所述第二模组包括第一异步训练选择块,所述第一异步训练选择块用于使能工作节点内部的训练循环的异步训练,所述第一异步训练选择块包括陈旧性感知模组、距离感知模组或者全局动量模组。
  31. 如权利要求21至30任一项所述的系统,其特征在于,所述第二模组还包括第二异步训练选择块,所述第二异步训练选择块用于使能不同工作节点之间的外部训练循环的异步训练,所述第二异步训练选择块包括陈旧性感知模组、距离感知模组或者全局动量模组。
  32. 如权利要求21至31任一项所述的系统,其特征在于,所述第二模组还包括反向传播随机冻结模组,所述反向传播随机冻结模组用于停止反向传播计算。
  33. 如权利要求21至32任一项所述的方法,其特征在于,所述第二模组还包括新型优化器模组,所述新型优化器模组用于更新工作节点内部本地模型参数。
  34. 一种计算机可读存储介质,其特征在于,所述计算机可读介质存储用于设备执行的程序代码,该程序代码包括用于执行如权利要求1至9中任一项所述的方法。
  35. 一种确定装置,其特征在于,包括处理器与数据接口,所述处理器通过所述数据接口读取存储器上存储的指令,以执行如权利要求1至9中任一项所述的方法。
PCT/CN2021/143339 2021-12-30 2021-12-30 确定分布式训练算法框架配置方法、装置及系统 WO2023123275A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
PCT/CN2021/143339 WO2023123275A1 (zh) 2021-12-30 2021-12-30 确定分布式训练算法框架配置方法、装置及系统
CN202180098682.2A CN117396851A (zh) 2021-12-30 2021-12-30 确定分布式训练算法框架配置方法、装置及系统

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2021/143339 WO2023123275A1 (zh) 2021-12-30 2021-12-30 确定分布式训练算法框架配置方法、装置及系统

Publications (1)

Publication Number Publication Date
WO2023123275A1 true WO2023123275A1 (zh) 2023-07-06

Family

ID=86997078

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/143339 WO2023123275A1 (zh) 2021-12-30 2021-12-30 确定分布式训练算法框架配置方法、装置及系统

Country Status (2)

Country Link
CN (1) CN117396851A (zh)
WO (1) WO2023123275A1 (zh)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190042887A1 (en) * 2017-08-04 2019-02-07 Fair Ip, Llc Computer System for Building, Training and Productionizing Machine Learning Models
CN109754060A (zh) * 2017-11-06 2019-05-14 阿里巴巴集团控股有限公司 一种神经网络机器学习模型的训练方法及装置
CN110929878A (zh) * 2019-10-30 2020-03-27 同济大学 一种分布式随机梯度下降方法
US20210357256A1 (en) * 2020-05-14 2021-11-18 Hewlett Packard Enterprise Development Lp Systems and methods of resource configuration optimization for machine learning workloads

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190042887A1 (en) * 2017-08-04 2019-02-07 Fair Ip, Llc Computer System for Building, Training and Productionizing Machine Learning Models
CN109754060A (zh) * 2017-11-06 2019-05-14 阿里巴巴集团控股有限公司 一种神经网络机器学习模型的训练方法及装置
CN110929878A (zh) * 2019-10-30 2020-03-27 同济大学 一种分布式随机梯度下降方法
US20210357256A1 (en) * 2020-05-14 2021-11-18 Hewlett Packard Enterprise Development Lp Systems and methods of resource configuration optimization for machine learning workloads

Also Published As

Publication number Publication date
CN117396851A (zh) 2024-01-12

Similar Documents

Publication Publication Date Title
US20220391771A1 (en) Method, apparatus, and computer device and storage medium for distributed training of machine learning model
US11715287B2 (en) Systems and methods for exchange of data in distributed training of machine learning algorithms
CN108122032B (zh) 一种神经网络模型训练方法、装置、芯片和系统
CN109948029B (zh) 基于神经网络自适应的深度哈希图像搜索方法
WO2018099085A1 (zh) 一种神经网络模型的训练方法、装置及芯片
CN106062786B (zh) 用于训练神经网络的计算系统
WO2021259090A1 (zh) 联邦学习的方法、装置和芯片
CN116415654A (zh) 一种数据处理方法及相关设备
CN107622303A (zh) 用于神经网络的方法和执行该方法的设备
WO2020147142A1 (zh) 一种深度学习模型的训练方法、系统
CN112101525A (zh) 一种通过nas设计神经网络的方法、装置和系统
CN111191709A (zh) 深度神经网络的持续学习框架及持续学习方法
CN113826117A (zh) 来自神经网络的高效二元表示
WO2023020613A1 (zh) 一种模型蒸馏方法及相关设备
CN113632106A (zh) 人工神经网络的混合精度训练
Addanki et al. Placeto: Efficient progressive device placement optimization
WO2020062299A1 (zh) 一种神经网络处理器、数据处理方法及相关设备
WO2023123275A1 (zh) 确定分布式训练算法框架配置方法、装置及系统
US11853391B1 (en) Distributed model training
US20230108177A1 (en) Hardware-Aware Progressive Training Of Machine Learning Models
WO2022252694A1 (zh) 神经网络优化方法及其装置
CN117035045A (zh) 模型参数更新方法、装置、设备、存储介质和程序产品
Oh et al. Application of Deep Learning Model Inference with Batch Size Adjustment
CN114386565A (zh) 提供神经网络
CN115210714A (zh) 通过基于知识蒸馏的nas进行大型模型仿真

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21969633

Country of ref document: EP

Kind code of ref document: A1