Method and device for executing graph neural network task, electronic device and storage medium
Patent Information
- Application Number
- CN202311845287.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-28
- Publication Date
- 2026-11-03
- Estimated Expiration
- 2043-12-28
AI Technical Summary
During graph partitioning, the preemption problem in edge allocation leads to low partitioning efficiency, increases the waiting time for downstream GNN tasks, and the neighbor edges of many nodes are located in different partitions, increasing the communication overhead between processes.
The knowledge graph is randomly divided into multiple subgraphs by an edge partitioning method, with each subgraph corresponding to a partition. The expansion direction of the neighbor edges is determined according to the construction method of the node features in the downstream graph neural network task. The iterative operation based on neighbor expansion is executed in parallel by multiple sub-servers to obtain the edge partitioning result, which is then converted into the node partitioning result for execution of the downstream task.
It avoids the problem of edge allocation preemption, improves partitioning efficiency, reduces the waiting time of downstream GNN tasks and the communication consumption between processes, optimizes the aggregation of neighbor edges of node features, and reduces the imbalance of node partitions.
Smart Images

Figure CN117807246B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of computer technology, and in particular relates to a method, apparatus, electronic device and storage medium for performing graph neural network tasks. Background Technology
[0002] A graph, such as a knowledge graph, is a knowledge network that includes entities and the relationships between them. Entities are nodes in the graph, and relationships are edges. Graph partitioning is the process of dividing a complete graph into several subgraphs to facilitate operation in a distributed system. Graph partitioning can be divided into vertex partitioning and edge partitioning. Vertex partitioning divides the graph based on the set of nodes, while edge partitioning divides the graph based on the set of edges.
[0003] In related technologies, when graph partitioning is performed using edge partitioning, a problem arises where two nodes on an edge are selected as expansion nodes by two different partitions. The process that first locks the edge first assumes the final ownership of the edge, then sends it globally, and iterates again only after all processes have determined the selection of the current edge. Due to the communication and waiting time between processes, the partitioning efficiency is low, which increases the waiting time for the execution of downstream Graph Neural Networks (GNN) tasks. Furthermore, the edge allocation preemption problem may result in many nodes having neighboring edges located in different partitions, increasing the communication overhead between processes during the execution of downstream GNN tasks. Summary of the Invention
[0004] The purpose of this application is to provide a method, apparatus, electronic device, and storage medium for executing graph neural network tasks, in order to solve the problems in related technologies, such as low partitioning efficiency caused by edge allocation preemption, which increases the waiting time for downstream GNN task execution, and the problem that many neighboring edges of nodes are located in different partitions, which increases the communication overhead between processes during the execution of downstream GNN tasks.
[0005] To achieve the above objectives, the embodiments of this application adopt the following technical solutions:
[0006] In a first aspect, embodiments of this application provide a method for executing a graph neural network task, comprising: randomly dividing an input knowledge graph to be partitioned into multiple subgraphs using an edge partitioning method, each subgraph corresponding to a partition; determining the expansion direction of the neighbor edges of the knowledge graph according to the construction method of node features in the downstream graph neural network task, the expansion direction including any one of the following directions: incident direction and outgoing direction; inputting the multiple subgraphs into multiple sub-servers respectively, one sub-server corresponding to one subgraph, and executing the following steps in parallel through the multiple sub-servers: for the partition corresponding to the sub-server, based on the expansion direction of the neighbor edges, calling the process corresponding to the partition to perform an iterative operation based on neighbor expansion on the partition to obtain the iterative expansion result corresponding to the partition; determining the iterative expansion results corresponding to the multiple partitions output by the multiple sub-servers as the edge partitioning result of the knowledge graph; converting the edge partitioning result of the knowledge graph to obtain the node partitioning result of the knowledge graph; and executing the downstream graph neural network task based on the node partitioning result.
[0007] Secondly, embodiments of this application provide an execution apparatus for a graph neural network task, comprising: a first partitioning module, configured to randomly partition an input knowledge graph to be partitioned into multiple subgraphs using an edge partitioning method, each subgraph corresponding to a partition; a determining module, configured to determine the expansion direction of the neighbor edges of the knowledge graph according to the construction method of node features in the downstream graph neural network task, the expansion direction including any one of the following directions: incident direction and outgoing direction; a second partitioning module, configured to input the multiple subgraphs into multiple subservers respectively, one subserver corresponding to one subgraph, and execute the following steps in parallel through the multiple subservers: for the partition corresponding to the subserver, based on the expansion direction of the neighbor edges, call the process corresponding to the partition to perform an iterative operation based on neighbor expansion on the partition to obtain the iterative expansion result corresponding to the partition; and determine the iterative expansion results corresponding to the multiple partitions output by the multiple subservers as the edge partitioning result of the knowledge graph; and a conversion module, configured to convert the edge partitioning result of the knowledge graph to obtain the node partitioning result of the knowledge graph, and execute the downstream graph neural network task based on the node partitioning result.
[0008] Thirdly, embodiments of this application provide an electronic device, including: a processor, a memory, and a program or instructions stored in the memory and executable on the processor, wherein when the program or instructions are executed by the processor, they implement the steps of the method for executing a graph neural network task as described in the first aspect of this application.
[0009] Fourthly, embodiments of this application provide a readable storage medium storing a program or instructions that, when executed by a processor, implement the steps of the graph neural network task execution method as described in the first aspect of this application.
[0010] The above-described technical solutions adopted in the embodiments of this application can achieve the following beneficial effects:
[0011] This application embodiment employs an edge partitioning method, randomly dividing the knowledge graph to be partitioned into multiple subgraphs, each subgraph corresponding to a partition. Based on the construction method of node features in the downstream graph neural network task, the expansion direction of the neighbor edges of the knowledge graph is determined. This expansion direction includes the incident direction and the outgoing direction. The multiple subgraphs are input to multiple sub-servers, with one sub-server corresponding to one subgraph. The following steps are executed in parallel by multiple sub-servers: For the partition corresponding to the sub-server, based on the expansion direction of the neighbor edges, the process corresponding to the partition is called to perform an iterative operation based on neighbor expansion for the partition, obtaining the iterative expansion result corresponding to the partition. The iterative expansion results corresponding to the multiple partitions output by the multiple sub-servers are determined as the edge partitioning result of the knowledge graph. Based on the edge partitioning result of the knowledge graph, the node partitioning result of the knowledge graph is obtained. The downstream graph neural network task is executed based on the node partitioning result. This application embodiment determines the expansion direction of neighbor edges in the knowledge graph based on the construction method of node features in the downstream graph neural network task. That is, it determines the expansion direction of neighbor edges when performing iterative operations based on neighbor expansion for each partition. This avoids the problem of edge allocation preemption during the subsequent neighbor expansion process. On the one hand, it saves the communication and waiting time of each process after edge preemption, improves partitioning efficiency, and reduces the waiting time of the downstream GNN task execution. On the other hand, it prioritizes the allocation of edges to partitions with nodes consistent with their expansion direction. Since the expansion direction is determined based on the construction method of node features in the downstream graph neural network task, it achieves the priority of gathering neighbor edges that affect node features into one partition, avoiding the neighbor edges of many nodes being located in different partitions, and reducing the communication consumption between processes during the execution of the downstream GNN task. Attached Figure Description
[0012] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0013] Figure 1 A flowchart illustrating an execution method for a graph neural network task, provided as an embodiment of this application;
[0014] Figure 2 A schematic diagram of a subgraph partitioning provided for one embodiment of this application;
[0015] Figure 3 A flowchart illustrating an execution method for a graph neural network task, provided as another embodiment of this application;
[0016] Figure 4 A schematic diagram of a neighbor expansion provided for one embodiment of this application;
[0017] Figure 5 A schematic diagram illustrating the allocation of first-order and second-order neighbor edges according to an embodiment of this application;
[0018] Figure 6 A flowchart illustrating an execution method for a graph neural network task, provided as another embodiment of this application;
[0019] Figure 7 A flowchart illustrating an execution method for a graph neural network task, provided as another embodiment of this application;
[0020] Figure 8 A schematic diagram of the overall process of a graph partitioning method provided in one embodiment of this application.
[0021] Figure 9 A schematic diagram of the structure of an execution device for a graph neural network task provided in one embodiment of this application;
[0022] Figure 10 A schematic diagram of the structure of an execution device for a graph neural network task is provided for another embodiment of this application;
[0023] Figure 11 This is a schematic diagram of the structure of an electronic device provided in one embodiment of this application. Detailed Implementation
[0024] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0025] The terms "first," "second," etc., used in this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein. Furthermore, "and / or" in this application indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship. It should be noted that all data involved in this application was obtained with the user's authorization.
[0026] In ultra-large-scale graph deep learning application scenarios, the training and inference tasks of GNN models are limited by single-machine computing resources. In order to meet the task requirements of distributed systems, the complete graph needs to be divided into several subgraphs before building the model. Each node (corresponding to each process) in the distributed cluster only undertakes the storage and computation of one subgraph.
[0027] Graph partitioning can be categorized into vertex partitioning and edge partitioning based on the partitioning method. Vertex partitioning, also known as vertex (or node) allocation, divides the set of nodes in the graph into several parts. Each node and its related information are stored in a partitioned subgraph, and an edge in the graph may become a cut edge because two vertices are partitioned into different subgraphs. Edge partitioning, also known as edge allocation, divides the set of edges in the graph into several parts. Each edge and its related information are stored in a partitioned subgraph, and when multiple neighboring edges of a node are partitioned into different subgraphs, this node will exist in multiple subgraphs. Such a node is called a cut vertex.
[0028] In related technologies, when graph partitioning is performed using edge partitioning, a preemptive problem arises when two nodes on an edge are selected as expansion nodes by two different partitions. The process that first locks the edge gains final ownership, then sends the edge globally, and iterates only after all processes have determined the current edge selection. Due to communication and waiting time among processes, partitioning efficiency is low, increasing the waiting time for downstream GNN tasks. Furthermore, the edge allocation preemptive problem may result in many nodes having neighboring edges located in different partitions, increasing inter-process communication overhead during downstream GNN task execution. To address these issues, this application proposes a graph neural network task execution method, apparatus, electronic device, and storage medium to solve the problems of low partitioning efficiency caused by edge allocation preemptiveness, increased waiting time for downstream GNN task execution, and increased inter-process communication overhead due to many nodes having neighboring edges located in different partitions.
[0029] The technical solutions provided by the various embodiments of this application are described in detail below with reference to the accompanying drawings.
[0030] Figure 1This is a flowchart illustrating an execution method for a graph neural network task, provided as an embodiment of this application. Figure 1 As shown, the method for executing a graph neural network task according to an embodiment of this application may specifically include the following steps:
[0031] S101, the input knowledge graph to be partitioned is randomly divided into multiple subgraphs using the edge partitioning method, and each subgraph corresponds to a partition.
[0032] In this embodiment of the application, the execution entity of the graph neural network task execution method is a graph neural network task execution device, which can be located in an electronic device. This electronic device can be a terminal device or a server. The terminal device can be a mobile phone, tablet computer, desktop computer, laptop, in-vehicle device, etc.; the server can be a standalone server or a server cluster composed of multiple servers.
[0033] The graph neural network task execution method of this application embodiment can be applied to various application scenarios in different fields, such as risk control, marketing and transportation.
[0034] In risk control scenarios, nodes in a knowledge graph can specifically include, but are not limited to, at least one of the following entities: people, bank cards, and wealth management products. Edges in a knowledge graph can specifically include, but are not limited to, at least one relationship between entities, such as holding, transferring, and purchasing. Correspondingly, downstream GNN tasks of graph partitioning can specifically include, but are not limited to, at least one of the following tasks: fund flow tracking tasks and abnormal transfer risk detection tasks.
[0035] In a marketing context, nodes in a knowledge graph can include, but are not limited to, at least one of the following entities: customers (or users) and products, etc. Edges in a knowledge graph can include, but are not limited to, at least one relationship between entities, such as browsing and purchasing. Correspondingly, downstream GNN tasks in graph partitioning can include, but are not limited to, at least one of the following tasks: product recommendation tasks, customer (or user) reach path tasks, and customer group (or user group) segmentation tasks, etc.
[0036] In a traffic scenario, nodes in a knowledge graph can include, but are not limited to, at least one of the following entities: road network, checkpoints, and vehicles. Edges in a knowledge graph can include, but are not limited to, communication relationships between entities. Correspondingly, downstream GNN tasks of graph partitioning can include, but are not limited to, at least one of the following tasks: shortest path planning and traffic flow control.
[0037] Since the execution of downstream GNN tasks requires node allocation (or partitioning) results as input, graph partitioning algorithms integrated into graph deep learning frameworks generally prioritize vertex partitioning. However, edge partitioning naturally supports large-scale graph partitioning tasks, and traditional vertex partitioning methods, in order to balance the number of edges, require the integration of complex balancing mechanisms during iteration. Therefore, this embodiment adopts edge partitioning as the starting point, and then converts the edge partitioning results into node partitioning results as input for downstream GNN tasks.
[0038] In this embodiment, the graph to be partitioned can be a knowledge graph. A knowledge graph is a knowledge network that includes entities and the relationships between entities. Entities are nodes in the graph, and relationships are edges. Each node has its own label, denoted as node label. Different nodes can correspond to the same or different node labels. The number of feature dimensions corresponding to each node label can be the same or different. All nodes in the graph are divided into a training set, a validation set, and a test set. Nodes in the training set are called training nodes, nodes in the validation set are called validation nodes, and nodes in the test set are called test nodes.
[0039] The input knowledge graph to be partitioned is randomly divided into multiple subgraphs by using edge partitioning. Each subgraph includes several edges from the knowledge graph. Each process is responsible for the storage and computation of one subgraph, and each process and each subgraph corresponds to a partition.
[0040] It should be noted that the number of subgraphs to be divided can be preset, and the knowledge graph to be divided can be randomly divided into the corresponding number of subgraphs. Considering the balance of the number of edges, the number of edges in the multiple randomly divided subgraphs is relatively balanced.
[0041] For example Figure 2 As shown, the knowledge graph includes 10 nodes and 13 edges, randomly divided into 3 subgraphs: Figure 1 ,son Figure 2 Kazuko Figure 3 .
[0042] in, Figure 2 The 10 nodes in the knowledge graph have two types of node labels, A and B. The feature dimensions corresponding to node label A are 64, and the feature dimensions corresponding to node label B are 128. The training set : validation set : test set = 7 : 2 : 1. The node data of the knowledge graph is shown in Table 1, and the corresponding edge data is shown in Table 2.
[0043] Table 1. Node data corresponding to the knowledge graph.
[0044]
[0045]
[0046] Table 2. Edge data corresponding to the knowledge graph.
[0047] Outgoing node (src) Incident node (dst) 0 1 1 2 2 3 1 4 2 4 4 3 4 5 0 6 5 6 5 8 7 6 7 8 8 9
[0048] son Figure 1 The corresponding edge data is shown in Table 3:
[0049] Table 3 Figure 1 Corresponding edge data
[0050]
[0051]
[0052] son Figure 2 The corresponding edge data is shown in Table 4:
[0053] Table 4 Figure 2 Corresponding edge data
[0054] Outgoing node (src) Incident node (dst) 1 2 2 4 4 3 7 6 5 8
[0055] son Figure 3 The corresponding edge data is shown in Table 5:
[0056] Table 5 Figure 3 Corresponding edge data
[0057] Outgoing node (src) Incident node (dst) 1 4 2 3 5 6 8 9
[0058] S102, Based on the construction method of node features in the downstream graph neural network task, determine the expansion direction of the neighbor edges of the knowledge graph.
[0059] In this embodiment, a neighboring edge is also called an adjacent edge. A node's neighboring edge is an edge that uses that node as an incident or emitting node. The expansion direction can specifically include any of the following directions: the incident direction and the emitting direction.
[0060] An edge partitioning method based on neighbor expansion is used to optimize edge partitioning for each partition. Considering the potential for contention when two nodes on an edge are selected as expansion nodes by two different partitions, the expansion direction of neighbor edges can be pre-determined when expanding neighbor nodes across multiple partitions. The direction of a neighbor edge includes both the incident and outgoing directions; one of these can be chosen as the expansion direction. When two nodes on an edge are selected as expansion nodes by two different partitions, the direction of the edge determines which partition it belongs to, thus avoiding contention for that edge.
[0061] The expansion direction of neighbor edges can be determined based on the construction method of node features in the downstream GNN task. Specifically, the construction method of node features differs in different GNN tasks. For example, the mainstream GNN framework DistDGL samples from the incident neighbor nodes of a node when training node features. Therefore, assigning edges to partitions consistent with the incident node of the edge ensures that each node only needs to obtain neighbor features from its local process during training. To achieve the assignment of edges to partitions consistent with the incident node of the edge, in this embodiment, the expansion direction of neighbor edges during neighbor expansion is determined as the incident direction. This allows the incident neighbor edges that affect node features to be aggregated in one partition, avoiding the situation where the incident neighbor edges of many nodes are located in different partitions, thereby reducing the communication overhead between processes during GNN training and inference. In addition, it avoids the edge preemption problem and eliminates the communication and waiting time of each process after edge preemption, improving partitioning efficiency.
[0062] S103, input multiple subgraphs into multiple sub-servers respectively, with one sub-server corresponding to one subgraph, and execute the following steps in parallel through multiple sub-servers: for the partition corresponding to the sub-server, based on the expansion direction of the neighbor edges, call the process corresponding to the partition to perform an iterative operation based on neighbor expansion on the partition, and obtain the iterative expansion result corresponding to the partition; and determine the iterative expansion results corresponding to the multiple partitions output by the multiple sub-servers as the edge partitioning result of the knowledge graph.
[0063] In this embodiment, multiple distributed sub-servers can be pre-configured, and these sub-servers are interconnected. Multiple subgraphs are input into their respective sub-servers. Each partition corresponds to a process, and each process is executed by a sub-server. Each process performs an iterative expansion operation based on neighbor expansion for its assigned partition, obtaining the iterative expansion result for that partition, i.e., which edges are partitioned within that partition. During the edge partitioning process based on neighbor expansion for its assigned partition, each process locks neighbor edges based on the expansion direction of the neighbor edges determined in step S102 when the expansion node locks the neighbor edges. The iterative expansion results of the multiple partitions corresponding to the knowledge graph output by the multiple sub-servers are determined as the edge partitioning result of the knowledge graph, i.e., which edges are partitioned within each partition, or which partition each edge in the knowledge graph is partitioned into.
[0064] S104: Based on the edge partitioning results of the knowledge graph, the node partitioning results of the knowledge graph are transformed, and the downstream graph neural network task is executed based on the node partitioning results.
[0065] In this embodiment of the application, since the execution of the downstream GNN task of graph partitioning requires the input of node allocation (or partitioning) results, the edge partitioning results of each subgraph obtained in step S103 need to be converted into the node partitioning results of the knowledge graph. That is, the node partitioning result conversion step is executed, and the node partitioning results are input to the downstream GNN task execution module. The GNN task execution module executes the graph neural network task according to the input node partitioning results.
[0066] In summary, the graph neural network task execution method of this application embodiment adopts an edge partitioning approach, randomly dividing the knowledge graph to be partitioned into multiple subgraphs, each subgraph corresponding to a partition. Based on the construction method of node features in the downstream graph neural network task, the expansion direction of the neighbor edges of the knowledge graph is determined. This expansion direction includes the incident direction and the outgoing direction. The multiple subgraphs are input to multiple sub-servers, with one sub-server corresponding to one subgraph. The following steps are executed in parallel by multiple sub-servers: for the partition corresponding to the sub-server, based on the expansion direction of the neighbor edges, the process corresponding to the partition is called to perform an iterative operation based on neighbor expansion for the partition, obtaining the iterative expansion result corresponding to the partition. The iterative expansion results corresponding to the multiple partitions output by the multiple sub-servers are determined as the edge partitioning result of the knowledge graph. Based on the edge partitioning result of the knowledge graph, the node partitioning result of the knowledge graph is obtained. The downstream graph neural network task is executed based on the node partitioning result. This application embodiment determines the expansion direction of neighbor edges in the knowledge graph based on the construction method of node features in the downstream graph neural network task. That is, it determines the expansion direction of neighbor edges when performing iterative operations based on neighbor expansion for each partition. This avoids the problem of edge allocation preemption during the subsequent neighbor expansion process. On the one hand, it saves the communication and waiting time of each process after edge preemption, improves partitioning efficiency, and reduces the waiting time of the downstream GNN task execution. On the other hand, it prioritizes the allocation of edges to partitions with nodes consistent with their expansion direction. Since the expansion direction is determined based on the construction method of node features in the downstream graph neural network task, it achieves the priority of gathering neighbor edges that affect node features into one partition, avoiding the neighbor edges of many nodes being located in different partitions, and reducing the communication consumption between processes during the execution of the downstream GNN task.
[0067] Figure 3 This is a flowchart illustrating a method for executing a graph neural network task, provided as another embodiment of this application. Figure 3 As shown, in Figure 1 Based on the illustrated embodiments, the method for executing the graph neural network task in this application embodiment may specifically include the following steps:
[0068] S301, the input knowledge graph to be partitioned is randomly divided into multiple subgraphs using an edge partitioning method, and each subgraph corresponds to a partition.
[0069] S302, Based on the construction method of node features in the downstream graph neural network task, determine the expansion direction of the neighbor edge of the knowledge graph. The expansion direction includes any one of the following directions: the incident direction and the outgoing direction.
[0070] In this embodiment, steps S301-S302 are the same as steps S101-S102 in the above embodiment, and will not be repeated here.
[0071] The step S103 in the above embodiment, "inputting multiple subgraphs into multiple sub-servers respectively, with one sub-server corresponding to one subgraph, and executing the following steps in parallel through multiple sub-servers: for the partition corresponding to the sub-server, based on the expansion direction of the neighbor edges, calling the process corresponding to the partition, performing an iterative operation based on neighbor expansion on the partition, and obtaining the iterative expansion result corresponding to the partition", may specifically include the following steps S303-S310.
[0072] S303, input multiple subgraphs to multiple sub-servers respectively, with one sub-server corresponding to one subgraph, and execute the following steps in parallel through multiple sub-servers: call the process to initialize the first node set, second node set and allocated edge set of the corresponding partition as empty sets.
[0073] In this embodiment of the application, the neighbor expansion during the edge partitioning process is as follows: Figure 4 As shown, each process initializes an empty first node set, an empty second node set, and an empty set of assigned edges.
[0074] The first set of nodes, also known as the boundary node set, is abbreviated as B set. B set refers to the set where, after edge partitioning, each node has only a subset of its neighboring edges belonging to the partition corresponding to that process. For example... Figure 4 Node 2 in the fourth image.
[0075] The second set of nodes, also known as the core set, or C set for short, refers to the set where, after edge partitioning, all neighboring edges of each node belong to the partition corresponding to that process. For example... Figure 4 Nodes 1, 3, and 4 in the fourth image.
[0076] The set of allocated edges (AllocEdges) refers to the set in which each edge belongs to the partition corresponding to the process after edge partitioning is completed. For example... Figure 4 The edge between nodes 1, 2, 3, and 4 in the fourth image.
[0077] The core idea of neighbor expansion is to strategically select nodes from set B to add to set C (if there are no nodes in set B in the initial state or during the iteration process, a node is randomly selected from the unassigned nodes to add to set B), add all the neighbor edges of the node to set AllocEdges, that is, assign them to the partition corresponding to the process, and add the nodes on these neighbor edges that have not yet been assigned to the partition corresponding to the process to set B. The above operation is repeated in the next iteration until all edges are assigned.
[0078] S304, Determine whether the first node set is an empty set.
[0079] In this embodiment, the process determines whether set B is empty, that is, whether there are no nodes in set B. If yes, step S305 is executed. If no, step S306 is executed.
[0080] Those skilled in the art will understand that, in the initial state, set B is an initialized empty set, so the step of "determining whether set B is an empty set" can be skipped, and step S305 can be executed directly.
[0081] S305, randomly select a node from the unassigned nodes in the subgraph and add it to the first node set.
[0082] In this embodiment, when set B is empty, a node can be randomly selected from the unassigned nodes of the subgraph and added to set B. For example, a node with a small number of neighboring edges (e.g., less than or equal to 2) can be randomly selected from the unassigned nodes of the subgraph and added to set B. The unassigned nodes of the subgraph are those nodes (vertices of edges within the subgraph, such as the incident and outgoing nodes in Table 3) that have not been added to the corresponding set B or set C of the subgraph.
[0083] S306. In the first node set, the node with the smallest number of unassigned neighbor edges in the expansion direction is determined as the current expansion node, and the current expansion node is added to the second node set.
[0084] In this embodiment of the application, each process locks a node in its respective B set as the current expansion node and adds it to its respective C set.
[0085] When there is only one node Vi in set B, determine node Vi as the current expansion node and add node Vi to set C.
[0086] When there are multiple nodes in set B, the number of unassigned neighbor edges in the expansion direction of each node can be obtained. For example, when the expansion direction determined in step S302 is the incident direction, the number of unassigned incident neighbor edges in each node can be obtained, and the node Vi with the smallest number of unassigned incident neighbor edges can be determined as the current expansion node and added to set C.
[0087] It should be noted here that when each process determines the current expansion node, a first priority level can be set for each process when determining the current expansion node. The first priority level is positively correlated with the number of unallocated edges corresponding to the process.
[0088] In other words, when each process locks the current expansion node, the more unallocated edges a process has, the higher its priority (denoted as first priority) for locking the current expansion node. That is, the first priority of a process with a higher number of unallocated edges is higher than that of a process with a lower number of unallocated edges. After the process with the higher first priority completes the locking of the current expansion node, the process with the lower first priority then locks the current expansion node.
[0089] S307: Add the first-order neighbor edge of the current expansion node to the allocated edge set, and add the nodes on the first-order neighbor edge that are not in the current partition to the first node set.
[0090] In the embodiments of this application, each process allocates the first-order neighbor edges and second-order neighbor edges of the expansion direction of the current expansion node based on its own determined current expansion node Vi.
[0091] Step S307 involves allocating (or locking) the first-order neighbor edges in the expansion direction of the current expanding node Vi. First-order neighbor edges in the expansion direction of the current expanding node Vi, such as first-order incident neighbor edges, are added to the AllocEdges set, and nodes Ui on these first-order neighbor edges that are not in the current partition are added to the B set.
[0092] S308, determine whether the second-order neighbor node in the expansion direction of the current expansion node is already in the corresponding partition.
[0093] If yes, proceed to step S309. If no, return to step S304 and proceed to the next iteration.
[0094] S309, add the second-order neighbor edge of the current expanding node in the expansion direction to the set of allocated edges. Return to step S304 and execute the next iteration.
[0095] In this embodiment of the application, steps S308-S309 are the process of allocating (or locking) the second-order neighbor edges of the current expansion node Vi in the expansion direction.
[0096] If the second-order incident neighbor node Wi of the current expansion node Vi is already in the corresponding partition, then add the second-order incident neighbor edge (Ui, Wi) of the current expansion node Vi to the AllocEdges set, and update the number of unassigned incident neighbor edges of each node in the B set.
[0097] It should be noted here that when each process adds a first-order neighbor edge or a second-order neighbor edge to the set of allocated edges, the second priority of the process where the expansion direction node of the first-order neighbor edge or the second-order neighbor edge is located is set higher than the second priority of the process where the expansion direction node is not located.
[0098] That is, when each process locks a first-order neighbor edge or a second-order neighbor edge, the process containing the node in the expansion direction of that first-order neighbor edge or second-order neighbor edge has a higher priority in locking the edge.
[0099] Figure 5 The diagram illustrates the allocation process for first-order and second-order neighbor edges, as shown below. Figure 5 As shown, hollow nodes represent unassigned nodes, solid nodes represent assigned nodes, dashed edges represent unassigned edges, and solid edges represent assigned edges. First, select the node v with the smallest number of unassigned edges in the Boundary set, and assign v's first-order neighbor edge (v, u) to the corresponding partition. Then, determine if node v's second-order neighbor w is already in the corresponding partition, and assign node v's second-order neighbor edge (u, w) to the corresponding partition.
[0100] Those skilled in the art will understand that prioritizing the selection of a node v with a smaller number of unallocated edges during the allocation of first-order and second-order neighbor edges is to reduce the number of nodes located in set B at the end of the partitioning, i.e., reducing the number of node replicas (i.e., cut vertices) after partitioning. Furthermore, simultaneously considering the allocation of second-order neighbor edges during an iteration can accelerate the iteration and expansion speed.
[0101] It should be noted here that during the process of each process locking the current expansion node and allocating first-order and second-order neighbor edges, the priority order of locking the current expansion node or edge by each process can be determined based on cross-process message communication. Each process locks in sequence according to this order, avoiding the single-point bottleneck problem caused by setting up an additional coordinator process to control the allocation and iterative expansion of edges.
[0102] For example:
[0103] for Figure 1 The three subgraphs obtained are divided into three partitions, and the three partitions are subjected to an iterative operation based on neighbor expansion. The specific process of obtaining the iterative expansion results for each partition is shown in Table 6, taking the expansion direction as the incident direction as an example:
[0104] Table 6 shows the edge partitioning process for each subgraph based on neighbor expansion.
[0105]
[0106]
[0107] S310 determines the iterative expansion results corresponding to multiple partitions output by multiple sub-servers as the edge partitioning results of the knowledge graph.
[0108] In this embodiment, the final iterative expansion results of each partition, i.e. the edge partitioning results of the knowledge graph, are shown in Table 7 below:
[0109] Table 7 Iterative expansion results for each partition
[0110]
[0111]
[0112] In step S309, after “adding the first-order neighbor edge of the current expansion node to the allocated edge set”, it can be determined whether the number of edges in the allocated edge set has reached the preset first edge number threshold. If yes, the neighbor-based expansion iteration operation for the current partition ends, and the iteration operation for other partitions based on neighbor expansion ends. If no, return to step S304 and execute the next round of iteration.
[0113] By determining whether the number of edges in the allocated edge set has reached the preset first edge count threshold, it is determined whether the neighbor-based expansion iteration operation for the current partition has ended, thus ensuring the balance of the number of edges in each partition.
[0114] Step S104 in the above embodiment, "converting the knowledge graph node partitioning result based on the edge partitioning result of the knowledge graph", may specifically include the following steps S311-S313:
[0115] S311 assigns the core nodes in each partition to that partition.
[0116] In this embodiment of the application, after all edges in the knowledge graph have been assigned, the node partitioning result conversion process is performed.
[0117] A core node is a node in a partition whose number of edges with the node as the expansion direction is equal to or greater than a preset second edge count threshold. For example, a node in a partition whose number of edges with the node as the incident node is ≥2 is defined as a core node. The core nodes in this partition are then assigned to that partition.
[0118] For example, as shown in Table 7, node 6 in partition 1 is designated as the core node and assigned to partition 1. Nodes 3 and 8 in partition 2 are designated as core nodes and assigned to partition 2. Node 4 in partition 3 is designated as the core node and assigned to partition 3.
[0119] S312: Obtain the number of core nodes connected to the opposite neighbor nodes of the core node in different partitions, and assign the opposite neighbor nodes to the partition with the largest number of connected core nodes.
[0120] In the embodiments of this application, the opposite neighbor node of a node is another node on the neighboring edge of the node.
[0121] For the opposite neighbor nodes of a core node, obtain the number of core nodes connected to that opposite neighbor node in different partitions, that is, determine how many core nodes that opposite neighbor node is connected to in different partitions, and assign that opposite neighbor node to the partition with the largest number of connected core nodes.
[0122] For example, the opposite neighbor nodes of core node 6 are nodes 0, 7 and 5, the opposite neighbor node of core node 3 is node 2, the opposite neighbor nodes of core node 8 are nodes 5 and 7, and the opposite neighbor nodes of core node 4 are nodes 1 and 2.
[0123] Count the number of core nodes connected to node 0 in different partitions, and assign node 0 to the partition with the largest number of connected core nodes. Finally, assign node 0 to partition 1. Similarly, count the number of core nodes connected to node 7 in different partitions, and assign node 7 to the partition with the largest number of connected core nodes. The final partition for node 7 is yet to be determined. Similarly, count the number of core nodes connected to node 5 in different partitions, and assign node 5 to the partition with the largest number of connected core nodes. Finally, assign node 5 to partition 1. Similarly, count the number of core nodes connected to node 2 in different partitions, and assign node 2 to the partition with the largest number of connected core nodes. Finally, assign node 1 to partition 1.
[0124] S313 assigns unassigned nodes based on node label balancing and training set balancing.
[0125] In this embodiment, node label balance means that the number of feature dimensions of the labels of all nodes within each partition is balanced. Training set balance means that the number of training nodes belonging to the training set within each partition is balanced.
[0126] For nodes other than those allocated in steps S311 and S312 (i.e., allocated nodes), allocation is performed based on node label balancing and training set balancing strategies.
[0127] S314, executes downstream graph neural network tasks based on node partitioning results.
[0128] In this embodiment, step S314 is the same as steps S101-S102 in the above embodiment, and will not be repeated here.
[0129] It should be noted that in the process of node allocation result transformation, after executing the edge partitioning method based on neighbor expansion, this embodiment of the application retains the advantages of the edge partitioning method by defining the core node and its allocation results to the edge neighbor nodes. At the same time, in the process of allocating the remaining nodes, it combines node label balancing and training set balancing to achieve multi-constraint load balancing, ensuring the load balancing of each partition, thereby improving the computational efficiency of downstream GNN tasks.
[0130] Furthermore, traditional edge partitioning algorithms only balance the number of edges. When dealing with downstream GNN tasks, the balance between the feature dimensions of node labels and the number of training nodes also affects the computational efficiency of the downstream GNN tasks. This application's embodiment controls the balance of the number of edges by implementing a neighbor-based edge partitioning method. Simultaneously, during the allocation of remaining nodes, it combines node label balancing and training set balancing, minimizing the load balancing (node label balancing and training set balancing) bias in each partition during the node allocation result transformation. In other words, it integrates a multi-constraint load balancing (edge balancing, node label balancing, and training set balancing) mechanism during graph partitioning, ensuring load balancing across partitions and improving the computational efficiency of downstream GNN tasks.
[0131] Furthermore, such as Figure 6 As shown, step S313 above, "assigning unassigned nodes based on node label balancing and training set balancing," may specifically include the following steps:
[0132] S601, calculate the average load balancing amount based on the number of training nodes corresponding to each node label in the training set and the number of feature dimensions of each node label.
[0133] In this embodiment, based on the node data corresponding to the knowledge graph shown in Table 1, specifically based on the node labels corresponding to each training node in the training set in Table 1, the number x of training nodes corresponding to each node label in the training set can be counted. i Based on the statistical data of the number of training nodes corresponding to each node label in the training set (x),... i and the number of feature dimensions n for each node label iThe total load balancing amount D is calculated using the following formula:
[0134]
[0135] Where T is the total number of node labels.
[0136] Based on the total load balancing amount D, calculate the average load balancing amount = D / P, where P is the total number of partitions, that is, the total number of subgraphs initially divided.
[0137] For example, based on the node data corresponding to the knowledge graph shown in Table 1, the total load balancing amount D = (3*64+4*128) / (64+128) = 11 / 3, and the average load balancing amount = D / P = (11 / 3) / 3 = 11 / 9.
[0138] S602, calculate the load balancing amount of each partition based on the allocation results of the allocated nodes, the node labels corresponding to each training node in the training set, and the number of feature dimensions of each node label.
[0139] In this embodiment of the application, in the downstream GNN task, the number of feature dimensions n for different node labels is... i and the number of training nodes p within the partition ji This directly affects the communication volume for fetching features across partitions, thus impacting the computational efficiency of that partition. Therefore, a load balancing matrix can be defined as shown in Table 8, which will balance the number of feature dimensions n of each node's label. i The number of training nodes p corresponding to each node label within each partition. ji Combined, define the component region load:
[0140] Table 8 Load Balancing Matrix
[0141]
[0142]
[0143] Where P is the total number of partitions, that is, the total number of subgraphs initially partitioned. j Let L be the j-th partition, j∈(1,P), T be the total number of node label categories, and L be the total number of categories. i Let n be the label of the i-th type of node. i for
[0144] Number of training nodes.
[0145] For example, the node partitioning results of steps S311 and S312, that is, the allocation results of the allocated nodes, are shown in Table 9:
[0146] Table 9 shows the allocation results of the assigned nodes.
[0147]
[0148] In this table, node label A is 64-dimensional and node label B is 128-dimensional. We calculate w1 = 64 / (64+128) = 1 / 3 and w2 = 128 / (64+128) = 2 / 3. Based on w1, w2, and Table 8, the load balancing matrix is constructed as shown in Table 10 below.
[0149] Table 10 Load Balancing Matrix
[0150]
[0151]
[0152] S603 calculates the load balancing deviation value of each partition based on the load balancing amount and average load balancing amount of each partition.
[0153] In this application embodiment, a load balancing calculation paradigm is defined, namely the calculation formula for load balancing deviation value, to integrate node label balancing and training set balancing.
[0154] Specifically, the absolute value of the difference between the load balancing amount of each partition and the average load balancing amount is defined as the load balancing deviation value ε. j The corresponding calculation formula is (taking the j-th partition as an example):
[0155]
[0156] S604 allocates unassigned nodes based on the load balancing deviation values of each partition.
[0157] In this embodiment, unassigned nodes are assigned sequentially. It should be noted that for each unassigned node after steps S311 and S312, if any unassigned node has been assigned based on the load balancing deviation value, the load balancing deviation value of the partition with the newly assigned node needs to be recalculated, while the load balancing deviation values of other partitions (i.e., partitions without the newly assigned node) remain unchanged.
[0158] For example, as shown in Table 9, the unassigned nodes after steps S311 and S312 are node 1, node 7, and node 9. Assuming that node 7 and node 9 are also training nodes in the training set, these three nodes can be randomly sorted, for example, to node 1, node 7, and node 9. Then, node 1, node 7, and node 9 are assigned in sequence. After node 1 is assigned, when assigning node 7, the load balancing deviation value of each partition needs to be recalculated. For example, assuming that node 1 is assigned to partition 1, the load balancing deviation value of partition 1 needs to be recalculated. The load balancing deviation values of partition 2 and partition 3 remain unchanged. Based on the recalculated load balancing deviation values of each partition, node 7 is assigned.
[0159] like Figure 7 As shown, in some embodiments, the above step S604, "allocating unallocated nodes according to the load balancing deviation value of each partition," may specifically include the following steps:
[0160] S701: Sort each partition according to the number of neighbor edges corresponding to the unassigned nodes in each partition. The number of neighbor edges corresponding to each partition is positively correlated with the sorting position of each partition.
[0161] In this embodiment of the application, for a node that is not currently assigned, the number of neighbor edges corresponding to that node in each partition can be obtained. The partition with more neighbor edges is ranked higher.
[0162] For example, when assigning node 1 in Table 9, we can obtain the number of neighboring edges of node 1 in partition 1 as 1, the number of neighboring edges of node 1 in partition 1 as 1, and the number of neighboring edges of node 1 in partition 1 as 1. Since the number of neighboring edges of node 1 in each partition is 1, we can randomly sort the 3 partitions, for example, sort them as partition 1, partition 2 and partition 3.
[0163] S702, based on the sorting position of each partition, determine whether the unassigned node should be assigned to the current partition: if the load balancing deviation value of the current partition is less than the preset load balancing deviation threshold, then the unassigned node is assigned to the current partition.
[0164] In this embodiment, for a currently unassigned node, it is determined whether the node should be assigned to the current partition according to the sorting position of each partition. When determining whether to assign the node to the current partition, if the load balancing deviation value of the current partition is less than a preset load balancing deviation threshold, the node is assigned to the current partition; if the load balancing deviation value of the current partition is equal to or greater than the preset load balancing deviation threshold, it is determined whether the node can be assigned to the next partition.
[0165] For example, let's assign node 1 in Table 9, assuming the corresponding partitions are partition 1, partition 2, and partition 3, and the load balancing deviation threshold is 0.35. First, determine if node 1 should be assigned to partition 1: The load balancing deviation value for partition 1 is ε1 = |5 / 3 - 11 / 9| = 4 / 9 = 0.444. Since 0.444 > the load balancing deviation threshold of 0.35, node 1 is not assigned to partition 1. Next, determine if node 1 should be assigned to partition 2: The load balancing deviation value for partition 2 is ε2 = |1 - 11 / 9| = 2 / 9 = 0.222. Since 0.222 < the load balancing deviation threshold of 0.35, node 1 is assigned to partition 2.
[0166] For the unassigned nodes 7 and 9, since nodes 7 and 9 are not training nodes in the training set, there is no need to consider node label balance and training set balance. Nodes 7 and 9 can be assigned based on the balance of the number of nodes. Specifically, there are 4 nodes assigned in partition 1, 3 nodes assigned in partition 2, and 1 node assigned in partition 3. Therefore, nodes 7 and 9 can be assigned to partition 3 to ensure the balance of the number of nodes in each partition.
[0167] In summary, the graph neural network task execution method of this application determines the expansion direction of neighbor edges of multiple knowledge graphs based on the construction method of node features in the downstream graph neural network task. This determines the expansion direction of neighbor edges during subsequent iterative operations based on neighbor expansion for each partition, avoiding edge allocation preemption issues during subsequent neighbor expansion. On one hand, it eliminates communication and waiting time between processes after edge preemption, improving partitioning efficiency and reducing the waiting time for downstream GNN task execution. On the other hand, it prioritizes allocating edges to partitions consistent with the nodes in its expansion direction. Since this expansion direction is determined based on the construction method of node features in the downstream graph neural network task, it prioritizes converging neighbor edges affecting node features into one partition, avoiding the occurrence of neighbor edges of many nodes in different partitions, and reducing communication overhead between processes during downstream GNN task execution. During iterative operations based on neighbor expansion for each partition, the first-order and second-order neighbor edges of the currently expanding node are considered simultaneously in each iteration, increasing iteration and expansion speed and improving partitioning efficiency. During the process of each process locking the current expansion node and allocating first-order and second-order neighbor edges, cross-process message communication determines the priority order for each process to lock the current expansion node or edge. Each process locks sequentially according to this order, avoiding the single-point bottleneck problem caused by setting up an additional coordinator process to control edge allocation and iterative expansion. After executing the neighbor-based edge partitioning method, during the node allocation result transformation process, the advantages of the edge partitioning method are preserved by defining the core node and its allocation results to its edge neighbor nodes. Simultaneously, during the allocation of remaining nodes, multi-constraint load balancing (edge balancing, node label balancing, and training set balancing) is achieved by combining node label balancing and training set balancing, ensuring load balancing across partitions and thus improving the computational efficiency of downstream GNN tasks. By defining a load balancing paradigm, node label balancing and training set balancing can be implemented conveniently and quickly.
[0168] To clearly illustrate the graph partitioning method of this application's embodiments, the following is combined with... Figure 8 The overall flow of the graph partitioning method according to the embodiments of this application is described in detail. For example... Figure 8 As shown, the graph partitioning method in this application embodiment may specifically include the following processes: preprocessing, iteration, cross-process message communication, multi-constraint load balancing mechanism, and node allocation result transformation, which may specifically include the following steps:
[0169] S801, the knowledge graph to be partitioned is randomly divided into multiple subgraphs using an edge partitioning method, with each subgraph corresponding to a partition.
[0170] S802, based on the construction method of node features in the downstream graph neural network task, determine the expansion direction of the neighbor edge of the knowledge graph as the incident direction.
[0171] S803, for each partition, the calling process initializes the corresponding partition's B set, C set, and AlloEdges set to empty sets.
[0172] S804, Determine if set B is empty. If yes, proceed to step S805. If no, proceed to step S806.
[0173] S805, randomly select a node from the unassigned nodes in the subgraph and add it to set B.
[0174] S806, determine the node Vi in set B with the smallest number of unassigned incident neighbor edges as the current expansion node, and add the current expansion node Vi to set C.
[0175] The more unallocated edges a process has, the higher its priority in locking the current expansion node.
[0176] S807, add the first-order incident neighbor edges of the current expanded node Vi to the AlloEdges set, and add the nodes Ui on the first-order neighbor edges that are not in the current partition to the B set.
[0177] S808, if it is determined that the second-order incident neighbor node Wi of the current expansion node Vi is already in the corresponding partition, then add the second-order incident neighbor edge (Ui, Wi) of the current expansion node Vi to the AllocEdges set, and update the number of unassigned incident neighbor edges of each node in the B set.
[0178] Among them, the process containing the incident node of a first-order neighbor edge or a second-order neighbor edge has a higher priority for locking the edge.
[0179] S809, determine whether the number of edges in the AllocEdges set has reached the preset first edge count threshold. If yes, the neighbor-based expansion iteration operation for the current partition ends, and the iteration operation for all partitions ends. If no, return to step S804 and execute the next iteration.
[0180] S810 assigns the core nodes from each partition to that partition.
[0181] S811: Obtain the number of core nodes connected to the opposite neighbor nodes of the core node in different partitions, and assign the opposite neighbor nodes to the partition with the largest number of connected core nodes.
[0182] S812 constructs a load balancing paradigm based on node label balancing and training set balancing.
[0183] S813, Calculate the load balancing amount of each partition based on the node partitioning results of steps S810 and S811.
[0184] S814 calculates the load balancing deviation value of each partition based on the load balancing amount and load balancing paradigm of each partition.
[0185] S815 allocates unassigned nodes based on the load balancing deviation values of each partition.
[0186] Figure 9 This is a schematic diagram of the structure of an execution device for a graph neural network task provided in one embodiment of this application. Figure 9 As shown, the graph neural network task execution device 900 of this application embodiment may specifically include: a first partitioning module 901, a determination module 902, a second partitioning module 903, and a conversion module 904.
[0187] in:
[0188] The first partitioning module 901 is used to randomly divide the input knowledge graph to be partitioned into multiple subgraphs using an edge partitioning method, with each subgraph corresponding to a partition.
[0189] The determination module 902 is used to determine the expansion direction of the neighbor edges of the knowledge graph based on the construction method of the node features in the downstream graph neural network task. The expansion direction includes any one of the following directions: the incident direction and the outgoing direction.
[0190] The second partitioning module 903 is used to input multiple subgraphs into multiple sub-servers respectively. Each sub-server corresponds to one subgraph. The following steps are executed in parallel by multiple sub-servers: for the partition corresponding to the sub-server, based on the expansion direction of the neighbor edges, the process corresponding to the partition is called to perform an iterative operation based on neighbor expansion on the partition to obtain the iterative expansion result corresponding to the partition; and the iterative expansion results corresponding to the multiple partitions output by the multiple sub-servers are determined as the edge partitioning result of the knowledge graph.
[0191] The conversion module 904 is used to convert the edge partitioning result of the knowledge graph into the node partitioning result of the knowledge graph, and to execute the downstream graph neural network task based on the node partitioning result.
[0192] In the embodiments of this application, the specific process by which each module and unit in the graph neural network task execution device of this application implements its function can be found in the relevant descriptions in the above-described graph neural network task execution method embodiments, and will not be repeated here.
[0193] In summary, the execution device for the graph neural network task in this application adopts an edge partitioning method to randomly divide the knowledge graph to be partitioned into multiple subgraphs, each subgraph corresponding to a partition. Based on the construction method of node features in the downstream graph neural network task, the expansion direction of the neighbor edges of the multiple knowledge graphs is determined. The expansion direction includes the incident direction and the outgoing direction. The multiple subgraphs are input to multiple sub-servers, with one sub-server corresponding to one subgraph. The following steps are executed in parallel by multiple sub-servers: for the partition corresponding to the sub-server, based on the expansion direction of the neighbor edges, the process corresponding to the partition is called to perform an iterative operation based on neighbor expansion for the partition, and the iterative expansion result corresponding to the partition is obtained. The iterative expansion results corresponding to the multiple partitions output by the multiple sub-servers are determined as the edge partitioning result of the knowledge graph. Based on the edge partitioning result of the knowledge graph, the node partitioning result of the knowledge graph is obtained. The downstream graph neural network task is executed based on the node partitioning result. This application embodiment determines the expansion direction of neighbor edges in the knowledge graph based on the construction method of node features in the downstream graph neural network task. That is, it determines the expansion direction of neighbor edges when performing iterative operations based on neighbor expansion for each partition. This avoids the problem of edge allocation preemption during the subsequent neighbor expansion process. On the one hand, it saves the communication and waiting time of each process after edge preemption, improves partitioning efficiency, and reduces the waiting time of the downstream GNN task execution. On the other hand, it prioritizes the allocation of edges to partitions with nodes consistent with their expansion direction. Since the expansion direction is determined based on the construction method of node features in the downstream graph neural network task, it achieves the priority of gathering neighbor edges that affect node features into one partition, avoiding the neighbor edges of many nodes being located in different partitions, and reducing the communication consumption between processes during the execution of the downstream GNN task.
[0194] Figure 10 This is a schematic diagram of the structure of an execution device for a graph neural network task, provided as another embodiment of this application. Figure 10 As shown, in Figure 9 Based on the illustrated embodiment, in the graph neural network task execution device 900 of this application embodiment, the second partitioning module 903 is further used for:
[0195] The calling process initializes the first node set, second node set, and allocated edge set of the corresponding partition as empty sets; it checks if the first node set is empty; if it is empty, it randomly selects a node from the unallocated nodes in the subgraph and adds it to the first node set; if it is not empty, it determines the node with the smallest number of unallocated neighbor edges in the expansion direction in the first node set as the current expansion node and adds it to the second node set; it adds the first-order neighbor edges in the expansion direction of the current expansion node to the allocated edge set, and adds nodes on the first-order neighbor edges that are not in the corresponding partition to the first node set; if the second-order neighbor nodes in the expansion direction of the current expansion node are already in the corresponding partition, it adds the second-order neighbor edges in the expansion direction of the current expansion node to the allocated edge set, and returns to the step of checking if the first node set is empty.
[0196] In one feasible implementation of the present application, the second partitioning module 903 is further configured to: after adding the first-order neighbor edge of the current expansion node to the allocated edge set, determine whether the number of edges in the allocated edge set reaches a preset first edge number threshold; if yes, the iterative operation based on neighbor expansion for partitioning ends; if no, the step of returning to determine whether the first node set is an empty set is executed.
[0197] In one feasible implementation of the present application, the second partitioning module 903 is further configured to: when calling each process to determine the current expansion node, set the first priority level of each process when determining the current expansion node, wherein the first priority level is positively correlated with the number of unallocated edges corresponding to the process.
[0198] In one feasible implementation of the present application, the second partitioning module 903 is further configured to: when calling each process to add first-order neighbor edges or second-order neighbor edges to the allocated edge set, set the second priority of the process where the expansion direction node of the first-order neighbor edge or second-order neighbor edge is located to be higher than the second priority of the process where the expansion direction node is not located.
[0199] In one feasible implementation of this application, the conversion module 904 further includes: a first allocation unit 1001, a second allocation unit 1002, and a third allocation unit 1003. Specifically: the first allocation unit 1001 is used to allocate core nodes in each partition to that partition. A core node is a node in that partition whose number of edges extending in the direction of expansion is equal to or greater than a preset second edge count threshold. The second allocation unit 1002 is used to obtain the number of connected core nodes in different partitions of the core node's opposite neighbor nodes and allocate the opposite neighbor nodes to the partition with the largest number of connected core nodes. The third allocation unit 1003 is used to allocate unallocated nodes based on node label balancing and training set balancing.
[0200] In one feasible implementation of this application, the third allocation unit 1003 is further configured to: calculate the average load balancing amount based on the number of training nodes corresponding to each node label in the training set and the number of feature dimensions of each node label; calculate the load balancing amount of each partition based on the allocation results of the allocated nodes, the node labels corresponding to each training node in the training set and the number of feature dimensions of each node label; calculate the load balancing deviation value of each partition based on the load balancing amount of each partition and the average load balancing amount; and allocate unallocated nodes based on the load balancing deviation value of each partition.
[0201] In one feasible implementation of this application, the third allocation unit 1003 is further configured to: sort each partition according to the number of neighbor edges corresponding to each partition for unallocated nodes, wherein the number of neighbor edges corresponding to each partition is positively correlated with the sorting position of each partition; and determine whether unallocated nodes should be allocated to the current partition according to the sorting position of each partition: if the load balancing deviation value of the current partition is less than a preset load balancing deviation threshold, then the unallocated node is allocated to the current partition.
[0202] In the embodiments of this application, the specific process by which each module and unit in the graph neural network task execution device of this application implements its function can be found in the relevant descriptions in the above-described graph neural network task execution method embodiments, and will not be repeated here.
[0203] In summary, the execution device for the graph neural network task in this application determines the expansion direction of the neighbor edges of the knowledge graph based on the construction method of node features in the downstream graph neural network task. This determines the expansion direction of neighbor edges during subsequent iterative operations based on neighbor expansion for each partition, avoiding edge allocation preemption issues during subsequent neighbor expansion. On one hand, this eliminates communication and waiting time between processes after edge preemption, improving partitioning efficiency and reducing the waiting time for downstream GNN task execution. On the other hand, it prioritizes allocating edges to partitions consistent with the nodes in its expansion direction. Since this expansion direction is determined based on the construction method of node features in the downstream graph neural network task, it prioritizes converging neighbor edges affecting node features into one partition, avoiding the occurrence of neighbor edges of many nodes in different partitions and reducing communication overhead between processes during downstream GNN task execution. During iterative operations based on neighbor expansion for each partition, the first-order and second-order neighbor edges of the currently expanding node are considered simultaneously in each iteration, increasing iteration and expansion speed and improving partitioning efficiency. During the process of each process locking the current expansion node and allocating first-order and second-order neighbor edges, cross-process message communication determines the priority order for each process to lock the current expansion node or edge. Each process locks sequentially according to this order, avoiding the single-point bottleneck problem caused by setting up an additional coordinator process to control edge allocation and iterative expansion. After executing the neighbor-based edge partitioning method, during the node allocation result transformation process, the advantages of the edge partitioning method are preserved by defining the core node and its allocation results to its edge neighbor nodes. Simultaneously, during the allocation of remaining nodes, multi-constraint load balancing (edge balancing, node label balancing, and training set balancing) is achieved by combining node label balancing and training set balancing, ensuring load balancing across partitions and thus improving the computational efficiency of downstream GNN tasks. By defining a load balancing paradigm, node label balancing and training set balancing can be implemented conveniently and quickly.
[0204] This application also provides an electronic device. For example... Figure 11As shown, the electronic device 1100 can vary considerably due to differences in configuration or performance. It may include one or more processors 1101 and memory 1102, with memory 1102 storing one or more application programs or data. Memory 1102 may be temporary or persistent storage. The application programs stored in memory 1102 may include one or more modules (not shown), each module including a series of computer-executable instructions for the electronic device 1100. Furthermore, processor 1101 may be configured to communicate with memory 1102 and execute the series of computer-executable instructions stored in memory 1102 on the electronic device 1100. The electronic device 1100 may also include one or more power supplies 1103, one or more wired or wireless network interfaces 1104, one or more input / output interfaces 1105, and one or more keyboards 1106.
[0205] Specifically, in this embodiment, the electronic device includes a memory and one or more programs, wherein one or more programs are stored in the memory, and one or more programs may include one or more modules, and each module may include a series of computer-executable instructions for use in the electronic device, configured to be executed by one or more processors. The one or more programs include computer-executable instructions for performing the following:
[0206] The input knowledge graph to be partitioned is randomly divided into multiple subgraphs using an edge partitioning method, with each subgraph corresponding to a partition.
[0207] Based on the construction method of node features in the downstream graph neural network task, the expansion direction of the neighbor edge of the knowledge graph is determined. The expansion direction includes any one of the following directions: the incident direction and the outgoing direction.
[0208] Multiple subgraphs are input into multiple sub-servers, with one sub-server corresponding to one subgraph. The following steps are executed in parallel by multiple sub-servers: For the partition corresponding to the sub-server, based on the expansion direction of the neighbor edges, the process corresponding to the partition is called to perform an iterative expansion operation based on the neighbor edges to obtain the iterative expansion result of the partition; and the iterative expansion results of the multiple partitions output by the multiple sub-servers are determined as the edge partitioning result of the knowledge graph.
[0209] Based on the edge partitioning results of the knowledge graph, the node partitioning results of the knowledge graph are obtained.
[0210] The downstream graph neural network task is executed based on the node partitioning results.
[0211] The electronic device in this application determines the expansion direction of the neighbor edges of the knowledge graph based on the construction method of node features in the downstream graph neural network task. That is, it determines the expansion direction of the neighbor edges when performing iterative operations based on neighbor expansion for each partition. This avoids the problem of edge allocation preemption during the subsequent neighbor expansion process. On the one hand, it saves the communication and waiting time of each process after edge preemption, improves partitioning efficiency, and reduces the waiting time of the downstream GNN task execution. On the other hand, it prioritizes the allocation of edges to partitions with nodes consistent with their expansion direction. Since the expansion direction is determined based on the construction method of node features in the downstream graph neural network task, it achieves the priority of gathering neighbor edges that affect node features into one partition, avoiding the neighbor edges of many nodes being located in different partitions, and reducing the communication consumption between processes during the execution of the downstream GNN task.
[0212] This application also proposes a readable storage medium storing one or more computer programs, each including instructions. When executed by a processor in an electronic device comprising multiple applications, the program or instructions enable the processor to perform various processes of the above-described graph neural network task execution method embodiments, specifically for executing:
[0213] The input knowledge graph to be partitioned is randomly divided into multiple subgraphs using an edge partitioning method, with each subgraph corresponding to a partition.
[0214] Based on the construction method of node features in the downstream graph neural network task, the expansion direction of the neighbor edge of the knowledge graph is determined. The expansion direction includes any one of the following directions: the incident direction and the outgoing direction.
[0215] Multiple subgraphs are input into multiple sub-servers, with one sub-server corresponding to one subgraph. The following steps are executed in parallel by multiple sub-servers: For the partition corresponding to the sub-server, based on the expansion direction of the neighbor edges, the process corresponding to the partition is called to perform an iterative expansion operation based on the neighbor edges to obtain the iterative expansion result of the partition; and the iterative expansion results of the multiple partitions output by the multiple sub-servers are determined as the edge partitioning result of the knowledge graph.
[0216] Based on the edge partitioning results of the knowledge graph, the node partitioning results of the knowledge graph are obtained.
[0217] The downstream graph neural network task is executed based on the node partitioning results.
[0218] The readable storage medium of this application determines the expansion direction of the neighbor edges of the knowledge graph based on the construction method of node features in the downstream graph neural network task. That is, it determines the expansion direction of the neighbor edges when performing iterative operations based on neighbor expansion on each partition. This avoids the problem of edge allocation preemption during the subsequent neighbor expansion process. On the one hand, it saves the communication and waiting time of each process after edge preemption, improves partitioning efficiency, and reduces the waiting time of the downstream GNN task execution. On the other hand, it prioritizes the allocation of edges to partitions with nodes consistent with their expansion direction. Since the expansion direction is determined based on the construction method of node features in the downstream graph neural network task, it achieves the priority of gathering neighbor edges that affect node features into one partition, avoiding the neighbor edges of many nodes being located in different partitions, and reducing the communication consumption between processes during the execution of the downstream GNN task.
[0219] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, a computer can be, for example, a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email device, game console, tablet computer, wearable device, or any combination of these devices.
[0220] For ease of description, the above devices are described separately by function as various units. Of course, in implementing this application, the functions of each unit can be implemented in one or more software and / or hardware.
[0221] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0222] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0223] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0224] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0225] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0226] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0227] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0228] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0229] This application can be described in the general context of computer-executable instructions, such as program modules, that are executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform a specific task or implement a specific abstract data type. This application can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.
[0230] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to interchangeably. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments.
[0231] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A method for executing a graph neural network task, characterized in that, include: The input knowledge graph to be partitioned is randomly divided into multiple subgraphs using an edge partitioning method, with each subgraph corresponding to a partition. Based on the construction method of node features in the downstream graph neural network task, the expansion direction of the neighbor edge of the knowledge graph is determined, and the expansion direction includes any one of the following directions: the incident direction and the outgoing direction. The multiple subgraphs are input into multiple sub-servers, with one sub-server corresponding to one subgraph. The following steps are executed in parallel through the multiple sub-servers: For the partition corresponding to the sub-server, based on the expansion direction of the neighbor edge, the process corresponding to the partition is called to perform an iterative operation based on neighbor expansion on the partition to obtain the iterative expansion result corresponding to the partition. The iterative expansion results corresponding to the multiple partitions output by the multiple sub-servers are determined as the edge partitioning results of the knowledge graph; Based on the edge partitioning results of the knowledge graph, the node partitioning results of the knowledge graph are obtained. The downstream graph neural network task is executed based on the node partitioning results.
2. The method according to claim 1, characterized in that, Based on the expansion direction of the neighbor edges, the process corresponding to the partition is invoked to perform an iterative expansion operation on the partition based on neighbor expansion, obtaining the iterative expansion result corresponding to the partition, including: The process is invoked to initialize the first node set, the second node set, and the allocated edge set of the corresponding partition to be empty sets. Determine if the first node set is an empty set; If the set is empty, a node is randomly selected from the unassigned nodes in the subgraph and added to the first node set. If the set is not empty, then the node with the smallest number of unassigned neighbor edges in the expansion direction in the first node set is determined as the current expansion node, and the current expansion node is added to the second node set; Add the first-order neighbor edge of the expansion direction of the current expansion node to the allocated edge set, and add the nodes on the first-order neighbor edge that are not in the corresponding partition to the first node set; If the second-order neighbor node in the expansion direction of the current expansion node is already in the corresponding partition, then the second-order neighbor edge in the expansion direction of the current expansion node is added to the allocated edge set, and the step of determining whether the first node set is an empty set is returned.
3. The method according to claim 2, characterized in that, After adding the first-order neighbor edge of the expansion direction of the current expanding node to the allocated edge set, the method further includes: Determine whether the number of edges in the allocated edge set has reached a preset first edge count threshold; If so, the neighbor-based expansion-based iterative operation on the partition ends; If not, then proceed with the step of returning to determine whether the first node set is an empty set.
4. The method according to claim 2, characterized in that, Also includes: When each process determines the current expansion node, a first priority level is set for each process when determining the current expansion node, wherein the first priority level is positively correlated with the number of unallocated edges corresponding to the process.
5. The method according to claim 2, characterized in that, Also includes: When each process adds the first-order neighbor edge or the second-order neighbor edge to the allocated edge set, the second priority of the process where the expansion direction node of the first-order neighbor edge or the second-order neighbor edge is located is set to be higher than the second priority of the process where the expansion direction node is not located.
6. The method according to claim 1, characterized in that, The step of converting the edge partitioning result of the knowledge graph into the node partitioning result of the knowledge graph includes: For each partition, the core node in the partition is assigned to that partition. The core node is the node in the partition whose number of edges with the node as the expansion direction is equal to or greater than a preset second edge number threshold. Obtain the number of times the opposite neighbor nodes of the core node are connected to the core node in different partitions, and assign the opposite neighbor nodes to the partition with the largest number of connected core nodes; Based on node label balancing and training set balancing, unassigned nodes are assigned.
7. The method according to claim 6, characterized in that, The allocation of unassigned nodes based on node label balancing and training set balancing includes: The average load balancing amount is calculated based on the number of training nodes corresponding to each node label in the training set and the number of feature dimensions of each node label. Based on the allocation results of the allocated nodes, the node labels corresponding to each training node in the training set, and the number of feature dimensions of each node label, calculate the load balancing amount of each partition. Calculate the load balancing deviation value for each partition based on the load balancing amount of each partition and the average load balancing amount. Unassigned nodes are allocated based on the load balancing deviation values of each partition.
8. The method according to claim 7, characterized in that, The process of allocating unallocated nodes based on the load balancing deviation values of each partition includes: The partitions are sorted according to the number of neighbor edges corresponding to the unassigned nodes in each partition, and the number of neighbor edges corresponding to each partition is positively correlated with the sorting position of each partition. Based on the sorting position of each partition, it is determined whether an unassigned node should be assigned to the current partition: if the load balancing deviation value of the current partition is less than the preset load balancing deviation threshold, then the unassigned node is assigned to the current partition.
9. An execution device for a graph neural network task, characterized in that, include: The first partitioning module is used to randomly divide the input knowledge graph to be partitioned into multiple subgraphs using an edge partitioning method, with each subgraph corresponding to a partition; The determination module is used to determine the expansion direction of the neighbor edges of the knowledge graph based on the construction method of the node features in the downstream graph neural network task. The expansion direction includes any one of the following directions: the incident direction and the outgoing direction. The second partitioning module is used to input the multiple subgraphs into multiple sub-servers respectively, with one sub-server corresponding to one subgraph. The multiple sub-servers execute the following steps in parallel: for the partition corresponding to the sub-server, based on the expansion direction of the neighbor edge, the process corresponding to the partition is called to perform an iterative operation based on neighbor expansion on the partition to obtain the iterative expansion result corresponding to the partition. The iterative expansion results corresponding to the multiple partitions output by the multiple sub-servers are determined as the edge partitioning results of the knowledge graph; The conversion module is used to convert the edge partitioning result of the knowledge graph into the node partitioning result of the knowledge graph, and to execute the downstream graph neural network task based on the node partitioning result.
10. An electronic device, characterized in that, It includes a processor, a memory, and a program or instructions stored in the memory and executable on the processor, wherein the program or instructions, when executed by the processor, implement the steps of the method as described in any one of claims 1-8.
11. A readable storage medium, characterized in that, The readable storage medium stores a program or instructions that, when executed by a processor, implement the steps of the method as described in any one of claims 1-8.
Citation Information
Patent Citations
System and method for external-memory graph search utilizing edge partitioning
US20080143723A1
Distributed processing of pose graphs for generating high definition maps for navigating autonomous vehicles
US20200284590A1
