Skip to content

Conversation

@mcgrof
Copy link

@mcgrof mcgrof commented Dec 16, 2025

Add support for building pyg-lib on ROCm (AMD GPUs) alongside existing CUDA support. This allows pyg-lib to work with PyTorch ROCm builds.

CMakeLists.txt:

  • Add WITH_HIP option to enable HIP/ROCm builds
  • Detect ROCm path and find HIP, rocBLAS, hipBLAS packages
  • Set appropriate GPU architectures for AMD (gfx906, gfx90a, etc.)
  • Compile .cu files as HIP sources on ROCm
  • Exclude CUTLASS/cuCollections files that have HIP replacements

setup.py:

  • Auto-detect torch.version.hip for ROCm PyTorch builds
  • Pass -DWITH_HIP=ON to CMake when building on ROCm

New HIP implementations:

  • ops/hip/matmul_kernel_hip.cpp: rocBLAS-based grouped GEMM
  • classes/hip/hash_map_hip.cpp: Sorted array + binary search hashmap

Modified CUDA kernels for HIP compatibility:

  • sampler/cuda/random_walk_kernel.cu: Add HIP header/API macros
  • ops/cuda/sampled_kernel.cu: Add HIP header/API macros
  • library.cpp: Use hip_runtime.h and HIP_VERSION on ROCm

The simple CUDA kernels work on HIP with compatibility macros for getCurrentCUDAStream -> getCurrentHIPStream and
C10_CUDA_KERNEL_LAUNCH_CHECK -> C10_HIP_KERNEL_LAUNCH_CHECK.

Tested on ROCm 6.2/6.4 with PyTorch 2.6.

Generated-by: Claude AI

mcgrof and others added 2 commits December 15, 2025 22:25
Add support for building pyg-lib on ROCm (AMD GPUs) alongside existing
CUDA support. This allows pyg-lib to work with PyTorch ROCm builds.

CMakeLists.txt:
- Add WITH_HIP option to enable HIP/ROCm builds
- Detect ROCm path and find HIP, rocBLAS, hipBLAS packages
- Set appropriate GPU architectures for AMD (gfx906, gfx90a, etc.)
- Compile .cu files as HIP sources on ROCm
- Exclude CUTLASS/cuCollections files that have HIP replacements

setup.py:
- Auto-detect torch.version.hip for ROCm PyTorch builds
- Pass -DWITH_HIP=ON to CMake when building on ROCm

New HIP implementations:
- ops/hip/matmul_kernel_hip.cpp: rocBLAS-based grouped GEMM
- classes/hip/hash_map_hip.cpp: Sorted array + binary search hashmap

Modified CUDA kernels for HIP compatibility:
- sampler/cuda/random_walk_kernel.cu: Add HIP header/API macros
- ops/cuda/sampled_kernel.cu: Add HIP header/API macros
- library.cpp: Use hip_runtime.h and HIP_VERSION on ROCm

The simple CUDA kernels work on HIP with compatibility macros for
getCurrentCUDAStream -> getCurrentHIPStream and
C10_CUDA_KERNEL_LAUNCH_CHECK -> C10_HIP_KERNEL_LAUNCH_CHECK.

Tested on ROCm 6.2/6.4 with PyTorch 2.6.

Generated-by: Claude AI
Signed-off-by: Luis Chamberlain <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant