Paddle Graph Learning
Project description
DOC | Quick Start | 中文
Breaking News !!
PGL v1.1 2020.4.29
-
You can find ERNIESage, a novel model for modeling text and graph structures, and its introduction here.
-
PGL for Open Graph Benchmark examples can be find here.
-
We add newly graph level operators like GraphPooling and GraphNormalization for graph level predictions.
-
We relase a PGL-KE toolkit here including classical knowledge graph embedding t algorithms like TransE, TransR, RotatE.
Paddle Graph Learning (PGL) is an efficient and flexible graph learning framework based on PaddlePaddle.
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: 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 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 to send the message from the source to the target node. For the second step, the recv function
is responsible for aggregating
messages together from different sources.
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 on each batch serially. For our PGL UDF aggregate function, we organize the message as a LodTensor in PaddlePaddle taking the message as variable length sequences. And we utilize the features of LodTensor in Paddle to obtain fast parallel aggregation.
Users only need to call the sequence_ops
functions provided by Paddle to easily implement efficient message aggregation. For examples, using sequence_pool
to sum the neighbor message.
import paddle.fluid as fluid
def recv(msg):
return fluid.layers.sequence_pool(msg, "sum")
Although DGL does some kernel fusion optimization for general sum, max and other aggregate functions with scatter-gather. For complex user-defined functions with degree bucketing algorithm, the serial execution for each degree bucket cannot take full advantage of the performance improvement provided by GPU. However, operations on the PGL LodTensor-based message is performed in parallel, which can fully utilize GPU parallel optimization. In our experiments, PGL can reach up to 13 times the speed of DGL with complex user-defined functions. Even without scatter-gather optimization, PGL still has excellent performance. Of course, we still provide build-in scatter-optimized message aggregation functions.
Performance
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) |
---|---|---|---|---|
Cora | GCN | 81.75% | 0.0047s | 0.0045s |
Cora | GAT | 83.5% | 0.0119s | 0.0141s |
Pubmed | GCN | 79.2% | 0.0049s | 0.0051s |
Pubmed | GAT | 77% | 0.0193s | 0.0144s |
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 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 |
---|---|---|---|
Cora | 0.0186s | 0.1638s | 8.80x |
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 as our distributed parameter servers, which supports large scale distributed embeddings and a lightweighted distributed storage engine so it can easily set up a large scale distributed training algorithm with MPI clusters.
Model Zoo
The following graph learning models have been implemented in the framework. You can find more examples and the details
Model | feature |
---|---|
ERNIESage | ERNIE SAmple aggreGatE for Text and Graph |
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
PGL requires:
- paddle >= 1.6
- cython
PGL supports both Python 2 & 3
Installation
You can simply install it via pip.
pip install pgl
The Team
PGL is developed and maintained by NLP and Paddle Teams at Baidu
E-mail: nlp-gnn[at]baidu.com
License
PGL uses Apache License 2.0.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for pgl-1.2.1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8eb00e4b19d2ea10a7f560ffbff0b0b29eb084d00922e790a82aebf77f5b1fda |
|
MD5 | 68eaece968b6115f3b7873ed6bb827fa |
|
BLAKE2b-256 | 3e0af9e9a4ee1ed9b5131b2fa5172a66e182fc1a6b70c98791c30149a0cd4f03 |
Hashes for pgl-1.2.1-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 657d90b9e86e1587b2fbc3bbbbc9048fe92437364111f9f7c207b48bd832e907 |
|
MD5 | ecf6b50bdc10c2311b3d7ccb7ad10eda |
|
BLAKE2b-256 | 9b768466ef63932a8d087d499fd15a392a6dbf332c22f04866caad4a390731c8 |
Hashes for pgl-1.2.1-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 512131124087103fba6aa76bdf67c6b0ac9905a84e064a0e3a5597954bd29bea |
|
MD5 | 185d97fbe1f4bbcdbb7affa5bbdc166b |
|
BLAKE2b-256 | e2846aac242f80a794f1169386d73bdc03f2e3467e4fa85b1286979ddf51b1a0 |
Hashes for pgl-1.2.1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 494fa1b3f39e7f1acf1f926c26b5cb897812fb3ddbd6c82a55874ae6ee821815 |
|
MD5 | 1640165a83918ef5d1630058bec96a72 |
|
BLAKE2b-256 | 30748359f9d1f81cfe3dae78f2c9c98b213ae80d183afbef38c070d0c459708c |
Hashes for pgl-1.2.1-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a25042fec1aedabf973b4ef8c02953ec054752e3c98e9c8f16ea0b2005c427ae |
|
MD5 | 52e929c00e5bebbad7cea93f1319d1cf |
|
BLAKE2b-256 | 135e74ffd82539bd76ce4394d2c4bd70e03fcf71f0b767338685f10a69786e18 |
Hashes for pgl-1.2.1-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8deafa1fdb94d4b541c7389218741d792b29073ac58c67070c722f112bfff4e3 |
|
MD5 | bd7aab914a561e089cf4c26d5b5edee5 |
|
BLAKE2b-256 | 35c971511635b931ea144996334df7dae9d08f3d112b358a3d096fcae12e3c1f |
Hashes for pgl-1.2.1-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fdd0d858add652b96daa7e006eae5770f83351eb471bddd77a403745f1aa7ede |
|
MD5 | 64cc5d34caeef0d9ef82da7cd1fc724d |
|
BLAKE2b-256 | 61a64453cc1b786fea69a356c108b5f676a495987b565cf59e88be0ead2973fa |
Hashes for pgl-1.2.1-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4574815d5c49ad876b22f47f35f4e8a7f472e91ff80e10b5579b2ad56b90012 |
|
MD5 | b18f58436edca6661a462b06361b19f4 |
|
BLAKE2b-256 | 6cf4f7432f7cb03948a6900b820752a29565d9abe08aad3054a0607562811131 |
Hashes for pgl-1.2.1-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 120546a3ee6396a8d4d7c8f6fff0970653707a5c25f98ca3b16b66dbdc207d46 |
|
MD5 | 97cbbfb2215bbb458d120d07122a8082 |
|
BLAKE2b-256 | 80252de681761c063d7c94f2d99fa4d86fd7dff86c230a851b04eccb6f103255 |
Hashes for pgl-1.2.1-cp27-cp27m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 225a59bc1f2c4ee68eb56e32750b2491675bb35d37128749512d3c3a6ea24b1f |
|
MD5 | 5132190717c55b9bed519c1810508ec7 |
|
BLAKE2b-256 | c4c203603b8db6aab9603566192cc84326e0797e6ec118395bfc8930edaeaee4 |