Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

ptgnn: A PyTorch GNN Library PyPI

This 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 its architecture and how to define GNN models or follow this tutorial.

Note that ptgnn takes care of defining the whole pipeline, including data wrangling tasks, such as data loading and tensorization. It also defines PyTorch nn.Modules for the neural network operations. These are independent of the AbstractNeuralModels and can be used as all other PyTorch's nn.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 architecture ptgnn can 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 Tasks

All task implementations can be found in the ptgnn.implementations package. Detailed instructions on the data and the training steps can be found here. We welcome external contributions. The following GNN-based tasks are implemented:

The tutorial gives a step-by-step example for coding the Graph2Class model.

Installation

This code was tested with PyTorch 1.4 and depends on pytorch-scatter. Please install the appropriate versions of these libraries based on your CUDA setup following their instructions. (Note that the pytorch-scatter binaries built for CUDA 10.1 also work for CUDA 10.2).

  1. To install PyTorch 1.4, use the up-to-date command from PyTorch Get Started, selecting the appropriate options, e.g. for Linux, pip, and CUDA 10.1 it's currently:

    pip install torch torchvision
    
  2. To install pytorch-scatter, follow the instructions from the GitHub repo, choosing the appropriate CUDA option, e.g., for CUDA 10.1:

    pip install torch-scatter==2.0.4+cu101 -f https://pytorch-geometric.com/whl/torch-1.4.0.html
    
  3. To install ptgnn from pypi, including all other dependencies:

    pip install ptgnn
    

    If you want to use ptgnn sampels with Azure ML (e.g. the --aml flag in the implementation CLIs), install with

     pip install ptgnn[aml]
    

    or directly from the sources, cd into the root directory of the project and run

    pip install -e .
    

    To check that installation was successful and run the unit tests:

    python setup.py test
    

Contributing

This 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, visit https://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 the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Developing ptgnn

Unit Tests Total alerts Code style: black

To contribute to this library, first follow the next steps to setup your development environment:

  • Install the library requirements.
  • Install the pre-commit hooks:
    • Run pip3 install pre-commit
    • Install the hooks pre-commit install
Using Conda

If you are using conda, then download the correct torch-scatter wheel. If using torch==1.5.0 and Python 3.7, you can use the environment.yml included 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 install
Releasing to PyPi

To create a PyPi release push a tag in the form v1.3.4 in this repository (make sure that you follow semantic versioning). The Publish on PyPi GitHub action will automatically upload a new release.

Metadata

Release files for ptgnn 0.10.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ptgnn 0.10.4
File Size Uploaded Provenance Actions
ptgnn-0.10.4.tar.gz 73.2 kB Without provenance Details for ptgnn-0.10.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ptgnn 0.10.4
File Interpreter ABI Platform Actions
ptgnn-0.10.4-py3-none-any.whl Python 3 none any Details for ptgnn-0.10.4-py3-none-any.whl

Total release size: 157.2 kB

Release files / ptgnn-0.10.4.tar.gz

Download URL ptgnn-0.10.4.tar.gz
Size 73.2 kB
Tags Source
SHA-256 checksum
How to use checksums
95adc168b23b0f7a69fbe5d222f82f363354a41a0db9e7a164bc279c7910d35b
BLAKE2b-256 checksum
How to use checksums
0a9561636dcd1fd4202edeab4ed026f6844931270c193448b55d599986477362
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.12

Release files / ptgnn-0.10.4-py3-none-any.whl

Download URL ptgnn-0.10.4-py3-none-any.whl
Size 84.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5bd7b3cff7a713241e926ac07cc04b332a06a367b66dc5cc3a8a7d418f5d607b
BLAKE2b-256 checksum
How to use checksums
6b672826f600b592d2954b4718d55c1d558675cbb33e3c6a2e49b44e090de807
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.12

Security for ptgnn 0.10.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page