A computing graph processing method and apparatus, and a storage medium
By identifying task nodes in the computation graph that execute in parallel without dependencies, the task execution order is optimized, solving the problem of long computation graph execution time and achieving more efficient task execution.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- TENCENT TECHNOLOGY (SHENZHEN) CO LTD
- Filing Date
- 2020-08-31
- Publication Date
- 2026-05-19
AI Technical Summary
In existing technologies, the execution time of computation graph tasks is relatively long, which affects the efficiency of task execution. This is mainly due to the serial execution caused by the dependency relationship between task nodes.
By obtaining the task nodes in the computation graph, we identify target task nodes that have no dependencies and add them to the node queue. Other task nodes are then executed in parallel, thus optimizing the task execution order.
It effectively improves the execution efficiency of the computation graph, shortens the task execution time, and enhances the parallelism and efficiency of task execution.
Smart Images

Figure CN112035229B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a computational graph processing method, apparatus, and storage medium. Background Technology
[0002] A computation graph is an abstract representation of business logic. Typically, a computation graph consists of at least two nodes and one directed edge. Different nodes correspond to different execution tasks, and the direction of the edge represents the flow of input and output data. There are usually execution order relationships between nodes, i.e., upstream and downstream dependencies.
[0003] In existing technologies, users can define computation graphs using languages such as YAML, JSON, ASL, and XML. This includes defining the calling relationships between services, components, and interfaces, as well as resource orchestration logic. The resource orchestration logic can be sequential, branching, looping, or parallel, thus forming a computation graph for the corresponding business. The computation graph is executed serially, in parallel, or in combination by calling the corresponding threads and handles according to the user-defined task node order. However, currently, when executing the various task nodes in the computation graph, they are usually executed in the user-defined order, which can easily lead to long task execution times and affect task execution efficiency. Summary of the Invention
[0004] This invention provides a computation graph processing method, apparatus, and storage medium that can accurately identify task nodes in a computation graph that do not have dependencies and execute these task nodes concurrently, thereby effectively improving the execution efficiency of the computation graph.
[0005] In a first aspect, embodiments of the present invention provide a computational graph processing method, the method comprising:
[0006] Obtain a computation graph, which includes multiple task nodes arranged in an ordered manner;
[0007] Identify a target task node among the plurality of task nodes that has no dependencies, and add the target task node to the node queue. The dependencies include one or both of the following: global dependencies and direct dependencies with adjacent upstream task nodes.
[0008] Obtain the other task nodes besides the target task node from the plurality of task nodes;
[0009] The other task nodes and the task nodes included in the node queue are executed in parallel.
[0010] In a second aspect, embodiments of the present invention provide a computational graph processing apparatus, the apparatus comprising:
[0011] An acquisition module is used to acquire a computation graph, which includes multiple task nodes arranged in an ordered manner;
[0012] The determination module is used to determine the target task node among the plurality of task nodes that has no dependency relationship, and add the target task node to the node queue. The dependency relationship includes one or both of the following: global dependency relationship and direct dependency relationship with adjacent upstream task nodes.
[0013] The acquisition module is also used to acquire other task nodes among the plurality of task nodes besides the target task node;
[0014] An execution module is used to execute the other task nodes and the task nodes included in the node queue in parallel.
[0015] Thirdly, embodiments of the present invention provide an electronic device, the electronic device including a processor and a storage device, the processor and the storage device being interconnected, the storage device being used to store a computer program, the computer program including program instructions, and the processor being configured to invoke the program instructions to execute the computational graph processing method described in the first aspect.
[0016] Fourthly, embodiments of the present invention provide a computer-readable storage medium storing a computer program, the computer program including program instructions, which are executed by a processor to perform the computational graph processing method described in the first aspect.
[0017] Fifthly, this invention discloses a computer program product or computer program comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the computational graph processing method described in the first aspect.
[0018] In this embodiment of the invention, a computation graph can be obtained, which includes multiple task nodes arranged in an ordered manner. A target task node without any dependencies among the multiple task nodes is identified and added to a node queue. The dependencies include one or both of global dependencies and direct dependencies with adjacent upstream task nodes. Other task nodes besides the target task node are obtained from the multiple task nodes, and the other task nodes and the task nodes included in the node queue are executed in parallel. This can accurately identify task nodes without dependencies in the computation graph and execute these task nodes concurrently, effectively improving the execution efficiency of the computation graph. Attached Figure Description
[0019] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1a This is a schematic diagram of a user-defined execution order calculation graph provided in an embodiment of this application;
[0022] Figure 1b This is a schematic diagram of the execution time of a user-defined execution order calculation graph provided in an embodiment of this application;
[0023] Figure 2 This is a schematic flowchart of a computational graph processing method provided in an embodiment of this application;
[0024] Figure 3 This is a flowchart illustrating the steps of another computational graph processing method provided in an embodiment of this application;
[0025] Figure 4a This is a schematic diagram of a computation graph execution order provided in an embodiment of this application;
[0026] Figure 4b This is a schematic diagram of the actual execution time of a computation graph provided in an embodiment of this application;
[0027] Figure 5 This is a schematic diagram of the structure of a computational graph processing device provided in an embodiment of the present invention;
[0028] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0029] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0030] Cloud technology is a collective term for network technologies, information technologies, integration technologies, management platform technologies, and application technologies applied based on the cloud computing business model. It can form resource pools, providing flexible and convenient on-demand access. Cloud computing technology will become a crucial support. Backend services of technical network systems require substantial computing and storage resources, such as video websites, image websites, and many portal websites. With the rapid development and application of the internet industry, every item may have its own identification mark in the future, requiring transmission to backend systems for logical processing. Data at different levels will be processed separately, and various industry data will all require robust system support, which can only be achieved through cloud computing.
[0031] Cloud computing refers to the delivery and usage model of IT infrastructure, meaning obtaining necessary resources in an on-demand and easily scalable manner through a network. In a broader sense, cloud computing also refers to the delivery and usage model of services, meaning obtaining necessary services in an on-demand and easily scalable manner through a network. These services can be IT and software related, internet-related, or other services. Cloud computing is a product of the development and integration of traditional computer and network technologies such as grid computing, distributed computing, parallel computing, utility computing, network storage technologies, virtualization, and load balancing.
[0032] With the development of the internet, real-time data streams, and the diversification of connected devices, as well as the demands for search services, social networks, mobile commerce, and open collaboration, cloud computing has rapidly developed. Unlike previous parallel and distributed computing, cloud computing will fundamentally revolutionize the entire internet model and enterprise management model.
[0033] For ease of description, the abbreviations and key terms used in the embodiments of this application are first listed below.
[0034] Orchestration: The method of combining various services, components, and interfaces.
[0035] YAML: A highly readable format used to express serialized data, often used for writing configuration files.
[0036] Computation graph: A graph data that defines the upstream and downstream relationships between services, components, and interfaces; it is an abstraction of business logic.
[0037] The electronic devices described in the embodiments of the present invention can specifically be backend service devices such as servers. The server can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms.
[0038] Please see Figure 1a , Figure 1a This is a schematic diagram illustrating a user-defined execution computation graph order provided in an embodiment of this application. For example... Figure 1a As shown, this sequential structure includes a start trigger node, an end node, eight task nodes, and multiple directed edges, encompassing both serial and parallel branch structures. If... Figure 1a Task node 6 does not depend on any other task node, but because it needs to be executed in the user-defined order, its branch execution path is: Start node → Task node 1 → Task node 4 → Task node 6 → Task node 7 → Task node 8 → End node. The user defines it to be executed after Task node 1 and Task node 4, so it must wait until all its upstream task nodes, i.e., Task node 1 and Task node 4, have finished executing before this task node 6 can start executing.
[0039] For better understanding, please refer to [link / reference]. Figure 1b This is a schematic diagram of the execution time of a user-defined execution order calculation graph provided in an embodiment of this application. For example... Figure 1b As shown, corresponding Figure 1a The execution time for each task node is as follows. It can be observed that the longest path in this computation graph is Start Node → Task Node 1 → Task Node 4 → Task Node 6 → Task Node 7 → Task Node 8 → End Node, with a total execution time of 22 seconds. In the serial execution branch, Task Node 6's upstream task node has a total execution time of 11 seconds. This task node begins execution after the 11th second. It can be seen that strictly following the user-defined execution order can easily lead to longer task execution times, affecting task execution efficiency.
[0040] To address the problem of long execution times in computation graphs, which negatively impact task efficiency, this invention provides a computation graph processing method that identifies task nodes without dependencies and executes these nodes along with other task nodes in the computation graph in parallel, thereby improving the execution efficiency of the computation graph.
[0041] Please see Figure 2 This is a schematic flowchart of a computational graph processing method provided in an embodiment of the present invention. The computational graph processing method includes the following steps:
[0042] 201. Obtain a computation graph, which includes multiple task nodes arranged in an ordered manner.
[0043] The computation graph consists of multiple task nodes connected by directed edges. Different task nodes perform different computation tasks, and the directed edges represent the input and output directions of data between adjacent nodes. The computation graph is defined by the user using the YAML language and arranged in a user-defined order. It includes multiple task nodes arranged in an ordered manner, and each task node can call various predefined resources such as services, components, and interfaces when it is executed.
[0044] 202. Determine the target task node among the multiple task nodes that has no dependency relationship, and add the target task node to the node queue.
[0045] The dependencies include one or both of the following: global dependencies and direct dependencies with adjacent upstream task nodes.
[0046] Global dependencies can include, but are not limited to, dependencies on global parameters, dependencies on execution time (must start execution after a certain point in time), dependencies on execution order (must start execution after a certain task node or in a specified order), and dependencies on external conditions (requires external services to trigger certain events).
[0047] It should be noted that external condition dependency can be considered as a separate dependency relationship, referred to as external condition dependency relationship. Of course, external condition dependency can also be regarded as a global dependency relationship, but this embodiment of the invention does not limit it.
[0048] Specifically, the electronic device can obtain the relevant configuration parameters of each task node in the computation graph. These configuration parameters include, for example, input parameters, output parameters, global parameters, execution rule restriction parameters, external service trigger events, etc., and find the target task node that has no dependency relationship based on one or more of these parameters.
[0049] The execution rule restriction parameter is used to restrict the execution of downstream task nodes. The external service trigger event is used to trigger the execution of downstream task nodes.
[0050] 203. Obtain the other task nodes among the plurality of task nodes besides the target task node.
[0051] 204. Execute the other task nodes and the task nodes included in the node queue in parallel.
[0052] Specifically, the task nodes included in the node queue can be executed synchronously with other task nodes. The electronic device sequentially retrieves task nodes from the node queue for execution, while simultaneously executing other task nodes in the order defined by the user in the computation graph.
[0053] In this embodiment of the invention, the electronic device can determine a target task node among multiple task nodes in the computation graph that has no dependencies, and add the target task node to the node queue. The dependencies include one or both of global dependencies and direct dependencies with adjacent upstream task nodes. Other task nodes besides the target task node are obtained from the multiple task nodes, and the other task nodes and the task nodes included in the node queue are executed in parallel. Thus, when executing the computation graph, the user-defined execution order can be automatically optimized, the task nodes without dependencies in the computation graph can be accurately identified, and such task nodes can be executed concurrently, effectively improving the execution efficiency of the computation graph.
[0054] Please see Figure 3 This is a schematic flowchart of another computational graph processing method provided in an embodiment of the present invention. The computational graph processing method includes the following steps:
[0055] 301. Obtain a computation graph, which includes multiple task nodes arranged in an ordered manner.
[0056] The specific implementation of step 301 can be found in the relevant description of step 201 in the foregoing embodiments, and will not be repeated here.
[0057] 302. Obtain task node pairs from the plurality of task nodes, wherein the node pair includes an upstream task node and a downstream task node adjacent to the upstream task node.
[0058] 303. Determine whether the downstream task node has a global dependency relationship and a direct dependency relationship with the upstream task node.
[0059] Global dependencies can include, but are not limited to, dependencies on global parameters, dependencies on execution time (must start execution after a certain point in time), dependencies on execution order (must start execution after a certain task node or in a specified order), and dependencies on external conditions (requires external services to trigger certain events).
[0060] In some feasible implementations, if a task node satisfies neither a global dependency nor a direct dependency with an upstream task node, it is determined that the task node has no dependencies. By comprehensively determining whether a task node is a node without dependencies through multiple dependencies, such as global and direct dependencies, the accuracy of the determination can be improved, which helps in ensuring the ordered execution of tasks in the computation graph. Of course, other possible potential dependencies can also be combined to comprehensively determine whether a task node is a node without dependencies. This embodiment of the invention does not limit the number of dependencies used.
[0061] 304. If the downstream task node does not have the global dependency relationship or the direct dependency relationship, then the downstream task node is regarded as the target task node without dependency relationship, and the target task node is added to the node queue.
[0062] Specifically, the electronic device can form a task node pair by any two adjacent upstream task nodes and downstream task nodes. For any task node pair, it can determine whether the downstream task node has a global dependency relationship and a direct dependency relationship with the upstream task node. If the downstream task node does not have a global dependency relationship or a direct dependency relationship, then the downstream task node is regarded as the target task node without a dependency relationship.
[0063] In some feasible implementations, the specific ways in which the electronic device determines whether there is a global dependency relationship with the downstream task node and a direct dependency relationship with the upstream task node may include: the electronic device can use the input parameters and output parameters of the task node to determine whether there is a direct dependency relationship with the upstream task node, and use the global parameters, execution rule restriction parameters, external service trigger events, etc. of the task node to determine whether there is a global dependency relationship.
[0064] For example, an electronic device can obtain the input parameters of a downstream task node and the output parameters of an upstream task node. The input parameters include target global parameters. If the target global parameters are obtained from the global parameter storage space, it is determined that the downstream task node has no global dependency. If the input parameters of the downstream task node do not include the output parameters of the upstream task node, it is determined that the downstream task node has no direct dependency on the upstream task node.
[0065] The global parameter storage space is used to store the global parameters required by the task nodes in the computation graph during execution. Some of the specific data of the global parameters of the task nodes can be set during initialization, while others can be generated by other task nodes during execution. The other task nodes then set the specific data of the corresponding global parameters in the global parameter storage space based on the generated data.
[0066] For example, electronic devices can also determine whether a downstream task node has a global dependency by executing rule restriction parameters. If the downstream task node has execution rule restriction parameters, it can be understood that the downstream task node has a global dependency. Execution rule restriction parameters can include execution restriction time, execution restriction order, etc. For example, the execution restriction time of the downstream task node is that it can only start execution after the 10th second of the task execution, or it can only start execution after a certain node has finished executing or in a specific order.
[0067] For example, electronic devices can also determine whether a downstream task node has a global dependency by triggering events through external services. If a downstream task node has an external service triggering event, it can be understood that the downstream task node has a global dependency.
[0068] In some feasible implementations, electronic devices can use multiple parameters to jointly determine whether a downstream task node has a global dependency. These multiple parameters can be two or three of the following: global parameters, execution rule restriction parameters, and external service trigger events. For example, the determination can be made using three parameters: global parameters, execution rule restriction parameters, and external service trigger events. Only when the global parameters of the downstream task node can be obtained from the global parameter storage space, and the downstream task node does not have execution rule restriction parameters or external service trigger events, can it be determined that the downstream task node does not have a global dependency. Using multiple parameters to comprehensively determine whether a task node has a global dependency can improve the accuracy of the determination result.
[0069] Specifically, for determining whether there is a direct dependency relationship with the upstream task node by using the input and output parameters of the task node, and determining whether there is a global dependency relationship by using the global parameters of the task node, this can be achieved through the dependency judgment function DependencyJudge() shown below. The input parameters of the dependency judgment function are a node pair (Node1, Node2) and a global parameter (Context), where Node1 is the upstream node and Node2 is the downstream node adjacent to Node1.
[0070] If Node2's global variables satisfy the condition that it can obtain the target global parameters required by Node2 from the global parameter storage space, and Node2's input parameters do not include any of Node1's output parameters, indicating that Node2 and Node1 have no direct dependency relationship and Node2 also has no global dependency relationship, then DependencyJudge() returns true, indicating that Node2 has no dependency relationship.
[0071] If the target global parameters required by Node2 cannot be obtained from the global parameter storage space, that is, the target global parameters need to be provided by other task nodes, then Node2 has a global dependency. If the input parameters of Node2 include any of the output parameters of Node1, then Node2 has a direct dependency with Node1. As long as Node2 has either a global dependency or a direct dependency, DependencyJudge() will return a false result, indicating that Node2 has a dependency.
[0072] function DependencyJudge(Node1,Node2,Context):
[0073] input←emptySet
[0074] output←emptySet
[0075] global_variables←Context.global_variables
[0076] for iin Node2.inputs do:
[0077] input.add(i)
[0078] end
[0079] for iin Node 1.outputs do:
[0080] output.add(i)
[0081] end
[0082] paramsHasDependency←false
[0083] for iin Node1.output do:
[0084] if input.contains(i):
[0085] paramsHasDependency←true
[0086] break
[0087] end
[0088] end
[0089] globalContextSatisfy←true
[0090] For iin input, do:
[0091] if not global_variabls.contains(i):
[0092] globalContextSatisfy ← false
[0093] break
[0094] end
[0095] end
[0096] return not paramsHasDependency and globalContextSatisfy
[0097] 305. Obtain the other task nodes among the plurality of task nodes besides the target task node.
[0098] 306. Execute the other task nodes and the task nodes included in the node queue in parallel.
[0099] Specifically, the task nodes included in the node queue can be executed synchronously with other task nodes. The electronic device sequentially retrieves task nodes from the node queue for execution, while simultaneously executing other task nodes in the order defined by the user in the computation graph.
[0100] For example, such as Figure 1a As shown, for the task node pair of task node 4 and task node 6, if the input parameters of task node 6 do not include any of the output parameters of task node 4, then it is determined that task node 6 and task node 4 have no direct dependency relationship. If the input parameters of task node 6 do not include global parameters or the required global parameters can be directly obtained from the global parameter storage space, then it is determined that task node 6 has no global dependency relationship. If both conditions are met, then it is determined that task node 6 has no dependency relationship, and task node 6 can be added to the execution queue so that task node 6 can be executed in parallel with task node 1 without waiting for task node 1 and task node 4 to finish executing before it can start execution.
[0101] 307. During the parallel execution of the other task nodes and the task nodes included in the node queue, unexecuted task nodes are obtained from the other task nodes. The unexecuted task nodes have the global dependency relationship and do not have a direct dependency relationship with adjacent upstream task nodes.
[0102] 308. If it is determined that the global dependency of the unexecuted task node is resolved, then the unexecuted task node is added to the node queue.
[0103] Specifically, during the parallel execution of task nodes and other task nodes in the node queue, the electronic device can obtain unexecuted task nodes from these other task nodes. Among them, the unexecuted task nodes have global dependencies but no direct dependencies with upstream adjacent task nodes. Then, it can be determined whether the global dependencies of the unexecuted task nodes have been resolved. If the global dependencies have been resolved, the unexecuted task nodes can be added to the node queue, so that the unexecuted task nodes can be executed with priority, further saving the execution time of the computation graph and improving execution efficiency.
[0104] The task nodes in the node queue and other task nodes in the computation graph can be executed in parallel by calling the RunGraph() function.
[0105]
[0106]
[0107] The overall implementation of the computation graph execution function can include: before execution begins, all task nodes are treated as white nodes (i.e., unexecuted task nodes). The computation graph is traversed to obtain all task node pairs. The dependency judgment function `DependencyJudge()` is called to find all task nodes `s.next` without dependencies, and `s.next` is added to the node queue `q` using the `q.add()` function. Then, other task nodes in the computation graph and the task nodes included in the node queue are executed in parallel. During execution, unexecuted task nodes can be retrieved from these other task nodes. If an unexecuted task node has a global dependency but no direct dependency with an upstream adjacent task node, the dependency judgment function `DependencyJudge()` can be called again to determine if the global dependency of the unexecuted task node has been resolved. If the global dependency is resolved, the unexecuted task node can be added to the node queue `q`, allowing it to be executed first, further saving computation graph execution time and improving execution efficiency.
[0108] For example, suppose Figure 1aTask node 6 has no direct dependency on task node 4, and task node 6 has no global dependency. Task node 7 has a direct dependency on task node 6, and task node 7 has no global dependency. Therefore, task node 6 can be added to the node queue. The actual execution order is as follows: Figure 4a As shown, task node 6 can be executed in parallel with task node 1 without waiting for task nodes 1 and 4 to finish before starting its own execution. Task nodes 6 and 7 form a new branch execution path: Start Node → Task Node 6 → Task Node 7 → Task Node 8 → End Node. It can be seen that... Figure 1a Compared to the previous execution path, the execution order structure has changed. Task node 6 only needs to be triggered by the start node to execute concurrently with task node 1.
[0109] Further, please see Figure 4b This is a schematic diagram of the actual execution time of a computation graph provided in an embodiment of this application. It can be seen that after adjusting the execution order, the longest path is Start Node → Task Node 1 → Task Node 4 → Task Node 8 → End Node, with a total execution time of 12 seconds. Compared to... Figure 1b The longest path took 22 seconds to execute, reducing the total execution time by 10 seconds and improving efficiency by 83%.
[0110] In some feasible implementations, during the parallel execution of task nodes and other task nodes in the node queue, for unexecuted task nodes with only global dependencies, it can be determined whether the global dependencies of the unexecuted task node have been resolved. Specifically, it can be determined whether the required global parameters can be obtained from the global parameter storage space, or whether the execution rule restrictions have been met, such as whether the execution time limit has been reached, whether the execution order has been met, or whether an external service trigger event has occurred. If it is determined that the global dependency has been resolved, the unexecuted task node can be added to the node queue, allowing it to be executed with priority, further saving the execution time of the computation graph and improving execution efficiency. For example, as... Figure 1aAs shown, task node 6 and task node 4 do not have a direct dependency, but they do have a global dependency. Assuming that the global parameters of task node 6 need to be provided by task node 2, and task node 2 takes 3 seconds to execute while task node 4 takes 5 seconds to execute, then during the execution of the nodes, it can be determined whether task node 2 has finished executing. If it has finished executing, then the global parameters required by task node 6 can be provided by task node 2. That is to say, the global parameters required by task node 6 are satisfied, and it can be considered that the global dependency of task node 6 is now resolved. Then task node 6 can be added to the node queue so that task node 6 can be executed first, instead of following the user-defined order (i.e., waiting for task node 4 to finish executing before executing task node 6), thereby further saving the execution time of the computation graph and improving execution efficiency.
[0111] In this embodiment of the invention, the electronic device can obtain task node pairs from multiple task nodes included in the computation graph. Each node pair includes an upstream task node and a downstream task node adjacent to the upstream task node. The device comprehensively judges whether a downstream task node has a dependency relationship based on global dependencies and direct dependencies with the upstream task node. If no global or direct dependency relationship exists, the downstream task node and other task nodes are executed in parallel. This accurately identifies task nodes in the computation graph that do not have dependencies and executes them concurrently, effectively improving the execution efficiency of the computation graph. Furthermore, during parallel execution, for unexecuted task nodes that only have global dependencies, it can be determined whether the global dependency relationship of the unexecuted task node has been resolved. If resolved, the unexecuted task node can also be added to the node queue, allowing it to be executed with priority, further saving computation graph execution time and improving execution efficiency.
[0112] Please see Figure 5 This is a schematic diagram of a computational graph processing device according to an embodiment of the present invention. The device includes:
[0113] The acquisition module 501 is used to acquire a computation graph, which includes multiple task nodes arranged in an ordered manner;
[0114] The determining module 502 is used to determine the target task node among the plurality of task nodes that does not have a dependency relationship, and add the target task node to the node queue. The dependency relationship includes one or both of the following: global dependency relationship and direct dependency relationship with adjacent upstream task nodes.
[0115] The acquisition module 501 is further configured to acquire other task nodes among the plurality of task nodes besides the target task node;
[0116] The execution module 503 is used to execute the other task nodes and the task nodes included in the node queue in parallel.
[0117] Optionally, the determining module 502 is specifically used for:
[0118] Obtain task node pairs from the plurality of task nodes, wherein the node pair includes an upstream task node and a downstream task node adjacent to the upstream task node;
[0119] Determine whether the downstream task node has a global dependency relationship and a direct dependency relationship with the upstream task node;
[0120] If the downstream task node does not have the global dependency or the direct dependency, then the downstream task node is regarded as the target task node without the dependency.
[0121] Optionally, the determining module 502 is specifically used for:
[0122] Obtain the input parameters of the downstream task node and the output parameters of the upstream task node, wherein the input parameters include target global parameters;
[0123] If the target global parameters are obtained from the global parameter storage space, it is determined that the downstream task node has no global dependency.
[0124] If the input parameters of the downstream task node do not include the output parameters of the upstream task node, then it is determined that the downstream task node does not have a direct dependency relationship with the upstream task node.
[0125] Optionally, the global parameter storage space is used to store the global parameters required by the task nodes in the computation graph during execution.
[0126] Optionally, the determining module 502 is further configured to determine that the downstream task node does not have a global dependency if there is no execution rule restriction parameter for the downstream task node, wherein the execution rule restriction parameter is used to restrict the execution of the downstream task node.
[0127] Optionally, the execution rule restriction parameters include one or more of the following: execution restriction time and execution restriction order.
[0128] Optionally, the determining module 502 is further configured to determine that the downstream task node does not have a global dependency if there is no external service triggering event for the downstream task node, wherein the external service triggering event is used to trigger the execution of the downstream task node.
[0129] Optionally, the acquisition module 501 is further configured to acquire unexecuted task nodes from the other task nodes during the parallel execution of the other task nodes and the task nodes included in the node queue, wherein the unexecuted task nodes have the global dependency relationship and do not have a direct dependency relationship with adjacent upstream task nodes.
[0130] The determining module 502 is further configured to add the unexecuted task node to the node queue if it is determined that the global dependency relationship of the unexecuted task node has been released.
[0131] It should be noted that the functions of each functional module of the computational graph processing device in the embodiments of the present invention can be specifically implemented according to the methods in the above method embodiments. The specific implementation process can be referred to the relevant descriptions in the above method embodiments, which will not be repeated here.
[0132] Please see Figure 6 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present invention. The electronic device of the present invention includes a power supply module and other structures, and includes a processor 601, a storage device 602, and a network interface 603. The processor 601, the storage device 602, and the network interface 603 can exchange data.
[0133] The storage device 602 may include volatile memory, such as random-access memory (RAM); the storage device 602 may also include non-volatile memory, such as flash memory, solid-state drive (SSD), etc.; the storage device 602 may also include a combination of the above types of memory.
[0134] The processor 601 may be a central processing unit (CPU). In one embodiment, the processor 601 may also be a graphics processing unit (GPU). The processor 601 may also be a combination of a CPU and a GPU. In one embodiment, the storage device 602 is used to store program instructions. The processor 601 can invoke the program instructions to perform the following operations:
[0135] Obtain a computation graph, which includes multiple task nodes arranged in an ordered manner;
[0136] Identify a target task node among the plurality of task nodes that has no dependencies, and add the target task node to the node queue. The dependencies include one or both of the following: global dependencies and direct dependencies with adjacent upstream task nodes.
[0137] Obtain the other task nodes besides the target task node from the plurality of task nodes;
[0138] The other task nodes and the task nodes included in the node queue are executed in parallel.
[0139] Optionally, the processor 601 is specifically used for:
[0140] Obtain task node pairs from the plurality of task nodes, wherein the node pair includes an upstream task node and a downstream task node adjacent to the upstream task node;
[0141] Determine whether the downstream task node has a global dependency relationship and a direct dependency relationship with the upstream task node;
[0142] If the downstream task node does not have the global dependency or the direct dependency, then the downstream task node is regarded as the target task node without the dependency.
[0143] Optionally, the processor 601 is specifically used for:
[0144] Obtain the input parameters of the downstream task node and the output parameters of the upstream task node, wherein the input parameters include target global parameters;
[0145] If the target global parameters are obtained from the global parameter storage space, it is determined that the downstream task node has no global dependency.
[0146] If the input parameters of the downstream task node do not include the output parameters of the upstream task node, then it is determined that the downstream task node does not have a direct dependency relationship with the upstream task node.
[0147] Optionally, the global parameter storage space is used to store the global parameters required by the task nodes in the computation graph during execution.
[0148] Optionally, the processor 601 is further configured to determine that the downstream task node does not have a global dependency if there is no execution rule restriction parameter for the downstream task node, wherein the execution rule restriction parameter is used to restrict the execution of the downstream task node.
[0149] Optionally, the execution rule restriction parameters include one or more of the following: execution restriction time and execution restriction order.
[0150] Optionally, the processor 601 is further configured to determine that the downstream task node does not have a global dependency if there is no external service triggering event for the downstream task node, wherein the external service triggering event is used to trigger the execution of the downstream task node.
[0151] Optionally, the processor 601 is further configured to, during the parallel execution of the other task nodes and the task nodes included in the node queue, obtain unexecuted task nodes from the other task nodes, wherein the unexecuted task nodes have the global dependency relationship and do not have a direct dependency relationship with adjacent upstream task nodes, and if it is determined that the global dependency relationship of the unexecuted task nodes is released, then add the unexecuted task nodes to the node queue.
[0152] In specific implementations, the processor 601, storage device 602, and network interface 603 described in the embodiments of the present invention can execute the embodiments of the present invention. Figure 2 or Figure 3 The implementation described in the relevant embodiments of the computational graph processing method provided can also be used to execute the embodiments of the present invention. Figure 5 The implementation methods described in the relevant embodiments of the computational graph processing device are not repeated here.
[0153] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program includes one or more instructions and can be stored in a computer storage medium. When executed, the program can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0154] This application also provides a computer program product or computer program that includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the steps described in the embodiments of the above methods.
[0155] The above-disclosed embodiments are only some of the embodiments of this application, and should not be construed as limiting the scope of this application. Therefore, any equivalent changes made in accordance with the claims of this application shall still fall within the scope of this application.
Claims
1. A computational graph processing method, characterized in that, include: Obtain a computation graph, which includes multiple task nodes arranged in an ordered manner; Identify a target task node among the plurality of task nodes that has no dependencies, and add the target task node to the node queue. The dependencies include global dependencies and direct dependencies with adjacent upstream task nodes. The existence of the global dependency is determined based on global parameters, execution rule restriction parameters, and external service trigger events; the existence of the direct dependency is determined based on the input and output parameters of the task node. Obtain the other task nodes besides the target task node from the plurality of task nodes; The other task nodes and the task nodes included in the node queue are executed in parallel, and during the parallel execution, the other task nodes are executed in the order of the computation graph. During the parallel execution of the other task nodes and the task nodes included in the node queue, unexecuted task nodes are obtained from the other task nodes. The unexecuted task nodes have the global dependency relationship, but do not have a direct dependency relationship with adjacent upstream task nodes. If it is determined that the global dependency of the unexecuted task node is resolved, then the unexecuted task node is added to the node queue.
2. The method according to claim 1, characterized in that, The step of determining the target task node among the plurality of task nodes that has no dependency relationship includes: Obtain task node pairs from the plurality of task nodes, wherein the node pair includes an upstream task node and a downstream task node adjacent to the upstream task node; Determine whether the downstream task node has a global dependency relationship and a direct dependency relationship with the upstream task node; If the downstream task node does not have the global dependency or the direct dependency, then the downstream task node is regarded as the target task node without the dependency.
3. The method according to claim 2, characterized in that, The step of determining whether the downstream task node has a global dependency relationship and a direct dependency relationship with the upstream task node includes: Obtain the input parameters of the downstream task node and the output parameters of the upstream task node, wherein the input parameters include target global parameters; If the target global parameters are obtained from the global parameter storage space, it is determined that the downstream task node has no global dependency. If the input parameters of the downstream task node do not include the output parameters of the upstream task node, then it is determined that the downstream task node does not have a direct dependency relationship with the upstream task node.
4. The method according to claim 3, characterized in that, The global parameter storage space is used to store the global parameters required by the task nodes in the computation graph during execution.
5. The method according to claim 3 or 4, characterized in that, The method further includes: If there are no execution rule restriction parameters for the downstream task node, it is determined that the downstream task node has no global dependency. The execution rule restriction parameters are used to restrict the execution of the downstream task node.
6. The method according to claim 5, characterized in that, The execution rule restriction parameters include one or more of the following: execution restriction time and execution restriction order.
7. The method according to claim 3, characterized in that, The method further includes: If no external service triggering event exists for the downstream task node, it is determined that the downstream task node has no global dependency, and the external service triggering event is used to trigger the execution of the downstream task node.
8. A computational graph processing apparatus, characterized in that, The device includes: An acquisition module is used to acquire a computation graph, which includes multiple task nodes arranged in an ordered manner; The determination module is used to determine the target task node among the plurality of task nodes that does not have a dependency relationship, and add the target task node to the node queue. The dependency relationship includes global dependency relationship and direct dependency relationship with adjacent upstream task nodes. The existence of the global dependency relationship is determined based on global parameters, execution rule restriction parameters and external service triggering events. The existence of the direct dependency relationship is determined based on the input parameters and output parameters of the task node. The acquisition module is also used to acquire other task nodes among the plurality of task nodes besides the target task node; An execution module is used to execute the other task nodes and the task nodes included in the node queue in parallel, wherein the other task nodes are executed in the order of the computation graph during the parallel execution process; The acquisition module is further configured to acquire unexecuted task nodes from the other task nodes during the parallel execution of the other task nodes and the task nodes included in the node queue. The unexecuted task nodes have the global dependency relationship and do not have a direct dependency relationship with adjacent upstream task nodes. The determining module is further configured to add the unexecuted task node to the node queue if it is determined that the global dependency relationship of the unexecuted task node has been resolved.
9. A computer-readable storage medium, characterized in that, The computer storage medium stores a computer program, the computer program including program instructions, which are executed by a processor to perform the computational graph processing method as described in any one of claims 1-7.
10. An electronic device, characterized in that, The electronic device includes a processor and a storage device interconnected thereto. The storage device is used to store a computer program, the computer program including program instructions. The processor is configured to invoke the program instructions to perform the computational graph processing method as described in any one of claims 1-7.
11. A computer program product comprising computer instructions, characterized in that, The computer instructions are stored in a computer-readable storage medium, read and executed by the processor of a computer device, causing the computer device to perform the computational graph processing method as described in any one of claims 1-7.