InferTurbo: A Scalable System for Boosting Full-graph Inference of Graph
  Neural Network over Huge Graphs
GNN inference is a non-trivial task, especially in industrial scenarios with
giant graphs, given three main challenges, i.e., scalability tailored for
full-graph inference on huge graphs, inconsistency caused by stochastic
acceleration strategies (e.g., sampling), and the serious redundant computation
issue. To address the above challenges, we propose a scalable system named
InferTurbo to boost the GNN inference tasks in industrial scenarios. Inspired
by the philosophy of ``think-like-a-vertex", a GAS-like (Gather-Apply-Scatter)
schema is proposed to describe the computation paradigm and data flow of GNN
inference. The computation of GNNs is expressed in an iteration manner, in
which a vertex would gather messages via in-edges and update its state
information by forwarding an associated layer of GNNs with those messages and
then send the updated information to other vertexes via out-edges. Following
the schema, the proposed InferTurbo can be built with alternative backends
(e.g., batch processing system or graph computing system). Moreover, InferTurbo
introduces several strategies like shadow-nodes and partial-gather to handle
nodes with large degrees for better load balancing. With InferTurbo, GNN
inference can be hierarchically conducted over the full graph without sampling
and redundant computation. Experimental results demonstrate that our system is
robust and efficient for inference tasks over graphs containing some hub nodes
with many adjacent edges. Meanwhile, the system gains a remarkable performance
compared with the traditional inference pipeline, and it can finish a GNN
inference task over a graph with tens of billions of nodes and hundreds of
billions of edges within 2 hours.
Dalong Zhang, Xianzheng Song, Zhiyang Hu, Yang Li, Miao Tao, Binbin Hu, Lin Wang, Zhiqiang Zhang, Jun Zhou
InferTurbo: A Scalable System for Boosting Full-graph Inference of Graph Neural Network over Huge Graphs

###### Abstract

With the rapid development of Graph Neural Networks (GNNs), more and more studies focus on system design to improve training efficiency while ignoring the efficiency of GNN inference. Actually, GNN inference is a non-trivial task, especially in industrial scenarios with giant graphs, given three main challenges, i.e., scalability tailored for full-graph inference on huge graphs, inconsistency caused by stochastic acceleration strategies (e.g., sampling), and the serious redundant computation issue. To address the above challenges, we propose a scalable system named InferTurbo to boost the GNN inference tasks in industrial scenarios. Inspired by the philosophy of "think-like-a-vertex", a GAS-like (Gather-Apply-Scatter) scheme is proposed to describe the computation paradigm and data flow of GNN inference. The computation of GNNs is expressed in an iteration manner, in which a vertex would gather messages via in-edges and update its state information by forwarding an associated layer of GNNs with those messages and then send the updated information to other vertexes via out-edges. Following the schema, the proposed InferTurbo can be built with alternative backends (e.g., batch processing system or graph computing system). Moreover, InferTurbo introduces several strategies like shadow-nodes and partial-gather to handle nodes with large degrees for better load balancing. With InferTurbo, GNN inference can be hierarchically conducted over the full graph without sampling and redundant computation. Experimental results demonstrate that our system is robust and efficient for inference tasks over graphs containing some hub nodes with many adjacent edges. Meanwhile, the system gains a remarkable performance compared with the traditional inference pipeline, and it can finish a GNN inference task over a graph with tens of billions of nodes and hundreds of billions of edges within 2 hours.

 Graph Neural Networks, Distributed System, Full-graph Inference, Big Data

## I Introduction

Graph Neural Networks (GNNs) generalize deep learning over regular grids (e.g., images) to highly unstructured data and have emerged as a powerful learning tool for graph data. Recently, GNNs have demonstrated impressive success on various tasks, ranging from traditional graph mining tasks (e.g., node classification [1, 2, 3, 4] and link prediction [5, 6]) to the fields of natural language processing [7] and computer vision [8]. Meanwhile, graph data forms the basis of innumerable industrial systems owing to its widespread utilization in real-world applications (e.g., recommendation [9, 10, 11, 12, 13], marketing [14, 15], fraud detection [16, 17]), further facilitating the flourishing of GNNs in industrial communities.

The key idea of current GNNs is taking advantage of information aggregation schema, which can effectively summarize multi-hop neighbors into representations via stacking multiple GNN layers. Essentially, the high computation cost exponentially growing with the number of GNN layers poses the non-trivial challenges for _GNN Training and Inference_ in industrial scenarios with huge graphs, containing billions of nodes and trillions of edges. With the aim of the possibility of performing the highly scalable and efficient GNN training in real industrial scenarios, several recent efforts have been made in industrial-purpose graph learning systems, including single-machine systems with the cooperation between GPUs and CPUs (i.e., DGL [18, 19] and PyG [20]), distributed systems based on localized convolutions (i.e., Aligraph [21]) and pre-processed information-complete sub-graphs (i.e., AGL [22]). Unfortunately, the main focus of these systems is training GNNs efficiently on graphs at scale, while few attention has been paid to the inference phase of GNNs 1, which is also the core of an industrial graph learning system.

Footnote 1: Different from online inference whose goal is guaranteeing the low latency of real-time online serving [25, 26], the focus of GNN inference in our paper aims at efficiently performing full-graph inference in the offline environment, which is ubiquitous in financial applications.

In current graph learning systems [18, 19, 20, 21], the inference phase is conducted by blindly imitating the pipeline of the training phase. However, the inference phase of GNN has its unique characteristics, making it distinct from the training phase, such that the pure design of inference stage in current graph learning systems is unsuitable for performing large-scale inference tasks in industrial scenarios.

