Graph neural network accelerated training method for GPU, storage medium and electronic device

By performing a graph segmentation operation on the GPU and updating the sub-graph based on incremental data, the problem of waste of computing power and training time due to frequent graph segmentation in the existing technology is solved, and efficient graph neural network training is achieved .

CN119417693APending Publication Date: 2025-02-11COMP NETWORK INFORMATION CENT CHINESE ACADEMY OF SCI
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411476492.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-22
Publication Date
2025-02-11

AI Technical Summary

Technical Problem

When training dynamic graphs, the prior art requires frequent graph segmentation, resulting in waste of computing power and prolonged training time.

Method used

A graph neural network acceleration training method for GPU is proposed. By acquiring the initial graph and dividing it into multiple subgraphs, the computational load of the subgraph is estimated and allocated to multiple GPUs for training. Get incremental data to update the subgraph, and redistribute GPU resources according to the calculation load to reduce graph segmentation operations.

Benefits of technology

During the training process of graph neural network, only one graph segmentation operation is performed, which reduces frequent computing power consumption, reduces training time and improves training efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119417693A_ABST
    Figure CN119417693A_ABST
Patent Text Reader

Abstract

The invention discloses a graph neural network accelerated training method for a GPU, a storage medium and an electronic device, and the method comprises the steps: obtaining an initial graph, segmenting the initial graph into N sub-graphs, and enabling the initial graph to be a static graph corresponding to a moment in a dynamic graph sample; calculating loads of the sub-graphs are estimated, the N sub-graphs are distributed to the M GPUs based on the calculating loads of the sub-graphs, training of the graph neural network is carried out, and at least two sub-graphs are distributed to each GPU; incremental data is obtained, the subgraph is updated based on the incremental data, and the incremental data is used for representing the change of a static graph in the dynamic graph sample scanned at the current moment relative to the static graph currently processed by the GPU; and distributing the N sub-graphs containing the incremental data to M GPUs and carrying out graph neural network training. According to the technology, the calculation and resource utilization rate is improved, the training time consumption is reduced, and the training efficiency of the graph neural network during training is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computers, and more specifically, to a graph neural network accelerated training method, storage medium, and electronic device for a GPU. Background Art

[0002] In the process of training dynamic graphs with existing graph neural networks, the graph structure changes dynamically over time, so the graph needs to be segmented frequently. Frequent graph segmentation operations will take up a lot of computing power during the training of graph neural networks, and will also prolong the training time of graph neural networks.

[0003] Accordingly, the field needs a new graph neural network training scheme to solve the above problems. Summary of the invention

[0004] In order to overcome the above-mentioned defects, the present invention is proposed to provide a solution or at least partially solve the technical problem in the prior art that when training a dynamic graph, graph segmentation needs to be frequently performed, which wastes computing power and time.

[0005] In a first aspect, the present invention provides a method for accelerating graph neural network training for a GPU, the method comprising: obtaining an initial graph, and dividing the initial graph into N subgraphs, wherein the initial graph is a static graph corresponding to a moment in a dynamic graph sample; estimating the computational load of the subgraph, and distributing the N subgraphs to M GPUs based on the computational load of the subgraphs and training the graph neural network, wherein at least two subgraphs are allocated to each GPU; obtaining incremental data, and updating the subgraphs based on the incremental data, wherein the incremental data is used to characterize the change of the static graph in the dynamic graph sample scanned at the current moment relative to the static graph currently processed by the GPU; distributing the N subgraphs containing the incremental data to M GPUs and training the graph neural network.

[0006] As an alternative or supplement to the above scheme, in a method according to an embodiment of the present invention, the incremental data is obtained and the sub-graph is updated based on the incremental data, including: scanning the dynamic graph samples in chronological order, obtaining the incremental data of the dynamic graph samples at different times relative to the static graph currently processed by the GPU; if the incremental data meets the preset update conditions, the incremental data is allocated to the sub-graph.

[0007] As an alternative or supplement to the above scheme, in a method according to an embodiment of the present invention, the incremental data includes newly added nodes, and the allocation of the incremental data to the subgraph includes: obtaining the affinity and contribution weight of the first node, wherein the affinity of the first node includes the variable affinity of the newly added node and the constant affinity of the neighbor nodes of the newly added node in the subgraph, the affinity is used to characterize the degree of affinity between the node and the subgraph, and the contribution weight is used to characterize the contribution of the node to the corresponding neighbor nodes; based on the affinity of the neighbor nodes of the newly added node and the contribution weight between the newly added node and the neighbor nodes of the newly added node, the affinity of the newly added node is obtained; based on the affinity of the newly added node, the newly added node is allocated to the subgraph.

[0008] As an alternative or supplement to the above scheme, in a method according to an embodiment of the present invention, the dimension of the variable affinity is the same as the number of subgraphs, wherein each dimension is used to characterize the degree of affinity with the corresponding subgraph, and the affinity of the newly added node is obtained based on the affinity of the neighbor nodes of the newly added node and the contribution weight between the newly added node and the neighbor nodes of the newly added node, including: at least multiplying the affinity of the neighbor nodes of the newly added node and the contribution weight between the newly added node and the neighbor nodes of the newly added node to obtain the variable affinity of the newly added node after the first iteration; continuously iterating the new affinity variable until the preset convergence condition is met to obtain the affinity of the new node.

[0009] As an alternative or supplement to the above scheme, in a method according to an embodiment of the present invention, the number N of subgraphs and the number M of GPUs satisfy: N = a*M, where a≥2, a is a positive integer, and the training of the graph neural network includes: on each GPU, running a computing pipeline and a communication pipeline in parallel, wherein the computing pipeline calculates the subgraphs in turn, and the communication pipeline communicates the calculation results of the subgraphs in turn.

