NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
PyPI · #3990 most downloaded on PyPI
Graph Neural Network Library for PyTorch
Last release 2 months ago
20 Jul 2026
Release timing varies
gaps range from 8 days to 13 months
Most releases are documented
notes for 41 of 46 stable releases
1 version withdrawn
withdrawn after publishing
8 years old
47 releases · first in 2018
Fixes #10748 .
Fixes #10748.
PyG 2.8 trims its optional accelerated dependencies: torch-cluster and torch-spline-conv are now deprecated and ignored, with their functionality prov…
We are excited to announce the release of PyG 2.8 🎉🎉🎉
PyG 2.8 includes 82 commits since torch-geometric==2.7.0, with feature and bug-fix work from 16 contributors.
PyG 2.8 supports PyTorch 2.9, 2.10, 2.11, and 2.12, along with Python 3.10-3.14. Prebuilt wheels are available for CUDA 12.6, 12.8, 13.0, and 13.2, depending on the PyTorch version (see the table below).
| PyTorch | Supported wheels |
|---|---|
| 2.12.* | cpu, cu126, cu130, cu132 |
| 2.11.* | cpu, cu126, cu128, cu130 |
| 2.10.* | cpu, cu126, cu128, cu130 |
| 2.9.* | cpu, cu126, cu128, cu130 |
For a typical installation, PyG remains installable directly from PyPI:
pip install torch-geometric
# Optional accelerated dependencies, matching your PyTorch install:
pip install pyg-lib torch-scatter torch-sparse -f https://data.pyg.org/whl/torch-${TORCH}+${CUDA}.htmlFor example, use TORCH=2.12.0 and CUDA=cu132 for PyTorch 2.12.* with CUDA 13.2.
PyG 2.8 trims its optional accelerated dependencies: torch-cluster and torch-spline-conv are now deprecated and ignored, with their functionality provided by pyg-lib==0.7.0. The installation and cuGraph documentation now point users toward the NVIDIA PyG container, the rapidsai/cugraph-gnn examples, and RAPIDS guidance for scalable GPU workflows (#10489, #10603, #10639, #10640).
The new examples/llm/txt2qa.py workflow introduces a synthetic multi-hop question-answer generation pipeline for text documents (#10559). It supports local vLLM and NVIDIA NIM API backends and is designed for creating training and evaluation data for retrieval-augmented generation systems.
torch-geometric==2.7.* if you need to stay on PyTorch 2.8. Older PyTorch 2.8 wheel links remain available for existing installs (#10708).torch-cluster and torch-spline-conv in favor of pyg-lib==0.7.0. These packages are now deprecated and ignored if installed; the operators they previously provided now require pyg-lib==0.7.0 (#10682, #10622).examples/llm/txt2qa.py for synthetic multi-hop QA generation from text documents with vLLM and NVIDIA NIM backends (#10559).examples/llm/relbench_gretriever.py, showing how to convert a RelBench database into a PyG graph and run GRetriever on it (#10681).examples/relbench_example.py for the new RelBench conversion utility (#10628).examples/graphland.py for the GraphLand benchmark (#10458).txt2kg model and its example indexing flow (#10623, #10546).torch_geometric.datasetsGraphLandDataset (#10458).torch_geometric.nnPowerMeanAggregation adjustable (#10366).torch_geometric.utilssegment_logsumexp (#10594).cu130 wheel references and PyTorch 2.12 cu132 wheel support (#10634, #10669, #10708).torch-geometric-pool (#10637).torch_geometric.nn.encoding (#10617).MovieLens dataset compatibility with sentence-transformers>=5.0.0 (#10668).UPFD politifact and gossipcop datasets (#10558).GLEM edge case in the LLM example stack (#10492).torch_dtype usage in favor of dtype in the LLM stack (#10556)..llm imports so importing LLM functionality does not trigger the deprecated .distributed warning (#10512).to_dense_batch in both eager mode and torch.compile (#10542, #10660).torch_geometric.utils.softmax (#10499).rapidsai/cugraph-gnn examples (#10383, #10489, #10639, #10640).examples/distributed/pyg; the directory now points users to cuGraph GNN guidance (#10489).DataParallel example (#10638).conda/ directory (#10464).Full Changelog: 2.7.0...2.8.0
One column per quarter.
from_relbench to convert RelBench databases into HeteroData (#10628)ci: full PR label that triggers the full test suite (pytest-full) on demand instead of the regular one (#10709)txt2qa.py example for synthetic multi-hop QA generation from text documents, supporting vLLM (local) and NVIDIA NIM (API) backends (#10559)GraphLandDataset (#10458)to_dense_batch in both eager and torch.compile (#10660)GATConv and GATv2Conv for correctness (#10596)torch-cluster in favor of pyg-lib>=0.6.0 (#10682)torch-spline-conv in favor of pyg-lib>=0.6.0 (#10622)GRetriever.inference (#10681)sentence-transformers>=5.0.0 (#10668)torch_geometric.utils.softmax (#10499)return_attention_weights: bool being not respected in GATConv and GATv2Conv (#10596)UPFD (#10558)Deprecated torch_geometric.distributed
We are excited to announce the release of PyG 2.7 🎉🎉🎉
PyG 2.7 is the culmination of work from 53 contributors who have worked on features and bug-fixes for a total of over 282 commits since torch-geometric==2.6.0.
PyG 2.7 is fully compatible with PyTorch 2.8 and supports the following combinations:
| PyTorch 2.8 | cpu |
cu126 |
cu128 |
cu129 |
|---|---|---|---|---|
| Linux | ✅ | ✅ | ✅ | ✅ |
| Windows | ✅ | ✅ | ✅ | ✅ |
| macOS | ✅ |
In addition, PyG 2.7 supports two previous PyTorch minor releases, PyTorch 2.7 and 2.6:
| PyTorch 2.7 | cpu |
cu118 |
cu126 |
cu128 |
|---|---|---|---|---|
| Linux | ✅ | ✅ | ✅ | ✅ |
| Windows | ✅ | ✅ | ✅ | ✅ |
| macOS | ✅ |
| PyTorch 2.6 | cpu |
cu118 |
cu124 |
cu126 |
|---|---|---|---|---|
| Linux | ✅ | ✅ | ✅ | ✅ |
| Windows | ✅ | ✅ | ✅ | ✅ |
| macOS | ✅ |
torch_geometric.distributed (#10411)ogbn_train_cugraph example for distributed cuGraph (#10439)safe_onnx_export function with workarounds for onnx_ir.serde.SerdeError issues in ONNX export (#10422)torch_geometric.graphgym and torch_geometric.data.lightning when using lightning instead of pytorch-lightning (#10404, #10417))detach() warnings in example scripts involving tensor conversions (#10357)cuGraph graph objects by ensuring cudf column names are correctly specified (#10343)_recursive_config() for torch.nn.ModuleList and torch.nn.ModuleDict (#10124, #10129)k_hop_subgraph() method for directed graphs (#9756)utils.group_cat concatenating dimension (#9766)WebQSDataset.process raising exceptions (#9665)is_node_attr() and is_edge_attr() errors when cat_dim is a tuple (#9895)num_gnn_layers == 0 (#10156)TAGDataset (#9918)torch_geometric.llm and its examples (#10436)sparse_cross_entropy (#10432)connected_components() method to Data and HeterData (#10388)BidirectionalSampler, which samples both forwards and backwards on graph edges (#10126)NeighborSampler (#10126)SamplerOutput objects (#10126)SamplerOutput (#10200)Polynormer model and example (#9908)ProteinMPNN model and example (#10289)Teeth3DS dataset, an extended benchmark for intraoral 3D scan analysis (#9833)torch.device to PatchTransformerAggregation #10342torch.device to normalization layers #10341total_influence for quantifying long-range dependency (#10263)MedShapeNet Dataset (#9823)CityNetwork dataset (#10115)visualize_graph to HeteroExplanation (#10207)AttentionExplainer (#10169)PGExplainer (#10168)GNNExplainer (#10158)ARLinkPredictor for implementing Attract-Repel embeddings for link prediction (#10105)HashTensor (#10072)SGFormer model and example (#9904)AveragePopularity metric for link prediction (#10022)Personalization metric for link prediction (#10015)HitRatio metric for link prediction (#10013)Diversity metric for link prediction (#10009)Coverage metric for link prediction (#10006)ogbn_train_cugraph.py and ogbn_train_cugraph_multigpu.py for ogbn-arxiv, ogbn-products and ogbn-papers100M (#9953)InstructMol dataset (#9975)LinkPredRecall metric (#9947)LinkPredNDCG metric (#9945)LinkPredMetricCollection (#9941)GRetriever architecture benchmarking examples (#9666)profiler.nvtxit with some examples (#9666)loader.RagQueryLoader with Remote Backend Example (#9666)data.LargeGraphIndexer (#9666)GIT-Mol (#9730)g_retriever.py pointing to Neo4j Graph DB integration demo (#9748)MoleculeGPT example (#9710)nn.models.GLEM (#9662)TAGDataset (#9662)Delaunay() triangulation via the torch_delaunay package (#9748)[4, num_faces] in the FaceToEdge transformation (#9776)use_pcst option to WebQSPDataset (#9722)edge_weight to GraphUNet models (#9737)examples/ogbn_{papers_100m,products_gat,products_sage}.py into examples/ogbn_train.py (#9467)dgcnn_classification example to work with ModelNet and MedShapeNet Datasets (#9823)NumNeighbors actually exist in the graph (#9807)GRetriever default llm (#9938)np.in1d to np.isin (#10283)Full Changelog: 2.6.0...2.7.0
PyG 2.6.1 includes a bugfix in the WebQSDataset .
PyG 2.6.1 includes a bugfix in the WebQSDataset.
WebQSDataset dataset where empty edges were not treated gracefully (#9665)Full Changelog: 2.6.0...2.6.1
`EdgeIndex` and `Index` will fully deprecate the usage of `SparseTensor` from `torch-sparse` in later releases, leaving us with just a single source o…
We are excited to announce the release of PyG 2.6 🎉🎉🎉
PyG 2.6 is the culmination of work from 59 contributors who have worked on features and bug-fixes for a total of over 238 commits since torch-geometric==2.5.0.
PyG 2.6 is fully compatible with PyTorch 2.4, and supports the following combinations:
| PyTorch 2.2 | cpu |
cu118 |
cu121 |
cu124 |
|---|---|---|---|---|
| Linux | ✅ | ✅ | ✅ | ✅ |
| macOS | ✅ | |||
| Windows | ✅ | ✅ | ✅ | ✅ |
You can still install PyG 2.6 with an older PyTorch release up to PyTorch 1.13 in case you are not eager to update your PyTorch version.
In order to facilitate further research on combining GNNs with LLMs, PyG 2.6 introduces
torch_geometric.nn.nlp with fast access to SentenceTransformer models and LLMsGRetriever that is able to co-train LLAMA2 with GAT for answering questions based on knowledge graph informationexamples/llm that shows how to utilize these models in practiceIndex Tensor RepresentationSimilar to the EdgeIndex class introduced in PyG 2.5, torch-geometric==2.6.0 introduces the Index class for efficient storage of 1D indices. While Index sub-classes a general torch.Tensor, it can hold additional (meta)data, i.e.:
dim_size: The size of the underlying sparse vector, i.e. the size of a dimension that can be indexed via Index. By default, it is inferred as dim_size=index.max() + 1is_sorted: Whether indices are sorted in ascending order.Additionally, Index caches data via indptr for fast CSR conversion in case its representation is sorted. Caches are filled based on demand (e.g., when calling Index.get_indptr() or when explicitly requested via Index.fill_cache_(), and are maintained and adjusted over its lifespan.
from torch_geometric import Index
index = Index([0, 1, 1, 2], dim_size=3, is_sorted=True)
assert index.dim_size == 3
assert index.is_sorted
# Flipping order:
index.flip(0)
assert not index.is_sorted
# Filtering:
mask = torch.tensor([True, True, True, False])
index[:, mask]
assert index.is_sorted
EdgeIndex and Index will interact seamlessly together, e.g., edge_index[0] will now return a Index instance.
This ensures optimal computation in GNN message passing schemes, while preserving the ease-of-use of regular COO-based PyG workflows. EdgeIndex and Index will fully deprecate the usage of SparseTensor from torch-sparse in later releases, leaving us with just a single source of truth for representing graph structure information in PyG.
None outputs in FeatureStore.get_tensor() - KeyError should now be raised based on the implementation in FeatureStore._get_tensor() (#9102)cugraph-based GNN layers such as CuGraphSAGEConv now expect EdgeIndex-based inputs (#8938)ogbn-mag240m example (#8249)cugraph data loading capabilities in the papers100m examples (#8173)](https://github.com/pyg-team/pytorch_geometric/blob/master/examples/ogbn_papers_100m.py) and [multi-node](https://github.com/pyg-team/pytorch_geometric/blob/master/examples/multi_gpu/papers100m_gcn_cugraph_multinode.py) ogbn-papers100m examples, and added evaluation on all ranks (#8823, #9386, #9445)EdgeIndex and Indextorch_geometric.Index (#9276, #9277, #9278, #9279, #9280, #9281, #9284, #9285, #9286, #9287, #9288, #9289, #9296, #9297)EdgeIndex in MessagePassing (#9007, #9026, #9131)torch.compile in combination with EdgeIndex (#9007)EdgeIndex.unbind() (#9298)EdgeIndex.sparse_narrow() (#9291)EdgeIndex.sparse_resize_() (#8983)torch_geometric.nnGRetriever model (#9480)ClusterPooling layer (#9627)PatchTransformerAggregation layer (#9487)residual option in GATConv and GATv2Conv (#9515)nlp.LLM model wrapper (#9462)nlp.SentenceTransformer model wrapper (#9350)HeteroJumpingKnowledge module for applying jumping knowledge in heterogeneous graphs (#9380)VariancePreservingAggregation layer (#9075)faiss-based KNN-search capabilities via ApproxKNN (#8952, #9046)torch_geometric.metricsLinkPredMRR metric (#9632)torch_geometric.transformsRemoveSelfLoops transformation (#9562)torch_geometric.utilsnormalize_edge_index() for symmetric/asymmetric normalization of graph edges (#9554)from_rdmol/to_rdmol functionality (#9452)scatter with min/max reductions (#9587)torch_geometric.datasetsWebQSPDataset (#9481)OPFDataset (#9379)CornellTemporalHyperGraphDataset hypergraph dataset (#9090) from_smiles functionality to PCQM4Mv2 and MoleculeNet (#9073)torch_geometric.loaderLinkLoader acccording to source and destination node weights (#9316)VirtualNode transform for empty edge indices (#9605)cugraph example could cause an rmm error (#9577)load_state_dict behavior with lazy parameters in HeteroDictLinear (#9493)Sequential modules can now be properly pickled (#9369)pickle.load for jittable MessagePassing modules (#9368)data.edge_index (#9317)MessagePassing.propagate() (#9245)RCDD dataset (#9234)edge_label and edge_label_index in ToSparseTensor transform (#9199)EgoData processing in SnapDataset in case filenames are unsorted (#9195)to_dgl() function (#9188)to_scipy_sparse_matrix() when CUDA is set as default torch device (#9146)MetaPath2Vec model in case the last node is isolated (#9145)MessagePassing via torch.load() (#9105)MessagePassing.propagate() functions (#9079)self.propagate appearances in comments when parsing MessagePassing implementation (#9044)OSError on read-only file systems within MessagePassing (#9032)Dataset (#8999)MessagePassing modules with nested inheritance (#8973)MessagePassing._check_input() on older torch versions (#9564)torch.load(weights_only=True) by default (#9618)MessagePassing (#9494)filename of the stored partitioned file in ClusterLoader (#9448)AttentionalAggregation (#9433)fmt argument to Dataset.print_summary() (#9408)MoleculeNet (#9318)OnDiskDataset for multi-threaded get calls (#9140)scatter() operations in MessagePassing in case torch.use_deterministic_algorithms is not set (#9009)Full Changelog: https://github.com/pyg-team/pytorch_geometric/compare/2.5.0...2.6.0
WebQSPDataset dataset (#9481)GRetriever model and an example (#9480, #9167)ClusterPooling layer (#9627)LinkPredMRR metric (#9632)utils.normalize_edge_index for symmetric/asymmetric normalization of graph edges (#9554)RemoveSelfLoops transformation (#9562)scatter with min/max reductions (#9587)residual option in GATConv and GATv2Conv (#9515)PatchTransformerAggregation layer (#9487)nn.nlp.LLM model (#9462)utils.from_rdmol/utils.to_rdmol functionality (#9452)OPFDataset (#9379)HeteroJumpingKnowledge module (#9380)LinkLoader acccording to source and destination node weights (#9316)EdgeIndex.unbind (#9298)torch_geometric.Index into torch_geometric.EdgeIndex (#9296)EdgeIndex.sparse_narrow for non-sorted edge indices (#9291)torch_geometric.Index (#9276, #9277, #9278, #9279, #9280, #9281, #9284, #9285, #9286, #9287, #9288, #9289, #9297)EdgeIndex in message_and_aggregate (#9131)CornellTemporalHyperGraphDataset (#9090)GAT in single node Papers100m examples (#8173)VariancePreservingAggregation (VPA) (#9075) from_smiles functionality to PCQM4Mv2 and MoleculeNet (#9073)group_cat functionality (#9029)EdgeIndex in spmm (#9026)ApproxKNN (#9046)EdgeIndex in MessagePassing (#9007)torch.compile in combination with EdgeIndex (#9007)ogbn-mag240m example (#8249)EdgeIndex.sparse_resize_ functionality (#8983)faiss-based KNN-search (#8952)torch.load(weights_only=True) by default (#9618)cugraph examples to its new API (#9541)MessagePassing (#9494)filename of the stored partitioned file in ClusterLoader (#9448)AttentionalAggregation (#9433)examples/ogbn_papers_100m.py script (#9386, #9445)fmt arg to Dataset.get_summary (#9408)MoleculeNet (#9318)OnDiskDataset for multi-threaded get calls (#9140)None outputs in FeatureStore.get_tensor() - KeyError should now be raised based on the implementation in FeatureStore._get_tensor() (#9102)ogbn-papers100m default hyperparameters and adding evaluation on all ranks (#8823)pytest (#8978)trim_to_layer functionality (#9021)scatter operations in MessagePassing in case torch.use_deterministic_algorithms is not set (#9009)MessagePassing interface thread-safe (#9001)EdgeIndex in cugraph GNN layers (#8938)dim arg to torch.cross calls (#8918)VirtualNode transform for empty edge indices (#9605)cugraph example could cause an rmm error (#9577)cugraph example more readable (#9577)load_state_dict behavior with lazy parameters in HeteroDictLinear (#9493)Sequential can now be properly pickled (#9369)pickle.load for jittable MessagePassing modules (#9368)data.edge_index (#9317)MessagePassing.propgate (#9245)RCDD dataset (#9234)edge_label and edge_label_index in ToSparseTensor transform (#9199)EgoData processing in SnapDataset in case filenames are unsorted (#9195)to_dgl (#9188)to_scipy_sparse_matrix when cuda is set as default torch device (#9146)MetaPath2Vec in case the last node is isolated (#9145)MessagePassing via torch.load (#9105)propagate functions (#9079)self.propagate appearances in comments when parsing MessagePassing implementation (#9044)OSError on read-only file systems within MessagePassing (#9032)Dataset (#8999)MessagePassing modules with nested inheritance (#8973)MessagePassing._check_input on older torch versions (#9564)PyG 2.5.3 includes a variety of bug fixes related to the MessagePassing refactoring.
PyG 2.5.3 includes a variety of bug fixes related to the MessagePassing refactoring.
MessagePassing via torch.load (#9105)propagate functions (#9079)propagate method twice in MessagePassing for decomposed_layers > 1 (#9198)Full Changelog: https://github.com/pyg-team/pytorch_geometric/compare/2.5.2...2.5.3
PyG 2.5.3 includes a variety of bug fixes related to the MessagePassing refactoring.
MessagePassing via torch.load (#9105)propagate functions (#9079)propagate method twice in MessagePassing for decomposed_layers > 1 (#9198)Full Changelog: 2.5.2...2.5.3
PyG 2.5.2 includes a bug fix for implementing MessagePassing layers in Google Colab.
PyG 2.5.2 includes a bug fix for implementing MessagePassing layers in Google Colab.
inspect.get_source is not supported (#9068)Full Changelog: https://github.com/pyg-team/pytorch_geometric/compare/2.5.1...2.5.2
PyG 2.5.2 includes a bug fix for implementing MessagePassing layers in Google Colab.
inspect.get_source is not supported (#9068)Full Changelog: 2.5.1...2.5.2
PyG 2.5.1 includes a variety of bugfixes.
PyG 2.5.1 includes a variety of bugfixes.
self.propagate appearances in comments when parsing MessagePassing implementation (#9044)OSError on read-only file systems within MessagePassing (#9032)MessagePassing interface thread-safe (#9001)Dataset (#8999)MessagePassing modules with nested inheritance (#8973)OSError when downloading datasets with simplecache (#8932)Full Changelog: https://github.com/pyg-team/pytorch_geometric/compare/2.5.0...2.5.1
…COO-based PyG workflows. `EdgeIndex` will fully deprecate the usage of `SparseTensor` from `torch-sparse` in later releases, leaving us with just a si…
We are excited to announce the release of PyG 2.5 🎉🎉🎉
PyG 2.5 is the culmination of work from 38 contributors who have worked on features and bug-fixes for a total of over 360 commits since torch-geometric==2.4.0.
torch_geometric.distributedWe are thrilled to announce the first in-house distributed training solution for PyG via the torch_geometric.distributed sub-package. Developers and researchers can now take full advantage of distributed training on large-scale datasets which cannot be fully loaded in memory of one machine at the same time. This implementation doesn't require any additional packages to be installed on top of the default PyG stack.
<p align="center"> <img height="150" src="https://pytorch-geometric.readthedocs.io/en/latest/_images/dist_part.png" /> </p>
GraphStore and FeatureStore APIs provides a flexible and tailored interface for distributing large graph structure information and feature storage.See here for the accompanying tutorial. In addition, we provide two distributed examples in examples/distributed/pyg to get started:
ogbn-productsMovieLensEdgeIndex Tensor Representationtorch-geometric==2.5.0 introduces the EdgeIndex class.
EdgeIndex is a torch.Tensor, that holds an edge_index representation of shape [2, num_edges]. Edges are given as pairwise source and destination node indices in sparse COO format. While EdgeIndex sub-classes a general torch.Tensor, it can hold additional (meta)data, i.e.:
sparse_size: The underlying sparse matrix sizesort_order: The sort order (if present), either by row or columnis_undirected: Whether edges are bidirectional.Additionally, EdgeIndex caches data for fast CSR or CSC conversion in case its representation is sorted (i.e. its rowptr or colptr). Caches are filled based on demand (e.g., when calling EdgeIndex.sort_by()), or when explicitly requested via EdgeIndex.fill_cache_(), and are maintained and adjusted over its lifespan (e.g., when calling EdgeIndex.flip()).
from torch_geometric import EdgeIndex
edge_index = EdgeIndex(
[[0, 1, 1, 2],
[1, 0, 2, 1]]
sparse_size=(3, 3),
sort_order='row',
is_undirected=True,
device='cpu',
)
>>> EdgeIndex([[0, 1, 1, 2],
... [1, 0, 2, 1]])
assert edge_index.is_sorted_by_row
assert edge_index.is_undirected
# Flipping order:
edge_index = edge_index.flip(0)
>>> EdgeIndex([[1, 0, 2, 1],
... [0, 1, 1, 2]])
assert edge_index.is_sorted_by_col
assert edge_index.is_undirected
# Filtering:
mask = torch.tensor([True, True, True, False])
edge_index = edge_index[:, mask]
>>> EdgeIndex([[1, 0, 2],
... [0, 1, 1]])
assert edge_index.is_sorted_by_col
assert not edge_index.is_undirected
# Sparse-Dense Matrix Multiplication:
out = edge_index.flip(0) @ torch.randn(3, 16)
assert out.size() == (3, 16)
EdgeIndex is implemented through extending torch.Tensor via the __torch_function__ interface (see here for the highly recommended tutorial).
EdgeIndex ensures for optimal computation in GNN message passing schemes, while preserving the ease-of-use of regular COO-based PyG workflows. EdgeIndex will fully deprecate the usage of SparseTensor from torch-sparse in later releases, leaving us with just a single source of truth for representing graph structure information in PyG.
Previously, all/most of our link prediction models were trained and evaluated using binary classification metrics. However, this usually requires that we have a set of candidates in advance, from which we can then infer the existence of links. This is not necessarily practical, since in most cases, we want to find the top-k most likely links from the full set of O(N^2) pairs.
torch-geometric==2.5.0 brings full support for using GNNs as a recommender system (#8452), including support for
MIPSKNNIndexf1@k, map@k, precision@k, recall@k and ndcg@k, including mini-batch supportmips = MIPSKNNIndex(dst_emb)
for src_batch in src_loader:
src_emb = model(src_batch.x_dict, src_batch.edge_index_dict)
_, pred_index_mat = mips.search(src_emb, k)
for metric in retrieval_metrics:
metric.update(pred_index_mat, edge_label_index)
for metric in retrieval_metrics:
metric.compute()
See here for the accompanying example.
PyG 2.5 is fully compatible with PyTorch 2.2 (#8857), and supports the following combinations:
| PyTorch 2.2 | cpu |
cu118 |
cu121 |
|---|---|---|---|
| Linux | ✅ | ✅ | ✅ |
| macOS | ✅ | ||
| Windows | ✅ | ✅ | ✅ |
You can still install PyG 2.5 with an older PyTorch release up to PyTorch 1.12 in case you are not eager to update your PyTorch version.
torch.compile(...) and TorchScript Supporttorch-geometric==2.5.0 introduces a full re-implementation of the MessagePassing interface, which makes it natively applicable to both torch.compile and TorchScript. As such, torch_geometric.compile is now fully deprecated in favor of torch.compile
- model = torch_geometric.compile(model)
+ model = torch.compile(model)
and MessagePassing.jittable() is now a no-op:
- conv = torch.jit.script(conv.jittable())
+ model = torch.jit.script(conv)
In addition, torch.compile usage has been fixed to not require disabling of extension packages such as torch-scatter or torch-sparse.
torch_geometric.distributed (examples/distributed/pyg/) (#8713)examples/hetero/temporal_link_pred.py) (#8383)examples/distributed/pyg/temporal_link_movielens_cpu.py) (#8820)examples/multi_gpu/distributed_sampling_xpu.py) (#8032)ogbn-papers100M (examples/multi_gpu/papers100m_gcn_multinode.py) (#8070)examples/multi_gpu/model_parallel.py) (#8309)ViSNet from "ViSNet: an equivariant geometry-enhanced graph neural network with vector-scalar interactive message passing for molecules" (#8287)examples/multi_gpu/distributed_sampling.py) (#8880)GATConv now initializes modules differently depending on whether their input is bipartite or non-bipartite (#8397). This will lead to issues when loading model state for GATConv layers trained on earlier PyG versions.torch_geometric.compile in favor of torch.compile (#8780)torch_geometric.nn.DataParallel in favor of torch.nn.parallel.DistributedDataParallel (#8250)MessagePassing.jittable (#8781, #8731)torch_geometric.data.makedirs in favor of os.makedirs (#8421)Package-wide Improvements
mypy (#8254)fsspec as file system backend (#8379, #8426, #8434, #8474)torch-scatter is not installed (#8852)Temporal Graph Support
NeighborLoader and LinkNeighborLoader (#8372, #8428)Data.{sort_by_time,is_sorted_by_time,snapshot,up_to} for temporal graph use-cases (#8454)torch_geometric.distributed (#8718, #8815)torch_geometric.datasets
RCDD) from "Datasets and Interfaces for Benchmarking Heterogeneous Graph Neural Networks" (#8196)StochasticBlockModelDataset(num_graphs: int) argument (#8648)FakeDataset and FakeHeteroDataset (#8404)InMemoryDataset.to(device) (#8402)force_reload: bool = False argument to Dataset and InMemoryDataset in order to enforce re-processing of datasets (#8352, #8357, #8436)TreeGraph and GridMotif generators (#8736)torch_geometric.nn
KNNIndex exclusion logic (#8573)KGEModel.test() (#8298)nn.to_hetero_with_bases on static graphs (#8247)ModuleDict, ParameterDict, MultiAggregation and HeteroConv for better support for torch.compile (#8363, #8345, #8344)torch_geometric.metrics
f1@k, map@k, precision@k, recall@k and ndcg@k metrics for link-prediction retrieval tasks (#8499, #8326, #8566, #8647)torch_geometric.explain
conv.explain = False (#8216)visualize_graph(node_labels: list[str] | None) argument (#8816)torch_geometric.transforms
AddRandomWalkPE (#8431)Other Improvements
utils.to_networkx (#8575)utils.noise_scheduler.{get_smld_sigma_schedule,get_diffusion_beta_schedule} for diffusion-based graph generative models (#8347)utils.dropout_node via relabel_nodes: bool argument (#8524)utils.cross_entropy.sparse_cross_entropy (#8340)profile.profileit("xpu") (#8532)ClusterData (#8438)HeteroData.to_homogeneous() (#8858)InMemoryDataset to reconstruct the correct data class when a pre_transform has modified it (#8692)OnDiskDataset (#8663)DMoNPooing loss function (#8285)NaN handling in SQLDatabase (#8479)CaptumExplainer in case no index is passed (#8440)edge_index construction in the UPFD dataset (#8413)AttentionalAggregation and DeepSetsAggregation (#8406)GraphMaskExplainer for GNNs with more than two layers (#8401)input_id computation in NeighborLoader in case a mask is given (#8312)Linear layers (#8311)Data.subgraph()/HeteroData.subgraph() in case edge_index is not defined (#8277)MetaPath2Vec (#8248)AttentionExplainer usage within AttentiveFP (#8244)load_from_state_dict in lazy Linear modules (#8242)DimeNet++ performance on QM9 (#8239)GNNExplainer usage within AttentiveFP (#8216)to_networkx(to_undirected=True) in case the input graph is not undirected (#8204)TwoHop and AddRandomWalkPE transformations (#8197, #8225)HeteroData objects converted via ToSparseTensor() when torch-sparse is not installed (#8356)add_self_loops=True in GCNConv(normalize=False) (#8210)use_segment_matmul based on benchmarking results (from a heuristic-based version) (#8615)NELL and AttributedGraphDataset are now represented as torch.sparse_csr_tensor instead of torch_sparse.SparseTensor (#8679)torch.sparse tensors (#8670)ExplainerDataset will now contain node labels for any motif generator (#8519)utils.softmax faster via the in-house pyg_lib.ops.softmax_csr kernel (#8399)utils.mask.mask_select faster (#8369)Dataset.num_classes on regression datasets (#8550)Full Changelog: https://github.com/pyg-team/pytorch_geometric/compare/2.4.0...2.5.0
segment in case torch-scatter is not installed (#8852)visualize_graph() (#8816)torch_geometric.distributed (#8718, #8815, #8874)TreeGraph and GridMotif generators (#8736)num_graphs option to the StochasticBlockModelDataset (#8648)ViSNet model (#8287)Data (#8454)to_networkx (#8575)profileit decorator (#8532)KNNIndex exclusion logic (#8573)dataset.num_classes on regression problems (#8550)dropout_node (#8524)mypy (#8254)ClusterData (#8438)is_torch_instance to check against the original class of compiled models (#8461)AddRandomWalkPE (#8431)fsspec as file system backend (#8379, #8426, #8434, #8474)FakeDataset and FakeHeteroDataset (#8404)InMemoryDataset (#8402)NeighborLoader and LinkNeighborLoader (#8372, #8428)torch.compile in ModuleDict and ParameterDict (#8363)force_reload option to Dataset and InMemoryDataset to reload datasets (#8352, #8357, #8436)torch.compile in MultiAggregation (#8345)torch.compile in HeteroConv (#8344)sparse_cross_entropy (#8340)KGEModel.test() (#8298)examples/multi_gpu/model_parallel.py) (#8309)ogbn-papers100M (#8070)to_hetero_with_bases on static graphs (#8247)RCDD dataset (#8196)GAT + ogbn-products example targeting XPU device (#8032)conv.explain = False (#8216)use_segment_matmul based on benchmarking (from a heuristic-based version) (#8615)utils.group_argsort if its input tensor is empty (#8752)NELL and AttributedGraphDataset are now represented as torch.sparse_csr_tensor instead of torch_sparse.SparseTensor (#8679)torch.sparse tensors (#8670)DistLoader with atexit not executed correctly in worker_init_fn (#8605)ExplainerDataset will now contain node labels for any motif generator (#8519)utils.softmax faster via softmax_csr (#8399)utils.mask.mask_select faster (#8369)DistNeighborSampler (#8209, #8367, #8375, (#8624, #8722)GraphStore and FeatureStore to support distributed training (#8083)add_self_loops=True in GCNConv(normalize=False) (#8210)torch_geometric.compile (#8220)MessagePassing.jittable (#8781)torch_geometric.compile; Use torch.compile instead (#8780)typing argument in MessagePassing.jittable() (#8731)torch_geometric.data.makedirs in favor of os.makedirs (#8421)DataParallel in favor of DistributedDataParallel (#8250)to_homogeneous() (#8858)InMemoryDataset did not reconstruct the correct data class when a pre_transform has modified it (#8692)OnDiskDataset (#8663)DMoNPooing loss function (#8285)NaN handling in SQLDatabase (#8479)CaptumExplainer in case no index is passed (#8440)edge_index construction in the UPFD dataset (#8413)AttentionalAggregation and DeepSetsAggregation (#8406)GraphMaskExplainer for GNNs with more than two layers (#8401)GATConv depending on whether the input is bipartite or non-bipartite (#8397)input_id computation in NeighborLoader in case a mask is given (#8312)Linear layers (#8311)Data.subgraph()/HeteroData.subgraph() in case edge_index is not defined (#8277)MetaPath2Vec (#8248)AttentionExplainer usage within AttentiveFP (#8244)load_from_state_dict in lazy Linear modules (#8242)DimeNet++ performance on QM9 (#8239)GNNExplainer usage within AttentiveFP (#8216)to_networkx(to_undirected=True) in case the input graph is not undirected (#8204)TwoHop and AddRandomWalkPE transformations (#8197, #8225)HeteroData converted using ToSparseTensor() when torch_sparse is not installed (#8356)torch_geometric.compile (#8698)Your coding agent can read these notes before it upgrades. Set up the MCP server →