WO2023082575A1 - 一种面向神经网络模型计算的图执行流水并行方法和装置 - Google Patents
一种面向神经网络模型计算的图执行流水并行方法和装置 Download PDFInfo
- Publication number
- WO2023082575A1 WO2023082575A1 PCT/CN2022/092481 CN2022092481W WO2023082575A1 WO 2023082575 A1 WO2023082575 A1 WO 2023082575A1 CN 2022092481 W CN2022092481 W CN 2022092481W WO 2023082575 A1 WO2023082575 A1 WO 2023082575A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- execution
- execution body
- data
- memory block
- batch
- Prior art date
- Legal status (The legal status 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 status listed.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/06—Physical realisation, i.e. hardware implementation of neural networks, neurons or parts of neurons
- G06N3/063—Physical realisation, i.e. hardware implementation of neural networks, neurons or parts of neurons using electronic means
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/04—Architecture, e.g. interconnection topology
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/04—Architecture, e.g. interconnection topology
- G06N3/045—Combinations of networks
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/0223—User address space allocation, e.g. contiguous or non contiguous base addressing
- G06F12/023—Free address space management
- G06F12/0253—Garbage collection, i.e. reclamation of unreferenced memory
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/90—Details of database functions independent of the retrieved data types
- G06F16/901—Indexing; Data structures therefor; Storage structures
- G06F16/9024—Graphs; Linked lists
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/30—Arrangements for executing machine instructions, e.g. instruction decode
- G06F9/38—Concurrent instruction execution, e.g. pipeline or look ahead
- G06F9/3885—Concurrent instruction execution, e.g. pipeline or look ahead using a plurality of independent parallel functional units
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
- G06F9/4843—Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5011—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
- G06F9/5016—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5011—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
- G06F9/5022—Mechanisms to release resources
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/08—Learning methods
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2209/00—Indexing scheme relating to G06F9/00
- G06F2209/50—Indexing scheme relating to G06F9/50
- G06F2209/5017—Task decomposition
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Definitions
- the invention relates to the technical field of deep learning, in particular to a graph execution pipeline parallel method and device for neural network model calculation.
- the graph execution pipeline parallel method for neural network model calculation isolates each batch of training data and different subgraphs, and each batch of training data flows sequentially in a 1F1B forward-to-backward manner Through the forward calculation graph and the reverse calculation graph.
- the invention can make each equipment process have a batch of data being processed, keep all equipment processes busy without pipeline suspension, and the entire assembly line is relatively balanced. At the same time, it can ensure that the parameter update on each subgraph is performed at a fixed cycle, which also helps to prevent too many small batches from being processed at the same time and ensures model convergence.
- the object of the present invention is to provide a graph execution pipeline parallel method and device oriented to neural network model calculation, so as to overcome the deficiencies in the prior art.
- the present invention provides the following technical solutions:
- the present application discloses a graph execution pipeline parallel method oriented to neural network model calculation.
- the neural network model is provided with several executors, and there are 2*N executors in total, and N is a positive integer.
- the execution body is provided with several memory blocks; the method specifically includes the following steps:
- the n-th executive executes the S2 operation on the i+1-th batch of sub-data, and at the same time, sends the address of the memory block where the i-th batch is located to the n-th +1 execution body; the n+1th execution body analyzes the memory block where the i-th batch is located, obtains the execution result of the n-th execution body on the i-th batch of sub-data, and uses the execution result of the n-th execution body as the n-th execution body The input data of +1 execution body, execute its own kernel function calculation, and write the execution result into the free memory block of the n+1th execution body; then input the sub-data of the i+2th batch;
- the nth executive executes the S2 operation on the i+2th batch of sub-data
- the nth executive and the n+1th executive execute the i+1th batch
- the second sub-data executes the operation of S3; at the same time, the n+1th execution body sends the address of the memory block where the i-th batch is located to the n+2th execution body, and the n+2th execution body analyzes the memory where the i-th batch is located block, obtain the execution result of the n+1th executive body on the i-th batch of sub-data, and use the execution result of the n+1th executive body as the input data of the n+2th executive body, perform its own kernel function calculation, and Write the execution result to the free memory block of the n+2th execution body;
- the nth execution body reclaims the memory block sent to the n+1th execution body
- the last execution body executes its own kernel function calculation, and writes the execution result into the memory block of the last execution body, and reclaims the memory block by itself immediately after execution.
- the executive body checks whether there is a free memory block in itself; if it exists, then executes its own kernel function calculation on the i-th batch of sub-data; The batch waits for a free block of memory to exist.
- the executable will check whether the execution of the sub-data of the N*(n-1)+1 batch is completed before executing its own kernel function calculation , the n is a positive integer.
- step S5 specifically includes the following operations:
- the n+1th execution body notifies the nth execution body that the memory block sent to the n+1th execution body has been consumed;
- the nth execution body reclaims the memory block sent to the n+1th execution body, and marks it as free.
- the construction of the execution body specifically includes the following sub-steps:
- S02. Create the thread of the executive body: the thread of the executive body is responsible for sequentially obtaining the current pending tasks from the kernel function task queue, and submitting them to the thread pool;
- S03. Create an executive body of kernel function create an executive body used for operator kernel function calculation according to the context information of the current kernel function task and the current thread; and use the executive body to run the kernel function task in the task queue;
- the thread of the event recall queue is responsible for taking out and returning the processed tasks in the event recall queue in turn.
- the invention also discloses a graph execution device oriented to neural network model calculation, which includes an execution body construction module and an execution body pipeline parallel work module, the execution body construction module is used for the construction of the execution body, and the execution body pipeline parallel work The module is used to implement the above-mentioned graph execution pipeline parallel method for neural network model calculation.
- the invention also discloses a graph execution device oriented to neural network model calculation, which includes memory and one or more processors, executable codes are stored in the memory, and the executable code is executed by the one or more processors.
- the code is used, it is used in the above-mentioned graph execution pipeline parallel method for neural network model calculation.
- the invention also discloses a computer-readable storage medium, on which a program is stored.
- a program is stored.
- the above-mentioned graph execution pipeline parallel method oriented to neural network model calculation is realized.
- the present invention Provides a graph execution pipeline parallel method and device for neural network model calculations, creates graph execution bodies on the machine based on the physical computing graphs compiled and generated by the deep learning framework, and allocates multiple free memories for each graph execution body by design
- the block scheme realizes that the entire calculation graph participates in the deep learning training tasks of different batches of data in a parallel manner.
- the graph executive parallel execution method based on multiple free tensor storage blocks disclosed by the present invention is easier to implement distributed training of large models than existing methods.
- the present invention has a low threshold for users, and enables the model to learn the internal correlation of a large number of data flowing into the neural network in batches, thereby obtaining the "intelligence" in the corresponding scenario. "Perception and judgment ability.
- the present invention provides a set of simple and easy-to-use operating device of the neural network model for algorithm engineers related to deep learning, so that the deep learning model can be trained conveniently.
- Figure 1 is an architecture diagram of a graph execution pipeline parallel method for neural network model calculation
- Fig. 2 is a flow chart of creating a management task executive body thread module
- FIG. 1 The basic actions of the task execution body pipeline parallel work module
- FIG. 5 is a schematic structural diagram of a graph execution device oriented to neural network model calculation in the present invention.
- FIG. 1 the architecture diagram of the neural network model calculation-oriented graph execution pipeline parallel method.
- the training data is fed into the neural network model in batches, and the graph execution body on the machine is created according to the physical computing graph compiled and generated by the deep learning framework, and multiple free memory blocks are allocated to each graph execution body, so that the entire calculation
- the graph simultaneously participates in the deep learning training task in a pipelined parallel manner.
- the specific operations are as follows:
- the n-th executive executes the S2 operation on the i+1-th batch of sub-data, and at the same time, sends the address of the memory block where the i-th batch is located to the n-th +1 execution body; the n+1th execution body analyzes the memory block where the i-th batch is located, obtains the execution result of the n-th execution body on the i-th batch of sub-data, and uses the execution result of the n-th execution body as the n-th execution body The input data of +1 execution body, execute its own kernel function calculation, and write the execution result into the free memory block of the n+1th execution body; then input the sub-data of the i+2th batch;
- the nth executive executes the S2 operation on the i+2th batch of sub-data
- the nth executive and the n+1th executive execute the i+1th batch
- the second sub-data executes the operation of S3; at the same time, the n+1th execution body sends the address of the memory block where the i-th batch is located to the n+2th execution body, and the n+2th execution body analyzes the memory where the i-th batch is located block, obtain the execution result of the n+1th executive body on the i-th batch of sub-data, and use the execution result of the n+1th executive body as the input data of the n+2th executive body, perform its own kernel function calculation, and Write the execution result to the free memory block of the n+2th execution body;
- the nth execution body reclaims the memory block sent to the n+1th execution body.
- the last execution body executes its own kernel function calculation, and writes the execution result into the memory block of the last execution body, and reclaims the memory block by itself immediately after execution.
- the executive body checks whether there is a free memory block; if there is, then executes its own kernel function calculation on the i-th batch of sub-data; exists, make the i-th batch wait for a free memory block.
- the executive will check the location of the sub-data of the N*(n-1)+1 batch before executing its own kernel function calculation. Whether the execution of the execution body is completed, and the n is a positive integer.
- step S5 specifically includes the following operations:
- the n+1th execution body notifies the nth execution body that the memory block sent to the n+1th execution body has been consumed;
- the nth execution body reclaims the memory block sent to the n+1th execution body, and marks it as free.
- the construction of the execution body specifically includes the following sub-steps:
- S02. Create the thread of the executive body: the thread of the executive body is responsible for sequentially obtaining the current pending tasks from the kernel function task queue, and submitting them to the thread pool;
- S03. Create an executive body of kernel function create an executive body used for operator kernel function calculation according to the context information of the current kernel function task and the current thread; and use the executive body to run the kernel function task in the task queue;
- the present invention is a graph execution device oriented to neural network model calculation, comprising an execution body construction module and an execution body pipeline parallel work module,
- the executive body construction module includes the following basic actions:
- Create the task queue of the operator kernel function add the calculation tasks of the current operator kernel function to the current kernel function task queue in turn; create the thread of the task executive body: create the thread of the task executive body.
- the thread of the task executor is responsible for sequentially obtaining the current pending tasks from the task queue; when the server receives a request, it submits the request to the thread pool and continues to wait for other requests. If there is an available thread in the pool, it will be woken up and the request will be serviced immediately. If there are no threads available in the pool, tasks are queued until a free thread becomes available. Once a thread has finished its service, it returns to the pool to wait for more work. Thread pools work well when the tasks submitted to them can be executed asynchronously.
- Create the task executive body of the kernel function Create a task executive body for operator kernel function calculation according to the context information of the current kernel function task and the current thread. And use the task executor to run the kernel function tasks in the task queue.
- the thread that creates the event recall queue the thread that creates the event recall queue.
- the threads of the event recall queue are responsible for sequentially taking out and returning the processed tasks in the event recall queue.
- the execution body pipeline parallel work module includes the following basic actions: the execution body inputs data, the current execution body sends a message to the downstream execution body, the downstream execution body prepares the tensor data to be consumed, and the current execution body sends the upstream execution body Send a message, the upstream execution body reclaims the tensor data that has been consumed, and the tail execution body recycles the calculation data by itself.
- Executive input data at time t, for the i-th batch of data, the executive inputs the i-th batch of data, loads its internal operator kernel function calculation task, executes the kernel function calculation, and generates the output tensor of the kernel function calculation task Data, write the execution result to the free memory block;
- the current executive sends a message to the downstream executive: at time t, for the i-th batch of data, store the tensor data produced by the current executive in an empty storage unit, and then match the address of the storage unit with the current executive
- the identity number of the downstream executable is packaged into a message, and then the message is sent to the target executable, and the target executable is the downstream executable corresponding to the current executable;
- the downstream execution body prepares the tensor data to be consumed: at time t, for the i-th batch of data, the downstream execution body receives the message, parses the tensor data produced by the above-mentioned current execution body from the message, and the tensor data will be As the input tensor when the downstream execution body runs its operator kernel function, and checks whether there are free memory blocks available in the memory block produced by itself, if there is an available free memory block, the downstream execution body executes the kernel function of the corresponding operator Computing tasks, read free memory blocks, and the downstream execution body writes the output tensor results generated by execution into memory blocks;
- the current execution body sends a message to the upstream execution body: at time t, for the i-th batch of data, the execution body sends a message to the upstream producer execution body to notify the upstream producer execution body that the execution body consumes the upstream producer execution body.
- Memory block the storage unit where the upstream executive can reclaim its output tensor data;
- the upstream execution body recycles the consumed data: at time t, for the i-th batch of data, the upstream execution body receives the recycling message sent by the downstream execution body, and starts to check whether the memory block has been consumed by all consumer execution bodies After the consumption is completed, if so, the memory block is reclaimed and marked as a free block;
- the tail execution body reclaims the calculation data by itself: at time t, for the i-th batch of data, the tail execution body executes the kernel function calculation task of the corresponding operator, writes its own free memory block, and executes body A to reclaim the memory block by itself immediately after execution.
- An embodiment of a graph execution device oriented to neural network model calculation in the present invention can be applied to any device with data processing capability, and any device with data processing capability can be a device or device such as a computer.
- the device embodiments can be implemented by software, or by hardware or a combination of software and hardware. Taking software implementation as an example, as a device in a logical sense, it is formed by reading the corresponding computer program instructions in the non-volatile memory into the memory for operation by the processor of any device capable of data processing.
- any device with data processing capability where the neural network model calculation-oriented graph execution device is located, except for the processor shown in Figure 5,
- any device with data processing capability where the device in the embodiment is usually based on the actual function of any device with data processing capability may also include other hardware. Let me repeat. For the implementation process of the functions and effects of each unit in the above device, please refer to the implementation process of the corresponding steps in the above method for details, and will not be repeated here.
- the device embodiment since it basically corresponds to the method embodiment, please refer to the part description of the method embodiment for relevant parts.
- the device embodiments described above are only illustrative, and the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in One place, or it can be distributed to multiple network elements. Part or all of the modules can be selected according to actual needs to achieve the purpose of the solution of the present invention. It can be understood and implemented by those skilled in the art without creative effort.
- An embodiment of the present invention also provides a computer-readable storage medium, on which a program is stored.
- a program is stored.
- a graph execution device oriented to neural network model calculation in the above-mentioned embodiments is implemented.
- the computer-readable storage medium may be an internal storage unit of any device capable of data processing described in any of the foregoing embodiments, such as a hard disk or a memory.
- the computer-readable storage medium can also be an external storage device of any device with data processing capabilities, such as a plug-in hard disk, a smart media card (Smart Media Card, SMC), an SD card, and a flash memory card equipped on the device. (Flash Card) etc.
- the computer-readable storage medium may also include both an internal storage unit of any device capable of data processing and an external storage device.
- the computer-readable storage medium is used to store the computer program and other programs and data required by any device capable of data processing, and may also be used to temporarily store data that has been output or will be output.
- building a physical calculation graph consists of forward operator x->forward operator y->forward operator z and reverse operator Z->reverse operator Y->reverse operator X, According to each operator, create an execution body that runs its own kernel function, corresponding to the execution calculation graph that constitutes execution body a->execution body b->execution body c->execution body C->execution body B->execution body A; start The execution body at runtime runs the entire computation graph in parallel.
- Execution body b, execution body c, execution body C, execution body B, and execution body A have no readable input tensor data, so execution bodies b, c, C, B, and A are in the waiting state.
- Step 3 Run the entire computational graph in parallel.
- execution body a For the second batch of data, execution body a inputs data: execution body a also checks whether it has free blocks to write, and finds that there are, and execution body a is also executing the second batch of input data at T2, and writes the execution result into Memory free block r12.
- the current execution body a sends a message to the downstream execution body b, and the downstream execution body b prepares the tensor data to be consumed: the execution body a sends a message to the execution body b to notify the execution body b to read the execution body a
- the output memory block r11, the execution body b receives the message, and checks whether the memory block b produced by itself has a free memory block available, and finds that there is an available free memory block r21, so the execution body b executes the forward operator b at time T2
- the kernel function calculation task reads the memory block r11, and the execution body b writes the output tensor result generated by the execution into the memory block r21.
- execution body a inputs data: execution body a will also check whether it has free blocks to write, if found, execution body a is also executing the third batch of input data, and writes the execution result into the memory Free block r13.
- the current execution body b sends a message to the downstream execution body c, the downstream execution body c prepares the tensor data to be consumed, the current execution body b sends a message to the upstream execution body a, and the upstream execution body a recycles Consumed tensor data:
- Executor b produced memory block r21, so it sent a message to downstream consumer executive c to notify executive c to read the memory block r21 produced by executive b, and executive c received it
- the memory block r21 finds that the memory block r31 is free, so the execution body c starts to execute, reads the memory block r21, and writes to the memory block r31.
- execution body b sends a message to the upstream producer execution body a to inform execution body a that execution body b has used up the memory block r11 of execution body a, and execution body a has received the memory block r11 returned by execution body b after running out, and checks the memory All consumers of block r11 are used up, so the memory block r11 is reclaimed and marked as a free block.
- the current execution body a sends a message to the downstream execution body b, and the downstream execution body b prepares the tensor data to be consumed: the execution body a sends a message to the execution body b to notify the execution body b to read the execution body a
- the output memory block r12 the execution body b receives the message, and checks whether the memory block b produced by itself has a free memory block available, and finds that there is an available free memory block r22, so the execution body b executes the kernel of the forward operator b
- the function computing task reads the memory block r12, and the execution body b writes the output tensor result generated by the execution into the memory block r22.
- execution body a inputs data: execution body a will also check whether it has free blocks to write and execution body A has finished executing. If it finds no, it will wait and not enter the pipeline.
- the current execution body c sends a message to the downstream execution body C, the downstream execution body C prepares the tensor data to be consumed, the current execution body c sends a message to the upstream execution body b, and the upstream execution body b recycles Consumed tensor data: executor c produced memory block r31, then sent a message to downstream consumer executor C to notify executor C to read the memory block r31 produced by executor c, and executor C received
- the memory block r31 finds that the memory block r11 is free, so the execution body C starts to execute, reads the memory block r31, and writes to the memory block r11.
- execution body c sends a message to the upstream producer execution body b to inform execution body b that execution body c has used up the memory block r21 of execution body b, and execution body b has received the memory block r21 returned by execution body c after running out, and checks the memory All consumers of block r21 are used up, so the memory block r21 is reclaimed and marked as a free block.
- the current execution body b sends a message to the downstream execution body c, the downstream execution body c prepares tensor data to be consumed, the current execution body b sends a message to the upstream execution body a, and the upstream execution body a recycles Consumed tensor data:
- Executor b produced memory block r22, so it sent a message to downstream consumer executive c to notify executive c to read the memory block r22 produced by executive b, and executive c received it
- the memory block r22 finds that the memory block r32 is free, so the execution body c starts to execute, reads the memory block r22, and writes to the memory block r32.
- execution body b sends a message to the upstream producer execution body a to inform execution body a that execution body b has used up the memory block r12 of execution body a, and execution body a has received the memory block r12 returned by execution body b after running out, and checks the memory All consumers of block r12 are used up, so the memory block r12 is reclaimed and marked as a free block.
- the current execution body a sends a message to the downstream execution body b, and the downstream execution body b prepares the tensor data to be consumed: the execution body a sends a message to the execution body b to notify the execution body b to read the execution body a
- the output memory block r13 the execution body b receives the message, and checks whether the memory block b produced by itself has a free memory block available, and finds that there is an available free memory block r23, so the execution body b executes the kernel of the forward operator b
- the function computing task reads the memory block r13, and the execution body b writes the output tensor result generated by the execution into the memory block r23.
- execution body a inputs data: execution body a will also check whether it has free blocks to write and execution body A has finished executing. If it finds no, it will wait and not enter the pipeline.
- the current execution body c sends a message to the downstream execution body C, the downstream execution body C prepares the tensor data to be consumed, the current execution body c sends a message to the upstream execution body b, and the upstream execution body b recycles Consumed tensor data: executor c produces memory block r11, then sends a message to downstream consumer executor B to notify executor B to read the memory block r11 produced by executor C, and executor B receives Memory block r11 finds that memory block r21 is free, so executive body B starts to execute, reads memory block r11, and writes to memory block r21.
- execution body C sends a message to the upstream producer execution body c to inform execution body c that execution body C has used up the memory block r31 of execution body c, and execution body c has received the memory block r31 returned by execution body C after running out, and checks the memory All consumers of block r31 are used up, so the memory block r31 is reclaimed and marked as a free block.
- the current execution body c sends a message to the downstream execution body C, the downstream execution body C prepares tensor data to be consumed, the current execution body c sends a message to the upstream execution body b, and the upstream execution body b recycles Consumed tensor data: executor c produces memory block r32, so it sends a message to downstream consumer executor C to notify executor C to read the memory block r32 produced by executor c, and executor C receives The memory block r32 finds that the memory block r12 is free, so the execution body C starts to execute, reads the memory block r32, and writes to the memory block r12.
- execution body c sends a message to the upstream producer execution body b to inform execution body b that execution body c has used up the memory block r22 of execution body b, and execution body b has received the memory block r22 returned by execution body c after running out, and checks the memory All consumers of block r22 are used up, so the memory block r22 is reclaimed and marked as a free block.
- the current execution body b sends a message to the downstream execution body c
- the downstream execution body c prepares tensor data to be consumed
- the current execution body b sends a message to the upstream execution body a
- the upstream execution body a recycles Consumed tensor data:
- Executor b produced memory block r23, and then sent a message to downstream consumer executive c to notify executive c to read the memory block r23 produced by executive b, and executive c received it
- the memory block r23 finds that the memory block r33 is free, so the execution body c starts to execute, reads the memory block r23, and writes to the memory block r33.
- execution body b sends a message to the upstream producer execution body a to inform execution body a that execution body b has used up the memory block r13 of execution body a, and execution body a has received the memory block r13 returned by execution body b after running out, and checks the memory All consumers of block r13 are used up, so the memory block r13 is reclaimed and marked as a free block.
- execution body a inputs data: execution body a will also check whether it has free blocks to write and execution body A has finished executing. If it finds no, it will wait and not enter the pipeline.
- the current execution body B sends a message to the downstream execution body A, the downstream execution body A prepares the tensor data to be consumed, and the tail execution body A recycles the calculation data by itself.
- the current execution body B sends it to the upstream execution body C Message, upstream executive body C reclaims the tensor data that has been consumed: executive body B produces memory block r21, and then sends a message to downstream consumer executive body A to notify executive body A to read the memory produced by executive body B Block r21, Executor A receives memory block r21 and finds that it has free memory block r31, so Executor A starts to execute, reads memory block r21, writes memory block r31, and executes A to recycle memory block r31 immediately after execution.
- execution body B sends a message to the upstream producer execution body C to inform execution body C that execution body B has used up the memory block r11 of execution body C, and execution body C has received the memory block r11 returned by execution body B after running out, and checks the memory All consumers of block r11 are used up, so the memory block r11 is reclaimed and marked as a free block.
- the current execution body C sends a message to the downstream execution body B, the downstream execution body B prepares the tensor data to be consumed, the current execution body C sends a message to the upstream execution body c, and the upstream execution body C recycles Consumed tensor data:
- Executor C produces memory block r12, and then sends a message to downstream consumer Executor B to notify Executor B to read the memory block r12 produced by Executor C, and Executor B receives
- the memory block r12 finds that the memory block r22 is free, so the execution body B starts to execute, reads the memory block r12, and writes to the memory block r22.
- execution body C sends a message to the upstream producer execution body c to inform execution body c that execution body C has used up the memory block r32 of execution body c, and execution body c has received the memory block r32 returned by execution body C after running out, and checks the memory All consumers of block r32 are used up, so the memory block r32 is reclaimed and marked as a free block.
- the current execution body c sends a message to the downstream execution body C, the downstream execution body C prepares the tensor data to be consumed, the current execution body c sends a message to the upstream execution body b, and the upstream execution body b recycles Consumed tensor data: executor c produced memory block r33, then sent a message to downstream consumer executor C to notify executor C to read the memory block r33 produced by executor c, and executor C received
- the memory block r33 finds that the memory block r13 is free, so the execution body C starts to execute, reads the memory block r33, and writes to the memory block r13.
- execution body c sends a message to the upstream producer execution body b to inform execution body b that execution body c has used up the memory block r23 of execution body b, and execution body b has received the memory block r23 returned by execution body c after running out, and checks the memory All consumers of block r23 are used up, so the memory block r23 is reclaimed and marked as a free block.
- execution body a execution body b, execution body c, execution body C, execution body B, and execution body A all start to work in parallel.
- execution body a inputs data: execution body a also checks whether it has free blocks to write and execution body A finishes execution, and if found, execution body a is also executing the fourth batch of input data , write the execution result into the memory free block r11.
- the current execution body B sends a message to the downstream execution body A, the downstream execution body A prepares tensor data to be consumed, the current execution body B sends a message to the upstream execution body C, and the upstream execution body C recycles Consumed tensor data:
- Executor B produces memory block r22, then sends a message to downstream consumer Executor A to notify Executor A to read the memory block r22 produced by Executor B, Executor A receives Memory block r22 finds that memory block r32 is free, so executive body A starts to execute, reads memory block r22, writes memory block r32, and executes body A to recycle memory block r32 immediately after execution.
- execution body B sends a message to the upstream producer execution body C to notify execution body C that execution body B has used up the memory block r12 of execution body C, and execution body C has received the memory block r12 returned by execution body B after running out, and checks the memory All consumers of block r11 are used up, so the memory block r12 is reclaimed and marked as a free block.
- the current execution body C sends a message to the downstream execution body B, the downstream execution body B prepares tensor data to be consumed, the current execution body C sends a message to the upstream execution body c, and the upstream execution body C recycles Consumed tensor data: the current execution body c sends a message to the downstream execution body C, the downstream execution body C prepares tensor data to be consumed, the current execution body c sends a message to the upstream execution body b, and the upstream execution body b recycles Consumed tensor data: executor c produced memory block r13, then sent a message to downstream consumer executor B to notify executor B to read the memory block r13 produced by executor C, and executor B received Memory block r13 finds that memory block r23 is free, so executive body B starts to execute, reads memory block r13, and writes to memory block r23.
- execution body C sends a message to the upstream producer execution body c to inform execution body c that execution body C has used up the memory block r33 of execution body c, and execution body c has received the memory block r33 returned by execution body C after running out, and checks the memory All consumers of block r33 are used up, so the memory block r32 is reclaimed and marked as a free block. So executive a, executive b, executive c, and executive C start to work in parallel. Executors B and A are still waiting because there is no data to read.
- Execution bodies a, b, c, C, B, and A are all working. At this time, a batch of data execution bodies are all executed and the next batch of data is input. Through the design of multiple free memory blocks, the execution body realizes pipeline parallelism.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Data Mining & Analysis (AREA)
- Biophysics (AREA)
- Health & Medical Sciences (AREA)
- Life Sciences & Earth Sciences (AREA)
- Biomedical Technology (AREA)
- Databases & Information Systems (AREA)
- Artificial Intelligence (AREA)
- Computational Linguistics (AREA)
- Evolutionary Computation (AREA)
- General Health & Medical Sciences (AREA)
- Molecular Biology (AREA)
- Computing Systems (AREA)
- Mathematical Physics (AREA)
- Neurology (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Complex Calculations (AREA)
Abstract
Description
Claims (8)
- 一种面向神经网络模型计算的图执行流水并行方法,其特征在于,所述神经网络模型中设有若干个执行体,所述执行体共有2*N个,所述N为正整数,所述执行体设有若干个内存块;所述方法具体包括如下步骤:S1、将训练数据分成若干个批次子数据;S2、若干个批次子数据依次输入神经网络模型中,当第i批次的子数据输入后,第n执行体对第i批次的子数据执行自身核函数计算,并将执行结果写入第n执行体空闲的内存块中;接着输入第i+1批次的子数据;所述i,n均为正整数;S3、当第i+1批次的子数据输入后,第n执行体对第i+1批次的子数据执行S2操作的同时,将第i批次所在的内存块的地址发送至第n+1执行体;第n+1执行体解析第i批次所在的内存块,得到第n执行体对第i批次的子数据的执行结果,并将第n执行体的执行结果作为第n+1执行体的输入数据,执行自身核函数计算,并将执行结果写入第n+1执行体空闲的内存块中;接着输入第i+2批次的子数据;S4、当第i+2批次的子数据输入后,第n执行体对第i+2批次的子数据执行S2操作,第n执行体和第n+1执行体对第i+1批次的子数据执行S3的操作;同时第n+1执行体将第i批次所在的内存块的地址发送至第n+2执行体,第n+2执行体解析第i批次所在的内存块,得到第n+1执行体对第i批次的子数据的执行结果,并将第n+1执行体的执行结果作为第n+2执行体的输入数据,执行自身核函数计算,并将执行结果写入第n+2执行体空闲的内存块中;S5、第n执行体回收发送给第n+1执行体的内存块;S6、最后一个执行体执行自身核函数计算,并将执行结果写入最后一个执行体的内存块,执行完毕即刻自行回收内存块。
- 如权利要求1所述的一种面向神经网络模型计算的图执行流水并行方法,其特征在于:执行体在执行自身核函数计算前,执行体会检查自身是否存在空闲的内存块;若存在,则对第i批次的子数据执行自身核函数计算;若不存在,则令第i批次等待存在空闲的内存块。
- 如权利要求2所述的一种面向神经网络模型计算的图执行流水并行方法,其特征在于,对于第N*n+1批次的子数据,执行体在执行自身核函数计算前,会检查第N*(n-1)+1批次的子数据所在的执行体是否执行完毕,所述n为正整数。
- 如权利要求1所述的一种面向神经网络模型计算的图执行流水并行方法,其特征在于:步骤S5具体包括如下操作:S51、第n+1执行体通知第n执行体已消费完发送给第n+1执行体的内存块;S52、第n执行体回收发送给第n+1执行体的内存块,并将其标记为空闲。
- 如权利要求1所述的一种面向神经网络模型计算的图执行流水并行方法,其特征在于:还包括执行体的构造,所述执行体的构造具体包括如下子步骤:S01、创建算子核函数的任务队列:将当前算子核函数的计算任务依次加入当前核函数任务队列;S02、创建执行体的线程:所述执行体的线程负责从所述核函数任务队列中依次获取当前待处理任务,并提交给线程池;S03、创建核函数的执行体:根据当前核函数任务和当前线程的上下文信息创建用于算子核函数计算的执行体;并使用执行体运行任务队列中的核函数任务;S04、创建事件召回队列:将任务执行体处理完的任务添加到事件召回队列中;S05、创建事件召回队列的线程:所述事件召回队列的线程负责将事件召回队列中已处理的任务依次取出并返回。
- 一种面向神经网络模型计算的图执行装置,其特征在于:包括执行体构造模块和执行体流水并行工作模块,所述执行体构造模块用于执行体的构造,所述执行体流水并行工作模块用于执行如权利要求1-4任一项所述的一种面向神经网络模型计算的图执行流水并行方法。
- 一种面向神经网络模型计算的图执行装置,其特征在于:包括存储器和一个或多个处理器,所述存储器中存储有可执行代码,所述一个或多个处理器执行所述可执行代码时,用于实现权利要求1-5任一项所述的一种面向神经网络模型计算的图执行流水并行方法。
- 一种计算机可读存储介质,其特征在于:其上存储有程序,该程序被处理器执行时,实现权利要求1-5任一项所述的一种面向神经网络模型计算的图执行流水并行方法。
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| US17/838,342 US12468921B2 (en) | 2022-04-27 | 2022-06-13 | Pipelining and parallelizing graph execution method for neural network model computation and apparatus thereof |
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202210447287.7A CN114548383A (zh) | 2022-04-27 | 2022-04-27 | 一种面向神经网络模型计算的图执行流水并行方法和装置 |
| CN202210447287.7 | 2022-04-27 |
Related Child Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| US17/838,342 Continuation US12468921B2 (en) | 2022-04-27 | 2022-06-13 | Pipelining and parallelizing graph execution method for neural network model computation and apparatus thereof |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2023082575A1 true WO2023082575A1 (zh) | 2023-05-19 |
Family
ID=81667147
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2022/092481 Ceased WO2023082575A1 (zh) | 2022-04-27 | 2022-05-12 | 一种面向神经网络模型计算的图执行流水并行方法和装置 |
Country Status (3)
| Country | Link |
|---|---|
| US (1) | US12468921B2 (zh) |
| CN (1) | CN114548383A (zh) |
| WO (1) | WO2023082575A1 (zh) |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN117032954A (zh) * | 2023-07-17 | 2023-11-10 | 北京泛睿科技合伙企业(有限合伙) | 针对终端训练模型的内存优化方法、系统、设备及介质 |
Families Citing this family (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN114548383A (zh) | 2022-04-27 | 2022-05-27 | 之江实验室 | 一种面向神经网络模型计算的图执行流水并行方法和装置 |
| CN115408157A (zh) * | 2022-08-31 | 2022-11-29 | 北京中科睿信科技有限公司 | 一种基于线程池的模型并行化数据仿真方法 |
| CN115688893B (zh) * | 2022-10-19 | 2024-09-03 | 北京百度网讯科技有限公司 | 内存调度方法及装置、电子设备和存储介质 |
Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20190362227A1 (en) * | 2018-05-23 | 2019-11-28 | Microsoft Technology Licensing, Llc | Highly performant pipeline parallel deep neural network training |
| CN112884086A (zh) * | 2021-04-06 | 2021-06-01 | 北京百度网讯科技有限公司 | 模型训练方法、装置、设备、存储介质以及程序产品 |
| CN114139702A (zh) * | 2021-11-25 | 2022-03-04 | 广东浪潮智慧计算技术有限公司 | 一种深度神经网络训练方法、系统、装置、设备及介质 |
| CN114186687A (zh) * | 2022-02-17 | 2022-03-15 | 之江实验室 | 一种面向神经网络模型计算的中间表示方法和装置 |
| CN114237918A (zh) * | 2022-02-28 | 2022-03-25 | 之江实验室 | 一种面向神经网络模型计算的图执行方法和装置 |
| CN114548383A (zh) * | 2022-04-27 | 2022-05-27 | 之江实验室 | 一种面向神经网络模型计算的图执行流水并行方法和装置 |
Family Cites Families (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| WO2022104223A1 (en) * | 2020-11-16 | 2022-05-19 | Lightmatter, Inc. | Parallelization and pipelining strategies for an efficient analog neural network accelerator |
| US12321855B2 (en) * | 2021-04-02 | 2025-06-03 | Tenstorrent Ai Ulc | Graph execution using access request response dynamic batch assembly |
| US20230004871A1 (en) * | 2021-06-30 | 2023-01-05 | Advanced Micro Devices, Inc. | Machine learning cluster pipeline fusion |
| US20230083345A1 (en) * | 2021-09-07 | 2023-03-16 | Nvidia Corporation | Multi-architecture execution graphs |
| US20230084951A1 (en) * | 2021-09-16 | 2023-03-16 | Nvidia Corporation | Synchronizing graph execution |
| US20230169408A1 (en) * | 2021-11-30 | 2023-06-01 | International Business Machines Corporation | Annotation of a Machine Learning Pipeline with Operational Semantics |
-
2022
- 2022-04-27 CN CN202210447287.7A patent/CN114548383A/zh active Pending
- 2022-05-12 WO PCT/CN2022/092481 patent/WO2023082575A1/zh not_active Ceased
- 2022-06-13 US US17/838,342 patent/US12468921B2/en active Active
Patent Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20190362227A1 (en) * | 2018-05-23 | 2019-11-28 | Microsoft Technology Licensing, Llc | Highly performant pipeline parallel deep neural network training |
| CN112884086A (zh) * | 2021-04-06 | 2021-06-01 | 北京百度网讯科技有限公司 | 模型训练方法、装置、设备、存储介质以及程序产品 |
| CN114139702A (zh) * | 2021-11-25 | 2022-03-04 | 广东浪潮智慧计算技术有限公司 | 一种深度神经网络训练方法、系统、装置、设备及介质 |
| CN114186687A (zh) * | 2022-02-17 | 2022-03-15 | 之江实验室 | 一种面向神经网络模型计算的中间表示方法和装置 |
| CN114237918A (zh) * | 2022-02-28 | 2022-03-25 | 之江实验室 | 一种面向神经网络模型计算的图执行方法和装置 |
| CN114548383A (zh) * | 2022-04-27 | 2022-05-27 | 之江实验室 | 一种面向神经网络模型计算的图执行流水并行方法和装置 |
Cited By (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN117032954A (zh) * | 2023-07-17 | 2023-11-10 | 北京泛睿科技合伙企业(有限合伙) | 针对终端训练模型的内存优化方法、系统、设备及介质 |
| CN117032954B (zh) * | 2023-07-17 | 2024-04-26 | 北京泛睿科技合伙企业(有限合伙) | 针对终端训练模型的内存优化方法、系统、设备及介质 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN114548383A (zh) | 2022-05-27 |
| US12468921B2 (en) | 2025-11-11 |
| US20230351145A1 (en) | 2023-11-02 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US20230236888A1 (en) | Memory allocation method, related device, and computer-readable storage medium | |
| US11609792B2 (en) | Maximizing resource utilization of neural network computing system | |
| Chen et al. | Accelerating mapreduce on a coupled cpu-gpu architecture | |
| US11941514B2 (en) | Method for execution of computational graph in neural network model and apparatus thereof | |
| US12468921B2 (en) | Pipelining and parallelizing graph execution method for neural network model computation and apparatus thereof | |
| CN112711478B (zh) | 基于神经网络的任务处理方法、装置、服务器和存储介质 | |
| CN114217966A (zh) | 基于资源调整的深度学习模型动态批处理调度方法和系统 | |
| CN104714785A (zh) | 任务调度装置、方法及并行处理数据的设备 | |
| CN110866610A (zh) | 一种深度学习模型分布式运算的方法及装置 | |
| CN112162854A (zh) | 一种cpu-gpu间计算任务调度方法、系统及介质 | |
| CN111708639A (zh) | 任务调度系统及方法、存储介质及电子设备 | |
| CN114637536B (zh) | 任务处理方法、计算协处理器、芯片及计算机设备 | |
| CN111190741A (zh) | 基于深度学习节点计算的调度方法、设备及存储介质 | |
| US20180046474A1 (en) | Method for executing child kernels invoked on device side utilizing dynamic kernel consolidation and related non-transitory computer readable medium | |
| WO2021008260A1 (zh) | 数据执行体及其数据处理方法 | |
| CN118313458A (zh) | 数据处理方法、数据处理器、电子设备、存储介质 | |
| CN112860396B (zh) | 一种基于分布式深度学习的gpu调度方法及系统 | |
| CN118535332A (zh) | 基于算子选择与细粒度融合的深度学习推理方法及装置 | |
| CN109840151B (zh) | 一种用于多核处理器的负载均衡方法和装置 | |
| CN106155799B (zh) | 基于遗传算法的Codelet调度方法 | |
| CN112395062A (zh) | 任务处理方法、装置、设备及计算机可读存储介质 | |
| CN116185615A (zh) | 减少gpu和cpu交互开销的方法及系统 | |
| CN116301874A (zh) | 代码编译方法、电子设备及存储介质 | |
| CN119847790A (zh) | 一种异步并行执行计算任务的方法及装置 | |
| CN117492973A (zh) | 高效任务分配 |
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: 22891386 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 22891386 Country of ref document: EP Kind code of ref document: A1 |
|
| 32PN | Ep: public notification in the ep bulletin as address of the adressee cannot be established |
Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 02.05.2025) |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 22891386 Country of ref document: EP Kind code of ref document: A1 |