Package: ptgnn
ptgnn: A PyTorch GNN LibraryThis is a library containing pyTorch code for creating graph neural network (GNN) models.
The library provides some sample implementations.If you are interested in using this library, please read about itsarchitectureandhow to define GNN modelsor followthis tutorial.Note thatptgnntakes care of defining the whole pipeline, including data wrangling tasks, such
as data loading and tensorization. It also defines PyTorchnn.Modules for
the neural network operations. These are independent of theAbstractNeuralModels and can be used as all other PyTorch'snn.Modules,
if one wishes to do so.The library is mainly engineered to be fast for sparse graphs. For example, for the
Graph2Class task (discussed below) on a V100 with the default hyperparameters and architectureptgnncan process about 82 graphs/sec (209k nodes/sec and 1,129k edges/sec) during training
and about 200 graph/sec (470k nodes/sec and 2,527k edges/sec) during testing.Implemented TasksAll task implementations can be found in theptgnn.implementationspackage.
Detailed instructions on the data and the training steps can be foundhere.
We welcome external contributions. The following GNN-based tasks are implemented:PPIThe PPI task as described byZitnik and Leskovec, 2017.VarMisuseThis is a re-implementation of the VariableMisuse task ofAllamaniset al., 2018.Graph2SequenceThis is re-implementation of the GNN->GRU model ofFernandeset. al., 2019.Graph2ClassClassify (Label) a subset of the input nodes into classes
similar to Graph2Class inTypilus.Thetutorialgives a step-by-step example for coding the Graph2Class model.InstallationThis code was tested with PyTorch 1.4 and depends
onpytorch-scatter.
Please install the appropriate versions of these libraries based
on your CUDA setup following their instructions. (Note
that thepytorch-scatterbinaries built for CUDA 10.1 also work for
CUDA 10.2).To install PyTorch 1.4, use the up-to-date command fromPyTorch Get Started, selecting the appropriate options, e.g. for Linux, pip, and CUDA 10.1 it's currently:pipinstalltorchtorchvisionTo installpytorch-scatter, follow the instructions from theGitHub repo, choosing the appropriate CUDA option,e.g., for CUDA 10.1:pipinstalltorch-scatter==2.0.4+cu101-fhttps://pytorch-geometric.com/whl/torch-1.4.0.htmlTo installptgnnfrom pypi, including all other dependencies:pipinstallptgnnIf you want to use ptgnn sampels with Azure ML (e.g. the--amlflag in the implementation CLIs), install withpipinstallptgnn[aml]or directly from the sources,cdinto the root directory of the project and runpipinstall-e.To check that installation was successful and run the unit tests:pythonsetup.pytestContributingThis project welcomes contributions and suggestions.  Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
the rights to use your contribution. For details, visithttps://cla.opensource.microsoft.com.When you submit a pull request, a CLA bot will automatically determine whether you need to provide
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
provided by the bot. You will only need to do this once across all repos using our CLA.This project has adopted theMicrosoft Open Source Code of Conduct.
For more information see theCode of Conduct FAQor
contactopencode@microsoft.comwith any additional questions or comments.Developing ptgnnTo contribute to this library, first follow the next steps to setup your
development environment:Install the library requirements.Install the pre-commit hooks:Runpip3 install pre-commitInstall the hookspre-commit installUsing CondaIf you are using conda, then download the correct torch-scatter wheel.
If usingtorch==1.5.0and Python 3.7, you can use theenvironment.ymlincluded in the repo, with the following steps:$ conda env create -f environment.yml
$ conda activate ptgnn-env
$ pip install torch_scatter-2.0.4+cu102-cp37-cp37m-linux_x86_64.whl
$ pip install -e .
$ python setup.py test
$ pip install pre-commit
$ pre-commit installReleasing to PyPiTo create a PyPi release push a tag in the formv1.3.4in this repository (make
sure that you followsemantic versioning). ThePublish on PyPiGitHub action will automatically upload a new release.