[0010] As an alternative or supplement to the above scheme, in a method according to one embodiment of the present invention, at least the affinity of the neighbor nodes of the newly added node and the contribution weight between the newly added node and the neighbor nodes of the newly added node are multiplied, including: multiplying the affinity of the neighbor nodes of the newly added node and the contribution weight between the newly added node and the neighbor nodes of the newly added node, and accumulating multiple multiplication results, wherein the number of multiplication results is the same as the number of the newly added nodes.

[0011] As an alternative or supplement to the above scheme, in a method according to an embodiment of the present invention, the estimating the computational load of the subgraph includes: inputting the subgraph into a pre-run neural network to obtain the time for the subgraph to perform forward propagation; and obtaining the computational load of the subgraph based on the forward propagation time.

[0012] As an alternative or supplement to the above scheme, in a method according to an embodiment of the present invention, the incremental data satisfies a preset update condition, including: the number of edges or nodes in the incremental data is greater than a preset update threshold; or, the N subgraphs are distributed to M GPUs based on the computational load of the subgraphs, including: load balancing based on the computational load of the subgraphs, and distributing the N subgraphs to M GPUs according to the load balancing results.

[0013] In a second aspect, a control device is provided, which includes a processor and a storage device, wherein the storage device is suitable for storing multiple computer programs, and the computer programs are suitable for being loaded and run by the processor to execute the graph neural network accelerated training method for GPU described in any of the technical solutions of the above-mentioned graph neural network accelerated training method for GPU.

[0014] In a third aspect, a computer-readable storage medium is provided, which stores a plurality of computer programs, wherein the computer programs are suitable for being loaded and run by a processor to execute the graph neural network accelerated training method for GPU described in any one of the technical solutions of the above-mentioned graph neural network accelerated training method for GPU.

[0015] The above one or more technical solutions of the present invention have at least one or more of the following beneficial effects:

[0016] In the technical solution of the present invention, during the training process of the graph neural network, only one graph segmentation operation is performed, thereby obtaining multiple subgraphs. Afterwards, when the incremental data is updated, only the subgraph is locally adjusted, and the graph segmentation operation is no longer performed. Moreover, the GPU resources are dynamically and evenly redistributed to the subgraphs after the local adjustment according to the computing load, so that the training process remains efficient. This technology ensures that the computing and resource utilization rates are improved. Compared with the prior art, there is no frequent consumption of computing power, which reduces the training time and improves the training efficiency of the graph neural network during training. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0018] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0019] Figure 1a is a schematic diagram of a diagram of an embodiment of the present invention;

[0020] Figure 1b Yes Figure 1a The schematic diagram after the image segmentation is performed in the middle figure;

[0021] Figure 2 It is a schematic diagram of the corresponding structure of two moments in a dynamic graph;

[0022] Figure 3 This is a schematic flow chart of the main steps of a method for accelerating graph neural network training on a GPU according to an embodiment of the present invention;

[0023] Figure 4 It is a specific flow chart of a method for accelerating training of a graph neural network for a GPU according to the present invention;

[0024] Figure 5 This is a schematic diagram of allocating subgraphs to the GPU;

[0025] Figure 6 This is a schematic diagram of the computation and communication performed by the GPU on the subgraph when training the graph neural network;

[0026] Figure 7 It is a schematic diagram of some static images in the dynamic image sample;

[0027] Figure 8 It is a schematic diagram of the steps of a subgraph updating method according to an embodiment of the present invention. DETAILED DESCRIPTION

[0028] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.

[0029] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0030] Here we first explain some terms involved in the present invention.

[0031] Graph: A data structure consisting of nodes (also called vertices) and edges that are used to represent entities and their relationships. Nodes represent entities in the data, while edges represent connections or relationships between entities. Figure 1a As shown in Figure 1a It is a schematic diagram of a graph, consisting of nodes and edges.

[0032] An example of an application scenario is as follows: In a graph neural network, the input data is a graph. Taking the training of a graph neural network as an example, during the training process of a graph neural network, the graph needs to be input, processed, and analyzed. However, if the input graph is too large, then directly inputting the graph into a processor (such as a GPU) for processing and analysis will overload the processor. Therefore, the graph is segmented at this time. Graph segmentation can divide a large graph into multiple smaller sub-graphs, which can be placed on different processors for separate calculations. In this way, the graph can be calculated in parallel, thereby improving the overall computing efficiency.

[0033] like Figure 1a and Figure 1b As shown, Figure 1a is a picture. Figure 1b Yes Figure 1a The middle figure is a schematic diagram after image segmentation. Figure 1a There are 6 nodes in Figure 1a Using the edge segmentation method, we get Figure 1b . Figure 1b The original graph is divided into three sub-graphs, namely P1, P2, and P3. In the subsequent processing of the graph neural network, P1, P2, and P3 will be stored on different processors and calculated.

[0034] observe Figure 1b, we can find that some nodes appear in multiple subgraphs at the same time in edge segmentation (such as node d and node z). These nodes are called replicated nodes. If the segmentation method is point segmentation, there will be edges that cross subgraphs, which are called cut edges. Ghost nodes and cut edges are collectively called cross-subgraph structures. Figure 1b , node d appears in both subgraphs P1 and P3, and is connected to node c in P1 and node z in P3.

