Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GlobalStorage#is_node_attr() breaks when cat_dim is a tuple #9895

Open
Wollents opened this issue Dec 26, 2024 · 0 comments
Open

GlobalStorage#is_node_attr() breaks when cat_dim is a tuple #9895

Wollents opened this issue Dec 26, 2024 · 0 comments
Labels

Comments

@Wollents
Copy link

🐛 Describe the bug

Hi,

when adj in the GlobalStorage is a ** sparse tensor**, _cat_dim_ would be a tuple. But I want to use the to_dgl(), it would throws an error. Because, when calling the method GlobalStorage#is_node_attr(), there are lines that make the application throw errows.

 cat_dim = self._parent().__cat_dim__(key, value, self)
 num_nodes, num_edges = self.num_nodes, self.num_edges
 if value.shape[cat_dim] != num_nodes:
     if value.shape[cat_dim] == num_edges:
         self._cached_attr[AttrType.EDGE].add(key)
     else:
         self._cached_attr[AttrType.OTHER].add(key)
     return False

The following snippet recreates the error:

import torch
from torch_geometric.data import Data
from torch_geometric.utils import to_dense_adj, to_dgl

edge_index = torch.tensor([
    [0, 1, 1, 2],
    [1, 0, 2, 1]
], dtype=torch.long)

adj = to_dense_adj(edge_index=edge_index).squeeze()
adj = adj.to_sparse_coo()

graph = Data(adj=adj, edge_index=edge_index)

dgl_graph = to_dgl(graph)

this example will throw the following error message:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/root/.pyenv/versions/3.9.21/envs/pygodEnv/lib/python3.9/site-packages/torch_geometric/utils/convert.py", line 539, in to_dgl
    for attr in data.node_attrs():
  File "/root/.pyenv/versions/3.9.21/envs/pygodEnv/lib/python3.9/site-packages/torch_geometric/data/data.py", line 215, in node_attrs
    return list(set(chain(*[s.node_attrs() for s in self.node_stores])))
  File "/root/.pyenv/versions/3.9.21/envs/pygodEnv/lib/python3.9/site-packages/torch_geometric/data/data.py", line 215, in <listcomp>
    return list(set(chain(*[s.node_attrs() for s in self.node_stores])))
  File "/root/.pyenv/versions/3.9.21/envs/pygodEnv/lib/python3.9/site-packages/torch_geometric/data/storage.py", line 530, in node_attrs
    return [key for key in self.keys() if self.is_node_attr(key)]
  File "/root/.pyenv/versions/3.9.21/envs/pygodEnv/lib/python3.9/site-packages/torch_geometric/data/storage.py", line 530, in <listcomp>
    return [key for key in self.keys() if self.is_node_attr(key)]
  File "/root/.pyenv/versions/3.9.21/envs/pygodEnv/lib/python3.9/site-packages/torch_geometric/data/storage.py", line 811, in is_node_attr
    if value.shape[cat_dim] != num_nodes:
TypeError: tuple indices must be integers or slices, not tuple


Versions

The following are my Versions and environments

PyTorch version: 2.3.1+cu121
Is debug build: False
CUDA used to build PyTorch: 12.1
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.3 LTS (x86_64)
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Clang version: Could not collect
CMake version: version 3.22.1
Libc version: glibc-2.35

Python version: 3.9.21 (main, Dec  5 2024, 07:41:01)  [GCC 11.4.0] (64-bit runtime)
Python platform: Linux-5.15.0-125-generic-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 3090
Nvidia driver version: 535.183.01
cuDNN version: Could not collect
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
Address sizes:                        46 bits physical, 48 bits virtual
Byte Order:                           Little Endian
CPU(s):                               88
On-line CPU(s) list:                  0-87
Vendor ID:                            GenuineIntel
Model name:                           Intel(R) Xeon(R) CPU E5-2696 v4 @ 2.20GHz
CPU family:                           6
Model:                                79
Thread(s) per core:                   2
Core(s) per socket:                   22
Socket(s):                            2
Stepping:                             1
CPU max MHz:                          3700.0000
CPU min MHz:                          1200.0000
BogoMIPS:                             4399.73
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
Virtualization:                       VT-x
L1d cache:                            1.4 MiB (44 instances)
L1i cache:                            1.4 MiB (44 instances)
L2 cache:                             11 MiB (44 instances)
L3 cache:                             110 MiB (2 instances)
NUMA node(s):                         2
NUMA node0 CPU(s):                    0-21,44-65
NUMA node1 CPU(s):                    22-43,66-87
Vulnerability Gather data sampling:   Not affected
Vulnerability Itlb multihit:          KVM: Mitigation: VMX disabled
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 Reg file data sampling: Not affected
Vulnerability Retbleed:               Not affected
Vulnerability Spec rstack overflow:   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; BHI Not affected
Vulnerability Srbds:                  Not affected
Vulnerability Tsx async abort:        Mitigation; Clear CPU buffers; SMT vulnerable

Versions of relevant libraries:
[pip3] numpy==1.26.3
[pip3] nvidia-cublas-cu12==12.1.3.1
[pip3] nvidia-cuda-cupti-cu12==12.1.105
[pip3] nvidia-cuda-nvrtc-cu12==12.1.105
[pip3] nvidia-cuda-runtime-cu12==12.1.105
[pip3] nvidia-cudnn-cu12==8.9.2.26
[pip3] nvidia-cufft-cu12==11.0.2.54
[pip3] nvidia-curand-cu12==10.3.2.106
[pip3] nvidia-cusolver-cu12==11.4.5.107
[pip3] nvidia-cusparse-cu12==12.1.0.106
[pip3] nvidia-nccl-cu12==2.20.5
[pip3] nvidia-nvjitlink-cu12==12.1.105
[pip3] nvidia-nvtx-cu12==12.1.105
[pip3] torch==2.3.1+cu121
[pip3] torch_cluster==1.6.3+pt23cu121
[pip3] torch-geometric==2.6.1
[pip3] torch_scatter==2.1.2+pt23cu121
[pip3] torch_sparse==0.6.18+pt23cu121
[pip3] torch_spline_conv==1.2.2+pt23cu121
[pip3] torchaudio==2.3.1+cu121
[pip3] torchvision==0.18.1+cu121
[pip3] triton==2.3.1
@Wollents Wollents added the bug label Dec 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant