pyg-team / pytorch_geometric

Graph Neural Network Library for PyTorch
https://pyg.org
MIT License
21.01k stars 3.62k forks source link

Graph loader (NeighborLoader, HGTLoader, etc) mysteriously crash on RCDD dataset #9212

Closed junhongmit closed 4 months ago

junhongmit commented 5 months ago

🐛 Describe the bug

I am trying to use the newly incorporated dataset RCDD since PyG 2.5. However, when I try to feed the dataset into heterogeneous graph loader, such as NeighborLoader or HGTLoader, both of them mysteriously crash and complain "Segmentation Fault".

You can reproduce it using:

from torch_geometric.datasets.rcdd import RCDD
from torch_geometric.loader import HGTLoader, NeighborLoader
dataset = RCDD()
print(dataset[0])

# Following lines will crash
HGTLoader(dataset[0],
        num_samples=[16, 16],
        input_nodes=('item', dataset[0]['item'].train_mask),
        batch_size=32)
NeighborLoader(dataset[0],
        num_neighbors=[10, 10],
        input_nodes=('item', dataset[0]['item'].train_mask),
        batch_size=32)

Versions

PyTorch version: 2.2.1 Is debug build: False CUDA used to build PyTorch: 12.1 ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.6 LTS (x86_64) GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0 Clang version: Could not collect CMake version: version 3.16.3 Libc version: glibc-2.31

Python version: 3.9.19 (main, Mar 21 2024, 17:11:28) [GCC 11.2.0] (64-bit runtime) Python platform: Linux-5.4.0-172-generic-x86_64-with-glibc2.31 Is CUDA available: True CUDA runtime version: Could not collect CUDA_MODULE_LOADING set to: LAZY GPU models and configuration: GPU 0: Tesla V100-SXM2-32GB GPU 1: Tesla V100-SXM2-32GB GPU 2: Tesla V100-SXM2-32GB GPU 3: Tesla V100-SXM2-32GB GPU 4: Tesla V100-SXM2-32GB GPU 5: Tesla V100-SXM2-32GB GPU 6: Tesla V100-SXM2-32GB GPU 7: Tesla V100-SXM2-32GB

Nvidia driver version: 535.154.05 cuDNN version: /usr/local/cuda-9.0/targets/x86_64-linux/lib/libcudnn.so.7 HIP runtime version: N/A MIOpen runtime version: N/A Is XNNPACK available: True

CPU: Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian Address sizes: 46 bits physical, 48 bits virtual CPU(s): 80 On-line CPU(s) list: 0-79 Thread(s) per core: 2 Core(s) per socket: 20 Socket(s): 2 NUMA node(s): 2 Vendor ID: GenuineIntel CPU family: 6 Model: 79 Model name: Intel(R) Xeon(R) CPU E5-2698 v4 @ 2.20GHz Stepping: 1 CPU MHz: 2699.532 CPU max MHz: 3600.0000 CPU min MHz: 1200.0000 BogoMIPS: 4390.57 Virtualization: VT-x L1d cache: 1.3 MiB L1i cache: 1.3 MiB L2 cache: 10 MiB L3 cache: 100 MiB NUMA node0 CPU(s): 0-19,40-59 NUMA node1 CPU(s): 20-39,60-79 Vulnerability Gather data sampling: Not affected Vulnerability Itlb multihit: KVM: Mitigation: Split huge pages Vulnerability L1tf: Mitigation; PTE Inversion; VMX conditional cache flushes, SMT vulnerable Vulnerability Mds: Mitigation; Clear CPU buffers; SMT vulnerable Vulnerability Meltdown: Mitigation; PTI Vulnerability Mmio stale data: Mitigation; Clear CPU buffers; SMT vulnerable Vulnerability Retbleed: Not affected Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization Vulnerability Spectre v2: Mitigation; Retpolines, IBPB conditional, IBRS_FW, STIBP conditional, RSB filling, PBRSB-eIBRS Not affected Vulnerability Srbds: Not affected Vulnerability Tsx async abort: Mitigation; Clear CPU buffers; SMT vulnerable Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cdp_l3 invpcid_single pti intel_ppin ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm rdt_a rdseed adx smap intel_pt xsaveopt cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts md_clear flush_l1d

Versions of relevant libraries: [pip3] numpy==1.26.4 [pip3] torch==2.2.1 [pip3] torch_geometric==2.5.2 [pip3] torch-scatter==2.1.2 [pip3] torch-sparse==0.6.18 [pip3] torchaudio==2.2.1 [pip3] torchdata==0.7.1 [pip3] torchvision==0.17.1 [pip3] triton==2.2.0 [conda] blas 1.0 mkl [conda] ffmpeg 4.3 hf484d3e_0 pytorch [conda] libjpeg-turbo 2.0.0 h9bf148f_0 pytorch [conda] mkl 2023.1.0 h213fc3f_46344 [conda] mkl-service 2.4.0 py39h5eee18b_1 [conda] mkl_fft 1.3.8 py39h5eee18b_0 [conda] mkl_random 1.2.4 py39hdb19cb5_0 [conda] numpy 1.26.4 py39h5f9d8c6_0 [conda] numpy-base 1.26.4 py39hb5e798b_0 [conda] pyg 2.5.2 py39_torch_2.2.0_cu121 pyg [conda] pytorch 2.2.1 py3.9_cuda12.1_cudnn8.9.2_0 pytorch [conda] pytorch-cuda 12.1 ha16c6d3_5 pytorch [conda] pytorch-mutex 1.0 cuda pytorch [conda] pytorch-scatter 2.1.2 py39_torch_2.2.0_cu121 pyg [conda] pytorch-sparse 0.6.18 py39_torch_2.2.0_cu121 pyg [conda] torchaudio 2.2.1 py39_cu121 pytorch [conda] torchdata 0.7.1 py39 pytorch [conda] torchtriton 2.2.0 py39 pytorch [conda] torchvision 0.17.1 py39_cu121 pytorch

junhongmit commented 5 months ago

I have further traced down the error. It's originated from the index2ptr operator from torch_geometric.utils.sparse. Here is the detailed running process before crashing:

  1. when initialize the graph loader, to_hetero_csc() is called to transform each edge_index to csc format.
  2. Within to_hetero_csc(), to_csc() is called for each edge_type.
  3. Particularly, the program runs totally fine until it runs to a specific edge type (a, G_1, f)={ edge_index=[2, 59208411] }.
  4. Edge type (a, G_1, f) is delivered to to_csc() function. Within it, the column pointer is generated by colptr = index2ptr(col, data.size(1)).
  5. It then crashes. I see that a precompiled torch._convert_indices_from_coo_to_csr operator is called within this index2ptr function.

I am wondering, is it because this specific edge_type has too many edges, or there are specific edge arrangement that break some assumption within the torch._convert_indices_from_coo_to_csr operator, so result in the crash? The graph loader worked totally fine on large-scale data such as ogbn-papers100M, so I don't think the number of edges in this case would break it.

rusty1s commented 5 months ago

How much RAM do you have on your machine? I receive OOM with 64GB sadly.

junhongmit commented 5 months ago

Hi rusty1s, I have 500GB RAM on my machine. I think I have figured out why the graph loader is crashing. When I explicitly print out the edge index from edge type (a, G_1, f), I found that the vertex number are very incorrect:

tensor([[     669,     2473,     2984,  ..., 11577605, 11577678, 11577949],
        [  339596,     9788, 11477793,  ...,   934295,   929511,  1150252]])

Notably, here are the number of node a and node f:

a={
  num_nodes=204128,
  x=[204128, 256],
},
f={
  num_nodes=1063739,
  x=[1063739, 256],
}

Certainly, the vertex number in the edge index are greater than those available. This situation also exist in the other edge type. I think there is something wrong in the RCDD dataset process() function, especially the mapping data structure.

EdisonLeeeee commented 5 months ago

Hi @junhongmit

I have reproduced the bug on my end, and will fix it today. Sorry for any inconvenience.