[0035] Furthermore, during the training process of the graph neural network, information vectors are generated to describe the characteristics of the nodes. This process is called node representation. Figure 1b Taking node d in P1 as an example, the representation of node d needs to be updated by aggregating the information of its neighboring nodes. For example, the representation process of node d in P1 will include the information of its neighbor node - node c, and the representation process of node d in P3 will include the information of its neighbor node - node z. However, the goal of the graph neural network in the processing process is to generate a globally consistent representation for each node. Therefore, in addition to the information of node c, node d in P1 also needs the information of node z in P3. Therefore, node d in P1 must also communicate with node d in P3, and vice versa, to ensure that the representation of the same node d in different subgraphs is consistent. If there is no cross-subgraph communication, nodes d in P1 and P3 will update their respective representations independently, resulting in node d in different subgraphs unable to obtain the information of neighboring nodes in other subgraphs, resulting in inconsistent representation of node d, affecting the overall performance of the model. Therefore, in order to ensure consistent representation of cross-subgraph structures (ghost nodes or cross-edges), communication between different subgraphs is required.

[0036] The communication between subgraphs depends on the processors that process the subgraphs, so the communication between subgraphs is manifested as communication between processors at the hardware level. Communication between processors usually takes more time than computing on subgraphs. It is not difficult to imagine that as the number of cross-subgraph structures increases, the time spent on communication will increase.

[0037] The above describes the problems encountered by graph neural networks in processing static graphs. When graph neural networks process dynamic graphs, they will face new problems. A dynamic graph refers to a graph whose structure changes dynamically over time. Its nodes, edges, or their features can be added, deleted, and changed over time. Unlike static graphs, dynamic graphs not only reflect the relationships between nodes, but also capture how these relationships evolve at different time points. In addition, every moment of a dynamic graph is a static graph.

[0038] like Figure 2 As shown, Figure 2A schematic diagram of the corresponding structure at two moments in a dynamic graph. Figure 2 It is divided into two parts, time t1 and time t2, where time t1 is earlier than time t2. At time t1, the graph consists of a set of nodes [a, b, c, d, g, z] and a set of edges, with each node connected by edges. At time t2, node m is added to the graph and establishes new edge connections with nodes c and d, forming a new structure.

[0039] It is assumed here that time t1 is the initial graph selected for the dynamic graph. In the training of the graph neural network, the static graph at time t1 is first edge-segmented to obtain the three subgraphs mentioned above: P1, P2, and P3. Each subgraph is then distributedly processed by the corresponding processor. However, t2 is a new graph, and due to the time continuity in the dynamic graph, t2 has very few changes relative to t1. There is only one new node m and two edges accompanying the new node m. In the prior art, the subgraph will be re-divided because of this small part of the new change, which greatly increases the time cost of the calculation.

[0040] In order to solve the above-mentioned problems: 1) reducing the time spent on communication, 2) the problem that new changes of dynamic graphs are difficult to handle in graph neural networks, in this application, a graph neural network accelerated training method for GPU is proposed to optimize graph segmentation to reduce the overall calculation time.

[0041] See attached Figure 3 and Figure 4 , Figure 3 is a schematic flow chart of the main steps of a method for accelerating graph neural network training on a GPU according to an embodiment of the present invention. Figure 4 This is a flowchart of the accelerated training method of graph neural network for GPU. Figure 3 As shown, the graph neural network accelerated training method for GPU in an embodiment of the present invention mainly includes the following steps S10 to S60.

[0042] Step S10: Obtain an initial image.

[0043] In this embodiment, the initial image is a static image corresponding to a moment in the dynamic image sample.

[0044] The dynamic graph sample is a data set sample used by the graph neural network when training the dynamic graph. It has been explained in the previous description that the dynamic graph is composed of static graphs with time series information, that is, the dynamic graph is a discrete dynamic graph. In this embodiment, the initial graph is a static graph at one moment in the dynamic graph sample.

[0045] There are many ways to determine the initial graph, because the dynamic graph sample is usually a sample of limited duration. Therefore, the initial graph can be selected from a moment earlier in the timeline in the dynamic graph sample as the initial graph. This ensures that the initial graph already contains enough nodes and edges, and that there are enough static graphs to provide graph neural network training in the future. For example, the static graph at the 1 / 4 position from the starting point of the timeline in the dynamic graph sample can be taken as the initial graph. In addition, the user can actively select a static image from the dynamic graph sample as the initial graph according to needs, which is not limited here.

[0046] Furthermore, when the initial graph is determined, the graphs before the initial graph in the dynamic graph samples will no longer be considered during the training process of the graph neural network. In subsequent graph updates, only the graphs after the initial graph will be considered.

[0047] After the initial graph is selected, the initial graph is preprocessed, and then the initial graph after the preprocessing is segmented. Specifically, the preprocessing at least includes compressing the initial graph. After the initial graph is compressed, the efficiency of subsequent segmentation can be improved and the consumption of computing resources can be reduced. In some embodiments, the initial graph can be compressed according to a compression structure such as CSR (Compressed Sparse Row), CSC (Compressed Sparse Column) or DOK (Dictionary of Keys).

[0048] Step S20: Divide the initial graph into N sub-graphs.

[0049] In some embodiments, the number of subgraphs after segmentation is N, and the number of subgraphs is related to the number of GPUs. The GPUs here refer to GPUs of the same model. In the training process of the graph neural network, the same model of GPUs is usually used to ensure the consistency of training hardware performance.

[0050] In some embodiments, the number of subgraphs N and the number of GPUs M satisfy: N = a*M, where a ≥ 2, and a is a positive integer. In other words, the number of subgraphs is an integer multiple of the number of GPUs. Thus, in subsequent allocations, each GPU can be allocated to at least a subgraphs, that is, at least 2 subgraphs.

[0051] In the process of graph segmentation, algorithms such as Kernighan-Lin algorithm, Metis algorithm or standard spectral clustering algorithm can be used for graph segmentation.

[0052] Step S30: Estimate the computational load of the subgraphs, distribute the N subgraphs to M GPUs based on the computational load of the subgraphs, and perform graph neural network training.

[0053] In this embodiment, the computational load of a subgraph is used to characterize the size of the entire computing task when the GPU calculates the subgraph during the training of the graph neural network.

[0054] In some embodiments, when estimating the computational load of a subgraph, a preset pre-run neural network is used to estimate the computational load of the subgraph. The pre-run neural network is obtained based on the graph neural network to be trained. The pre-run neural network contains most of the relevant network layers and computational operations of the neural network. The subgraph is input into the pre-run neural network, and only forward propagation is performed to obtain the time for the subgraph to perform forward propagation. Forward propagation refers to the process in which the neural network is transmitted layer by layer through the network layer during the reasoning process to finally obtain the output result. Afterwards, the computational load of the subgraph is obtained based on the time of forward propagation.

[0055] The time of forward propagation is used to characterize the computational complexity of the subgraph. The longer the time of forward propagation, the higher the computational complexity of the corresponding subgraph, and the heavier the computational load. In some embodiments, the time of forward propagation can be directly used as the computational load, or the time of forward propagation can be normalized, so that the relative load size between different subgraphs can be seen more clearly, which is convenient for comparison. Similarly, the method of multiple forward propagations and averaging can be used to obtain a more accurate average value. Those skilled in the art can use the above method or a similar method to convert the time of forward propagation into computational load, which is not limited here.

[0056] The subgraphs are then distributed to the M GPUs based on the computational load. In some embodiments, the load on each GPU is made as balanced as possible during the distribution, wherein the number of subgraphs distributed to the GPUs may be the same or different. However, in most cases, the number of subgraphs distributed to the GPUs is the same.

[0057] refer to Figure 5 , Figure 5 This is a schematic diagram of allocating subgraphs to the GPU. Figure 5 There are 9 subgraphs and 3 GPUs in the system. During the allocation process, each GPU is allocated 3 subgraphs. During the allocation process, methods such as greedy algorithms, dynamic programming algorithms, or algorithms that combine objective functions with constraints can be used to make the computational load of each GPU as balanced as possible. Among them, the greedy algorithm calculates the subgraph with the largest computational load and allocates it to the GPU with the lightest computational load through step-by-step selection, thereby achieving a state close to equilibrium.

[0058] In the present invention, each GPU is assigned at least two subgraphs. When the GPU is training the graph neural network, the computation pipeline and the communication pipeline are run in parallel on each GPU, wherein the computation pipeline calculates the subgraphs in sequence, and the communication pipeline communicates the computation results of the subgraphs in sequence. This allows the computation and communication to be processed in parallel, thereby saving the overall computation time of the graph neural network during the training process.

[0059] like Figure 6 As shown, Figure 6 This is a schematic diagram of the calculation and communication performed on the subgraph by the GPU when training the graph neural network. Figure 6 It is divided into two parts, namely part (a) and part (b). Part (a) is a schematic diagram of a GPU processing a sub-graph in the prior art. Part (b) is a schematic diagram of a GPU processing multiple sub-graphs (4 in the figure) using the technology of the present application.

[0060] In part (a), since a GPU only processes one subgraph, the computation and communication parts can only be separated. First, the subgraph is computed, which takes time 1, and then the communication takes time 2. Finally, the time to complete the processing of the subgraph is alltime = time1 + time2.

[0061] In part (b), when the GPU processes more than one subgraph, parallel processing can be performed. After each calculation on a subgraph is completed, the result of the calculation based on the subgraph is communicated and sent to other required GPUs. In part (b), the computation pipeline runs the calculation of four subgraphs in sequence, namely SA1, SA2, SA3 and SA4. The communication pipeline runs four communications in sequence, namely CO1, CO2, CO3 and CO4. Each communication can only be communicated when the calculation of the corresponding subgraph is completed. For example, the communication of CO1 depends on the completion of the calculation of SA1. Therefore, in part (b), the total time alltime' used will be shorter than the technology in part (a).

[0062] In this embodiment, an active communication mechanism is used, that is, the GPU sends the calculation result to the GPU of the receiving party according to the subgraph, wherein the calculation result at least includes the characterization result about the cross-subgraph structure.

[0063] Step S40: Execute the loop process until the graph neural network training is completed.

[0064] In this embodiment, the graph neural network can only process one static image at a time, and this static image comes from the dynamic image sample. Figure 2As shown in the figure, the dynamic graph samples change with the time sequence, and the nodes, edges or their features will also change with time. The changes in the static graph at the end of the time sequence relative to the static graph at the beginning of the time sequence are called incremental data. Figure 2 For example, the static graph at time t2 has an additional node m and two edges of node m compared to the static graph at time t1. Node m and the two edges of node m are the incremental data of the static graph at time t2 relative to the static graph at time t1.

[0065] In some embodiments, the dynamic graph samples will continue to add nodes or edges as the time sequence changes. That is, the static graphs that are later in the time sequence in the dynamic graph will not only contain all the graph structures and node information of the static graphs that are earlier in the time sequence, but also new nodes and edges will appear. Therefore, there is only incremental data in the incremental data.

[0066] It should be noted that when describing the changes of a dynamic graph, you can selectively describe the changes of either nodes or edges, or describe the changes of both nodes and edges at the same time, depending on the needs. Therefore, as a description of the changes of a dynamic graph, incremental data can only describe one of the nodes or edges, or describe both nodes and edges at the same time.

[0067] In the process of processing the dynamic image samples, not only the initial image is processed, but multiple static images in the dynamic image samples are processed in stages, that is, one of the static images is processed in different stages. In this embodiment, the processing method of the incremental data used in any two adjacent stages is the same. Therefore, this processing method of the incremental data constitutes a cyclic process, and the cyclic process will be repeated until the end of training (the end of training can be determined using methods such as preset steps, accuracy, F1 value, etc.).

