Task execution method and apparatus, storage medium, and electronic device
By analyzing the network layer and computing device information of the deep neural network model, task allocation is optimized, solving the problems of idle CPU resources and high training costs, and improving resource utilization and training efficiency.
Patent Information
- Application Number
- PCT/CN2023/105037
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-03-29
- Filing Date
- 2023-06-30
- Publication Date
- 2024-10-03
AI Technical Summary
In the existing technology, during the training process of the deep neural network model, the computing resources of the central processing unit (CPU) are not effectively utilized, resulting in a waste of resources and an increase in training costs, and the parallel training of the model relies on a large amount of GPU computing resources, resulting in a loss of CPU resources. idle.
By analyzing the computing tasks of each network layer of the target model and the information of multiple devices participating in the calculation, determine the appropriate computing device to perform the computing tasks, including CPU and GPU, and optimize the data transmission method to improve resource utilization.
It improves the utilization of different types of computing devices, reduces the execution cost of computing tasks, and ensures that both CPU and GPU can effectively participate in the model training process.
Smart Images

Figure CN2023105037_03102024_PF_FP_ABST
Abstract
Description
A method, device, storage medium and electronic device for executing a task Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, device, storage medium, and electronic device for executing a task. Background Art
[0002] With the development of deep neural network technology, some extremely large deep neural network models have gradually emerged. Due to the extremely large number of parameters in these models, the computing systems used to train them have brought many challenges. Large-scale training not only requires a large amount of computing resources, but also places high demands on device memory and transmission resources. Therefore, parallel training of models has gradually become a mainstream development trend.
[0003] Currently, models are usually divided into multiple computing tasks and assigned to different graphics processing units (GPUs) to perform calculations, while the central processing unit (CPU) is only responsible for data transmission and scheduling. This method requires a large amount of GPU computing resources, while the CPU computing resources are not effectively utilized. This not only causes a waste of resources during model training, but deploying more GPUs to perform computing tasks will further increase the cost of model training.
[0004] Therefore, how to improve the utilization of different types of equipment during model training and reduce the training cost of the model is an urgent problem to be solved.
[0005] Summary of the Invention
[0006] The present application provides a method, device, storage medium and electronic device for executing a task to solve the above-mentioned problems existing in the prior art.
[0007] This application adopts the following technical solutions:
[0008] This application provides a method for executing a task, including:
[0009] Get the model data of the target model;
[0010] Parsing the model data to determine a computing task corresponding to each network layer in the target model, and determining device information corresponding to a plurality of computing devices participating in the target model calculation, wherein the computing devices include at least one central processing unit (CPU) and at least one graphics processing unit (GPU);
[0011] For each network layer, determining, based on the number of calculations involved in executing the computing task corresponding to the network layer and the device information corresponding to the multiple computing devices, a computing time required to execute the computing task corresponding to the network layer by the multiple computing devices;
[0012] For each network layer, based on at least one of the computing duration, the data transmission duration between the computing device that performs the computing task corresponding to the previous network layer and the other computing devices, the memory space required for the data of the network layer, and the remaining memory of the multiple computing devices, determine the computing device that performs the computing task corresponding to the network layer as the target device corresponding to the network layer, wherein the data transmission duration is determined based on the transmission information between the computing device that performs the computing task corresponding to the previous network layer and the other computing devices, and the amount of data output by the previous network layer;
[0013] The computing tasks corresponding to each network layer in the target model are deployed in the target devices corresponding to each network layer, so that the computing tasks are executed through the target devices after receiving the execution requests of the computing tasks corresponding to each network layer.
[0014] Optionally, before determining the computing device corresponding to the network layer, the method further includes:
[0015] determining at least one execution unit in each of the plurality of computing devices to obtain a plurality of execution units;
[0016] The computing capability corresponding to each of the plurality of execution units is determined according to the device information corresponding to the plurality of computing devices.
[0017] Optionally, determining, for each network layer, the computing time required to execute the computing task corresponding to the network layer by the multiple computing devices based on the number of computations involved in executing the computing task corresponding to the network layer and the device information corresponding to the multiple computing devices, includes:
[0018] For each network layer, the computing time required for each execution unit to execute the computing task corresponding to the network layer is determined based on the number of calculations involved in executing the computing task corresponding to the network layer and the computing power corresponding to each execution unit.
[0019] Optionally, determining the computing device that performs the computing task corresponding to the network layer as the target device corresponding to the network layer based on at least one of the computing duration, the data transmission duration between the computing device that performs the computing task corresponding to the previous network layer and other computing devices, the memory space required for the data of the network layer, and the remaining memory of the multiple computing devices includes:
[0020] Determine, based on at least one of the computation time corresponding to each execution unit, the data transmission time between the reference execution unit and the other execution units, the memory space, and the remaining memory, an execution unit that executes the computation task corresponding to the network layer as the target execution unit corresponding to the network layer, wherein the reference execution unit is the execution unit that executes the computation task corresponding to the previous network layer;
[0021] The step of deploying the computing tasks corresponding to the respective network layers in the target model in the target devices corresponding to the respective network layers, so as to execute the computing tasks through the target devices after receiving execution requests for the computing tasks corresponding to the respective network layers, includes:
[0022] The computing tasks corresponding to the network layers are deployed in the target device where the target execution units corresponding to the network layers are located, so that the computing tasks are executed by the target execution units after receiving the execution requests of the computing tasks corresponding to the network layers.
[0023] Optionally, the data transmission duration is determined based on the transmission information between the reference execution unit and the other execution units and the amount of data output by the previous network layer.
[0024] Optionally, determining, based on at least one of the calculation duration corresponding to each execution unit, the data transmission duration between the reference execution unit and the other execution units, the memory space, and the remaining memory, an execution unit that executes the computing task corresponding to the network layer as a target execution unit corresponding to the network layer includes:
[0025] If the network layer is not the starting network layer of the target model, then for each execution unit, determining the comprehensive duration corresponding to the execution unit according to the calculation duration and data transmission duration corresponding to the execution unit;
[0026] Determine one or more candidate execution units from the multiple execution units, each candidate execution unit corresponding to a computing device with a remaining memory greater than the memory space and a corresponding comprehensive duration less than a computation duration required for executing the corresponding computation task of the network layer through the reference execution unit;
[0027] The target execution unit corresponding to the network layer is determined according to the comprehensive duration corresponding to each candidate execution unit.
[0028] Optionally, determining, based on at least one of the calculation duration corresponding to each execution unit, the data transmission duration between the reference execution unit and the other execution units, the memory space, and the remaining memory, an execution unit that executes the computing task corresponding to the network layer as a target execution unit corresponding to the network layer includes:
[0029] If the network layer is a starting network layer of the target model, determining one or more candidate execution units;
[0030] Determine the computation time corresponding to each candidate execution unit based on the number of computations required to execute the computation task corresponding to the network layer and the computation capability corresponding to each candidate execution unit;
[0031] The target execution unit corresponding to the network layer is determined according to the calculation duration corresponding to each candidate execution unit.
[0032] Optionally, determining one or more candidate execution units includes:
[0033] An execution unit whose remaining memory is greater than the memory space is determined as the one or more candidate execution units.
[0034] Optionally, the method further includes:
[0035] For each network layer, if there are at least two transmission modes between the target execution unit corresponding to the network layer and the target execution unit corresponding to the adjacent network layer of the network layer, the transmission status of the current transmission mode is monitored;
[0036] Determining whether the current transmission mode needs to be adjusted according to the transmission status;
[0037] If adjustment is required, the current transmission mode is adjusted to another transmission mode.
[0038] Optionally, the method further includes: determining a transmission mode between the multiple execution units and a bandwidth corresponding to each transmission mode, wherein the transmission mode includes: at least one of a first transmission mode and a second transmission mode.
[0039] Optionally, the method further includes:
[0040] If the target execution unit corresponding to the network layer and the target execution unit corresponding to the adjacent network layer are both related to the GPU, and the second transmission mode exists between the target execution unit corresponding to the network layer and the target execution unit corresponding to the adjacent network layer, then the data between the network layer and the adjacent network layer is transmitted through the second transmission mode; otherwise, the data between the network layer and the adjacent network layer is transmitted through the first transmission mode.
[0041] Optionally, the first transmission mode includes: a high-speed serial computer expansion bus PCI-e, and the second transmission mode includes: NVLINK.
[0042] This application provides a task execution device, including:
[0043] Get module to get model data of target model;
[0044] a parsing module that parses the model data to determine a computing task corresponding to each network layer in the target model, and determines device information corresponding to a plurality of computing devices participating in the target model calculation, wherein the computing devices include at least one central processing unit (CPU) and at least one graphics processing unit (GPU);
[0045] A first determining module determines, for each network layer, a computing time required for executing the computing task corresponding to the network layer by the plurality of computing devices based on the number of computations involved in executing the computing task corresponding to the network layer and the device information corresponding to the plurality of computing devices;
[0046] a second determining module, for each network layer, determining, based on at least one of the computing duration, the data transmission duration between the computing device that performs the computing task corresponding to the previous network layer and the other computing devices, the memory space required for the data of the network layer, and the remaining memory of the plurality of computing devices, a computing device that performs the computing task corresponding to the previous network layer as the target device corresponding to the network layer, wherein the data transmission duration is determined based on the transmission information between the computing device that performs the computing task corresponding to the previous network layer and the other computing devices, and the amount of data output by the previous network layer;
[0047] An execution module deploys the computing tasks corresponding to each network layer in the target model in the target device corresponding to each network layer, so as to execute the computing tasks through the target device after receiving an execution request for the computing tasks corresponding to each network layer.
[0048] The present application provides a computer-readable storage medium, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the method for executing the above-mentioned task is implemented.
[0049] The present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned task execution method when executing the program.
[0050] At least one of the above technical solutions adopted in this application can achieve the following beneficial effects:
[0051] In the task execution method provided in the present application, the computing tasks corresponding to each network layer in the target model and the device information corresponding to multiple computing devices participating in the target model calculation are determined. For each network layer, the computing time required to execute the computing tasks corresponding to the network layer through multiple computing devices is determined based on the number of calculations involved in executing the computing tasks corresponding to the network layer and the device information of multiple computing devices. Based on the computing time, the data transmission time between the computing device corresponding to the previous network layer and other computing devices, the memory space required for the data of the network layer, and at least one of the remaining memory of each computing device, the target device corresponding to the network layer is determined, and the computing task is executed through the target device after receiving the execution request of the computing task corresponding to each network layer.
[0052] It can be seen from the above method that this solution can allocate different computing devices to different network layers based on the device information of different types of computing devices (CPU and GPU) to perform corresponding computing tasks. Compared with the current method of only using GPU to perform major computing tasks, in this solution, both CPU and GPU can determine the network layer that matches it based on its device information, and then execute the computing tasks corresponding to the network layer, which greatly improves the utilization rate of different computing devices and further reduces the execution cost of computing tasks. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0054] FIG1 is a flow chart of a method for executing a task provided in this application.
[0055] FIG2 is a schematic diagram of a task execution process during model training provided in this application.
[0056] FIG3 is a schematic diagram of a task execution system provided by this application.
[0057] FIG4 is a schematic diagram of a task execution device provided in this application.
[0058] FIG5 is a schematic diagram of an electronic device provided by the present application corresponding to FIG1 . DETAILED DESCRIPTION
[0059] To make the purpose, technical solutions, and advantages of this application more clear, the technical solutions of this application will be clearly and completely described below in conjunction with the specific embodiments of this application and the corresponding drawings. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0060] During model training, the training processes of each network layer of the model usually have a sequential relationship. The input calculated by the next network layer depends on the output calculated by the previous network layer. Therefore, many GPUs spend most of the time waiting for the calculation of the upper layer input to be completed, resulting in idle computing resources.
[0061] Pipeline parallelism is a method that accelerates neural network training by combining model parallelism with data pipelining. The core idea is to partition the model layer by layer into several chunks, each of which is assigned to a separate device. During the forward pass, each device passes intermediate activations to the next stage. During the backward pass, each device passes the gradient of the input tensor back to the previous pipeline stage. This approach mitigates some of the resource waste associated with model parallelism.
[0062] However, during the current parallel model training process, most computing tasks are completed by the GPU, and the CPU only performs data transmission and control, resulting in low CPU resource utilization, and even being idle most of the time, causing a waste of CPU resources.
[0063] Based on this, the present application provides a method for task execution, which determines the execution unit corresponding to the computing task of each network layer of the target model among the execution units of different types of computing devices, and then executes the computing task to improve the utilization rate of different types of computing resources.
[0064] In this application, the execution subject of the method for executing the task execution may refer to a designated device such as a server or workstation. For the sake of convenience of description, this application only takes the server as the execution subject as an example to illustrate a task execution method provided in this application.
[0065] The following describes in detail the technical solutions provided by various embodiments of the present application in conjunction with the accompanying drawings.
[0066] FIG1 is a flow chart of a method for executing a task provided by the present application, which includes the following steps:
[0067] S101: Acquire model data of a target model.
[0068] In the process of executing the computing task for the target model, the server needs to obtain the model data of the target model. The computing task can be a computing task in the model training process (including computing tasks in the forward pass and backward pass processes). After obtaining the training request of the model, the server can obtain the model data. Of course, the above computing task can also be a computing task of the model in the actual working process.
[0069] S102: parse the model data to determine the computing tasks corresponding to each network layer in the target model, and determine the device information corresponding to multiple computing devices participating in the target model calculation, wherein the computing devices include at least one central processing unit (CPU) and at least one graphics processing unit (GPU).
[0070] After obtaining the model data, the server can parse the model data. For example, the server can store the model structure in the form of a data flow graph. After parsing the model structure, the computing tasks corresponding to each network layer of the target model can be determined.
[0071] At the same time, the server can determine the device information corresponding to each computing device. Each computing device can be deployed in the same terminal device (such as a computer), and of course, can also be deployed in multiple nodes of a distributed computing system.
[0072] Each computing device refers to a computing device that is planned to participate in the target model calculation. For example, before actually training the target model, the number of computing devices participating in the training can be determined.
[0073] In this application, the above-mentioned computing device may include at least one central processing unit CPU and at least one graphics processing unit GPU. Of course, it may also include other computing devices such as a tensor processing unit (TPU) and an embedded neural network processor (NPU). This application does not make specific limitations on this.
[0074] The device information of each computing device may include the number of CPUs, CPU frequency, CPU memory size, number of GPUs, number of GPU stream processors, GPU stream processor frequency, and GPU memory size, etc., among which the CPU memory size refers to the memory that can be used by the CPU on the motherboard, and the GPU memory size refers to the video memory of the GPU. This application does not make specific restrictions on this.
[0075] In addition, the server may also determine transmission information between the computing devices, where the transmission information includes transmission modes between different computing devices and bandwidths corresponding to different transmission modes. In the present application, the transmission mode may include at least one of a first transmission mode and a second transmission mode, the first transmission mode may include a high-speed serial computer expansion bus (Peripheral Component Interconnect Express, PCI-e), and the second transmission mode may include NVLINK, wherein NVLINK may be used for data transmission between GPUs.
[0076] The first and second transmission modes may also include other high-speed buses connecting the CPU and GPU, or between GPUs. This application does not impose any restrictions on this. For simplicity, the following description uses PCI-e as the first transmission mode and NVLINK as the second transmission mode as an example.
[0077] Furthermore, the server may determine at least one execution unit contained in each computing device, obtain multiple execution units, and instantiate each execution unit. In this application, the execution unit may be determined based on the number of threads of the computing device, or, of course, the number of cores of the computing device, which is not specifically limited in this application.
[0078] For example, on a GPU, an execution unit may include one or more GPUs, and on a CPU, an execution unit may include one or more CPUs or one or more CPU cores.
[0079] For each execution unit, the server can determine the computing power corresponding to the execution unit based on the device information of the computing device to which the execution unit belongs. The computing power can be expressed as the number of floating-point operations per second (FLOPS) corresponding to the execution unit.
[0080] S103: For each network layer, determine the computing time required to execute the computing task corresponding to the network layer through the multiple computing devices based on the number of calculations involved in executing the computing task corresponding to the network layer and the device information corresponding to the multiple computing devices.
[0081] S104: For each network layer, determine the computing device that performs the computing task corresponding to the previous network layer as the target device corresponding to the network layer based on the computing time, the data transmission time between the computing device that performs the computing task corresponding to the previous network layer and other computing devices, the memory space required for the data of the network layer, and at least one of the remaining memories of the multiple computing devices, wherein the data transmission time is determined based on the transmission information between the computing device that performs the computing task corresponding to the previous network layer and the other computing devices, and the amount of data output by the previous network layer.
[0082] In the process of determining the computing devices corresponding to each network layer, for each network layer, the server derives the number of calculations required to execute the computing tasks corresponding to the network layer (such as the number of floating-point operations) and the amount of data output by the network layer, and determines the memory space required for the data of the network layer (such as model parameters, tensors, etc.).
[0083] For the starting network layer of the target model, the server can determine the execution unit corresponding to the starting network layer based on the number of calculations and memory space corresponding to the starting network layer, the computing power corresponding to each execution unit, and the remaining memory of the computing device corresponding to each execution unit. The method for determining the execution unit can be expressed by the following formula (1):
[0084] Among them, L a .flop is the number of calculations required to start the network layer a (number of floating-point operations), EC i is the computing power (floating point operations per second) corresponding to execution unit i, i is the remaining memory of the computing device corresponding to execution unit i, L a .Mem is the memory space required by network layer a.
[0085] Exemplarily, the starting network layer is the first layer at the beginning of a model. The above formula (1) can be used to quickly determine on which execution unit the first layer is calculated.
[0086] For example, if the execution unit is a CPU, the remaining memory of the computing device corresponding to execution unit i is the device's memory. If the execution unit is a GPU, the remaining memory of the computing device corresponding to execution unit i is the remaining video memory of the GPU where the execution unit is located.
[0087] The server can determine the execution unit whose remaining memory is greater than the memory space required by network layer a based on the above formula, and use the execution unit as a candidate execution unit. According to the number of calculations required for the starting network layer a and the computing power corresponding to each candidate execution unit, the server can determine the calculation time corresponding to each candidate execution unit. Then, based on the calculation time corresponding to each candidate execution unit, the server can determine the only execution unit corresponding to the network layer (such as using the candidate execution unit with the shortest calculation time as the execution unit corresponding to the starting network layer a) as the target execution unit corresponding to the network layer.
[0088] For network layers other than the starting network layer, the server can determine the execution unit corresponding to the network layer based on the number of calculations and the required memory space corresponding to the network layer, the computing power corresponding to each execution unit, the remaining memory of the computing device corresponding to each execution unit, the amount of data output by the network layer above the network layer, and the transmission information between the execution unit corresponding to the previous network layer (i.e., the execution unit that executes the computing task corresponding to the previous network layer) and each execution unit. The method for determining the execution unit can be expressed by the following formula (2):
[0089] Among them, L a-1 .size is the amount of data output by the previous network layer, BW i,j,k is the bandwidth between execution unit j corresponding to the previous network layer and other execution units i. When execution unit j and execution unit i belong to different computing devices, k has two values, representing two transmission modes. k = 0 means using PCI-e for data transmission, and k = 1 means using NVLINK for data transmission. Execution unit j can also be called the reference execution unit. When execution units i and j belong to the same computing device, BW i,j,k It is a maximum value, and its purpose is to make the transmission time approach 0. The value of k is 0, which belongs to the PCI-e data transmission method.
[0090] Specifically, the server can determine the calculation duration corresponding to each execution unit based on the above formula, according to the number of calculations corresponding to the network layer a (a>1) and the computing power corresponding to each execution unit, and determine the data transmission duration corresponding to each execution unit based on the transmission information between the computing device corresponding to the previous network layer and each computing device, as well as the amount of data output by the previous network layer. Then, based on the above calculation duration and data transmission duration, the comprehensive duration corresponding to each execution unit is determined, that is,
[0091] Furthermore, in the process of determining the execution unit corresponding to network layer a (a>1), the server can determine, among each execution unit, an execution unit whose remaining memory of the corresponding computing device is greater than the memory space required by network layer a (a>1), and whose corresponding comprehensive duration is less than the computing time required to execute the corresponding computing task of the network layer through the execution unit of the previous network layer, as a candidate execution unit, and then determine the target execution unit corresponding to the network layer based on the comprehensive duration corresponding to each candidate execution unit (such as taking the candidate execution unit with the smallest comprehensive duration as the computing unit corresponding to network layer a).
[0092] It should be noted that in actual applications, it is not necessary to divide the execution units corresponding to each computing device. Instead, the computing devices corresponding to different network layers can be determined. Each computing device can be equivalent to an execution unit, so that the computing tasks corresponding to each network layer are executed through the computing devices corresponding to different network layers.
[0093] During this process, the server can determine, for each non-starting network layer, the computing time required for each computing device to execute the computing task corresponding to the network layer based on the number of calculations involved in executing the computing task corresponding to the network layer and the device information corresponding to each computing device, determine the data transmission time corresponding to each computing device based on the transmission information between the computing device corresponding to the previous network layer (i.e., the computing device that executes the computing task corresponding to the previous network layer) and each computing device, and the amount of data output by the previous network layer, and then determine the comprehensive time of each computing device based on the computing time and data transmission time corresponding to each computing device, and then determine the computing device corresponding to the network layer as the target device corresponding to the network layer based on the comprehensive time corresponding to each computing device, the remaining memory of each computing device and at least one of the above-mentioned memory spaces.
[0094] S105: Deploy the computing tasks corresponding to each network layer in the target model in the target device corresponding to each network layer, so as to execute the computing tasks through the target device after receiving an execution request for the computing tasks corresponding to each network layer.
[0095] Specifically, the server can output a tuple list based on the above device information, transmission information, and derivation information. The derivation information may include the target devices corresponding to the aforementioned network layers, and may also include parameters such as the number of calculations corresponding to each network layer and the amount of output data. The list may include information such as the neural model network layer, forward and backward operations, location in the computing device, whether direct memory access (DMA) is used, and whether NVLINK is used. The server can then execute the computing task based on the above tuple list through the execution units corresponding to each network layer.
[0096] In the process of executing computing tasks, the server can first deploy the computing tasks corresponding to each network layer on the target device where the corresponding target execution unit is located. It should be noted that for each network layer, if there are at least two transmission modes (including NVLINK and PCI-e) between the target execution unit corresponding to the network layer and the target execution unit corresponding to the adjacent network layer of the network layer, the transmission status of the current transmission mode is monitored, and based on the monitored transmission status, it is determined whether the current transmission mode needs to be adjusted. The above-mentioned transmission status may include the busyness or traffic size of the current transmission mode. If the current transmission mode is relatively busy, the current transmission mode can be adjusted to another transmission mode.
[0097] In one example, considering the types of buses supported by the CPU, NVLINK (second transmission mode) can be set only between execution units related to the GPU, while NVLINK is not set between execution units related to the CPU and between execution units related to the CPU and execution units related to the GPU.
[0098] For example, the server may determine the transmission information (such as bandwidth and transmission mode) between the execution units included in the computing device based on the transmission information between the computing devices, thereby determining the transmission mode between multiple execution units and the bandwidth corresponding to each transmission mode.
[0099] In addition, in the present application, for each network layer, if the target execution unit corresponding to the network layer and the target execution unit corresponding to the adjacent network layer are related to the GPU, and there is an NVLINK transmission method between the target execution unit corresponding to the network layer and the target execution unit corresponding to the adjacent network layer, since the transmission efficiency of the NVLINK transmission method is much higher than PCI-e, the server can give priority to transmitting data between the network layer and the adjacent network layer through the NVLINK transmission method. If it does not exist, it will choose to transmit through PCI-e.
[0100] During the execution of a computing task, if the NVLINK transmission status is detected to be relatively busy, NVLINK can be adjusted to PCI-e. If both transmission modes exist at the same time, when the PCI-e transmission status is relatively busy, it can also be adjusted to NVLINK to ensure the execution efficiency of the computing task. For ease of understanding, this application provides a schematic diagram of the task execution process during model training, as shown in Figure 2.
[0101] FIG2 is a schematic diagram of a task execution process during model training provided in this application.
[0102] In the process of training the target model, the server can first obtain the training request submitted by the user, and then parse the structure of the model to determine the computing tasks corresponding to each network layer and the computing amount (number of floating-point operations) corresponding to each network layer. At the same time, it obtains the device information of each computing device, determines the execution unit corresponding to each computing device, and judges the transmission method between each execution unit, such as whether there is NVLINK. If so, determine its bandwidth, and then determine the allocation strategy based on the above device information, estimated information of each network layer and transmission information.
[0103] After determining the allocation strategy, the server can initialize each execution unit and monitor the transmission status after starting training. If it is determined that the transmission method needs to be modified, the transmission method will be adjusted after the conditions are met. The forward and backward operations in the model training process are executed through each target execution unit, and the optimizer outputs the model parameters. The training of the target model is stopped after the preset number of training times is reached.
[0104] The training process in Figure 2 is only an example of model training and can be modified according to the actual training situation. For example, whether the preset number of training times is reached can be changed to whether the objective function has found the optimal solution, whether the loss function has been minimized, etc. This application does not impose any restrictions on this.
[0105] In this application, a corresponding task execution system can also be deployed in the server to complete the computing task through the task execution system. For ease of understanding, this application provides a task execution system schematic diagram, as shown in Figure 3.
[0106] FIG3 is a schematic diagram of a task execution system provided by this application.
[0107] Among them, the task execution system includes an execution unit manager, a monitoring module and a dynamic resource scheduler. The dynamic resource scheduler includes: a model analysis module, an allocation module, a judgment module and a configuration selection module. The execution unit manager includes the execution unit and transmission unit corresponding to each computing device. The monitoring module includes a function modification unit and a reallocation unit.
[0108] The execution unit manager is responsible for instantiating multiple execution units on each computing device. For example, a GPU can have one or more execution units. These execution units are responsible for completing the computing tasks corresponding to each network layer and providing input data for the next layer of the network; the transmission unit is responsible for transmitting the input data of the next layer. The number of transmission units and execution units is not consistent. If the next layer of the network and the execution unit are on different computing devices, then a transmission unit will be instantiated. If the next layer of the network and the neural network layer that the execution unit is responsible for are on the same computing unit, then there is no need to generate a transmission unit. The transmission unit is generated based on whether data transmission is required in the allocation plan, and the transmission method of the transmission unit is also determined based on the allocation plan.
[0109] The monitoring module is responsible for monitoring the changes in node resources during each batch processing of the deep neural network to calculate whether the data transmission method between the deep neural network layers needs to be modified. When the allocation scheme changes (that is, the execution units corresponding to each network layer change), the function modification unit of the monitoring module can modify the transmission method of the corresponding transmission unit. Through such modifications, the overlap of data transmission and data calculation in the parallel process of the model can be dynamically adjusted to improve the efficiency of deep neural network training.
[0110] It can be seen from the above method that this solution can allocate different computing devices to different network layers based on the device information of different types of computing devices (CPU and GPU) to perform corresponding computing tasks. Compared with the current method of only using GPU to perform major computing tasks, in this solution, both CPU and GPU can determine the network layer that matches it based on its device information, and then execute the computing tasks corresponding to the network layer, which greatly improves the utilization rate of different computing devices and further reduces the execution cost of computing tasks.
[0111] In addition, this solution can also monitor the transmission status of the transmission mode between each execution unit, so as to adjust the transmission mode when the change conditions are met to ensure the data communication efficiency during model training.
[0112] The above are one or more methods for implementing task execution of this application. Based on the same idea, this application also provides a corresponding task execution device, as shown in Figure 4.
[0113] FIG4 is a schematic diagram of a task execution device provided by the present application, including:
[0114] Acquisition module 401, used to acquire model data of the target model;
[0115] A parsing module 402 is configured to parse the model data, determine a computing task corresponding to each network layer in the target model, and determine device information corresponding to a plurality of computing devices participating in the target model calculation, wherein the computing devices include at least one central processing unit (CPU) and at least one graphics processing unit (GPU);
[0116] A first determining module 403 is configured to determine, for each network layer, a computing time required for executing the computing task corresponding to the network layer by the multiple computing devices based on the number of computations involved in executing the computing task corresponding to the network layer and the device information corresponding to the multiple computing devices;
[0117] A second determining module 404 is configured to determine, for each network layer, a computing device that performs the computing task corresponding to the network layer as a target device corresponding to the network layer based on at least one of the computing duration, the data transmission duration between the computing device that performs the computing task corresponding to the previous network layer and the other computing devices, the memory space required for the data of the network layer, and the remaining memory of the plurality of computing devices, wherein the data transmission duration is determined based on the transmission information between the computing device that performs the computing task corresponding to the previous network layer and the other computing devices, and the amount of data output by the previous network layer;
[0118] The execution module 405 is used to deploy the computing tasks corresponding to each network layer in the target model in the target device corresponding to each network layer, so as to execute the computing tasks through the target device after receiving the execution request of the computing tasks corresponding to each network layer.
[0119] Optionally, before determining the computing device corresponding to the network layer, the first determination module 403 is also used to determine at least one execution unit in each of the multiple computing devices to obtain multiple execution units; and determine the computing capacity corresponding to each of the multiple execution units based on the device information corresponding to the multiple computing devices.
[0120] Optionally, the first determination module 403 is specifically used to determine, for each network layer, the computing time required for each execution unit to execute the computing task corresponding to the network layer based on the number of calculations involved in executing the computing task corresponding to the network layer and the computing capability corresponding to each execution unit.
[0121] Optionally, the second determination module 404 is specifically used to determine the execution unit that executes the computing task corresponding to the network layer as the target execution unit corresponding to the network layer based on the computing time corresponding to each execution unit, the data transmission time between the reference execution unit and other execution units, the memory space and at least one of the remaining memory, wherein the reference execution unit is the execution unit that executes the computing task corresponding to the previous network layer; the computing tasks corresponding to each network layer in the target model are deployed in the target devices corresponding to each network layer, so that the computing tasks are executed through the target devices after receiving the execution requests of the computing tasks corresponding to each network layer, including: deploying the computing tasks corresponding to each network layer in the target devices where the target execution units corresponding to each network layer are located, so that the computing tasks are executed through the target execution units after receiving the execution requests of the computing tasks corresponding to each network layer.
[0122] Optionally, the data transmission duration is determined based on the transmission information between the reference execution unit and the other execution units and the amount of data output by the previous network layer.
[0123] Optionally, the second determination module 404 is specifically used to, if the network layer is not the starting network layer of the target model, determine, for each execution unit, the comprehensive duration corresponding to the execution unit based on the calculation duration and data transmission duration corresponding to the execution unit; determine one or more candidate execution units from the multiple execution units, each candidate execution unit corresponding to a computing device with a remaining memory greater than the memory space and a corresponding comprehensive duration less than the calculation time required to execute the corresponding computing task of the network layer through the reference execution unit; determine the target execution unit corresponding to the network layer based on the comprehensive duration corresponding to each candidate execution unit.
[0124] Optionally, the second determination module 404 is specifically used to, if the network layer is the starting network layer of the target model, determine one or more candidate execution units; determine the calculation time corresponding to each candidate execution unit based on the number of calculations required to execute the corresponding computing task of the network layer and the computing power corresponding to each candidate execution unit; and determine the target execution unit corresponding to the network layer based on the calculation time corresponding to each candidate execution unit.
[0125] Optionally, the second determining module 404 is specifically configured to determine the execution units whose remaining memory is greater than the memory space as the one or more candidate execution units.
[0126] Optionally, the execution module 405 is also used to monitor the transmission status of the current transmission mode for each network layer if there are at least two transmission modes between the target execution unit corresponding to the network layer and the target execution unit corresponding to the adjacent network layer of the network layer; determine whether the current transmission mode needs to be adjusted based on the transmission status; if adjustment is required, adjust the current transmission mode to another transmission mode.
[0127] Optionally, the execution module 405 is further configured to determine a transmission mode between the plurality of execution units and a bandwidth corresponding to each transmission mode, wherein the transmission mode includes at least one of a first transmission mode and a second transmission mode.
[0128] Optionally, the execution module 405 is also used to, if the target execution unit corresponding to the network layer and the target execution unit corresponding to the adjacent network layer are both related to the GPU, and the second transmission mode exists between the target execution unit corresponding to the network layer and the target execution unit corresponding to the adjacent network layer, then transmit the data between the network layer and the adjacent network layer through the second transmission mode; otherwise, transmit the data between the network layer and the adjacent network layer through the first transmission mode.
[0129] Optionally, the first transmission mode includes: a high-speed serial computer expansion bus PCI-e, and the second transmission mode includes: NVLINK.
[0130] The present application also provides a computer-readable storage medium, which stores a computer program. The computer program can be used to execute a task execution method provided in FIG. 1 above.
[0131] The present application also provides a schematic structural diagram of an electronic device corresponding to Figure 1 as shown in Figure 5. As shown in Figure 5, at the hardware level, the electronic device includes a processor, an internal bus, a network interface, a memory and a non-volatile memory, and of course may also include hardware required for other services. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to implement the method of task execution described in Figure 1 above. Of course, in addition to software implementation, this application does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc., that is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0132] Improvements to a technology can be clearly distinguished as either hardware improvements (for example, improvements to circuit structures such as diodes, transistors, and switches) or software improvements (improvements to process flows). However, with technological advancements, many process flow improvements today can now be considered direct improvements to hardware circuit structures. Designers almost always create the corresponding hardware circuit structure by programming the improved process flow into the hardware circuit. Therefore, it cannot be said that a process flow improvement cannot be implemented using a hardware module. For example, a programmable logic device (PLD), such as a field programmable gate array (FPGA), is an integrated circuit whose logical function is determined by user programming. Designers can "integrate" a digital system onto a PLD by programming it themselves, without having to hire a chip manufacturer to design and manufacture a dedicated integrated circuit chip. Moreover, nowadays, instead of manually fabricating integrated circuit chips, this programming is mostly performed using "logic compiler" software. This is similar to the software compilers used during program development. Before compilation, the original code must be written in a specific programming language, called a hardware description language (HDL). There are many different HDLs, including ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, and RHDL (Ruby Hardware Description Language). Currently, the most commonly used are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art will also appreciate that simply by programming the method flow in one of these hardware description languages and then programming it into an integrated circuit, a hardware circuit that implements the logic method flow can be easily obtained.
[0133] The controller can be implemented in any suitable manner. For example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, application-specific integrated circuits (ASICs), programmable logic controllers, and embedded microcontrollers. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The controller can also be implemented as part of the control logic of a memory. Those skilled in the art will also know that in addition to implementing the controller in the form of computer-readable program code, it is entirely possible to implement the same functions in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers by logically programming the method steps. Therefore, such a controller can be considered a hardware component, and the devices included therein for implementing various functions can also be considered as structures within the hardware component. Or even, the devices for implementing various functions can be considered as both software modules that implement the method and structures within the hardware component.
[0134] The systems, devices, modules, or units described in the above embodiments may be implemented by computer chips or entities, or by products having certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0135] For the convenience of description, the above devices are described as being divided into various units according to their functions. Of course, when implementing this application, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0136] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0137] The present application is described with reference to the flow chart and / or block diagram of the method, device (system), and computer program product according to the embodiment of the present application. It should be understood that each flow process and / or box in the flow chart and / or block diagram and the combination of the flow process and / or box in the flow chart and / or block diagram can be realized by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processing machine or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device for realizing the function specified in one flow chart flow or multiple flows and / or one box or multiple boxes of the block diagram.
[0138] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a product including an instruction device that implements the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0139] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0140] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.
[0141] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM), and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
[0142] Computer-readable media include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, Phase Change RAM (PRAM), Static Random-Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read-Only Memory (ROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Flash Memory or other memory technologies, Compact Disc Read-Only Memory (CD-ROM), Digital Versatile Disc (DVD) or other optical storage, magnetic cassettes, tape and disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. According to the definition in this article, computer-readable media does not include transitory media such as modulated data signals and carrier waves.
[0143] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.
[0144] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0145] The present application may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communications network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.
[0146] The various embodiments in this application are described in a progressive manner. Similar parts between the various embodiments can be referred to in conjunction with each other. Each embodiment focuses on the differences from other embodiments. In particular, the system embodiment is generally similar to the method embodiment, so the description is relatively simple. For relevant parts, refer to the partial description of the method embodiment.
[0147] The foregoing is merely an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principles of the present application should be included within the scope of the claims of the present application.
Claims
1. A method for executing a task, characterized in that: include: Get the model data of the target model; Parsing the model data, determining the computing tasks corresponding to each network layer in the target model, and determining the device information corresponding to a plurality of computing devices participating in the target model computing, wherein the computing devices include at least one central processing unit (CPU) and at least one graphics processing unit (GPU); For each network layer, according to the number of calculations involved in executing the computing task corresponding to the network layer and the device information corresponding to the multiple computing devices, determine the computing time required for executing the computing task corresponding to the network layer by the multiple computing devices; For each network layer, according to at least one of the calculation duration, the data transmission duration between the computing device that performs the computing task corresponding to the previous network layer and other computing devices, the memory space required for the data of the network layer, and the remaining memory of the plurality of computing devices, determine the computing device that performs the computing task corresponding to the network layer as the target device corresponding to the network layer, wherein the data transmission duration is determined according to the transmission information between the computing device that performs the computing task corresponding to the previous network layer and the other computing devices, and the amount of data output by the previous network layer; The computing tasks corresponding to each network layer in the target model are deployed in the target devices corresponding to each network layer, so that the computing tasks are executed through the target devices after receiving execution requests for the computing tasks corresponding to each network layer.
2. The method according to claim 1, characterized in that Before determining the computing device corresponding to the network layer, the method further includes: Determine at least one execution unit in each of the plurality of computing devices to obtain a plurality of execution units; The computing capability corresponding to each of the plurality of execution units is determined according to the device information corresponding to the plurality of computing devices.
3. The method according to claim 2, characterized in that The determining, for each network layer, according to the number of calculations involved in executing the corresponding computing task of the network layer and the device information corresponding to the multiple computing devices, the computing time required for executing the corresponding computing task of the network layer by the multiple computing devices includes: For each network layer, the computing time required for each execution unit to execute the computing task corresponding to the network layer is determined based on the number of calculations involved in executing the computing task corresponding to the network layer and the computing capacity corresponding to each execution unit.
4. The method according to claim 3, characterized in that The determining, according to at least one of the calculation duration, the data transmission duration between the computing device that executes the computing task corresponding to the previous network layer and other computing devices, the memory space required for the data of the network layer, and the remaining memory of the plurality of computing devices, of the computing device that executes the computing task corresponding to the network layer as the target device corresponding to the network layer includes: According to the calculation duration corresponding to each execution unit, the data transmission duration between the reference execution unit and other execution units, the memory space and at least one of the remaining memory, determine the execution unit that executes the computing task corresponding to the network layer as the target execution unit corresponding to the network layer, wherein the reference execution unit is the execution unit that executes the computing task corresponding to the previous network layer; The step of deploying the computing tasks corresponding to the network layers in the target model in the target devices corresponding to the network layers, so as to execute the computing tasks through the target devices after receiving execution requests for the computing tasks corresponding to the network layers, includes: The computing tasks corresponding to the network layers are deployed in the target device where the target execution units corresponding to the network layers are located, so that the computing tasks are executed by the target execution units after receiving the execution requests of the computing tasks corresponding to the network layers.
5. The method according to claim 4, characterized in that The data transmission duration is determined based on the transmission information between the reference execution unit and the other execution units and the amount of data output by the previous network layer.
6. The method according to claim 4, characterized in that The step of determining, according to the calculation duration corresponding to each execution unit, the data transmission duration between the reference execution unit and other execution units, the memory space, and at least one of the remaining memory, an execution unit that executes the calculation task corresponding to the network layer as a target execution unit corresponding to the network layer includes: If the network layer is not the starting network layer of the target model, for each execution unit, determine the comprehensive duration corresponding to the execution unit according to the calculation duration and data transmission duration corresponding to the execution unit; Determine one or more candidate execution units from the multiple execution units, each candidate execution unit corresponding to a computing device with a remaining memory greater than the memory space and a corresponding comprehensive duration less than the computing duration required when the reference execution unit executes the corresponding computing task of the network layer; The target execution unit corresponding to the network layer is determined according to the comprehensive duration corresponding to each candidate execution unit.
7. The method according to claim 4, characterized in that The step of determining, according to the calculation duration corresponding to each execution unit, the data transmission duration between the reference execution unit and other execution units, the memory space, and at least one of the remaining memory, an execution unit that executes the calculation task corresponding to the network layer as a target execution unit corresponding to the network layer includes: If the network layer is a starting network layer of the target model, determining one or more candidate execution units; Determine the computing time corresponding to each candidate execution unit according to the number of calculations required to execute the computing task corresponding to the network layer and the computing capacity corresponding to each candidate execution unit; The target execution unit corresponding to the network layer is determined according to the calculation duration corresponding to each candidate execution unit.
8. The method according to claim 7, characterized in that The determining one or more candidate execution units comprises: An execution unit whose remaining memory is greater than the memory space is determined as the one or more candidate execution units.
9. The method according to claim 4, characterized in that The method further comprises: For each network layer, if there are at least two transmission modes between a target execution unit corresponding to the network layer and a target execution unit corresponding to an adjacent network layer of the network layer, monitoring the transmission state of the current transmission mode; Determining whether the current transmission mode needs to be adjusted according to the transmission state; If adjustment is needed, the current transmission mode is adjusted to another transmission mode.
10. The method according to claim 4, characterized in that The method further comprises: A transmission mode between the plurality of execution units and a bandwidth corresponding to each transmission mode are determined, wherein the transmission mode includes at least one of a first transmission mode and a second transmission mode.
11. The method according to claim 10, characterized in that The method further comprises: If the target execution unit corresponding to the network layer and the target execution unit corresponding to the adjacent network layer are both related to the GPU, and the second transmission mode exists between the target execution unit corresponding to the network layer and the target execution unit corresponding to the adjacent network layer, the data between the network layer and the adjacent network layer is transmitted through the second transmission mode; otherwise, the data between the network layer and the adjacent network layer is transmitted through the first transmission mode.
12. The method according to claim 10, characterized in that The first transmission mode includes: a high-speed serial computer expansion bus PCI-e, and the second transmission mode includes: NVLINK.
13. A task execution device, characterized in that: include: Acquisition module, acquiring model data of the target model; A parsing module, which parses the model data, determines the computing tasks corresponding to each network layer in the target model, and determines the device information corresponding to a plurality of computing devices participating in the target model calculation, wherein the computing devices include at least one central processing unit (CPU) and at least one graphics processing unit (GPU); A first determination module determines, for each network layer, a computing time required for executing the computing task corresponding to the network layer through the multiple computing devices according to the number of computing times involved in executing the computing task corresponding to the network layer and the device information corresponding to the multiple computing devices; The second determination module determines, for each network layer, a computing device that performs a computing task corresponding to the previous network layer as a target device corresponding to the network layer according to at least one of the computing time, the data transmission time between the computing device that performs a computing task corresponding to the previous network layer and other computing devices, the memory space required for the data of the network layer, and the remaining memory of the plurality of computing devices, wherein the data transmission time is determined according to the transmission information between the computing device that performs a computing task corresponding to the previous network layer and the other computing devices, and the amount of data output by the previous network layer; An execution module deploys the computing tasks corresponding to each network layer in the target model in the target device corresponding to each network layer, so as to execute the computing tasks through the target device after receiving the execution request of the computing tasks corresponding to each network layer.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 12 is implemented.
15. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 12 is implemented.
Citation Information
Patent Citations
Neural network segmentation calculation method and device, storage medium and mobile terminal
CN110298437A
Image feature extraction method and device, electronic equipment and storage medium
CN110889439A
Model parallel training task load balancing method, device and equipment, and storage medium
CN111752713A
Neural network training method and device, electronic equipment, medium and program product
CN113222118A
Method and device for distributing network layers in neural network model
CN114418063A
