diff --git a/README.md b/README.md index 3a58bf618ebcde862336f281b21ca5078dfb7ef0..61cfbab48096d8f2fc6edac48ad2d0986f2ea7b3 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,17 @@ -# Paddle Graph Learning (PGL) + [DOC](https://pgl.readthedocs.io/en/latest/) | [Quick Start](https://pgl.readthedocs.io/en/latest/instruction.html) | [中文](./README.zh.md) -Paddle Graph Learning (PGL) is an efficient and flexible graph learning framework based on [PaddlePaddle](https://github.com/PaddlePaddle/Paddle). +Paddle Graph Learning (PGL) is an efficient and flexible graph learning framework based on [PaddlePaddle](https://github.com/PaddlePaddle/Paddle). -We provide python interfaces for storing/reading/querying graph structured data and two fundamental computational interfaces, which are walk based paradigm and message-passing based paradigm as shown in the above framework of PGL, for building cutting-edge graph learning algorithms. Combined with the PaddlePaddle deep learning framework, we are able to support both graph representation learning models and graph neural networks, and thus our framework has a wide range of graph-based applications. +The newly released PGL supports heterogeneous graph learning on both walk based paradigm and message-passing based paradigm by providing MetaPath sampling and Message Passing mechanism on heterogeneous graph. Furthermor, The newly released PGL also support distributed graph storage and some distributed training algorithms, such as distributed deep walk and distributed graphsage. Combined with the PaddlePaddle deep learning framework, we are able to support both graph representation learning models and graph neural networks, and thus our framework has a wide range of graph-based applications. -## Highlight: Efficient and Flexible Message Passing Paradigm +## Highlight: Efficiency - Support Scatter-Gather and LodTensor Message Passing One of the most important benefits of graph neural networks compared to other models is the ability to use node-to-node connectivity information, but coding the communication between nodes is very cumbersome. At PGL we adopt **Message Passing Paradigm** similar to [DGL](https://github.com/dmlc/dgl) to help to build a customize graph neural network easily. Users only need to write ```send``` and ```recv``` functions to easily implement a simple GCN. As shown in the following figure, for the first step the send function is defined on the edges of the graph, and the user can customize the send function ![](http://latex.codecogs.com/gif.latex?\\phi^e}) to send the message from the source to the target node. For the second step, the recv function ![](http://latex.codecogs.com/gif.latex?\\phi^v}) is responsible for aggregating ![](http://latex.codecogs.com/gif.latex?\\oplus}) messages together from different sources. @@ -19,7 +19,7 @@ One of the most important benefits of graph neural networks compared to other mo -As shown in the left of the following figure, to adapt general user-defined message aggregate functions, DGL uses the degree bucketing method to combine nodes with the same degree into a batch and then apply an aggregate function ![](http://latex.codecogs.com/gif.latex?\\oplus}) on each batch serially. For our PGL UDF aggregate function, we organize the message as a [LodTensor](http://www.paddlepaddle.org/documentation/docs/en/1.4/user_guides/howto/basic_concept/lod_tensor_en.html) in [PaddlePaddle](https://github.com/PaddlePaddle/Paddle) taking the message as variable length sequences. And we **utilize the features of LodTensor in Paddle to obtain fast parallel aggregation**. +As shown in the left of the following figure, to adapt general user-defined message aggregate functions, DGL uses the degree bucketing method to combine nodes with the same degree into a batch and then apply an aggregate function ![](http://latex.codecogs.com/gif.latex?\\oplus}) on each batch serially. For our PGL UDF aggregate function, we organize the message as a [LodTensor](http://www.paddlepaddle.org/documentation/docs/en/1.4/user_guides/howto/basic_concept/lod_tensor_en.html) in [PaddlePaddle](https://github.com/PaddlePaddle/Paddle) taking the message as variable length sequences. And we **utilize the features of LodTensor in Paddle to obtain fast parallel aggregation**. @@ -38,7 +38,7 @@ Although DGL does some kernel fusion optimization for general sum, max and other ## Performance -We test all the GNN algorithms with Tesla V100-SXM2-16G running for 200 epochs to get average speeds. And we report the accuracy on test dataset without early stoppping. +We test all the following GNN algorithms with Tesla V100-SXM2-16G running for 200 epochs to get average speeds. And we report the accuracy on test dataset without early stoppping. | Dataset | Model | PGL Accuracy | PGL speed (epoch time) | DGL 0.3.0 speed (epoch time) | | -------- | ----- | ----------------- | ------------ | ------------------------------------ | @@ -49,6 +49,7 @@ We test all the GNN algorithms with Tesla V100-SXM2-16G running for 200 epochs t | Citeseer | GCN |70.2%| **0.0045** |0.0046s| | Citeseer | GAT |68.8%| **0.0124s** |0.0139s| + If we use complex user-defined aggregation like [GraphSAGE-LSTM](https://cs.stanford.edu/people/jure/pubs/graphsage-nips17.pdf) that aggregates neighbor features with LSTM ignoring the order of recieved messages, the optimized message-passing in DGL will be forced to degenerate into degree bucketing scheme. The speed performance will be much slower than the one implemented in PGL. Performances may be various with different scale of the graph, in our experiments, PGL can reach up to 13 times the speed of DGL. | Dataset | PGL speed (epoch time) | DGL 0.3.0 speed (epoch time) | Speed up| @@ -57,7 +58,49 @@ If we use complex user-defined aggregation like [GraphSAGE-LSTM](https://cs.stan | Pubmed | **0.0388s** |0.5275s | 13.59x| | Citeseer | **0.0150s** | 0.1278s | 8.52x | +## Highlight: Flexibility - Natively Support Heterogeneous Graph Learning + +Graph can conveniently represent the relation between things in the real world, but the categories of things and the relation between things are various. Therefore, in the heterogeneous graph, we need to distinguish the node types and edge types in the graph network. PGL models heterogeneous graphs that contain multiple node types and multiple edge types, and can describe complex connections between different types. + +### Support meta path walk sampling on heterogeneous graph + + +The left side of the figure above describes a shopping social network. The nodes above have two categories of users and goods, and the relations between users and users, users and goods, and goods and goods. The right of the above figure is a simple sampling process of MetaPath. When you input any MetaPath as UPU (user-product-user), you will find the following results + +Then on this basis, and introducing word2vec and other methods to support learning metapath2vec and other algorithms of heterogeneous graph representation. + +### Support Message Passing mechanism on heterogeneous graph + + +Because of the different node types on the heterogeneous graph, the message delivery is also different. As shown on the left, it has five neighbors, belonging to two different node types. As shown on the right of the figure above, nodes belonging to different types need to be aggregated separately during message delivery, and then merged into the final message to update the target node. On this basis, PGL supports heterogeneous graph algorithms based on message passing, such as GATNE and other algorithms. + + +## Large-Scale: Support distributed graph storage and distributed training algorithms +In most cases of large-scale graph learning, we need distributed graph storage and distributed training support. As shown in the following figure, PGL provided a general solution of large-scale training, we adopted [PaddleFleet](https://github.com/PaddlePaddle/Fleet) as our distributed parameter servers, which supports large scale distributed embeddings and a lightweighted distributed storage engine so tcan easily set up a large scale distributed training algorithm with MPI clusters. + + + + +## Highlight: Tons of Models +The following are 13 graph learning models that have been implemented in the framework. + +|Model | feature | +|---|---|--- | +| GCN | Graph Convolutional Neural Networks | +| GAT | Graph Attention Network | +| GraphSage |Large-scale graph convolution network based on neighborhood sampling| +| unSup-GraphSage | Unsupervised GraphSAGE | +| LINE | Representation learning based on first-order and second-order neighbors | +| DeepWalk | Representation learning by DFS random walk | +| MetaPath2Vec | Representation learning based on metapath | +| Node2Vec | The representation learning Combined with DFS and BFS | +| Struct2Vec | Representation learning based on structural similarity | +| SGC | Simplified graph convolution neural network | +| GES | The graph represents learning method with node features | +| DGI | Unsupervised representation learning based on graph convolution network | +| GATNE | Representation Learning of Heterogeneous Graph based on MessagePassing | +The above models consists of three parts, namely, graph representation learning, graph neural network and heterogeneous graph learning, which are also divided into graph representation learning and graph neural network. ## System requirements @@ -72,7 +115,7 @@ PGL supports both Python 2 & 3 ## Installation -The current version of PGL is 1.0.0. You can simply install it via pip. +You can simply install it via pip. ```sh pip install pgl diff --git a/README.zh.md b/README.zh.md index 5af657c1e05f7ce5f52cfffe5edf1355cf96c163..7b434dacf11153e2326a962c8a9c22ace3a43e39 100644 --- a/README.zh.md +++ b/README.zh.md @@ -1,4 +1,4 @@ -# Paddle Graph Learning (PGL) + [文档](https://pgl.readthedocs.io/en/latest/) | [快速开始](https://pgl.readthedocs.io/en/latest/instruction.html) | [English](./README.md) @@ -6,10 +6,10 @@ Paddle Graph Learning (PGL)是一个基于[PaddlePaddle](https://github.com/Padd -我们提供一系列的Python接口用于存储/读取/查询图数据结构,并且提供基于游走(Walk Based)以及消息传递(Message Passing)两种计算范式的计算接口(见上图)。利用这些接口,我们就能够轻松的搭建最前沿的图学习算法。结合PaddlePaddle深度学习框架,我们的框架基本能够覆盖大部分的图网络应用,包括图表示学习以及图神经网络。 +在最新发布的PGL中引入了异构图的支持,新增MetaPath采样支持异构图表示学习,新增异构图Message Passing机制支持基于消息传递的异构图算法,利用新增的异构图接口,能轻松搭建前沿的异构图学习算法。而且,在最新发布的PGL中,同时也增加了分布式图存储以及一些分布式图学习训练算法,例如,分布式deep walk和分布式graphsage。结合PaddlePaddle深度学习框架,我们的框架基本能够覆盖大部分的图网络应用,包括图表示学习以及图神经网络。 -## 特色:高效灵活的消息传递范式 +# 特色:高效性——支持Scatter-Gather及LodTensor消息传递 对比于一般的模型,图神经网络模型最大的优势在于它利用了节点与节点之间连接的信息。但是,如何通过代码来实现建模这些节点连接十分的麻烦。PGL采用与[DGL](https://github.com/dmlc/dgl)相似的**消息传递范式**用于作为构建图神经网络的接口。用于只需要简单的编写```send```还有```recv```函数就能够轻松的实现一个简单的GCN网络。如下图所示,首先,send函数被定义在节点之间的边上,用户自定义send函数![](http://latex.codecogs.com/gif.latex?\\phi^e})会把消息从源点发送到目标节点。然后,recv函数![](http://latex.codecogs.com/gif.latex?\\phi^v})负责将这些消息用汇聚函数 ![](http://latex.codecogs.com/gif.latex?\\oplus}) 汇聚起来。 @@ -31,9 +31,7 @@ Paddle Graph Learning (PGL)是一个基于[PaddlePaddle](https://github.com/Padd 尽管DGL用了一些内核融合(kernel fusion)的方法来将常用的sum,max等聚合函数用scatter-gather进行优化。但是对于**复杂的用户定义函数**,他们使用的Degree Bucketing算法,仅仅使用串行的方案来处理不同的分块,并不同充分利用GPU进行加速。然而,在PGL中我们使用基于LodTensor的消息传递能够充分地利用GPU的并行优化,在复杂的用户定义函数下,PGL的速度在我们的实验中甚至能够达到DGL的13倍。即使不使用scatter-gather的优化,PGL仍然有高效的性能表现。当然,我们也是提供了scatter优化的聚合函数。 -## 性能测试 - - +### 性能测试 我们用Tesla V100-SXM2-16G测试了下列所有的GNN算法,每一个算法跑了200个Epoch来计算平均速度。准确率是在测试集上计算出来的,并且我们没有使用Early-stopping策略。 | 数据集 | 模型 | PGL准确率 | PGL速度 (epoch) | DGL 0.3.0 速度 (epoch) | @@ -54,6 +52,52 @@ Paddle Graph Learning (PGL)是一个基于[PaddlePaddle](https://github.com/Padd | Citeseer | **0.0150s** | 0.1278s | 8.52x | +## 特色:易用性——原生支持异构图 + +图可以很方便的表示真实世界中事物之间的联系,但是事物的类别以及事物之间的联系多种多样,因此,在异构图中,我们需要对图网络中的节点类型以及边类型进行区分。PGL针对异构图包含多种节点类型和多种边类型的特点进行建模,可以描述不同类型之间的复杂联系。 + +### 支持异构图MetaPath walk采样 + +上图左边描述的是一个购物的社交网络,上面的节点有用户和商品两大类,关系有用户和用户之间的关系,用户和商品之间的关系以及商品和商品之间的关系。上图的右边是一个简单的MetaPath采样过程,输入metapath为UPU(user-product-user),采出结果为 + +然后在此基础上引入word2vec等方法,支持异构图表示学习metapath2vec等算法。 + +### 支持异构图Message Passing机制 + + +在异构图上由于节点类型不同,消息传递也方式也有所不同。如上图左边,它有五个邻居节点,属于两种不同的节点类型。如上图右边,在消息传递的时候需要把属于不同类型的节点分开聚合,然后在合并成最终的消息,从而更新目标节点。在此基础上PGL支持基于消息传递的异构图算法,如GATNE等算法。 + + +## 特色:规模性——支持分布式图存储以及分布式学习算法 + +在大规模的图网络学习中,通常需要多机图存储以及多机分布式训练。如下图所示,PGL提供一套大规模训练的解决方案,我们利用[PaddleFleet](https://github.com/PaddlePaddle/Fleet)(支持大规模分布式Embedding学习)作为我们参数服务器模块以及一套简易的分布式存储方案,可以轻松在MPI集群上搭建分布式大规模图学习方法。 + + + + +## 特色:丰富性——覆盖业界大部分图学习网络 + +下列是框架中已经自带实现的十三种图网络学习模型 + +| 模型 | 特点 | +|---|---|--- | +| GCN | 图卷积网络 | +| GAT | 基于Attention的图卷积网络 | +| GraphSage | 基于邻居采样的大规模图卷积网络 | +| unSup-GraphSage | 无监督学习的GraphSAGE | +| LINE | 基于一阶、二阶邻居的表示学习 | +| DeepWalk | DFS随机游走的表示学习 | +| MetaPath2Vec | 基于metapath的表示学习 | +| Node2Vec | 结合DFS及BFS的表示学习 | +| Struct2Vec | 基于结构相似的表示学习 | +| SGC | 简化的图卷积网络 | +| GES | 加入节点特征的图表示学习方法 | +| DGI | 基于图卷积网络的无监督表示学习 | +| GATNE | 基于MessagePassing的异构图表示学习 | + +上述模型包含图表示学习,图神经网络以及异构图三部分,而异构图里面也分图表示学习和图神经网络。 + + ## 依赖 PGL依赖于: @@ -67,7 +111,7 @@ PGL支持Python 2和3。 ## 安装 -当前,PGL的版本是1.0.0。你可以简单的用pip进行安装。 +你可以简单的用pip进行安装。 ```sh pip install pgl diff --git a/docs/source/_static/distributed_frame.png b/docs/source/_static/distributed_frame.png new file mode 100644 index 0000000000000000000000000000000000000000..5f8728caa19b6b7594bcc4d655391d4e7d00dfab Binary files /dev/null and b/docs/source/_static/distributed_frame.png differ diff --git a/docs/source/_static/framework_of_pgl.png b/docs/source/_static/framework_of_pgl.png index e65f3cd57fc13a7ae93a663988b7e7dacb3f0a65..f8f6293a6821f7a13901f5b83d6d904a4f64ee0d 100644 Binary files a/docs/source/_static/framework_of_pgl.png and b/docs/source/_static/framework_of_pgl.png differ diff --git a/docs/source/_static/him_message_passing.png b/docs/source/_static/him_message_passing.png new file mode 100644 index 0000000000000000000000000000000000000000..52b0286ded75deaa2eac47fd25478099c73008ce Binary files /dev/null and b/docs/source/_static/him_message_passing.png differ diff --git a/docs/source/_static/logo.png b/docs/source/_static/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..f118f4cdc75ab9744644cbc109a294c556dd2c68 Binary files /dev/null and b/docs/source/_static/logo.png differ diff --git a/docs/source/_static/message_passing_paradigm.png b/docs/source/_static/message_passing_paradigm.png index c4501c33d2bb116ad18019ff37704f55dae8fe6b..64afa0e9e425024025827bee8360ee1c337792cf 100644 Binary files a/docs/source/_static/message_passing_paradigm.png and b/docs/source/_static/message_passing_paradigm.png differ diff --git a/docs/source/_static/metapath_result.png b/docs/source/_static/metapath_result.png new file mode 100644 index 0000000000000000000000000000000000000000..1f2a323e40cc7c6ecb1d25cc7243be850ffd389f Binary files /dev/null and b/docs/source/_static/metapath_result.png differ diff --git a/docs/source/_static/metapath_sampling.png b/docs/source/_static/metapath_sampling.png new file mode 100644 index 0000000000000000000000000000000000000000..c5ea7b1d50592f5669e827a0f47a9ab5ef0ef856 Binary files /dev/null and b/docs/source/_static/metapath_sampling.png differ diff --git a/docs/source/_static/parallel_degree_bucketing.png b/docs/source/_static/parallel_degree_bucketing.png index 695e097be3e22f2f6cf37ff502d61755eb6597be..fb9d5a4f9ca5ddcd5d48564934aad640e53e3482 100644 Binary files a/docs/source/_static/parallel_degree_bucketing.png and b/docs/source/_static/parallel_degree_bucketing.png differ diff --git a/docs/source/_static/quick_start_graph.png b/docs/source/_static/quick_start_graph.png new file mode 100644 index 0000000000000000000000000000000000000000..5c220f3cdf9e03ff809aeeced7c31eb4941ea34a Binary files /dev/null and b/docs/source/_static/quick_start_graph.png differ diff --git a/docs/source/md/introduction.md b/docs/source/md/introduction.md index bd42565b410e84661cf18731645dbc131102085f..1392b2275667f03af9125c8fa67c1efd5072e67a 100644 --- a/docs/source/md/introduction.md +++ b/docs/source/md/introduction.md @@ -1,7 +1,9 @@ -# Paddle Graph Learning (PGL) +# Paddle Graph Learning (PGL) - -Paddle Graph Learning (PGL) is an efficient and flexible graph learning framework based on [PaddlePaddle](https://github.com/PaddlePaddle/Paddle). +
+ + +Paddle Graph Learning (PGL) is an efficient and flexible graph learning framework based on [PaddlePaddle](https://github.com/PaddlePaddle/Paddle). @@ -9,17 +11,18 @@ Paddle Graph Learning (PGL) is an efficient and flexible graph learning framewor