Tutorials¶
Guides to the parts of mlx-graphs you build on, and Jupyter notebooks that train complete models, most of them side by side with PyTorch Geometric on accuracy and runtime. New to mlx-graphs? Start with the Quickstart.
Guides¶
-
The
MessagePassingcontract, aggregations, attention layers, fused message passing, and how to check a layer against PyG. -
Fuse an operation of your own in Metal, with gradients, a fallback, tests and a benchmark: a per-edge score whose forward pass runs about 5.5x faster than with MLX operations on 2 million edges (M5 Pro).
-
Train on graphs larger than the memory with memory-mapped feature stores, and sample neighborhoods that respect time.
-
The built-in datasets, their sizes and how to load them, and how to add your own.
Notebooks¶
Each page shows the notebook with the outputs of its last run; download it to run it yourself.
Classify the MUTAG molecules with a GCN, mini-batches and global pooling.
Node embeddings from biased random walks on Cora, sampled on the GPU, compared with PyG.
Embeddings of a heterogeneous graph from meta-path guided random walks, on a toy graph and on DBLP.
Mini-batch training on large graphs
Train on ogbn-arxiv one subgraph at a time with NeighborLoader, ClusterLoader and GraphSAINT.
Split edges without leakage, train a GCN encoder and dot-product decoder, rank with LinkPred metrics.
A TGN with memory, trained on the JODIE Wikipedia stream of events, against PyG.
Heterogeneous graphs with to_hetero
Turn a homogeneous GraphSAGE or GAT into a heterogeneous model on DBLP, as in PyG.
GPSConv with random-walk encodings on Peptides-func, plus Performer, SGFormer and Polynormer.
Intrusion detection on provenance graphs, anti-money laundering, network flows and malware classification.
Run the G-reasoner checkpoint with a custom Metal kernel as the retriever of a local LLM.
Predict quantum-chemical properties of small molecules with a GNN.
Example scripts¶
The examples/
folder of the repository has runnable scripts that train models end to end
from the command line: node classification, GCN and GAT on Cora, link
prediction, heterogeneous GraphSAGE, MetaPath2Vec, TGN on JODIE and TGB, GPS, PointNet++ and more.
See all the example scripts.