
PyG
A PyTorch library for building and training graph neural networks on structured data.pyg-team/pytorch_geometric
- Stars
- 24.1k
- Forks
- 4.1k
- Licence
- MIT
- Language
- Python
- Last update
- 15 days ago
- Type
- Library
What it is
PyG (PyTorch Geometric) is a Python library built on top of PyTorch for writing and training graph neural networks, which learn from data shaped like networks, such as citation graphs or molecules. It bundles many published GNN methods, data loaders for large and small graphs, and common benchmark datasets. People use it so they do not have to implement graph operations from scratch.
- Train a 2-layer GCN node classifier on the Cora citation dataset, as in the README quick tour
- Implement a custom message-passing layer such as the EdgeConv example shown in the README
- Run mini-batch training on many small graphs or a single very large graph using the provided loaders
- Apply GNN models to 3D meshes or point clouds using the included transforms
Great for
- Researchers who want ready-made implementations of published graph neural network methods
- Python developers already comfortable with PyTorch who want to work on graph data
- Students learning graph machine learning with standard benchmark datasets like Cora
- Engineers training GNNs on large graphs that need mini-batch loaders and sampling
Not ideal for
- People who only need standard tabular or image models, since the library targets graph-structured data
- Users without Python or PyTorch experience, because the quick tour assumes familiarity with PyTorch training loops
- Anyone needing a finished no-code product, since this is a code library
How to get it
- 1
Install with a package manager
You'll need: Python · PyTorch
Clone the repository
git clone https://github.com/pyg-team/pytorch_geometric - 2
Run it
- Install PyTorch and PyG following the installation section of the documentation
- Run the Cora GCN quick tour code from the README
- Follow the training loop example to optimize the model for 200 epochs
- Consult the linked examples such as examples/gcn.py for evaluation
- 3
Get the most out of it
- Use the message passing API to build custom GNN layers, as shown with EdgeConv
- Enable torch.compile support for faster execution, per the compile docs
- Use the multi-GPU examples for training across several GPUs
- Use the provided Colab notebooks and external resources to learn the library
- Add pyg-lib for efficient CPU and CUDA sparse operations
Downloads
Strengths
- Built on PyTorch with a tensor-centric API that stays close to standard PyTorch code
- Includes many implemented GNN models and a message passing API for writing new layers
- Offers loaders, benchmark datasets, and transforms in one library
Trade-offs
- Requires understanding of both PyTorch and graph machine learning concepts to use effectively
- The README is truncated, so the full feature list and version-specific details are not visible here
- Some advanced features like multi-GPU, torch.compile, and DataPipe are referenced as separate docs and examples rather than explained in detail
How it compares
| Project | Stars | Type | Level | Updated | Best for |
|---|---|---|---|---|---|
| pytorch_geometric (this) | 24.1k | Library | intermediate | 15 days ago | Researchers who want ready-made implementations of published graph neural network methods |
| wandb | 11.3k | Library | beginner | 4 days ago | Machine learning engineers who want to compare training runs over time |
| onnxruntime | 22.2k | Library | intermediate | 4 days ago | Developers who want to deploy a trained model inside an application or service |
| nano-vllm | 16.3k | Library | intermediate | 6 months ago | Developers who want to understand how LLM inference engines work internally |
| nni | 14.4k | Library | intermediate | 2.3 years ago | Researchers comparing hyperparameter tuning algorithms such as TPE, Hyperband, or Bayesian methods |
| LoRA | 13.9k | Library | intermediate | 1.9 years ago | Machine learning engineers adapting RoBERTa, DeBERTa or GPT-2 style models in PyTorch |
Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.