-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Description
🐛 Describe the bug
import copy
import inspect
from torch_geometric.data import Data, Batch
import torch
def copy_test():
data = [Data(torch.rand((3, 5))) for _ in range(5)]
batch = Batch.from_data_list(data)
copy_batch = copy.deepcopy(batch)
batch_slice_id = id(batch._slice_dict)
copy_slice_id = id(copy_batch._slice_dict)
print(f"{batch_slice_id}: {batch_slice_id == copy_slice_id}")
copy_batch._slice_dict.update({"y": torch.tensor([0, 2, 4, 6, 7, 8])})
print(batch._slice_dict) # <--- assume that it only prints {'x': ...}
key = "_slice_dict"
print(key in batch.__dict__)
print(key in dir(batch))
mems = inspect.getmembers(batch)
print(key in mems)
if __name__ == "__main__":
copy_test()
The output of batch._slice_dict
shows that the copy.deepcopy
does not clone everything about Batch
.
I don't know whether it is sane that Batch
shares _slice_dict
and _inc_dict
when copy.deepcopy
.
What's more, I can't find where the variable or property _slice_dict
lies. It is not a member or property in the instance.
The output is pasted below.
140015623809472: True
{'x': tensor([ 0, 3, 6, 9, 12, 15]), 'y': tensor([0, 2, 4, 6, 7, 8])}
False
False
False
And the expected result for me is:
<id>: False
{'x': tensor([ 0, 3, 6, 9, 12, 15])}
...
Versions
PyTorch version: 1.13.1+cu116
Is debug build: False
CUDA used to build PyTorch: 11.6
ROCM used to build PyTorch: N/A
OS: Ubuntu 20.04.6 LTS (x86_64)
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
Clang version: Could not collect
CMake version: version 3.16.3
Libc version: glibc-2.31
Python version: 3.9.17 (main, Jul 5 2023, 20:41:20) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.4.0-144-generic-x86_64-with-glibc2.31
Is CUDA available: True
CUDA runtime version: 11.6.124
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration:
GPU 0: NVIDIA A100 80GB PCIe
GPU 1: NVIDIA A100 80GB PCIe
GPU 2: NVIDIA A100 80GB PCIe
GPU 3: NVIDIA A100 80GB PCIe
GPU 4: NVIDIA A100 80GB PCIe
GPU 5: NVIDIA A100 80GB PCIe
GPU 6: NVIDIA A100 80GB PCIe
GPU 7: NVIDIA A100 80GB PCIe
Nvidia driver version: 565.57.01
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.8.4.0
/usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8.4.0
/usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8.4.0
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8.4.0
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8.4.0
/usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8.4.0
/usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8.4.0
Is XPU available: False
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: 43 bits physical, 48 bits virtual
CPU(s): 256
On-line CPU(s) list: 0-255
Thread(s) per core: 2
Core(s) per socket: 64
Socket(s): 2
NUMA node(s): 2
Vendor ID: AuthenticAMD
CPU family: 23
Model: 49
Model name: AMD EPYC 7742 64-Core Processor
Stepping: 0
Frequency boost: enabled
CPU MHz: 3298.621
CPU max MHz: 2250.0000
CPU min MHz: 1500.0000
BogoMIPS: 4499.81
Virtualization: AMD-V
L1d cache: 4 MiB
L1i cache: 4 MiB
L2 cache: 64 MiB
L3 cache: 512 MiB
NUMA node0 CPU(s): 0-63,128-191
NUMA node1 CPU(s): 64-127,192-255
Vulnerability Itlb multihit: Not affected
Vulnerability L1tf: Not affected
Vulnerability Mds: Not affected
Vulnerability Meltdown: Not affected
Vulnerability Mmio stale data: Not affected
Vulnerability Retbleed: Vulnerable
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: Not affected
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 hw_pstate sme ssbd mba sev ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 cqm rdt_a rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local clzero irperf xsaveerptr wbnoinvd arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif umip rdpid overflow_recov succor smca
Versions of relevant libraries:
[pip3] mkl-fft==1.3.6
[pip3] mkl-random==1.2.2
[pip3] mkl-service==2.4.0
[pip3] mypy-extensions==1.0.0
[pip3] numpy==1.25.2
[pip3] pytorch-lightning==2.0.8
[pip3] torch==1.13.1+cu116
[pip3] torch-geometric==2.6.1
[pip3] torch-scatter==2.1.1
[pip3] torchaudio==0.13.1+cu116
[pip3] torchdiffeq==0.2.5
[pip3] torchmetrics==1.1.1
[pip3] torchvision==0.14.1+cu116
[conda] blas 1.0 mkl
[conda] intel-openmp 2023.1.0 hdb19cb5_46305
[conda] mkl 2023.1.0 h213fc3f_46343
[conda] mkl-service 2.4.0 py39h5eee18b_1
[conda] mkl_fft 1.3.6 py39h417a72b_1
[conda] mkl_random 1.2.2 py39h417a72b_1
[conda] numpy 1.25.2 py39h5f9d8c6_0
[conda] numpy-base 1.25.2 py39hb5e798b_0
[conda] pytorch-lightning 2.0.8 pypi_0 pypi
[conda] tbb 2021.8.0 hdb19cb5_0
[conda] torch 1.13.1+cu116 pypi_0 pypi
[conda] torch-geometric 2.6.1 pypi_0 pypi
[conda] torch-scatter 2.1.1 pypi_0 pypi
[conda] torchaudio 0.13.1+cu116 pypi_0 pypi
[conda] torchdiffeq 0.2.5 pypi_0 pypi
[conda] torchmetrics 1.1.1 pypi_0 pypi
[conda] torchvision 0.14.1+cu116 pypi_0 pypi