Skip to content

[ROCm] Add HIP support for AMD Instinct GPUs#31

Open
andyluo7 wants to merge 1 commit intoJeffreyXiang:mainfrom
andyluo7:add-rocm-support
Open

[ROCm] Add HIP support for AMD Instinct GPUs#31
andyluo7 wants to merge 1 commit intoJeffreyXiang:mainfrom
andyluo7:add-rocm-support

Conversation

@andyluo7
Copy link
Copy Markdown

Summary

Port CuMesh to support AMD ROCm GPUs (MI300X / gfx942) via HIP.

Changes

  • 15 files modified with #ifdef __HIP_PLATFORM_AMD__ guards for cross-compilation
  • CUDA → HIP API mapping (cudaMalloc → hipMalloc, cub → hipcub, etc.)
  • ::cuda::std::tuple::rocprim::tuple for DeviceRadixSort decomposer
  • Vec3f default constructor added for hipcub DeviceSegmentedReduce compatibility
  • setup.py: default arch gfx942, CUDA-only flags gated behind IS_HIP
  • cubvh submodule: ATen/cuda → ATen/hip header mappings

Testing

  • ✅ Compiles with hipcc on ROCm 7.0.2 + PyTorch 2.9.1
  • import cumesh succeeds on AMD MI300X
  • ✅ All code remains cross-compilable for CUDA (guarded with __HIP_PLATFORM_AMD__)
  • Tested as part of TRELLIS.2 ROCm enablement

Motivation

TRELLIS.2's setup.sh already detects ROCm and installs ROCm PyTorch, but CuMesh's CUDA-specific code prevents it from building on AMD GPUs. This PR enables the full TRELLIS.2 pipeline on AMD hardware.

Port all CUDA-specific code to work on both CUDA and ROCm via HIP:

- Headers: #ifdef __HIP_PLATFORM_AMD__ guards for cuda.h → hip/hip_runtime.h,
  cub/cub.cuh → hipcub/hipcub.hpp
- API: cudaMalloc/Free/Memcpy → hipMalloc/Free/Memcpy (guarded)
- CUB → hipcub namespace mapping
- ::cuda::std::tuple → ::rocprim::tuple (for DeviceRadixSort decomposer)
- ::cuda::std::plus → hipcub::Sum()
- Vec3f: add default __host__ __device__ constructor for hipcub compatibility
- ATen/cuda → ATen/hip (in cubvh submodule)
- setup.py: default arch gfx942, gate CUDA-only flags behind IS_HIP check

Tested on AMD MI300X (gfx942) with ROCm 7.0.2 + PyTorch 2.9.1.
All code remains cross-compilable for CUDA.

Signed-off-by: Andy Luo <andyluo7@users.noreply.github.com>
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