* _The large gap of data scale between training and inference phases._ In a general graph learning task, only a small number of nodes (e.g., 1% or even less in actual scenarios) are labeled for GNN training, while the inference tasks are usually expected to be taken over the entire graph. Such a gap is steadily worsening in the industrial scenarios with huge graphs, containing hundreds of millions or even billions of nodes [22, 27, 28] (e.,
Facebook2, Ant Group3). Both observations encourage us to re-consider the scalability issue encountered in the inference tasks with the careful thought of memory storage and communication bandwidth. Footnote 2: [https://en.wikipedia.org/wiki/Facebook_Inc](https://en.wikipedia.org/wiki/Facebook_Inc). Footnote 3: [https://en.wikipedia.org/wiki/Alipay](https://en.wikipedia.org/wiki/Alipay)
* _No guarantee for the consistency of predictions in inference phase._ As a basic requirement in industrial scenarios, the prediction score for a certain node should keep consistency at multiple runs, which unfortunately gets no guarantee in the GNN inference of current systems. To extend GNNs to large-scale graphs, the \(k\)-hop neighbor sampling strategy is widely adopted in current graph learning systems [18, 19, 20, 21, 22, 23]. Although the training phase could greatly benefit from the efficiency-oriented strategy for generalized GNNs, the inherent stochasticity for prediction is unacceptable in inference phase, especially for financial applications (e.g., fraud detection and loan default prediction [16, 17]).
* _Serious redundant computation issue in the inference phase._ Current graph learning systems [18, 19, 20, 21] follow the procedure that performs forward and backward of GNNs over \(k\)-hop neighborhoods in a mini-batch manner, and would obtain a well-trained GNN by repeating this procedure enough times. In spite of its potential capability of enjoying mature optimization algorithms and data-parallelism in training phase, \(k\)-hop neighbor sampling with the mini-batch training manner would introduce the undesirable redundant computation issue in the inference phase since only one forward pass of GNNs is required.

Addressing the limitations of current graph learning systems, we aim to facilitate GNN inference in industrial scenarios through a collaborative setting of mini-batch-based training and full-batch-based inference. The significance of the cooperative setting is not trivial considering two major challenges that are not explored in current graph learning systems:

* _C1: How to unify the mini-batch based training and full-batch based inference in a graph learning system?_ As mentioned above, the mini-batch strategy is the promising way for efficient GNNs training, while the full-batch strategy is suitable for inference to alleviate computation issues. To combine those two advantages, it is impressive to abstract a new schema of graph learning that a GNN trained in the mini-batch manner could naturally perform inference in the full-batch manner.
* _C2: How to efficiently perform GNN inference in distributed environments, especially for huge graphs with extremely skew degree distribution?_ To ensure the consistency of prediction in inference tasks, we discard the strategies related to neighbor sampling, which put forward the urgent request for efficient GNN inference on huge graphs. In addition, due to the ubiquity of Power-Law, it is critically important to handle long-tailed nodes with extremely large degrees in terms of time cost and resource utilization, as well as avoiding the unexpected Out Of Memory (OOM) issues.

To this end, we design a system named **InferTurbo** to boost the inference tasks on industrial-scale graphs. We propose a GAS-like (Gather-Apply-Scatter) schema [30] together with an annotation technique to describe different stages of the data flow and the computation flow of GNNs, which could be used to unify the mini-batch training and full-graph inference phases. The training and inference phases share the same computation flow but use different implementations of data flow. The data flow parts are made as built-in functions currently, and users would only focus on how to write models in our computation flow. Moreover, to handle the corner cases in natural graphs in industrial scenarios, such as nodes with extremely large amount of in-edges or out-edges, a set of strategies without any sampling like _partial-gather_, _broadcast_, and _shadow-nodes_ are proposed to balance the load of computation and communication and mitigate the long tail effect caused by those nodes. As a result, consistency prediction results could be guaranteed at different runs, and the system enjoys a better load-balancing. At last, the system is implemented on both the batch processing system [31, 32] and the graph process system [33], which makes it gain good system properties (e.g., scalability, fault tolerance) of those mature infrastructures. The main contributions of this work are summarized as follows:

* We propose a GAS-like schema together with an annotation technique to describe the data and computing flow of GNNs, and make it possible to hierarchically conduct the inference phase over a full graph. In this way, the redundant computation caused by k-hops neighborhood is eliminated in inference phase.
* We describe implementation details of the system on both batch processing system [31, 32] and graph computing system [33], which are mature infrastructures and widely available in industrial communities.
* We design a set of strategies such as _partial-gather_, _broadcast_, and _shadow-nodes_ for inference tasks to handle the power-law problem in industrial graphs.
* Compared with some state-of-the-art GNN systems (DGL, PyG), the proposed system demonstrates remarkable results in efficiency and scalability while achieving comparable prediction performance, and it could finish a node classification task over a graph with tens of billions of nodes and hundreds of billions of edges within 2 hours.

## II Preliminaries

### _K-hop Neighborhood and Sampling_

A _directed_, _weighted_, and _attributed_ graph is denoted as \(\mathcal{G}=\{\mathcal{V},\mathcal{E},\mathbf{X},\mathbf{E}\}\), where \(\mathcal{V}\) and \(\mathcal{E}\subseteq\mathcal{V}\times\mathcal{V}\) are the node set and edge set of \(\mathcal{G}\), respectively. \(\mathbf{X}\) and \(\mathbf{E}\) are node features and edge features. The \(k\)-hop neighborhood \(\mathcal{G}_{v}^{k}\) of node \(v\), is defined as the _induced attributed subgraph_ of \(\mathcal{G}\) whose node set is \(\mathcal{V}_{v}^{k}=\{v\}\cup\{u|d(v,u)\leq k\}\), where \(d(v,u)\) denotes the length of the shortest path from \(u\) to \(v\), and edge set is
\(\mathcal{E}_{v}^{k}=\{(u,u^{\prime})|(u,u^{\prime})\in\mathcal{E}\wedge u\in \mathcal{V}_{v}^{k}\wedge u^{\prime}\in\mathcal{V}_{v}^{k}\}\). Additionally, \(\mathcal{G}_{v}^{k}\) also contains the feature vectors of the nodes and edges. Without loss of generality, node \(v\) itself is treated as its \(0\)-hop neighborhood. It is proved that \(k\)-hop neighborhood would provide sufficient and necessary information for \(k\)-layer GNNs [22].

However, the size of k-hop neighborhood grows exponentially with the number of hops, making the computations performed on it memory-intensive and time-consuming. _K-hop sampling_ is proposed to address those problems. It would sample neighbors in a top-down manner, i.e., sample neighbors in the \(k\)-th hop given the nodes in the \((k-1)\)-th hop recursively. In particular, different sampling approaches [23, 24, 10, 22] employ different ways to select the neighbors, and one typical method is to randomly choose a fixed number of neighbors in each iteration.

### _Graph Neural Networks_

Graph neural network is a popular way to learn over graph data, and it aggregates neighbors' information for a certain node in an iterative way. Given an attributed graph \(\mathcal{G}\), a GNN layer can be formulated in a **message passing paradigm**[18, 20, 34], which first computes _messages_ via edges and then _updates_ the state of the target node with those messages:

\[\begin{split}\text{message:}&\quad m_{v,u}^{k+1}= \mathcal{M}(\mathbf{h}_{v}^{k},\mathbf{h}_{u}^{k},e_{v,u}),\\ \text{update:}&\quad\mathbf{h}_{v}^{k+1}=\mathcal{U}( \mathbf{h}_{v}^{k},\mathcal{R}(\{m_{v,u}^{k+1}\}_{u\in\mathcal{N}_{v}^{+}})), \end{split} \tag{1}\]

where \(\mathbf{h}_{v}^{k}\) denotes intermediate embedding of node \(v\) at the \(k\)-th layer and \(\mathbf{h}_{v}^{0}=\mathbf{x}_{v}\), \(e_{v,u}\) and \(m_{v}^{k+1}\) indicate edge features and messages associated with \(v\)'s in-edge from \(u\) respectively, \(\mathcal{M}\) represents the _message_ function that generates messages according to adjacent node features and edge features on each edge, \(\mathcal{U}\) means the _update_ function that updates node embedding by aggregating incoming messages based on the _reduce_ function \(\mathcal{R}\). The _message_ function and _update_ function are usually neural networks, while the _reduce_ function could be a certain pooling function (such as sum, mean, max, min) or neural networks.

Most GNN algorithms (e.g., GCN [1], GraphSAGE [4], GAT [3]) could be expressed in this paradigm with a few changes in those functions. For example, _message_ functions for GCN, GraphSAGE, and GAT, only take the source node's hidden state (or with edge features) as input. In addition, _reduce_ functions for GCN and GraphSAGE are set to pooling functions, while for GAT, the reduce function would perform a weighted sum over messages based on the attention mechanism.

## III Related Works

### _Graph Processing System_

The idea of message passing could be traced back to the graph processing field, which focuses on understanding the structure properties or topology of graphs, such as finding out the most important vertices (e.g., PageRank [35]), seeking the shortest path between nodes (e.g., SSSP [36]), and so on. In the following, some gifted works will be introduced as they motivate our work a lot.

In the graph processing field, with the rapid growth of graph data, many efforts [37, 38] have been paid to conduct graph processing tasks distributedly to handle extremely large graphs. Pregel [33] adopts a "think like a vertex" programming model, in which each node receives messages from its neighbors in the previous iteration, modifies its own state or mutates the graph topology, and sends messages to other nodes via its out-edges. PowerGraph [30] further develops the vertex-centric programming model with three fine-grained conceptual phases to describe the data flow, i.e., Gather, Apply, and **S**catter (**GAS**). The _gather_ and _scatter_ are a pair of symmetrical operations that demonstrate the information flowing in and out a node and perform edge-wise processing on the corresponding in-edges and out-edges. The _apply_ stage is used to update the state of the node itself. It enables a node-level paralleling by assigning nodes to partitions, along with their states and adjacent edges. Many graph processing algorithms (e.g., PageRank, SSSP) could be expressed in this paradigm. The following works [39, 40, 41, 42] expand the abstraction and propose many talented strategies to optimize graph processing systems such as partitioning, communication, and so on.

The key difference between graph processing algorithm and GNN is that the former mainly focuses on graph structure, while the latter usually models graph structure and rich attribute information together and is optimized by gradient-based algorithms (e.g., SGD [43]). That is, GNNs are more compute-intensive and communication-intensive, and data dependency exists in both forward and backward pass.

### _Graph Learning System_

Inspired by the development in deep learning communities, researchers also design and build systems to perform graph learning algorithms based on some deep learning frameworks, such as TensorFlow [44] and PyTorch [45]. Many works [18, 19, 20, 22] build graph learning systems following the message-passing paradigm to unify different GNN variants, which help researchers design new GNN algorithms in an easy way.

The development of graph learning systems evolves from optimizing systems on a single machine [18, 19, 46, 47] to providing an efficient way to learn over large graphs distributedly [19, 20, 21, 22]. Inspired by the k-hop sampling strategy [4, 10], recent works [19, 20, 21, 22] perform localized convolutions on sampled k-hop neighborhoods to mitigate the inherent data dependency problem and enjoy the mature data-parallelism architecture in graph learning. Specially, Aligraph [21] implements distributed in-memory graph storage engine, and workers will query subgraphs for a batch of training samples and do the training workloads. DGL [19] proposes to use a partitioning algorithm when building the graph storage engine to reduce the number of edge cuts between different partitions, which is helpful to reduce the communication overhead when querying subgraphs of training samples. PyG [20] provides lightweight, user-friendly sampling APIs,
whereas users usually need to prepare an extra graph storage engine for distributed training. AGL [22] proves that the k-hop neighborhood could provide sufficient and necessary information for k-layer GNN models and pre-generates the k-hop neighborhoods with a MapReduce pipeline to solve the inherent data dependency problem. It also provides a way to estimate the errors caused by random sampling strategy, and errors would decrease as the sampling number increases. Users might trade off computing speed and prediction accuracy by changing the number of neighbors for each layer.

However, little attention has been paid to the inference phase of GNNs. Many works thought that inference tasks could be perfectly conducted in the same way as the training phase, which is hard to meet the requirements of inference tasks in industrial scenarios. The inference should be efficiently conducted over huge graphs with skewed degree distribution, and the prediction result should keep consistent at different runs. A few existing works [48, 49] mainly focus on the efficiency problem in the inference phase on a single machine and propose some techniques, such as operation fusion and graph-specific caching, to reduce intermediate results and achieve better IO speed. AGL [22] proposes a full-graph inference module to mitigate the redundant computation problem caused by k-hop neighborhoods but misses to solve the consistency problem and straggler problems caused by 'hub' nodes in industrial scenarios. It is still challenging to build an efficient and scalable inference system for industrial applications.

## IV System

This section will first provide an overview of the InferTurbo inference system. The system is then detailed from three aspects: the programming model abstraction, implementations using various backends, and large-graph optimization techniques.

### _System Overview_

The key motivation of the work is to build an efficient GNN inference system on top of scalability for huge graphs in industrial scenarios. Therefore, instead of designing and optimizing inference system over a single monster machine, we'd rather build the system on mature, scalable infrastructures with high throughput capacity, such as batch processing systems and graph processing systems. In addition, to boost the inference efficiency, the system is expected to address the following issues: serious redundant computation caused by inferring on \(k\)-hop neighborhoods and the straggler problem brought on by skewed degree distribution. Furthermore, as the consistency of prediction results at different runs is a fundamental requirement for industrial applications, some optimization strategies with randomness should be avoided.

To this end, we propose InferTurbo to boost the inference tasks over industrial graphs. The overall architecture is illustrated in Fig. 1. First, a GAS-like abstraction is proposed to describe the data flow and computation flow of GNNs by combining the classical message-passing schema in (1) and the GAS schema in graph processing system. This abstraction is utilized to integrate the mini-batch training phase and full-batch inference phase. In this way, the inference phase would not rely on k-hop neighborhoods and thus avoids redundant computation, while we could still enjoy the mature optimization algorithms in mini-batch manner and the data parallelism in training phase.

In addition, by designing and implementing adaptors, a well-trained GNN model in our abstraction could be deployed on batch processing systems or graph processing systems, which are mature industrial infrastructures with properties of high throughput and scalability. Applications could choose one of them as the backend by trading off the efficiency and resource cost.

Furthermore, a set of strategies without dropping any information are proposed to handle problems caused by nodes with a large degree, since the degree distribution could be skewed for industrial graphs. With those strategies, our system could achieve consistent prediction results at different runs and gain better load-balancing by mitigating the stragglers caused by those "hub" nodes.

### _InferTurbo Abstraction_

In industrial scenarios, there are some key distinctions between the training and inference phases of GNN algorithms. In the training phase, the labeled nodes may be one percent of all nodes or even less, and the optimization procedure would be repeated several times on them to obtain a converged model. It is a wise decision to conduct localized GNNs on those labeled nodes based on their k-hop neighborhoods since we can benefit from data parallelism and sophisticated optimization methods in the mini-batch setting. The cost is also reasonable since labeled nodes would be scattered throughout the whole graph, and there would not be many overlaps between k-hop neighborhoods of corresponding labeled nodes. On the contrary, inference tasks usually should be conducted on the entire graph. Forwarding localized GNNs over the k-hop neighbors of all those nodes might result in the redundant computation problem. A good way to solve it is to design a full-batch distributed inference pipeline and bridge the gap

Fig. 1: System overview.
between those two different modes in training and inference phases.

Inspired by the philosophy [33] of "think-like-a-vertex" in the graph processing field, we re-express the classical message-passing schema of GNNs to a GAS-like abstraction to unify the mini-batch training and full-graph inference phases. As shown in Fig. 2, for a certain GNN layer, the GAS-like abstraction can be defined as follows:

* _gather_nbrs (Data Flow)_: A "vertex" receives messages from its in-edges and then vectorizes the collected information into tensors.
* _aggregate (Computation Flow)_: The "vertex" would preliminarily process the messages from its in-edges, which is quite similar to the reduce function in \(\mathcal{R}\) in (1). The difference is that this process should obey the commutative law and associative law (like max/min/sum/mean pooling or union) for further optimization in inference phase. Otherwise, the computation should be placed in the next stage.

* _apply_node (Computation Flow)_: The "vertex" then updates its state information by combing the former state of itself and the "gathered" message from the former stage.

* _apply_edge (Computation Flow)_: The "vertex" would generate messages according to the updated state information together with edge features.
* _scatter_nbrs (Data Flow)_: The "vertex" sends messages via out-edges.

Those five stages are used to describe the data flow and computation flow in GNNs, and their roles are emphasized by underlining and annotating the corresponding part. Compared with the classical GAS schema, both the _Gather_ and _Scatter_ are expanded to two sub-stages to distinguish the data flow and computation flow in those stages. In general, _gather_nbrs_ and _scatter_nbrs_, a pair of symmetry operations in the data flow, are used to receive and send messages via in-edges or out-edges, respectively. We make them as built-in methods since they are the same among a variety of commonly used GNNs.

Computation stages would vary for different GNNs, and users should override those stages according to their specific requirements. Specially, a rule is defined to set a boundary between _aggregate_ and _apply_node_ stages: the computation of the _aggregate_ should obey the commutative law and associative law. Otherwise, related operations should be placed in the _apply_node_ stage. For example, many pooling functions (such as sum, mean, max, min), used as the reduce function in GCN and GraphSAGE, should be placed in the _aggregate_ stage following the rule. For GAT, the computation of attention would break the rule, and thus, we simply union messages in the _aggregate_ stage and perform the reduce function in the _apply_node_ stage. This rule also facilitates further optimizations, which will be detailed in the next several sections.

The mini-batch training and full-graph inference are unified with such abstraction:

#### Iii-B1 Training

In the training phase, following the traditional training-inference pipeline, the system still takes k-hop neighborhoods as input and train GNNs in the mini-batch manner. As shown in Fig. 3, we take two widely used GNN algorithms (i.e., GraphSAGE, GAT) as examples to demonstrate how to organize codes in such abstraction.

The data flow in training phase is quite simple. Since k-hops neighborhoods provide sufficient information for \(k\)-layer GNNs [22] and are locally available for a certain training worker, the data flow is just accessing and updating related local tensors.

Meanwhile, a model doesn't need much change and only should be expressed in our schema. As shown in Fig. 3, a certain GNN algorithm should override three methods (_gather_, _apply_node_, and _apply_edge_) from the base class. In addition, we also provide an interface named _scatter_and_gather_ in case the _scatter_ and _gather_ stages could be fused together to avoid storing intermediate edge-level messages in training phase [18]. For example, the scatter and gather processes in GraphSAGE are fused by a generalized sparse-dense matrix multiplication operation. It's worth noting that since the _gather_nbrs_ is just accessing local tensors in training phase, it is ignored here for simplicity. The _gather_ interface in Fig. 3 represents the computation of _aggregate_ stage.

Furthermore, some function decorators are developed to mark the beginning point and end point of functions, as shown in Fig. 3. Meanwhile, we would generate layer-wise signature files to record those information at the time to save a well-trained model (parameters and so on). In this way, different parts of the computation flow could be reorganized and deployed in corresponding stages in the inference phase. Note that parameters in those decorators indicate whether to enable optimization strategies and also would be recorded in signature files. Those information would be loaded in the inference phase to avoid excessive manual configurations.

Fig. 2: InferTurbo abstraction
#### Iv-B2 Inference

Different from the training phase, the inference task is conducted in the full-graph manner. Since the InferTurbo abstraction is expressed from the perspective of a node, the forward pass of GNNs could be treated as a "vertex" program over a certain node. By partitioning nodes in a graph into different machines, the total inference task could be conducted distributedly.

The data flow in the inference phase is quite different from that in the training phase. Neighbors of a certain node could be placed on different machines, and data should be exchanged among those machines to prepare sufficient information to perform the computation flow on the node. Therefore, rather than simply accessing local tensors, the data flow in inference phase mainly plays a role in communicating with other nodes on remote machines: the _gather_nbrs_ would receive information from remote nodes via in-edges and vectorize those information into adjacency matrix, node/edge feature matrix, and so on. The _scatter_nbrs_ would send messages to other machines according to the destination node's id for the next iteration.

In contrast, the computation flow could be shared in training and inference phases. In general, a certain computation stage of a well-trained model would be attached to the corresponding part in inference phase. Specially, the computation flow would be reorganized for optimization. For example, the _aggregate_ function may be performed in the _Scatter_ stage in advance to reduce messages sent to the same destination node.

The implementation details about how to conduct the inference tasks with specific backends and the optimization strategies will be presented in the following sections.

### _Alternative Backends and Implementation Details_

Scalability is the key property that should be taken into consideration when implementing the InferTurbo in the inference phase. Except for scalability, different industrial applications also have some specific requirements. Inference tasks for some time-sensitive applications should be finished as fast as possible, even with relatively high costs on expensive and exclusive resources (like memory). Others may be cost-sensitive and seek a way to conduct the inference over large graphs with limited commodity computation resources since the resource cost is also critical in industrial scenarios.

InferTurbo provides two alternative backends on graph processing systems (i.e., Pregel-like systems) and batch processing systems (i.e., MapReduce, Spark) to trade off computation efficiency and resource cost. In general, InferTurbo on the graph processing system could be more efficient than that on batch processing system but with more strict requirements on stable and exclusive resources, such as, memory, CPU cores. In contrast, InferTurbo on batch processing systems is more flexible in memory and CPU requirements as it processes data from external storage. For example, the batch processing system could handle large graphs even with a single reducer if sufficient external storage is available.

The implement details of those two backends are introduced respectively as follows:

#### Iv-C1 InferTurbo on Graph Processing System

We implement the InferTurbo abstraction on a Pregel-like graph processing system, which is one of the most popular distributed graph processing systems. Note that it could be easily migrated to other graph processing systems as the abstraction originates from the graph processing field.

**Graph Partition.** Following Pregel [33], a graph is divided into partitions according to node ids by a partitioning function (like, mod N), and each partition contains a set of nodes and all out-edges of those nodes. Each partition is assigned to a worker to perform the "vertex" program (i.e., a layer of GNN). As shown in Fig. 4, a certain node would also maintain the node state and edge state (out-edges), such as raw features,

Fig. 3: GraphSAGE, GAT in InferTurbo abstraction
intermediate embeddings, or even historical embeddings. In this way, structure information and feature information could be stored in one place to avoid redundant storage.

It's worth mentioning that, with this partitioning strategy, the forward pass for a layer of GNNs over a certain node could be finished in one superstep by receiving messages from other nodes (maybe on other machines), which avoids synchronizing between different workers within a superstep.

**Execution.** As shown in Fig. 4, we mainly perform the computation flow of GNN models in the _compute()_ function of the Pregel-like system.

At first, we implement the _gather_ stage based on the _message iterator_ in Pregel, which is used to collect all messages sent to a certain node. Meanwhile, we provide a built-in _vectorization_ function to transfer the messages and local state information into tensors, including structure information (i.e., adjacent matrix), node-level information (i.e., node state), and edge-level information (i.e., edge-wise messages or state). Then, we perform the computation flow based on those matrices and provide functions to update node and edge states maintained in the machine. At last, the messages generated by the model would be sent to other nodes via the _send_message_ function in Pregel. Specially, we design an optimization strategy for performing the aggregation part of the GNN model in the combiner stage of Pregel to reduce the communication cost, as shown in Fig. 4.

After \(k\) iterations (supersteps), we would finally get the result of a \(k\)-layer GNN model. Note that the first and the last supersteps play special roles in the full pipeline. The _first_ superstep could be treat as an initialization step since there are no messages received at this stage. It mainly transforms the raw node states and edge features into initial embeddings and then calls the _Scatter_ stage to send those information to other nodes to start the following supersteps. For the _last_ superstep, we attach a prediction part after the _apply_node_ stage to get prediction scores for nodes (if needed) and then output the results (node embeddings or scores).

#### Iii-B2 InferTurbo on MapReduce

We also provide an alternative backend on MapReduce (or Spark), as shown in Fig. 5.

Compared with the backend on the graph processing system, the MapReduce backend could not maintain some information (e.g., node states, out-edges) in memory. Owing to this, the communication between different "supersteps" could be quite different: all necessary information should be treated as messages and sent to the next round.

The MapReduce pipeline takes a _node table_ and an _edge table_ as input. The _node table_ consists of node id, node features, and ids of all out-edge neighbors, while the _edge table_ contains source node id, destination node id, and edge features. The overall pipeline on MapReduce is as follows:

* _Map._ The phase acts as the initialization step. At first, it transforms the raw features of nodes and edges to initial embeddings. Then, for a certain mapper, the initial embeddings of a certain node would be sent to itself and all its out-edge neighbors, while the edge information would be sent to both the source and the destination nodes. In short, the _Map_ phase generates three kinds of information for each node: self-state information, in-edge information (i.e., edge features of in-edges, node features of the in-edge neighbors), and out-edge information (i.e., edge features of out-edges).
* _Reduce._ The reduce phase performs the forward pass for a certain GNN layer. Compared with the backend on graph processing system, the input and output in this phase are a little different. In the _Gather_ stage, a node needs to receive edge messages and its own state. However, in the _Scatter_ stage, the node also sends the updated state as an additional message to itself. That is, messages (e.g., node state, updated edge embeddings via out-edges) would be sent not only to destination nodes but also to itself. The shuffle keys for those messages are set as ids of destination nodes or itself, respectively. Messages for destination nodes represent in-edge information in the next round, while for itself, indicate new self-state information and out-edge information.

Similar to the implementation on Pregel, the prediction slice of a well-trained model will be merged to the last reduce phase, and after \(k\) times _Reduce_ stages, we could finish the forward propagation of a \(k\)-layer GNN.

Though the number of messages could be larger than that in the backends of graph processing system, this backend is promising for industrial applications since messages and state information usually are stored and exchanged with external

Fig. 4: The backend of a Pregel-like graph processing system

Fig. 5: The backend of MapReduce
storage (HHD or SSD). As a result, a reducer could load a part of nodes together with their information into memory instead of loading all the data in the partition. The peak usage of memory could be far less than that in the backends of graph processing system, as the latter backend usually should maintain all necessary information belonging to it in memory. Therefore, it could be more suitable for scaling to extremely large graphs. Moreover, many applications would leverage the ability of the powerful GNNs on various specific graphs in industrial scenarios. The solution based on graph processing system is strict on stable and exclusive resources and may lead to resource competition for different applications. The implementation on the batch processing system could release the heavy resource competition by sacrificing a little efficiency.

### _Optimization Strategies_

It is still challenging to conduct GNN inference tasks for industrial applications on those implementations since a hallmark property of graphs is _skewed_ power-law degree distribution [22, 30]. The power law means a few nodes act as hubs and have many neighbors, while most nodes have few neighbors. Those "hub" nodes could increase the cost of computation and communication in inference phase, and substantially slow down the machines that contain them. What's worse, the inference pipeline could crash as those nodes may lead to the OOM problem. The neighbor-sampling strategy [4] may mitigate those problems but lead to unstable embeddings or prediction scores, which is unacceptable for industrial applications.

By diving into those problems, we classify them into two categories: problems caused by the skewed in-degree and the skewed out-degree, and propose several strategies to address them respectively:

Partial-GatherFor nodes with many in-edges, the time cost of receiving and computing over messages could increase significantly and lead workers containing them in the long tail. We propose a _partial-gather_ strategy to address this problem, and the schematic diagram is illustrated in Fig. 6.

The basic idea of this strategy is to conduct the _Gather_ stage in advance to balance the computation of messages on the sender side while reducing the total amount of messages to be sent out. In addition, the five-stage GAS-like abstraction and the annotation technique described above make it possible to call related computation modules at any time in the pipeline. Therefore, in a certain round, the _aggregate_ part of the model (i.e., gather function, partial=True) could be conducted using partially available messages when they are sent to the same destination. Then in the next round, the receiver receives those aggregated messages from different workers and conducts the _Gather_ stage as usual. Since the _aggregate_ function satisfies the commutative law and associative law, this strategy would not lead to any difference in final results. We implement the strategy on both the Pregel-like system and the MapReduce (Spark) system with their built-in "combining" function.

With this strategy, the communication complexity for a particular node is reduced to a constant level and only depends on the number of workers. Additionally, the computation of _Gather_ is carried out relatively uniformly across source workers, which also avoids the computation hubs and may reduce the long-tail effect caused by large in-degree nodes. This strategy involves almost no overhead and can be applied to all nodes regardless of their degrees.

BroadcastFor many GNN algorithms, all or part of messages sent via out-edges are usually the same. For example, the intermediate embeddings of a certain source node could be sent to all its neighbors via out-edges, which leads to overhead in communication. For nodes with many out-edges, the communication would be the bottleneck, which should be avoided by "compressing" those repeated messages.

To address this problem, we propose a _broadcast_ strategy as shown in Fig. 6. In detail, instead of sending edge-level messages, nodes will send "one" unique message to each machine together with a unique identifier (e.g., UUID or the source node id) as the index. Meanwhile, identifiers would be sent as messages via out-edges. Then, in the next round, the receiver should look up real messages by those identifiers and then perform the inference tasks as usual. We implement this strategy with the built-in "aggregator" class in batch processing systems and graph processing systems. Furthermore, this strategy could be easily migrated on the latest graph processing systems which provide a native "broadcast" mechanism.

It's obvious that the _broadcast_ could mitigate the overhead caused by the repeated messages and thus release the heavy communication pressure for nodes with large out-degree.

Shadow NodesA strategy named _shadow nodes_ is designed as an alternative solution for nodes with large out-degree, since the _broadcast_ strategy may not work well when messages vary with out-edges and cannot be compressed.

The basic idea of this strategy is to average the communication load caused by out-edges, as shown in Fig. 6. First, the out-edges of a node are divided into \(n\) groups evenly. Then the node is duplicated \(n\) times, and each mirror is associated with a group of out-edges and all in-edges. Note that the id of each mirror would be appended with the group information. This process would be conducted in the preprocessing phase, and out-edges will be averaged to each mirror which could be placed on different machines. Since each mirror holds all the in-edges of the original node and the out-edges of all the duplicates are equal to that of the original node, conducting GNN algorithms with this strategy is just the same as the original pipeline and would not change the result. This strategy is simple but more general than the _Broadcast_ strategy. It could re-balance the computation load whether messages could be compressed or not.

Note that, in those two strategies for large out-degree problems, a heuristic formula is designed to estimate the threshold: \(threshold=\lambda\times total\_edges/total\_workers\). That is, those strategies should be activated when the number of out-edges for a node exceeds a certain percentage of edges on the worker. In our experiment, the hyper-parameter \(\lambda\) is set to an empirical value of 0.1.
## V Experiment

In this section, we conduct extensive experiments to evaluate our inference system and compare it with two state-of-the-art GNN systems, PyG [20] and DGL [18].

### _Experiment Settings_

**Datasets.** Four datasets are used in the experiments, including PPI [50], OGB-Products [51], OGB-MAG240M [52], and Power-Law, whose data scales range from small, medium, large, to extremely large.

The properties of those datasets are shown in Tab. I. The first three datasets are collected from the real world, and following the experimental settings in [3, 4, 22, 53], they are divided into three parts as the training, validation, and test sets. Note that settings of MAG240M follow the baseline examples provided by OGB team4, and only a part of the graph is used in the examples, and thus we count what we used in Tab. I.

Footnote 4: [https://ogb.stanford.edu/](https://ogb.stanford.edu/)

The Power-Law dataset is synthesized following the power-law [30] for the following two considerations. Firstly, to verify the scalability of the system, graphs at different scales with the same degree distribution should be used in experiments, since the time cost could be affected a lot by different degree distributions even with the same scale. Secondly, experiments for analyzing large in-degree and out-degree problems should be conducted on datasets with in-degree and out-degree following the power law respectively, for variable-controlling purposes. In our experiment, we synthesize datasets following the same rule with different scales and Tab. I only records the largest one we used. Specially, all nodes in Power-Law datasets are used in inference task, while millesimal are used in training phase.

**Evaluation.** We design a series of experiments to evaluate our system in terms of effectiveness, efficiency, consistency, and scalability.

We first evaluate two widely used GNNs (GraphSAGE [4], GAT [3]) on three real-world datasets to verify the effectiveness of our system. Then, some experiments are conducted to show the unstable prediction scores caused by neighbor-sampling and prove the consistency of our inference system. Moreover, we also record the time cost and compare it with traditional inference pipelines to see the efficiency of our system.

We verify the scalability of the system and analyze the effectiveness of optimization strategies on the Power-Law dataset. We use _cpu*min_ to measure the usage of resources and record it at different data scales to prove the scalability of the system. The data scales range from 100 million nodes (about 1 billion edges), 1 billion nodes (10 billion edges), to 10 billion nodes (100 billion edges). Specially, when analyzing the effectiveness of different optimization strategies individually, power-law datasets are generated with in-degree and out-degree following the power-law, respectively.

The different backends of our system are deployed on different clusters. The backend on graph processing system consists of about 1000 instances, and each is powered by 2 CPU (Intel Xeon E5-2682 v4@2.50GHz) and 10GB memory, while the one on MapReduce contains about 5000 instances (2-CPU, 2GB memory). The network bandwidth is about 20 Gb/s. For fairness, only 1000 instances are used in experiments to compare those two backends.

### _Results and Analysis_

#### V-B1 Comparisons

We conduct a set of experiments to compare the system with traditional training-inference pipelines and present experimental results to demonstrate the effectiveness, efficiency, consistency, and scalability of the system.

**Effectiveness.** Effectiveness is always in the first place. Table II illustrates comparisons of performance between our system and traditional training-inference pipelines powered by PyG and DGL. We report the results of GraphSAGE and

Fig. 6: Optimization strategies
GAT on PPI, OGB-Product, and OGB-MAG240M in different inference pipelines. Configurations of those GNN algorithms follow examples in OGB leaderboard5.

Footnote 5: [https://ogb.stanford.edu/docs/lsc/leaderboards/](https://ogb.stanford.edu/docs/lsc/leaderboards/)

In general, results achieved by our system are comparable with those on PyG and DGL across different datasets and algorithms. It's reasonable since our system just changes the way to perform the inference but never changes the formula of GNNs or introduces any approximation strategy in inference phase. As those two algorithms represent the two most widely used algorithms while the scale of datasets ranges from small, medium, and large, those comparisons and results prove the effectiveness of our system in different scenarios.

**Efficiency.** We evaluate the efficiency of our system by comparing it with the traditional inference pipelines powered by PyG and DGL, and record the resource cost measured by _cpu*min_ together with time cost on the OGB-MAG240M dataset. Note that, in traditional pipelines, we use a distributed graph store (20 workers) to maintain the graph data and 200 workers (10-CPU, 10G memory) for inference tasks. Increasing the number of workers would exacerbate the communication problem between workers and the graph store, reducing the efficiency of traditional pipelines. For fairness, the total CPU cores of inference workers are equal to our system with different backends, and the CPU utilization remains 90%+ during the inference tasks.

Table III demonstrates the experimental results compared with traditional inference pipelines. Generally, both the two backends of our system demonstrate superior efficiency. Our system achieves 30\(\times\sim\) 50\(\times\) speedup compared with traditional inference pipelines, while in terms of the total resource cost, traditional inference pipelines take about 40\(\times\sim\) 50\(\times\) more than our system. Those results show that our system is quite promising for industrial scenarios: it not only could finish inference tasks faster but also is more economy friendly for industrial applications as it takes fewer resources. The results we achieved mainly benefit from the new inference pattern in our system. That is, with the InferTurbo abstraction, it could conduct layer-wise inference over the entire graph while enjoying the good property of parallelism. In this way, redundant computation caused by \(k\)-hop neighborhoods could be avoided. Notably, even ignoring the bottleneck of communication in traditional pipelines and assuming they could achieve \(5\times\) speedup by scaling up \(5\times\) resource (i.e., 1000 workers), our system still gains up to \(10\times\) speedup over them.

In addition, we also design a set of experiments to demonstrate the relationship between time cost and the number of GNN layers for further analysis, and results are presented in Tab. IV. Without loss of generality, the comparisons are mainly conducted between PyG (traditional pipeline) and the MapReduce backend. _nbr50_ and _nbr10000_ mean the number of neighbors for a certain node is limited to 50 and 10000 respectively with neighbor-sampling strategy for experiments on PyG, while there is no sampling for our system. Both the time cost and resource usage of our system increase nearly linearly by varying hops of GNNs, while they increase exponentially in the traditional pipeline. Specially, the traditional pipeline even crashes with the OOM problem when the number of neighbors is set to 10000. Because, in the forward pass of the traditional pipeline, the k-hop neighborhoods of nodes increase exponentially with the hop count, resulting in the exponential growth of communication and computation. However, k-hops neighborhoods for different target nodes could overlap with each other, and the communication and computation on the overlaps are unnecessary. Our system avoids those redundant problem by conducting inference tasks over the entire graph in the full-batch manner. For each node on each layer, it will be used only once in our system. Therefore, the time cost and resources are only related to the hop count.

**Consistency.** We take the GraphSAGE model in PyG on the OGB-MAG240M dataset as baselines to verify the consistency of our system and traditional pipelines. The number of neighbors for a node in traditional pipelines is limited to 10, 50, 100, 1000 in different experiments. We count the number of node classes predicted in the traditional pipeline at 10 runs and summarize such information for about 130,000 nodes to see whether predicting scores would keep unchanged.

The statistical results are presented in Fig. 7. The x-axis denotes how many classes a certain node belongs to, while
the y-axis indicates how many nodes would be predicted to a certain number of classes at 10 runs. For example, when the number of neighbors is set to 10, 30840 nodes are predicted into 2 different classes at 10 runs. In all, about 30% nodes would be predicted to at least 2 different classes when the sampling number is set to 10, which indicates that the prediction score is not trusted. Even increasing the sampling number to 1000, there are still about 0.1% nodes in trouble, which is unacceptable in industrial scenarios, especially in financial applications. Note that when the sampling number increases to 10000, such risk is mitigated, but the time cost increases a lot and even causes the OOM problem as shown in Tab. IV.

In contrast, our system achieves the same results at different runs since it conducts the inference phase over the full graph without sampling. And we propose a series of strategies to avoid the OOM problem caused by nodes with a large degree. Therefore, the system is suitable for inference tasks on large graphs, even with skewed degree distribution.

**Scalability.** Scalability is a key issue for industrial scenarios. We design a series of experiments and illustrate the relationship between the resource usage (cpu*min) and the data scale to evaluate the scalability of our system. The experiments are conducted over Power-Law datasets, and the data scale includes three orders of magnitude as mentioned in Sec. V-A. A 2-layer GAT model with an embedding size of 64 is conducted on those datasets, and we record the time and resource cost to see how they vary with different data scales. Note that the backend of our system is set to MapReduce as the resource on the cluster for graph processing backend is not enough for the largest dataset.

Figure 8 demonstrates the experimental results. The y-axis on the left and right represent resource usage (cpu*min) and time cost (s), respectively, while the x-axis is the data scale. Both the resource and the time-cost curves demonstrate a nearly linear relationship between them and the data scale, which proves the linear scalability of our system. It is worth noting that our system could finish the inference task for all 10 billion nodes (with about 100 billion edges) within 2 hours (6765 seconds), which shows that our system could scale to extremely large graphs and finish inference tasks efficiently.

#### V-A2 Analysis for Optimization Strategies

For further analysis of our systems, we also design a set of experiments to verify the effectiveness of the optimization strategies for hub nodes proposed in Sec. IV-D. We enable those strategies on the GraphSAGE model over Power-law datasets (about 100 million nodes, 1.4 billion edges) respectively for variable-controlling purposes.

Figure 9 illustrates experimental results on the large in-degree problem and the effect of the _partial-gather_ strategy. The x-axis indicates the number of in-edges for nodes in one instance, while the y-axis denotes the instance latency, and each point represents an instance. Results show that latency is positively associated with the number of in-edges. It's reasonable since the time cost for receiving messages and the computation to aggregate those messages are related to the number of in-edges. Therefore, nodes with large in-degree would lead the time cost of the related instance in the long tail and become the bottleneck of the whole inference task. In contrast, the _partial-gather_ strategy helps release the stress caused by a large number of in-edges: the variance of time cost on different instances shrinks a lot, and points are close to the mean line. The reason is from two aspects: firstly, with the _partial-gather_ strategy, messages would be partially aggregated on the sender side, which brings down the time cost in communication. Secondly, the computation of in-edge messages is uniformly conducted in advance on different instances, which balances the computation load for hub nodes.

We also make an analysis of the large out-degree problem, and the results are illustrated in Fig. 10. _Base_ denotes the experiment without optimization strategy, while _SN_, _BC_, and _SN+BC_ indicate experiments with _shadow node_ strategy, _broadcast_ strategy, and the combination of them respectively. The y-axis represents the variance of time cost in all instances. Compared with the baseline, both the _shadow node_ and _broadcast_ strategies are helpful in mitigating the problem caused by nodes with large out-edges, and the latter one is slightly better than the former one since _shadow node_ strategy would lead to some overhead by duplicating in-edges to average the communication over different mirror nodes. Specially, for GraphSAGE, we could achieve better results by combining the two strategies since messages for different out-edges are the same.

Furthermore, we develop some experiments to evaluate our system's IO costs. Figures 11, 12, and 13 show the results of strategies for large in- and out-degree problems, respectively. Their y-axises show the input or output bytes of each instance. For Fig. 11 and 12, x-axises show the initial number of input or output records for different instances. Specially, the x-axis for Fig. 13 is worker index sorted according to the output bytes since the _shadow node_ strategy would re-arrange the placement of records.
degree since there is no overhead involved. The _partial-gather_ strategy reduces the total communication cost of all works by roughly 25% while saving up to 73% IO cost for the 10% workers in the tail. The reason is that each instance would only send one message for a particular node in the upcoming round since the messages have already been pre-aggregated. Each node would only receive as many as instance-number messages in the following round.

Moreover, we also vary the threshold for those strategies to verify the heuristic formula in Sec. IV-D. The hyper-parameter \(\lambda\) is set to 0.1 in our system, and the threshold to distinguish whether a node is a 'hub' node then becomes 100,000 (1 billion edges, 1000 workers). Compared with the baselines, both the _broadcast_ and _shadow nodes_ strategies in this setting could decrease the IO cost for "hub" nodes significantly. For instance, the communication costs for the last 10% workers are reduced by 42% and 53% when activating those two techniques, respectively. Furthermore, the efficacy of those strategies would increase as the threshold decreases. However, there is no significant difference for the threshold in the range of [10,000, 100,000], and the difference in IO cost is less than 5%. This is because a low threshold would enable more nodes to benefit from those techniques, but their overhead could not be disregarded. For example, the memory cost is nearly doubled. Therefore, although the threshold determined by the heuristic formula may not be the optimal one, it is reasonable to use it to quickly estimate the threshold, and in this setting, those strategies successfully reduce the IO cost for straggler workers.

In summary, the experimental results demonstrate that those strategies proposed in Sec. IV-D help eliminate the stragglers caused by the power law, and as a result, our system achieves better load-balancing.

## VI Conclusion

In this paper, we propose InferTurbo, to boost the inference tasks at industrial-scale graphs. The design follows the GAS-like paradigm underlying the computation of GNNs, with which we could specify the data flow and computation flow of GNNs and hierarchically conduct the inference phase in full-graph manner. In this way, our system could avoid the redundant computation problem. We provide alternative backends of MapReduce and Pregel for different industrial applications, and both could scale to large graphs. Furthermore, a set of strategies without dropping any information is used to solve problems caused by nodes with large in-degree or out-degree. The experimental results demonstrate that our system achieves \(30\times\sim 50\times\) speedup compared with some state-of-the-art graph learning systems. Our system could finish the inference task over a graph with 10 billion nodes and 100 billion edges within 2 hours, which shows the superior efficiency and scalability of our system.

Fig. 11: IO cost for partial gather strategy Fig. 12: IO cost for broadcast strategy Fig. 13: IO cost for shadow node strategy