Registry / ai-ml / torch-geometric

torch-geometric

JSON →
library2.8.0.post1pypypi✓ verified 24d ago

PyTorch Geometric (PyG) is a library built upon PyTorch to easily write and train Graph Neural Networks (GNNs) for a wide range of applications related to structured data. It consists of various methods for deep learning on graphs and other irregular structures, providing easy-to-use mini-batch loaders, multi-GPU support, `torch.compile` support, a large number of common benchmark datasets, and helpful transforms. It is actively maintained with frequent minor releases delivering new features and bug fixes.

pip install torch_geometric
INSTALL
IMPORT
SIG · TORCH-GEOMETRIC
T
torch-geometric
ai-mlpythonv2.8.0.post1
Install
8.6s avg
Import
Disk
121MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.8.0.post1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 118.3MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 8.6s · import 0.000s · 117MB
121MB installed
● package 121MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Data
from torch_geometric.data import Data
from torch_geometric.data import Data

This example demonstrates how to create a basic graph using PyTorch Geometric's `Data` object, which is the fundamental building block for representing graphs. It defines node features and graph connectivity (edges) and then prints basic properties of the created graph.

import torch from torch_geometric.data import Data # Define an edge list (COO format: [source_nodes, target_nodes]) edge_index = torch.tensor([[0, 1, 1, 2], [1, 0, 2, 1]], dtype=torch.long) # Define node features (3 nodes, 1 feature per node) x = torch.tensor([[-1], [0], [1]], dtype=torch.float) # Create a Data object to represent the graph data = Data(x=x, edge_index=edge_index) print(data) print(f"Number of nodes: {data.num_nodes}") print(f"Number of edges: {data.num_edges}") print(f"Is undirected: {data.is_undirected()}")
Debug
Known issues
breakingPyG 2.7.0 dropped support for Python 3.9 and PyTorch versions 1.11 through 2.5. Ensure your environment uses Python >=3.10 and PyTorch >=2.6 for compatibility.
fix
Upgrade Python to 3.10 or newer, and PyTorch to 2.6 or newer. Check the official PyG installation guide for specific PyTorch/CUDA compatibility tables.
affects: >=2.7.0
gotchaInstallation of optional C++/CUDA extensions (e.g., `torch-scatter`, `torch-sparse`) is complex and requires careful matching of PyTorch and CUDA versions, often necessitating specific pre-built wheels. Mismatched versions can lead to compilation errors or runtime issues.
fix
Always refer to the official PyTorch Geometric installation instructions. Use the provided `-f https://data.pyg.org/whl/torch-${TORCH}+${CUDA}.html` link, replacing `${TORCH}` and `${CUDA}` placeholders with your exact PyTorch and CUDA versions.
affects: All versions
deprecatedThe `torch_geometric.compile` utility and `MessagePassing.jittable` attribute have been deprecated. Users should migrate to `torch.compile` for model optimization.
fix
Replace usages of `torch_geometric.compile(model)` with `torch.compile(model)`. Remove `jittable=True` from `MessagePassing` layer initializations if present.
affects: >=2.6.0
breakingThe interface and implementation of `GraphMultisetTransformer` changed in PyG 2.7.0, potentially affecting existing models that use this layer.
fix
Review the updated documentation for `GraphMultisetTransformer` and adjust your model's implementation accordingly.
affects: >=2.7.0
Upgrade
Version history
2.8.0.post1latest on PyPI · released Jul 20, 2026
Audit
Dependencies
torchrequiredCore deep learning framework. PyG 2.7.0 requires PyTorch >=2.6 and is compatible up to PyTorch 2.8. Specific PyTorch versions require matching CUDA versions for GPU usage.
pyg-liboptionalProvides heterogeneous GNN operators and advanced graph sampling routines. Recommended for full feature set and performance.
torch-scatteroptionalAccelerated and efficient sparse reductions, critical for many GNN operations. Recommended for performance.
torch-sparseoptionalSparseTensor support, crucial for memory-efficient graph computations. Recommended for performance.
torch-clusteroptionalGraph clustering routines, used in certain pooling layers and graph processing tasks. Recommended for specific features.
torch-spline-convoptionalProvides SplineConv support for specialized graph convolutions. Recommended for specific GNN architectures.
Agent activity
32 hits · last 30 days
node
28
OpenAI (training)
1
Resources
torch-geometric — pip install torch-geometric · libregistry