Skip to content

Add HIP/ROCm build paths and conditional GPU kernels for CUDA extensions - #3

Draft
Looong01 wants to merge 3 commits into
mainfrom
codex/add-rocm-backend-support
Draft

Add HIP/ROCm build paths and conditional GPU kernels for CUDA extensions#3
Looong01 wants to merge 3 commits into
mainfrom
codex/add-rocm-backend-support

Conversation

@Looong01

Copy link
Copy Markdown
Owner

Motivation

  • Provide ROCm/HIP support across the repository so the CUDA extensions and kernels can be built for AMD/ROCm as well as NVIDIA/CUDA.
  • Make backend selection explicit and controllable and ensure third-party bundled extensions (curope) follow the same backend logic.
  • Avoid hard-coded CUDA-only APIs in kernel sources so code is portable between nvcc/cuda and hipcc/ROCm toolchains.

Description

  • Added backend detection and selection to the top-level setup.py using SPLATT3R_GPU_BACKEND with auto|cuda|rocm|cpu options and emit backend-appropriate extra_compile_args and CUDAExtension configuration.
  • Updated splatt3r_slam/backend/src/gn_kernels.cu and splatt3r_slam/backend/src/matching_kernels.cu to conditionally include hip/hip_runtime.h (and hip/hip_fp16.h where needed) under ROCm and to replace cuda::std usage with portable std::numeric_limits.
  • Reworked both curope copies (splatt3r_core/src/.../curope and thirdparty/mast3r/.../curope) to add a CUROPE_GPU_BACKEND auto|cuda|rocm selector in their setup.py and to make kernels.cu use backend-agnostic aliases (gpuGetLastError, gpuGetErrorString, gpuError_t, gpuSuccess) guarded by USE_ROCM/__HIP_PLATFORM_AMD__.
  • Documented ROCm install and build options in README.md and added examples for forcing builds (SPLATT3R_GPU_BACKEND and CUROPE_GPU_BACKEND).

Testing

  • Ran Python syntax checks with python -m py_compile setup.py splatt3r_core/src/mast3r_src/dust3r/croco/models/curope/setup.py thirdparty/mast3r/dust3r/croco/models/curope/setup.py which completed successfully.
  • Verified backend-selection validation by running CUROPE_GPU_BACKEND=invalid python .../curope/setup.py --name which produced the expected RuntimeError for an invalid backend.
  • Confirmed source edits by searching for new ROCm symbols with rg (checks for hip_runtime, hip_fp16, CUROPE_GPU_BACKEND, PYTORCH_ROCM_ARCH, and numeric_limits<scalar_t>::lowest) which matched the updated files.
  • Note: full compilation and runtime validation of the GPU extensions (CUDA or ROCm) could not be completed in this environment because the container lacks a full CUDA/ROCm toolchain and device drivers, so final build verification should be performed on a machine with the target GPU toolchain installed.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant