Overview
falkordb-pyg implements PyG’s Remote Backend interface (FeatureStore + GraphStore) for FalkorDB. Once connected, you can plug the backend directly into NeighborLoader, LinkNeighborLoader, and other standard PyG data loaders — no changes to your model or training code required.
Key features:
- Zero-copy lazy loading — features and topology are fetched on demand and cached locally
- Heterogeneous graph support — multiple node and edge types
- Automatic ID remapping — non-contiguous FalkorDB node IDs are mapped to contiguous PyG indices transparently
- Drop-in replacement — works with any PyG workflow that accepts a remote backend
Installation
Prerequisite: PyTorch and PyTorch Geometric must be installed first. Follow the PyTorch and PyG installation guides for your platform and CUDA version.
Requires: Python ≥ 3.10, PyTorch ≥ 2.0, PyTorch Geometric ≥ 2.4, FalkorDB Python client ≥ 1.0.
Quick Start
1. Start FalkorDB
2. Load data into FalkorDB
3. Create the remote backend
4. Use with NeighborLoader
API Reference
get_remote_backend
(FalkorDBFeatureStore, FalkorDBGraphStore) tuple.
FalkorDBFeatureStore
Implements torch_geometric.data.FeatureStore.
Constructor:
FalkorDBGraphStore
Implements torch_geometric.data.GraphStore.
Constructor:
NodeIDMapper
Bidirectional mapping between FalkorDB internal node IDs and contiguous 0-based PyG indices.
Node ID Remapping
FalkorDB assigns internal integer IDs to nodes that may not be contiguous or start at zero.falkordb-pyg transparently builds a NodeIDMapper for each node type on first access, converting FalkorDB IDs to contiguous PyG indices. Edges referencing IDs not present in the mapper are silently dropped.
Example: Training GraphSAGE
Seeexamples/train_example.py for a complete GraphSAGE training script that:
- Populates FalkorDB with a synthetic paper-citation graph
- Creates a remote backend with
get_remote_backend - Fetches features and edge indices lazily
- Trains a two-layer GraphSAGE classifier
Reference
Frequently Asked Questions
What is falkordb-pyg used for?
What is falkordb-pyg used for?
It enables you to train Graph Neural Networks (GNNs) directly on graphs stored in FalkorDB using PyTorch Geometric’s remote backend interface, without exporting data to files first.
What are the minimum version requirements?
What are the minimum version requirements?
You need Python >= 3.10, PyTorch >= 2.0, PyTorch Geometric >= 2.4, and FalkorDB Python client >= 1.0. Install with
pip install falkordb-pyg or pip install 'falkordb-pyg[torch]' for bundled PyTorch.Does falkordb-pyg support heterogeneous graphs?
Does falkordb-pyg support heterogeneous graphs?
Yes, it fully supports heterogeneous graphs with multiple node and edge types. Use the
node_type_to_label and edge_type_to_rel parameters in get_remote_backend to map PyG types to FalkorDB labels.How does node ID remapping work?
How does node ID remapping work?
FalkorDB assigns internal integer IDs that may not be contiguous. The
NodeIDMapper automatically builds a bidirectional mapping between FalkorDB IDs and contiguous 0-based PyG indices on first access.Can I use standard PyG data loaders with this backend?
Can I use standard PyG data loaders with this backend?
Yes, the remote backend works as a drop-in replacement with
NeighborLoader, LinkNeighborLoader, and any other PyG data loader that accepts a (FeatureStore, GraphStore) tuple.