[0068] The loop process includes step S50 and step S60, which are specifically as follows:

[0069] Step S50: Acquire incremental data, and update the subgraph based on the incremental data.

[0070] During the training process of the graph neural network, the subgraph corresponding to the initial graph is updated through three steps, namely: 1. Obtain incremental data. 2. Determine whether the update conditions are met based on the incremental data. 3. When the update conditions are met, update the subgraph. The following content will describe them one by one, as follows:

[0071] 1) Get incremental data:

[0072] In this embodiment, the incremental data is different data in different loop processes. As described above, the incremental data is a description of the dynamic graph change process. In other words, the start and end of the selected dynamic graph change determine the specific data in the incremental data. In this embodiment, the start position of the corresponding change of the incremental data is the static graph currently processed by the current GPU.

[0073] Furthermore, by scanning the dynamic image samples in chronological order, incremental data at different moments in the dynamic image samples relative to the static image currently processed by the GPU are obtained.

[0074] Specifically, by scanning the static images in the time series of the dynamic image samples one by one, the change process of the dynamic image samples can be extracted and the incremental data can be analyzed. The starting position of the change process is the static image currently processed by the GPU, and the end position of the change process corresponds to the static image in the dynamic image sample scanned at the current moment. In summary, the incremental data is used to characterize the change of the static image in the dynamic image sample scanned at the current moment relative to the static image currently processed by the GPU. Furthermore, if it is the first cycle after segmentation, the incremental data refers to the change of the static image in the dynamic image sample scanned at the current moment relative to the initial image.

[0075] Take a discrete dynamic graph sample as an example. Figure 7 . Figure 7 This is a schematic diagram of some static images in the dynamic image sample. Assume that this dynamic image sample has 7 static images after counting from the initial image. The initial image is represented as G(T0), and the subsequent static images are represented as: G(T1), G(T2), G(T3), G(T4), G(T5), G(T6) and G(T7). Among them, G(T0), G(T1), G(T2) and G(T3) are Figure 5 The following static images are shown in Figure 5 It is not shown in FIG. Assume that the static image currently processed by the current GPU is the initial image G(T0). Afterwards, the dynamic image samples are scanned in time sequence, that is, in the order of T1 to T7.

[0076] Every time a subsequent static image is scanned, an incremental data relative to the initial image is obtained. Figure 5 The incremental data relative to the initial graph are all represented by bold lines. For example, after completing the scan of G(T1), the incremental data is obtained. If the incremental data at this time is expressed by edges, then the incremental data at this time is the edge with nodes m and g at both ends. For another example, after completing the scan of G(T2), the incremental data is the edge with nodes m and g at both ends and the edge with nodes m and d at both ends. It can be seen that the incremental data will change with the changes in the real-time scanning results.

[0077] In the above example, the static graph currently processed by the GPU is used as the initial graph. It is not difficult to see that when the static graph currently processed by the GPU changes, the incremental data will also change accordingly. For example, when the static graph currently processed by the GPU is G(T1), then after completing the scan of G(T2), the incremental data is the edge between node m and node d. Then after completing the scan of G(T3), the incremental data is the edge between node m and node d and the edge between node m and node z. Compared with the situation when the static graph currently processed by the GPU is G(T0), it can be seen that the incremental data will change with the change of the static graph currently processed by the GPU.

[0078] In summary, the incremental data is related to the static image currently processed by the GPU and corresponds to the real-time scanning results of the dynamic image samples.

[0079] The acquisition of incremental data enables graph neural networks to capture the dynamic characteristics of dynamic graphs over time and effectively learn these changing patterns during the training process, thereby improving the model's ability to learn time series features and the accuracy of predicting future states.

[0080] 2) Determine whether the update conditions are met based on incremental data:

[0081] In a single cycle, as the dynamic graph samples are scanned, the incremental data is also increasing. When the incremental data meets the preset update conditions, the sub-graph is updated.

[0082] In this embodiment, when the number of edges or nodes in the incremental data exceeds a preset update threshold, an update operation on the subgraph is triggered.

[0083] The preset update threshold is a pre-set parameter used to control the update frequency. When the amount of incremental data is less than the update threshold, it means that the amount of incremental data is small and the change is not obvious. The incremental data at this time has little impact on the structure of the graph currently processed by the GPU, so you can choose to postpone the update and continue to accumulate change information. When the incremental data exceeds the update threshold, it means that the currently scanned graph has changed significantly relative to the graph structure currently processed by the GPU. At this time, the sub-graph is updated in time to reflect the latest status.

[0084] For example, the incremental data is represented by edges. The update threshold is 1 / 10 of the number of edges in the initial graph. Assume that the initial graph has 10,000 edges. Then in the subsequent loop process, the update threshold is 1,000 edges. In each loop process, as the dynamic graph samples are scanned, the incremental data will continue to increase, but the subgraph will not be updated in this stage. When the incremental data is greater than 1,000, it is determined that the update condition is met and the subgraph is updated.

[0085] Here, an example of using the update threshold is given, with reference to Table 1. Table 1 is a static image of a dynamic image in chronological order, and these static images are continuous.

[0086] Sequence number Static image name Number of edges 1 (initial image) GA 10000 2 GB 10800 3 GC 11600 4 GD 12400 5 GE 12700

[0087] Table 1

[0088] As shown in Table 1, there are 5 static graphs, namely GA, GB, GC, GD and GE. Assuming that the update threshold is 1000 edges, when the static graph currently processed by the GPU is GA, the dynamic graph sample is scanned. When scanning to GB, the incremental data at this time is 800 edges, which is less than the update threshold, so the scan continues. When scanning to GC, the incremental data at this time is 1600 edges, which is greater than the update threshold, and the subgraph is updated. At this time, the static graph currently processed by the GPU is GC.

