mirror of
https://github.com/kvcache-ai/Mooncake.git
synced 2026-11-05 01:17:55 +00:00
[GH-ISSUE #674] [Feature Request]: [TransferEngine] Migrate RDMA to use dma buf compatible library calls (ie ibv_reg_mr(...) calls to ibv_reg_dmabuf_mr(...)) #216
Labels
No labels
ascend
auto-closed
bug
bug
CI/Build
Common
documentation
enhancement
feature request
good first issue
help wanted
high priority
MetaX
nightly-failure
pull-request
PyTorch Backend
question
RFC
Roadmap
stale
Store
Tests
Transfer Engine
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
kvcache-ai/Mooncake#216
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @misterwilliam on GitHub (Jul 25, 2025).
Original GitHub issue: https://github.com/kvcache-ai/Mooncake/issues/674
Describe your feature request
I would like to run Mooncake in an environment where nvidia-peermem is not installed.
To do that I need to migrate the RDMA memory register from using ibv_reg_mr(...) to using ibv_reg_dmabuf_mr(...). Also before calling I will also need to call cuMemGetHandleForAddressRange()2 to get the dma buf struct. This should have no performance impact, it just changes the way these libraries are called.
Using ibv_reg_mr(...) is considered deprecated 1 and using ibv_reg_dma_mr(...) is the new way which does not rely on proprietary software. Some more historical / technical background on this can be found here: https://medium.com/@datenlord/the-evolution-and-implementation-of-gpudirect-rdma-19751f7b9413
I am happy to contribute the pull request to make this happen. I just wanted to start the conversation.
Proposed code change:
Before submitting a new issue...
@staryxchen commented on GitHub (Jul 26, 2025):
Are you trying to run Mooncake in a non-Nvidia environment (GPU/RDMA NIC)? If so, I think we can control the use of different APIs to adapt to different hardware environments through compilation options.
@misterwilliam commented on GitHub (Jul 26, 2025):
I am trying to use Mooncake with nvidia (b200), but I am trying to run with (Google) GKE Autopilot which uses COS (Container Optimized OS) which has constraints on being allowed to install kernel modules (ie install nvidia-peermem is not allowed).
My change should be thought of the updating nvidia RDMA implementation from deprecated API to supported API. I've updated my initial proposal with a proposed code change snippet to show it can be made to made backwards compatible in situations where dma-buf is not supported.
@stmatengss commented on GitHub (Jul 27, 2025):
Regarding the difference between
ibv_reg_mrandibv_reg_dma_mr(see https://forums.developer.nvidia.com/t/gpudirect-rdma-difference-between-ibv-reg-mr-and-ibv-reg-dmabuf-mr/262313, https://man7.org/linux/man-pages/man3/ibv_reg_mr.3.html), it appears thatibv_reg_dma_mris the preferred alternative toibv_reg_mrwhen the NV peer-memory driver is unavailable. My concern is ensuring DRAM compatibility across all RDMA transport paths, as we don't differentiate between VRAM and DRAM.@stmatengss commented on GitHub (Jul 27, 2025):
That's correct; it should be done in the compilation stage.
@misterwilliam commented on GitHub (Jul 27, 2025):
So it sounds like we want to:
ibv_dmabuf_reg_mr(). Otherwise useibv_reg_mr()So something like this:
@stmatengss commented on GitHub (Jul 28, 2025):
Yes. Most users use GDR-based VRAM-to-VRAM transfer. Using compilation options can reduce code changes. Welcome to submit a PR
@misterwilliam commented on GitHub (Jul 29, 2025):
Sounds good. I expect I will get it ready in the next couple of days.
@misterwilliam commented on GitHub (Jul 31, 2025):
I made a pull request. Some things worth highlighting.
ibv_dmabuf_reg_mr()returns aibv_mrstruct with addr set to the offset link. There is existing code that assumesibv_mr->addris always set to the start of the memory region. I created a new structMrMetato track this info since we can't rely onibv_mrto track it and updated all existing usage to useMrMeta.