[TransferEngine][ROCm] Add ROCm HIP support to the Mooncake Python package - #1742
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Mooncake Python package by introducing full support for ROCm HIP. The changes enable AMD GPU transport for Python users, ensuring the end-to-end HIP path is robust and functional, particularly within containerized environments. This broadens the compatibility and utility of the Mooncake Transfer Engine for systems leveraging AMD's ROCm platform. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces comprehensive support for the HIP (Heterogeneous-compute Interface for Portability) transport protocol within the Mooncake Transfer Engine. Key changes include adding HIP-specific headers and transport classes, integrating HIP memory allocation and transport initialization into the Python API, and enabling dynamic selection of cross-node transport based on HIP availability. New Python tests have been added to validate HIP functionality, P2P error handling for HIP has been refined, and the build script has been updated to exclude HIP-related system libraries from the Python wheel. Feedback from the review suggests addressing a redundant xgmi protocol validation in initMemoryAllocator to centralize validation logic, and refactoring duplicated code for installing manual transports in transfer_engine_py.cpp to improve maintainability.
| } else if (strcmp(protocol, "xgmi") == 0) { | ||
| allocateMemory = malloc; | ||
| freeMemory = free; | ||
| LOG(ERROR) << "Protocol 'xgmi' is not exposed in the Python API. " | ||
| << "Use 'hip' instead."; |
There was a problem hiding this comment.
The check for the deprecated xgmi protocol is redundant here. The initializeExt function already performs this validation (lines 189-193) and correctly returns an error code to stop initialization.
This check in initMemoryAllocator only logs an error but allows execution to proceed, which could be confusing. To centralize the validation logic, I recommend removing this else if block.
| if (manual_transport) { | ||
| auto *transport = engine_->installTransport(protocol, nullptr); | ||
| if (!transport) { | ||
| LOG(ERROR) << "Failed to install transport: " << protocol; | ||
| return -1; | ||
| } | ||
| } |
There was a problem hiding this comment.
There's a duplication of the logic for installing manual transports. This block is identical to lines 243-248 within the #ifdef USE_EFA block.
To improve maintainability, consider refactoring this to avoid repeating the code. You could, for example, extract this logic into a helper function or restructure the conditional compilation blocks.
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
| if (USE_HIP) | ||
| add_subdirectory(hip_transport) | ||
| target_sources(transport PUBLIC $<TARGET_OBJECTS:hip_transport>) | ||
| endif() | ||
|
|
||
| if (USE_MNNVL AND NOT USE_HIP) | ||
| add_subdirectory(nvlink_transport) | ||
| target_sources(transport PUBLIC $<TARGET_OBJECTS:nvlink_transport>) |
| #if defined(USE_HIP) | ||
| constexpr const char* kCrossNodeTransport = "hip"; | ||
| constexpr const char* kCrossNodeTransportName = "HIP"; | ||
| #else |
There was a problem hiding this comment.
#if defined (USE_MNNVL) || defined(USE_INTRA_NVLINK)
There was a problem hiding this comment.
Thanks for pointing out this issue. The original code incorrectly treated HIP the same as NVLink (MNNVL), but NVLink is cross-node capable and can replace RDMA, while HIP IPC is intra-node only and should coexist with it. And I fixed this issue in following commits.
| return -1; | ||
| } | ||
|
|
||
| bool manual_transport = strcmp(protocol, "hip") == 0 || |
There was a problem hiding this comment.
Why is manual transport needed? Please provide more design details.
There was a problem hiding this comment.
The manual_transport flag was introduced to disable auto_discover and install HIP explicitly, because we assumed HIP would conflict with the auto-discovered RDMA transport. This was based on a wrong assumption -- we treated HIP the same as NVLink (MNNVL), which replaces RDMA as the cross-node transport. But HIP IPC is actually intra-node only and can coexist with RDMA. Once we moved HIP to an independent install path in TransferEngineImpl::init(), auto_discover=true works correctly and manual_transport is no longer needed. Removed entirely -- the Python binding now matches main behavior. Thanks for pushing on this.
| allocateMemory = malloc; | ||
| freeMemory = free; |
There was a problem hiding this comment.
This logic looks a little bit weird. Why do we need this when NVLink checking fails? Should we put them in the else if (strcmp(protocol, "hip") == 0) block?
There was a problem hiding this comment.
Thank you for pointing this, you're right. Setting allocateMemory = malloc in the error branch silently locked in a wrong allocator state. Removed -- error branches now only log without touching allocator.
alogfans
left a comment
There was a problem hiding this comment.
Please respond all issues.
|
LGTM. Double check if you have time @stmatengss |
amd-arozanov
left a comment
There was a problem hiding this comment.
LGTM. Please fix CI failures, if they are related to the changes from this PR
Expose HIP as the Python-facing AMD GPU transport, wire HIP transport into the build and runtime selection paths, and fix sticky peer-access errors so repeated connector initialization works reliably. Update wheel packaging and container validation to cover ROCm HIP usage in vllm-omni. Signed-off-by: Zejian Wang <zejianwang@sjtu.edu.cn>
HIP IPC is intra-node only and should coexist with RDMA, not replace it. Signed-off-by: Zejian Wang <zejianwang.sjtu.edu.cn> Signed-off-by: Zejian Wang <zejianwang@sjtu.edu.cn>
Signed-off-by: Zejian Wang <zejianwang.sjtu.edu.cn> Signed-off-by: Zejian Wang <zejianwang@sjtu.edu.cn>
Signed-off-by: Zejian Wang <zejianwang@sjtu.edu.cn> Made-with: Cursor Signed-off-by: Zejian Wang <zejianwang@sjtu.edu.cn>
2291334 to
d18c85e
Compare
|
LGTM. @alogfans @amd-arozanov Thank you for reviewing this PR! |
…ckage (kvcache-ai#1742) * Add ROCm HIP support to the Mooncake Python package Expose HIP as the Python-facing AMD GPU transport, wire HIP transport into the build and runtime selection paths, and fix sticky peer-access errors so repeated connector initialization works reliably. Update wheel packaging and container validation to cover ROCm HIP usage in vllm-omni. Signed-off-by: Zejian Wang <zejianwang@sjtu.edu.cn> * [Bugfix] Decouple HIP transport from NVLink branch HIP IPC is intra-node only and should coexist with RDMA, not replace it. Signed-off-by: Zejian Wang <zejianwang.sjtu.edu.cn> Signed-off-by: Zejian Wang <zejianwang@sjtu.edu.cn> * Abandon manual transport Signed-off-by: Zejian Wang <zejianwang.sjtu.edu.cn> Signed-off-by: Zejian Wang <zejianwang@sjtu.edu.cn> * style: apply clang-format to changed files Signed-off-by: Zejian Wang <zejianwang@sjtu.edu.cn> Made-with: Cursor Signed-off-by: Zejian Wang <zejianwang@sjtu.edu.cn> --------- Signed-off-by: Zejian Wang <zejianwang@sjtu.edu.cn> Signed-off-by: Zejian Wang <zejianwang.sjtu.edu.cn> Co-authored-by: Zejian Wang <zejianwang@sjtu.edu.cn>
Expose HIP as the Python-facing AMD GPU transport, wire HIP transport into the build and runtime selection paths, and fix sticky peer-access errors so repeated connector initialization works reliably.
Description
This PR enables ROCm HIP usage from the Mooncake Python package and makes the
end-to-end HIP path usable in containerized environments.
The changes include:
hipas the Python-facing AMD GPU transport in the Python bindingHipTransportindependently from NVIDIA-specificMNNVL logic
hipin the relevant runtime transport-installation pathshipErrorPeerAccessAlreadyEnabledruntime state that couldbreak repeated connector initialization in the same process
without vendoring incompatible ROCm runtime libraries
Module
mooncake-transfer-engine)mooncake-store)mooncake-ep)mooncake-integration)mooncake-p2p-store)mooncake-wheel)mooncake-pg)mooncake-rl)Type of Change
How Has This Been Tested?
dist-rocm-hip.python3 mooncake-wheel/tests/test_transfer_on_hip.pysuccessfully.Checklist
./scripts/code_format.shbefore submitting.