Repository navigation
[EP] Enable the native XPU EP over RDMA - #5207
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Constructor failure paths leak RDMA resources, IPC-only tests can pass without exercising RDMA, and negative source GPU indices can cause out-of-bounds access.
4 open issues
What changed in this PR
Adds multi-node Intel XPU support to Mooncake EP through a host-driven RDMA path, while retaining Level Zero IPC for local peers and the collective fallback when native setup fails.
Changes:
- Adds RDMA setup, proxy transfers, and hybrid dispatch/combine buffer layouts.
- Extends validation with multi-node launches, hardware checks, bandwidth benchmarks, and FP8 rounding tests.
- Documents the design, measured behavior, and remaining multi-node validation.
| File | Description |
|---|---|
python/tests/ep/test_mooncake_ep_xpu.py |
Adds torchrun support and native/fallback path checks. |
python/tests/ep/test_fp8_cast.py |
Adds exact FP8 rounding regression coverage. |
python/mooncake/mooncake_ep_buffer.py |
Adds XPU RDMA bootstrap and adjusts fallback FP8 rounding. |
mooncake-ep/tests/xpu_rdma_test.cpp |
Checks RDMA payload visibility and signaling on hardware. |
mooncake-ep/tests/xpu_ep_hybrid_test.cpp |
Validates hybrid layouts with simulated remote transfers. |
mooncake-ep/src/xpu/xpu_rdma.h |
Declares RDMA device, memory, and queue-pair interfaces. |
mooncake-ep/src/xpu/xpu_rdma.cpp |
Implements NIC selection, registration, and RDMA writes. |
mooncake-ep/src/xpu/xpu_ipc.h |
Exposes the Level Zero context for registration. |
mooncake-ep/src/xpu/xpu_ipc.cpp |
Enables dma-buf export for RDMA-capable builds. |
mooncake-ep/src/xpu/xpu_ep_proxy.h |
Declares the asynchronous host transfer proxy. |
mooncake-ep/src/xpu/xpu_ep_proxy.cpp |
Implements remote connections and queued writes. |
mooncake-ep/src/xpu/xpu_ep_kernels.h |
Adds hybrid kernel arguments and transfer descriptors. |
mooncake-ep/src/xpu/xpu_ep_kernels.cpp |
Implements remote staging, receiving, and transfer plans. |
mooncake-ep/src/xpu/xpu_ep_common.h |
Extends buffer layouts for hybrid transfers. |
mooncake-ep/src/xpu/mooncake_ep_xpu_buffer.h |
Adds RDMA setup interfaces and hybrid state. |
mooncake-ep/src/xpu/mooncake_ep_xpu_buffer.cpp |
Integrates proxy transfers into the native buffer lifecycle. |
mooncake-ep/src/ep_py.cpp |
Exposes XPU RDMA setup through Python bindings. |
mooncake-ep/src/CMakeLists.txt |
Detects RDMA support and adds validation targets. |
mooncake-ep/benchmarks/xpu_peer_bw.cpp |
Adds configurable intra-node peer bandwidth measurements. |
docs/source/index.md |
Links the multi-node XPU design page. |
docs/source/design/mooncake-ep.md |
Updates the XPU transport overview. |
docs/source/design/mooncake-ep-xpu-multinode.md |
Documents architecture, validation stages, and measurements. |
Review effort: Balanced
| XPU_EP_CHECK(port_attr_.state == IBV_PORT_ACTIVE, | ||
| name + " port " + std::to_string(port_) + " is not active"); | ||
| pd_ = ibv_alloc_pd(ctx_); | ||
| XPU_EP_CHECK(pd_, "ibv_alloc_pd failed on " + name); |
| qp_ = ibv_create_qp(device_.pd_, &init); | ||
| XPU_EP_CHECK(qp_, | ||
| "ibv_create_qp on " + device_.name_ + ": " + errnoText(errno)); |
| if (a.src_gpu >= static_cast<int>(gpus.size()) || | ||
| dst_gpu >= static_cast<int>(gpus.size())) |
| if not self.runtime.rdma_available(): | ||
| warnings.warn( | ||
| f"[Rank {self.rank}] ranks on other nodes need the XPU verbs " | ||
| "path, which this build lacks (rdma-core with " | ||
| "ibv_reg_dmabuf_mr)", | ||
| RuntimeWarning, | ||
| stacklevel=3, | ||
| ) | ||
| else: | ||
| try: | ||
| info = list(self.runtime.init_rdma(remote)) | ||
| except Exception as e: | ||
| warnings.warn( | ||
| f"[Rank {self.rank}] XPU RDMA setup failed: {e}", | ||
| RuntimeWarning, | ||
| stacklevel=3, | ||
| ) |
e70dbc5 to
76e0eb2
Compare
446a893 to
47463fc
Compare
|
[Functionality]: On one node with 8 B60s and 4 mlx5 NICs (dual-port), test_mooncake_ep_xpu.py passes with MC_EP_RANKS_PER_NODE unset (all IPC), 4 (mixed IPC and RDMA) and 1 (all RDMA).
|
|
[Benchmark]: native RDMA vs native IPC between ranks on one host Setup: one host with 8× Arc Pro B60 and one RDMA NIC port per XPU. 8 ranks, hidden 7168, 64 experts, top-k 8, random routing. Times are in µs for the slowest rank.
[MC_EP_RANKS_PER_NODE=1] python mooncake-ep/benchmarks/xpu_buffer_perf.py --num-ranks 8 \
--hidden 7168 --experts 64 --topk 8 --tokens 1,16,64,128 --pipelined [--weights-at-dispatch --fp8]
Summary
Steady state, BF16 (
|
| tokens | dispatch IPC | dispatch RDMA | speedup | round trip IPC | round trip RDMA | speedup |
|---|---|---|---|---|---|---|
| 1 | 99.6 | 117.9 | 0.84× | 149.5 | 145.9 | 1.02× |
| 16 | 459.7 | 166.8 | 2.76× | 1074.9 | 268.8 | 4.00× |
| 64 | 1467.5 | 384.4 | 3.82× | 2807.5 | 781.8 | 3.59× |
| 128 | 1612.3 | 718.6 | 2.24× | 3494.4 | 1466.8 | 2.38× |
Closest to an MoE layer (--pipelined --weights-at-dispatch --fp8)
| tokens | dtype | dispatch IPC | dispatch RDMA | speedup | round trip IPC | round trip RDMA | speedup |
|---|---|---|---|---|---|---|---|
| 1 | bf16 | 97.9 | 145.5 | 0.67× | 136.1 | 201.9 | 0.67× |
| 1 | fp8 | 126.4 | 135.2 | 0.93× | 147.2 | 192.4 | 0.77× |
| 16 | bf16 | 483.4 | 149.7 | 3.23× | 931.7 | 304.2 | 3.06× |
| 16 | fp8 | 253.3 | 142.6 | 1.78× | 596.3 | 231.4 | 2.58× |
| 64 | bf16 | 1358.1 | 400.0 | 3.40× | 2354.4 | 681.8 | 3.45× |
| 64 | fp8 | 601.2 | 248.9 | 2.42× | 1504.8 | 508.5 | 2.96× |
| 128 | bf16 | 1768.6 | 698.9 | 2.53× | 2973.2 | 1243.0 | 2.39× |
| 128 | fp8 | 775.3 | 404.0 | 1.92× | 2201.4 | 966.2 | 2.28× |
Without --pipelined (median, µs)
Each iteration starts from a CPU barrier with an idle GPU. That adds a floor of about 1.1 ms, which dominates at small token counts, so these numbers say little about the transport.
| config | tokens | dtype | IPC dispatch / round trip | RDMA dispatch / round trip |
|---|---|---|---|---|
--weights-at-dispatch |
1 | bf16 | 1085.1 / 1183.4 | 1226.4 / 1571.1 |
| 16 | bf16 | 1204.4 / 1740.2 | 1374.7 / 1433.7 | |
| 64 | bf16 | 2037.5 / 3713.0 | 1577.6 / 1905.8 | |
| 128 | bf16 | 2209.2 / 4084.5 | 1979.9 / 2555.3 | |
--fp8 |
1 | bf16 | 1102.8 / 1350.9 | 1202.1 / 1274.9 |
| 1 | fp8 | 1151.3 / 1448.7 | 1450.7 / 1459.7 | |
| 16 | bf16 | 1271.0 / 1948.3 | 1350.1 / 1529.0 | |
| 16 | fp8 | 1263.0 / 2056.7 | 1408.6 / 1521.0 | |
| 64 | bf16 | 1765.6 / 3854.7 | 1677.2 / 1878.3 | |
| 64 | fp8 | 1250.6 / 3031.4 | 1750.5 / 1866.6 | |
| 128 | bf16 | 2044.0 / 4698.2 | 2035.7 / 2628.2 | |
| 128 | fp8 | 1083.3 / 3223.0 | 1807.1 / 2425.1 |
|
Hi @UNIDY2002 @staryxchen @alogfans , could you pls have a look? It's to add a basic native XPU EP over RDMA. thx P.S., . Current validations are run on one host with 8 x B60 GPU and 4 x dual-port ConnectX-7 NIC. It also did some benchmarks compared to native XPU EP over IPC(PCIe) that only reflects the results on current test setup. We may do more tuning and cross-node test later. Let's have basic functionality in place first. |
|
Thanks for this substantial contribution. Native XPU EP over RDMA is a useful capability, and the proxy pattern seems broadly applicable to other platforms, including platforms without IBGDA and CI environments where only TCP is available. I would like to discuss two points:
These two questions are open for discussion. |
Hi @UNIDY2002 , Thanks for review and yes that makes sense! My suggestion is to make native XPU EP over RDMA in upstream first. Afterwards I will raise a RFC to abstract proxy mode with a general backend (may also collect broad opinions from different vendors) and refactor XPU as well with a separate PR. WDYT? I understand the proposed TCP transport backend is just for CI setup with NICs which do not support RDMA? However the proxy mode is mainly designed for GDR and we need to double check it along with above RFC. One more potential point is about GDA abstraction. I may also look into it when I enable XPU EP over GDA in next phase. That's another topic we may investigate together as well later. |
UNIDY2002
left a comment
There was a problem hiding this comment.
Thank you for your significant work.
After careful consideration, I draw back my proposal on the TCP fallback, as it is quite strange to have a CI environment which could run the GPU kernels but only have TCP transport. Also, the proxy abstraction is just an optional bonus. I think this PR is ready to merge.
Ranks on different nodes can now use the native path instead of the
Python fallback: a host proxy pushes to them over RDMA. Ranks on one
node can also use RDMA between them by setting MC_EP_RANKS_PER_NODE=n.
- Verbs (xpu_rdma.{h,cpp}): picks the NIC nearest the GPU by sysfs path
and a RoCE v2 GID (MC_EP_XPU_NIC / MC_EP_XPU_GID_INDEX override),
registers the Level Zero buffer, which xpu_ipc.cpp now exports as a
dma-buf, and wraps an RC queue pair: write(), an inline writeValue()
for flags, poll().
- Layout: per source, a landing zone for dispatch metadata and a combine
inbox; per destination, an outbox. The size hint includes them.
- Kernels: dispatch_send copies messages for remote ranks to the
outbox, and both send kernels record per-rank counts in host memory.
For sources on other nodes, dispatch_recv reads the metadata from the
landing zone and the messages from the local stage, and combine_recv
reads rows from the inbox after waiting for their flags in one
work-group, since many polling work-groups slow incoming RDMA writes.
- Proxy (xpu_ep_proxy.cpp): waits for each send kernel, then posts the
data writes and, last, the ready flag, so receivers wait for the data
by polling the flag.
- Python: connect() sets up RDMA when a rank has peers on other nodes;
if any rank fails, all take the fallback.
- RDMA is compiled in only when rdma-core has ibv_reg_dmabuf_mr;
otherwise _ep reaches only ranks on its node.
- test_mooncake_ep_xpu.py can also be launched by torchrun, on one node
or several.
- mooncake-ep.md documents the RDMA path and MC_EP_RANKS_PER_NODE.
Two tests, not built by default:
- xpu_rdma_test, built only with ibv_reg_dmabuf_mr, RDMA-writes a
payload and then a flag between XPUs on two NICs, and checks the
payload once a kernel on the receiver sees the flag. No flush READ
before the flag was needed on B60.
- xpu_ep_hybrid_test checks the RDMA path without a NIC: the ranks of a
simulated multi-node group share one GPU and run the real kernels and
dispatch_puts / combine_puts. Only the proxy is replaced: the test
applies its writes as device copies, after every send kernel and
before every receive kernel.
On one node with 8 B60s and 4 mlx5 NICs, test_mooncake_ep_xpu.py passes
with MC_EP_RANKS_PER_NODE unset (IPC), 4 (mixed IPC and RDMA) and 1
(RDMA).
Signed-off-by: Zhan Xue <zhan.xue@intel.com>
nearestRdmaDevice() took the first NIC by name among those nearest the GPU. Both ports of a dual-port card are always equally near, so two GPUs beside one card shared its first port and the second port went unused. Now the GPUs nearest the same set of NICs take them in turn, in PCI order. GPUs are enumerated from sysfs, so the choice does not depend on which devices a process can see. With one NIC per GPU nothing changes. Signed-off-by: Zhan Xue <zhan.xue@intel.com>
With --fp8, combine() built its stand-in expert output by casting the whole receive buffer, [local experts, ranks x max tokens, hidden], to BF16 on every call, inside the timed dispatch+combine region. The cast does not depend on the token count and is not EP work, yet it dominated the FP8 round trip: on Arc Pro B60 it takes 5.4 ms for 64 x 512 x 7168, and FP8 round trips read a near-constant 4.3-4.5 ms above BF16 at 4 and 8 ranks. Cast once, on the first call, which falls in warmup, and reuse the result. FP8 dispatch-only and all BF16 numbers are unaffected. Signed-off-by: Zhan Xue <zhan.xue@intel.com>
The XPU hybrid path staged every dispatch message in the outbox and the receiver's local stage at the BF16 message stride, and the proxy wrote n * BF16 size per peer. An FP8 dispatch therefore sent as many bytes over RDMA as a BF16 one, about half of them padding: on 8 ranks with MC_EP_RANKS_PER_NODE=1, FP8 cut RDMA dispatch at 128 tokens by only 15%, against 2.3x on the PCIe pull path. Use the call's own message size as the stride in the send kernel, the receive kernel and dispatch_puts. All ranks agree on the dtype of a call and the stage only lives within one, so the buffer layout, still sized for BF16, is unchanged. Same 8-rank RDMA setup, --pipelined --weights-at-dispatch --fp8, 128 tokens: FP8 dispatch 600 -> 365 us (now 1.8x faster than BF16), dispatch plus combine 1159 -> 911 us. The PCIe pull path is unchanged (dispatch 763 -> 754 us). test_mooncake_ep_xpu.py passes on 8 ranks over both paths. Signed-off-by: Zhan Xue <zhan.xue@intel.com>
Signed-off-by: Zhan Xue <zhan.xue@intel.com>
* upstream/main: (28 commits) [Store] Remove unreachable dead code in reserved OpLog paths (kvcache-ai#5043) [Store][BUGFIX]: Avoid repeated NoF cleanup for unregistered buffers (kvcache-ai#5301) [Store] Fence the local disk tier on the first unrecoverable disk error (kvcache-ai#4490) [Store] Add opt-in aligned O_DIRECT bucket writes (kvcache-ai#4820) [Store] posix support Read DFS replicas straight into host buffers (kvcache-ai#5201) [TENT] Pipeline RDMA slice preparation with worker posting (kvcache-ai#5277) [TE] HipTransport: submit copies asynchronously, one stream and event per device (kvcache-ai#4953) [Misc] Add staryxchen as a HIP transport code owner (kvcache-ai#5351) [Doc] nvlink_intra works over PCIe P2P, not only NVLink (kvcache-ai#5266) [Bugfix][TENT] Propagate io_uring staging copy failures (kvcache-ai#5335) [Bugfix][TENT] Make UB batch submission all-or-nothing (kvcache-ai#5274) Add store rs tone tests (kvcache-ai#5282) [EP] Validate XPU Buffer constructor arguments (kvcache-ai#5329) [EP] Decouple PG builds and add TCPStore bootstrap (kvcache-ai#5312) [Bugfix][PG] Serialize RPC socket operations and drain shutdown (kvcache-ai#5098) [EP] Enable the native XPU EP over RDMA (kvcache-ai#5207) [Store] Use the AWS default credential chain when S3 static keys are unset (kvcache-ai#5303) [Bugfix][Store] Register dummy query RPC handlers in mooncake_client (kvcache-ai#5200) [Store] Preserve variadic RPC compatible fields with NDEBUG (kvcache-ai#5269) [TransferEngine] Avoid false CQ timeout diagnostics after idle periods (kvcache-ai#5281) ...

Description
Ranks on different nodes can now use the native path (a host proxy pushes to them over RDMA) instead of the
Python fallback. Ranks on one node can also use RDMA between them by setting MC_EP_RANKS_PER_NODE=n.
Two tests, not built by default:
On one node with 8 B60s and 4 mlx5 NICs, test_mooncake_ep_xpu.py passes with MC_EP_RANKS_PER_NODE unset (all IPC), 4 (mixed IPC and RDMA) and 1 (all RDMA).
Suggested Merge Priority
Module
mooncake-transfer-engine)mooncake-store)mooncake-conductor)mooncake-reshard)mooncake-ep)mooncake-pg)mooncake-integration)mooncake-p2p-store)mooncake-wheel)mooncake-common)mooncake-rl)Type of Change
How Has This Been Tested?
Test commands:
# Example: bash scripts/run_ci_test.shTest results:
Checklist
Signed-off-bytrailer certifying the DCO./scripts/code_format.shAI Assistance Disclosure