Add AMD ROCm/HIP support (2-line fix)#17
Closed
ZJLi2013 wants to merge 4 commits intoJeffreyXiang:mainfrom
Closed
Conversation
Made-with: Cursor
Made-with: Cursor
Made-with: Cursor
Made-with: Cursor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Enable FlexGEMM to compile and run on AMD GPUs (ROCm/HIP) with only 2 lines of core code changed.
Changes
flex_gemm/kernels/cuda/spconv/migemm_neighmap_pp.cu#define __syncwarp(...) __builtin_amdgcn_wave_barrier()(guarded by__HIP_PLATFORM_AMD__)__syncwarp()(no-arg form) is not in HIP builtins. AMD wavefronts execute in SIMD lockstep, sowave_barrieris semantically equivalent.flex_gemm/kernels/triton/spconv/config.pyallow_tf32 = not torch.version.hipieeeprecision (fp32/fp16). The Triton kernels already haveinput_precision='tf32' if allow_tf32 else 'ieee'branching — this change just sets the flag correctly at config level.Scope
Covered (tested and passing):
IMPLICIT_GEMM,IMPLICIT_GEMM_SPLITK,MASKED_IMPLICIT_GEMM,MASKED_IMPLICIT_GEMM_SPLITKsetup.pyNot tested:
EXPLICIT_GEMM(puretorch.mm/ im2col path — expected to work via hipBLAS, but not explicitly verified)Usage on AMD GPUs
Testing
Hardware: AMD Instinct MI300X
Software: ROCm 6.4.3, PyTorch 2.6.0, Triton 3.2.0
Docker: rocm/pytorch:rocm6.4.3_ubuntu24.04_py3.12_pytorch_release_2.6.0
Notes
Complementary to PR #15 (which added a missing __syncwarp in neighbor_map.cu for NVIDIA correctness). This PR fixes a different file (migemm_neighmap_pp.cu) for AMD/HIP portability.
setup.py already has robust HIP support (IS_HIP_EXTENSION, --offload-arch). hipify auto-converted 100% of CUDA calls (0 unsupported). No build system changes needed.
warpSize 32 vs 64 difference caused zero failures — the existing adaptive logic in reduce_code_kernel handles 64-wide wavefronts correctly.