Skip to content

_SymmetricMemory.empty_strided_p2p is limited to 2GB #137145

@tohtana

Description

@tohtana

🐛 Describe the bug

get_symm_mem_workspace throws an OOM error when it is passed to 2GB or a larger value as the size of the workspace. Here is the repro:

import torch
import torch.distributed as dist
from torch.distributed._symmetric_memory import enable_symm_mem_for_group, get_symm_mem_workspace

dist.init_process_group(backend='nccl')

rank = dist.get_rank()
torch.cuda.set_device(rank)

group_name = dist.group.WORLD.group_name
enable_symm_mem_for_group(group_name)

symm_mem = get_symm_mem_workspace(
    group_name,
    2*1024*1024*1024 # error
    # 2*1024*1024*1024 - 1 # works
)

Output:

$ torchrun test_symmem.py
[rank0]: Traceback (most recent call last):
[rank0]:   File "/home/mtanaka/work/z3n/run_z3_graph_rewrite/test_symmem.py", line 13, in <module>
[rank0]:     symm_mem = get_symm_mem_workspace(
[rank0]:   File "/home/mtanaka/.local/lib/python3.10/site-packages/torch/distributed/_symmetric_memory/__init__.py", line 115, in get_symm_mem_workspace
[rank0]:     tensor = _SymmetricMemory.empty_strided_p2p(
[rank0]: RuntimeError: CUDA driver error: out of memory

Versions

Collecting environment information...
PyTorch version: 2.5.0+cu124
Is debug build: False
CUDA used to build PyTorch: 12.4
ROCM used to build PyTorch: N/A

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

Python version: 3.10.12 (main, Jul 29 2024, 16:56:48) [GCC 11.4.0] (64-bit runtime)
Python platform: Linux-5.15.0-1073-azure-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: 12.6.20
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration:
GPU 0: NVIDIA H100 NVL
GPU 1: NVIDIA H100 NVL

Nvidia driver version: 560.35.03
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.9.3.0
/usr/lib/x86_64-linux-gnu/libcudnn_adv.so.9.3.0
/usr/lib/x86_64-linux-gnu/libcudnn_cnn.so.9.3.0
/usr/lib/x86_64-linux-gnu/libcudnn_engines_precompiled.so.9.3.0
/usr/lib/x86_64-linux-gnu/libcudnn_engines_runtime_compiled.so.9.3.0
/usr/lib/x86_64-linux-gnu/libcudnn_graph.so.9.3.0
/usr/lib/x86_64-linux-gnu/libcudnn_heuristic.so.9.3.0
/usr/lib/x86_64-linux-gnu/libcudnn_ops.so.9.3.0
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:                        48 bits physical, 48 bits virtual
Byte Order:                           Little Endian
CPU(s):                               80
On-line CPU(s) list:                  0-79
Vendor ID:                            AuthenticAMD
Model name:                           AMD EPYC 9V84 96-Core Processor
CPU family:                           25
Model:                                17
Thread(s) per core:                   1
Core(s) per socket:                   80
Socket(s):                            1
Stepping:                             1
BogoMIPS:                             4800.06
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 tsc_reliable nonstop_tsc cpuid extd_apicid aperfmperf pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm cmp_legacy cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw topoext perfctr_core invpcid_single vmmcall fsgsbase bmi1 avx2 smep bmi2 erms invpcid avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves avx512_bf16 clzero xsaveerptr rdpru arat avx512vbmi umip avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq rdpid fsrm
Hypervisor vendor:                    Microsoft
Virtualization type:                  full
L1d cache:                            2.5 MiB (80 instances)
L1i cache:                            2.5 MiB (80 instances)
L2 cache:                             80 MiB (80 instances)
L3 cache:                             320 MiB (10 instances)
NUMA node(s):                         2
NUMA node0 CPU(s):                    0-39
NUMA node1 CPU(s):                    40-79
Vulnerability Gather data sampling:   Not affected
Vulnerability Itlb multihit:          Not affected
Vulnerability L1tf:                   Not affected
Vulnerability Mds:                    Not affected
Vulnerability Meltdown:               Not affected
Vulnerability Mmio stale data:        Not affected
Vulnerability Reg file data sampling: Not affected
Vulnerability Retbleed:               Not affected
Vulnerability Spec rstack overflow:   Mitigation; safe RET, no microcode
Vulnerability Spec store bypass:      Vulnerable
Vulnerability Spectre v1:             Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:             Mitigation; Retpolines; STIBP disabled; RSB filling; PBRSB-eIBRS Not affected; BHI Not affected
Vulnerability Srbds:                  Not affected
Vulnerability Tsx async abort:        Not affected

Versions of relevant libraries:
[pip3] mypy-extensions==1.0.0
[pip3] numpy==1.24.4
[pip3] onnx==1.16.0
[pip3] optree==0.12.1
[pip3] pytorch-lightning==2.4.0
[pip3] pytorch-triton==3.1.0
[pip3] torch==2.5.0+cu124
[pip3] torch-tb-profiler==0.4.3
[pip3] torch_tensorrt==2.5.0a0
[pip3] torchaudio==2.5.0+cu124
[pip3] torchmetrics==1.4.2
[pip3] torchvision==0.20.0+cu124
[conda] Could not collect

cc @XilunWu @H-Huang @awgu @kwen2501 @wanchaol @fegin @fduwjj @wz337 @wconstab @d4l3k @c-p-i-o

Metadata

Metadata

Assignees

Labels

oncall: distributedAdd this issue/PR to distributed oncall triage queue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions