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.1.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | be62aa2335ddeb901953b3a054be6a00f343cc670e8e631a42ab1147f381053f |
|
MD5 | 940b6f805d8ab4a19be1a0a5771bd223 |
|
BLAKE2b-256 | a297b0653190913b10a532a103eb22e9fe140831a8b1cb5c48ae87b62a8a067b |
Hashes for pgl-1.1.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8e80252136f9ca6532074f96f57f63cf29b886988efac1d5cbaaadc20135f804 |
|
MD5 | c47c5463cf219b0cb876e8aa15b530b0 |
|
BLAKE2b-256 | 0af85965e00bfcbe61f7b1c751d94ca5e53f4bc4c44250f492af10fe4d878dab |
Hashes for pgl-1.1.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 84765be7d333f13082c8f0df94d2433960ba05ef0318f722539ce6e4215c6cd4 |
|
MD5 | 228b63532cfce58850c99b975c1be961 |
|
BLAKE2b-256 | 3fd93a9db4a342545b1270cedf0ef68685108b1cf8cd2143a6aa5ee13ec2febf |
Hashes for pgl-1.1.0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b596a9a62a606e7ab4e3b63e4e7881b1c4f7bea335a7fa1eb034cef466c7dd8 |
|
MD5 | bea802aeec8a05e346b5daf127bb193a |
|
BLAKE2b-256 | b00f46043ff1b67c6a80ace1a90ec107ad5e41954a383b8733f7820b46373c82 |
Hashes for pgl-1.1.0-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a6390c1d03ed38f3f67f37ed17456d4e141723e0e0766fa782543bd395a6422 |
|
MD5 | 90b93e9316f3fb3ac54ce6c912e95fe8 |
|
BLAKE2b-256 | 75755a5b2d69d97db234a2267b46bb31c70a2ace50867c0400e68ebe9b610e1e |
Hashes for pgl-1.1.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5eb286411daca67da716574032c2973b7334c0bc8fe16fd59f7b3a5856fd9d7 |
|
MD5 | d33eb18f8d04f5f65f1ca27ee1a93622 |
|
BLAKE2b-256 | f43f0ecd4e0f0f764a45e6dd5465ef9c1e1351c74c36e3f092926db736492f48 |
Hashes for pgl-1.1.0-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 923fd2a050965162b8c76887c9fd93b75430dd48a1c2cf6804262d7e6651aaba |
|
MD5 | 3d09f0e7b13348d91c0462fef49b3973 |
|
BLAKE2b-256 | 4aa1f5a711ce31ca874d6503af16f76483ce649f0e52b6a0951a3f49a882668e |
Hashes for pgl-1.1.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d9fe46735a8f88ba151dfeefb27a7248d4a5419f3db2fd72ea94349154c2742 |
|
MD5 | 43e6b03b90c2a949fda821b7497ef282 |
|
BLAKE2b-256 | b27a30b46df91114409350dc9bd95c016a24f574100059f2458f411d9603a416 |
Hashes for pgl-1.1.0-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d455adb85d387d3de9b20c070bdd23cbfab31fcf1186646786e44d9c474e76b |
|
MD5 | 0a3047cda10a9ca9755a0d5ea6a5e413 |
|
BLAKE2b-256 | 7dde6826bb872555404f3c6efef92f121a8d667704fde913e1fdc14839897c2b |
Hashes for pgl-1.1.0-cp27-cp27m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8747618635d7c812e29055b5c7bb17dbd79af72c05bfe41411ad224118851fab |
|
MD5 | a5fa6756404c35158b9278e194078c2b |
|
BLAKE2b-256 | a7a08667968713e33e92da208b6d376be82233a292753b3a0de5a441d7c6f7fc |