[0089] Then, in the next cycle, when scanning to GD, the incremental data at this time should be calculated based on GC. The incremental data at this time is 800 edges, so it is less than the update threshold, and the scanning continues. When scanning to GE, the incremental data at this time is 2100 edges, which is greater than the update threshold, and the subgraph is updated at this time.

[0090] This update threshold-based strategy can effectively reduce unnecessary small-scale updates and reduce the computational burden of the system, while ensuring that obvious changes can be captured in a timely manner to support subsequent analysis and training.

[0091] 3) When the update conditions are met, the subgraph is updated:

[0092] When the preset update conditions are met, the incremental data is allocated to the subgraph. In the process of allocating incremental data to subgraphs, the number of subgraphs does not change, but the structure (nodes and edges) inside the subgraphs changes. Since it is divided into N subgraphs in advance, N subgraphs containing incremental data will be obtained after the update.

[0093] In the process of allocating incremental data to subgraphs, new cross-subgraph structures will be generated. The increase in cross-subgraph structures will cause the communication time of the graph neural network to be extended during the training process. In the training of dynamic graph samples, there will be multiple loop processes, that is, multiple subgraph update processes, which will aggravate this phenomenon. Therefore, in the process of allocating incremental data to subgraphs, the generation of cross-subgraph structures should be reduced as much as possible.

[0094] In order to reduce the generation of cross-subgraph structures during the subgraph update process, the present invention proposes a subgraph update method by calculating affinity to update the subgraph, thereby reducing the generation of cross-subgraph structures during the subgraph update process as much as possible.

[0095] Among them, Figure 8 As shown, the subgraph updating method includes: steps S501-S503, which are specifically as follows:

[0096] Step S501: Obtain the affinity and contribution weight of the first node.

[0097] In this embodiment, the first node includes at least: a newly added node and a neighbor node of the newly added node in the subgraph. The newly added node is a node in the incremental data that does not belong to a node in the subgraph. Whether the incremental data is represented in the form of nodes or edges, it contains information about the newly added nodes. Taking the form of edges as an example, the incremental data contains not only the number of edges, but also information about the nodes at both ends of the edges. The nodes in the incremental data are compared with the nodes in the subgraph, and the nodes that are different from the nodes in the subgraph are the newly added nodes. The neighbor nodes of the newly added node in the subgraph refer to the nodes in the subgraph that are connected to the newly added node.

[0098] Then the affinity of the first node and the contribution weight of the first node are explained as follows:

[0099] Affinity of the first node:

[0100] The affinity of the first node includes two parts, the variable affinity of the newly added node and the constant affinity of the neighbor nodes of the newly added node in the subgraph. Affinity is used to characterize the affinity between the node and the subgraph. Since the neighbor nodes of the newly added node in the subgraph are already in the subgraph, they will not change during the update of the subgraph. Therefore, the affinity of the neighbor nodes of the newly added node in the subgraph is a constant, that is, the affinity is true for the subgraph in which it is located and false for other subgraphs.

[0101] For example, suppose there are three subgraphs, P1, P2, and P3. For example, if the neighbor node of a newly added node in a subgraph is in P1, the quantitative affinity of the node can be expressed as [1,0,0]. Here, an array consisting of three elements represents the quantitative affinity of the node. The three elements represent the affinity of the node to different subgraphs in turn. Since the node is in P1, the first element is 1, and the other elements are all 0.

[0102] Variable affinity can also be expressed in a similar way, but since it is not clear to which subgraph the newly added node will be assigned, the variable affinity is initialized when the variable affinity of the newly added node is obtained, so the initial variable affinity is the initialized affinity. Variable affinity is also represented by an array with dimensions. The number of dimensions of variable affinity is the same as the number of subgraphs, both N. Each dimension is used to represent the affinity with the corresponding subgraph, and each dimension has the same affinity with the corresponding subgraph.

[0103] Taking the example of only three subgraphs, the variable affinity of the newly added node can be [1 / 3, 1 / 3, 1 / 3] at the beginning. If there are four subgraphs, the variable affinity of the newly added node can be [1 / 4, 1 / 4, 1 / 4, 1 / 4] at the beginning. This means that before the newly added node is assigned to a subgraph, the affinity of each subgraph is assumed to be equal. In subsequent calculations, the variable affinity will be continuously iterated until the preset convergence condition is met. Then the subgraph corresponding to the largest element is selected as the subgraph to be assigned to the newly added node.

[0104] Contribution weight of the first node:

[0105] The contribution weight is used to characterize the contribution of a node to the corresponding neighbor node. The contribution of the corresponding neighbor node can be calculated by a weighted adjacency matrix calculation algorithm, a PageRank-based contribution matrix generation algorithm, a common neighbor contribution calculation algorithm based on the number of common neighbor nodes, or by using the contribution weight of the edge as the inverse of the degree of its source node. Based on the above method, those skilled in the art can find other methods for obtaining the contribution weight of a node, which are not limited here.

[0106] Since the contribution weight of a node is mainly related to the connection relationship between nodes, both the contribution weight of a newly added node and the contribution weight of the neighboring nodes of the newly added node in the subgraph can be calculated from the data in the static graph corresponding to the incremental data. Therefore, the contribution weight of a node is a fixed value.

[0107] Step S502: Obtaining the affinity of the newly added node based on the affinity of the neighboring nodes of the newly added node and the contribution weights between the newly added node and the neighboring nodes of the newly added node.

[0108] In this embodiment, the neighbor nodes of the newly added node may be in the subgraph or not in the subgraph. That is, the affinity of the neighbor nodes of the newly added node may be a variable affinity or a constant affinity.

[0109] In calculating the affinity of the newly added node, multiple iterations are performed until the preset convergence conditions are met. In each iteration, at least the affinity of the neighboring nodes of the newly added node and the contribution weight between the newly added node and the neighboring nodes of the newly added node are multiplied to obtain the variable affinity of the newly added node after iteration. Specifically, the affinity of the neighboring nodes of the newly added node and the contribution weight between the newly added node and the neighboring nodes of the newly added node are multiplied, and multiple multiplication results are accumulated to obtain the variable affinity of the newly added node after iteration. The number of multiplication results is the same as the number of the newly added nodes.

[0110] In addition, during a single iteration, the overall data will be updated only after the variable affinities of all newly added nodes have been iterated.

[0111] Here is an example to illustrate the calculation process. In a certain iteration, the newly added node u is iterated. The newly added node u has two neighboring nodes, both of which are newly added nodes, namely neighbor node v1 and neighbor node v2. In the result of the previous iteration, the affinity of v1 and v2 is as follows:

[0112] L[v1]=[0.1,0.7,0.2], L[v2]=[0.3,0.2,0.5].

[0113] It can be seen that in the current iteration, the neighbor node v1 pair Figure 2 The affinity of neighbor node v2 is strong. Figure 3 The affinity is strong.

[0114] The variable affinity of the newly added node u is calculated in this iteration as follows:

[0115] L[u]=L[v1]*M[u,v1]+L[v2]*M[u,v2],

[0116] Where M[u,v1] is the contribution weight between node u and node v1, and M[u,v2] is the contribution weight between node u and node v2.

[0117] Assuming M[u,v1]=0.6 and M[u,v2]=0.4, we can calculate that the variable affinity of the newly added node u will be updated to: L[u]=[0.18,0.50,0.32]. From the calculation results, we can see that the newly added node u currently has Figure 2 The affinity is the strongest.

[0118] In this iteration, neighbor nodes v1 and v2 will also update their affinities based on their neighbor nodes. In the next iteration, the affinity of the newly added node u will be recalculated again based on the changes in neighbor nodes. This process will continue until the changes in affinity converge in consecutive iterations. Finally, the affinity of each newly added node is obtained.

[0119] In some embodiments, the preset convergence condition may be to check the maximum value position in the variable affinity of the newly added node in each iteration. If the maximum value position in the affinity does not change in two consecutive iterations, it means that the node has stabilized. When all nodes are stable, it is determined that convergence has occurred, thereby obtaining the affinity of each newly added node. In other embodiments, the preset convergence condition is the number of iterations, for example, convergence is considered after completing 10 iterations.

[0120] Step S503: Allocate the newly added node to the subgraph based on the affinity of the newly added node.

[0121] In this embodiment, the subgraph corresponding to the element with the largest value in the dimension of the newly added node is used as the allocated subgraph.

[0122] The greater the affinity of the newly added node for a specific subgraph, the closer the connection between the newly added node and the subgraph is. Then, when the newly added node is assigned to the subgraph, the fewer cross-subgraph structures it generates, and the less communication time is ultimately caused, thereby reducing the training time of the graph convolutional neural network.

[0123] After the subgraph is updated, N subgraphs containing incremental data are obtained. Then, the N subgraphs containing incremental data are distributed to M GPUs and the graph neural network is trained. This process is similar to step S30. First, the computational load of each subgraph containing incremental data is estimated, and then redistributed, as follows:

[0124] Step S60: Estimate the computational load of the subgraph containing incremental data, distribute the N subgraphs containing incremental data to M GPUs based on the computational load of the subgraph containing incremental data, and perform graph neural network training.

[0125] This step is similar to step S30 and will not be described again here.

[0126] Through steps S10-S60, during the training process of the graph neural network, only one graph segmentation operation is performed, thereby obtaining multiple subgraphs. Afterwards, when the incremental data is updated, only local adjustments are made to the subgraph, and the graph segmentation operation is no longer performed. Moreover, the GPU resources are dynamically and evenly redistributed according to the computing load to the subgraph after local adjustment, so that the training process can remain efficient. In the subsequent process, the subgraphs can be continuously updated by repeating the processes of steps S50 and S60, thereby completing the training of the graph neural network for dynamic graph samples, which will not be repeated here. This technology ensures improved computing and resource utilization, without frequent computing power consumption, reduces training time, and improves the training efficiency of the graph neural network during training.

[0127] It should be pointed out that although the various steps in the above embodiments are described in a specific order, those skilled in the art can understand that in order to achieve the effects of the present invention, different steps do not have to be performed in such an order. They can be performed simultaneously (in parallel) or in other orders. These changes are within the scope of protection of the present invention.

[0128] It is understood by those skilled in the art that the present invention implements all or part of the processes in the method of the above embodiment, and can also be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of each of the above method embodiments when executed by the processor. Among them, the computer program includes a computer program, and the computer program can be in source code form, object code form, executable file or some intermediate form. The computer-readable storage medium may include: any entity or device, medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory, random access memory, electric carrier signal, telecommunication signal and software distribution medium that can carry the computer program. It should be noted that the content contained in the computer-readable storage medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable storage media do not include electric carrier signals and telecommunication signals.

[0129] Furthermore, the present invention also provides a control device. In one embodiment of a control device according to the present invention, the control device includes a processor and a storage device. The storage device can be configured to store a program for executing the method for accelerating the training of a graph neural network for a GPU in the above-mentioned method embodiment, and the processor can be configured to execute the program in the storage device, which includes but is not limited to executing the method for accelerating the training of a graph neural network for a GPU in the above-mentioned method embodiment. For ease of explanation, only the parts related to the embodiment of the present invention are shown. For specific technical details not disclosed, please refer to the method part of the embodiment of the present invention. The control device may be a control device device formed by various electronic devices.

[0130] Furthermore, the present invention also provides a computer-readable storage medium. In a computer-readable storage medium embodiment according to the present invention, the computer-readable storage medium can be configured to store a program for executing the graph neural network accelerated training method for GPU of the above-mentioned method embodiment, and the program can be loaded and run by the processor to implement the above-mentioned graph neural network accelerated training method for GPU. For ease of explanation, only the parts related to the embodiment of the present invention are shown. For specific technical details not disclosed, please refer to the method part of the embodiment of the present invention. The computer-readable storage medium may be a storage device formed by various electronic devices. Optionally, the computer-readable storage medium in the embodiment of the present invention is a non-temporary computer-readable storage medium.

[0131] Further, it should be understood that since the setting of each module is only for illustrating the functional units of the device of the present invention, the physical devices corresponding to these modules may be the processor itself, or a part of the software in the processor, a part of the hardware, or a part of the combination of software and hardware. Therefore, the number of each module in the figure is only schematic.

[0132] Those skilled in the art will appreciate that the modules in the device can be adaptively split or merged. Such splitting or merging of specific modules will not cause the technical solution to deviate from the principle of the present invention, and therefore, the technical solutions after splitting or merging will fall within the protection scope of the present invention.

[0133] It should be noted that, for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of this application, and these improvements and modifications should also be regarded as the scope of protection of this application.

Claims

1. A method for accelerating graph neural network training on GPU, characterized in that: include: Acquire an initial image, and divide the initial image into N sub-images, wherein the initial image is a static image corresponding to a moment in the dynamic image sample; estimating the computational load of the subgraphs, and distributing the N subgraphs to M GPUs based on the computational load of the subgraphs and performing graph neural network training, wherein at least two subgraphs are distributed to each GPU; Acquire incremental data, and update the sub-graph based on the incremental data to obtain N sub-graphs containing incremental data, wherein the incremental data is used to characterize the change of the static graph in the dynamic graph sample scanned at the current moment relative to the static graph currently processed by the GPU; The N subgraphs containing incremental data are distributed to M GPUs and the graph neural network is trained.

2. The method according to claim 1, characterized in that The acquiring of incremental data and updating of the subgraph based on the incremental data includes: Scan the dynamic image samples in chronological order to obtain the incremental data of the dynamic image samples at different times relative to the static image currently processed by the GPU; If the incremental data meets the preset update condition, the incremental data is allocated to the subgraph.

3. The method according to claim 2, characterized in that The incremental data includes newly added nodes, and allocating the incremental data to the subgraph includes: Obtain the affinity and contribution weight of the first node, wherein the affinity of the first node includes the variable affinity of the newly added node and the constant affinity of the neighboring nodes of the newly added node in the subgraph, the affinity is used to characterize the affinity between the node and the subgraph, the variable affinity is the initialized affinity, and the contribution weight is used to characterize the contribution of the first node to the corresponding neighboring node; Obtaining the affinity of the newly added node based on the affinity of the neighboring nodes of the newly added node and the contribution weight between the newly added node and the neighboring nodes of the newly added node; Based on the affinity of the newly added node, the newly added node is allocated to the subgraph.

4. The method according to claim 3, characterized in that The affinity is represented by an array with dimensions, wherein the number of dimensions is the same as the number of subgraphs, each dimension is used to characterize the affinity with the corresponding subgraph, and the affinity between each dimension and the corresponding subgraph in the variable affinity is the same, and the affinity of the newly added node is obtained based on the affinity of the neighboring nodes of the newly added node and the contribution weight between the newly added node and the neighboring nodes of the newly added node, including: At least multiply the affinity of the neighboring nodes of the newly added node and the contribution weight between the newly added node and the neighboring nodes of the newly added node to obtain the variable affinity of the newly added node after the first iteration; continuously iterate the new affinity variable until the preset convergence condition is met to obtain the affinity of the newly added node.

5. The method according to any one of claims 1 to 4, characterized in that: The number of subgraphs N and the number of GPUs M satisfy: N=a*M, where a≥2, a is a positive integer, The training of the graph neural network includes: On each GPU, the computation pipeline and the communication pipeline are run in parallel, where the computation pipeline computes the subgraphs in sequence, and the communication pipeline communicates the computation results of the subgraphs in sequence.

6. The method according to claim 4, characterized in that At least multiplying the affinity of the neighboring node of the newly added node and the contribution weight between the newly added node and the neighboring node of the newly added node comprises: The affinity of the neighboring nodes of the newly added node and the contribution weight between the newly added node and the neighboring nodes of the newly added node are multiplied, and multiple multiplication results are accumulated, wherein the number of multiplication results is the same as the number of the newly added nodes.

7. The method according to any one of claims 1 to 4, characterized in that: The estimating the computational load of the subgraph includes: Input the subgraph into the pre-run neural network to obtain the time for the subgraph to perform forward propagation; Based on the forward propagation time, the computational load of the subgraph is obtained.

8. The method according to any one of claims 1 to 4, characterized in that: The incremental data meets the preset update conditions, including: The number of edges or nodes in the incremental data is greater than a preset update threshold; or, The allocating the N subgraphs to the M GPUs based on the computational load of the subgraphs includes: Load balancing is performed based on the computational loads of the subgraphs, and the N subgraphs are distributed to the M GPUs according to the load balancing result.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein the program executes the method according to any one of claims 1 to 8 when executed.

10. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to execute the method according to any one of claims 1 to 8 through the computer program.

Citation Information

Cited By

  • Resource allocation method and system based on pipeline parallelism

    CN119917286A