alibaba / graphlearn-for-pytorch

A GPU-accelerated graph learning library for PyTorch, facilitating the scaling of GNN training and inference.
Apache License 2.0
113 stars 34 forks source link

does not support pyg sampler for hetero-graph #46

Closed kaixuanliu closed 1 year ago

kaixuanliu commented 1 year ago

šŸ› Describe the bug

When I replace sampler from gltorch to pyg (add as_pyg_v1=True in glt.loader.NeighborLoader), and run training example for igbh dataset, it returned error like this: `Traceback (most recent call last): File "train_rgnn.py", line 194, in train(model, device, train_loader, val_loader, test_loader, args) File "train_rgnn.py", line 72, in train for batch in train_dataloader: File "/mnt/disk1/kaixuan/anaconda3/envs/gltorch-cpu/lib/python3.8/site-packages/graphlearn_torch/loader/neighbor_loader.py", line 104, in next return self.sampler.sample_pyg_v1(seeds) File "/mnt/disk1/kaixuan/anaconda3/envs/gltorch-cpu/lib/python3.8/site-packages/graphlearn_torch/sampler/neighbor_sampler.py ", line 414, in sample_pyg_v1 srcs = inducer.init_node(srcs) TypeError: init_node(): incompatible function arguments. The following argument types are supported:

  1. (self: graphlearn_torch.py_graphlearn_torch.CPUHeteroInducer, seed: Dict[str, at::Tensor]) -> Dict[str, at::Tensor]

Invoked with: <graphlearn_torch.py_graphlearn_torch.CPUHeteroInducer object at 0x7f9658039270>, tensor([ 9612, 26762, 38719, ..., 11742, 47627, 47025])`

cmd line: python train_rgnn.py --model='rgat' --dataset_size='tiny' --num_classes=19 --cpu_mode

I looked through the code, and find the definition in sample_pyg_v1 only supports homogeneous graph, while glt supports both homo and hetero graph. So do you have plan to support pyg sampler for hetero graph?

Environment

husimplicity commented 1 year ago

@kaixuanliu sample_pyg_v1 is to adapt to the format of PyG's old version sampler. GLT's sampler output format is compatible to the current PyG data format.

kaixuanliu commented 1 year ago

Thanks for the info