Skip to content

[EP] Enable the native XPU EP over RDMA - #5207

Merged
UNIDY2002 merged 5 commits into
kvcache-ai:mainfrom
zxue2:xpu_ep_multinode
Nov 6, 2026
Merged

UNIDY2002 merged 5 commits into
kvcache-ai:mainfrom
zxue2:xpu_ep_multinode

Conversation

@zxue2

@zxue2 zxue2 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

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.

  • 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 (all IPC), 4 (mixed IPC and RDMA) and 1 (all RDMA).

Suggested Merge Priority

  • P0 — Urgent: Critical security vulnerability, data loss/corruption, or widespread production outage requiring immediate action
  • P1 — High: Significant correctness or stability issue in existing functionality, or a regression blocking users without a practical workaround
  • P2 — Normal: Routine bug fix, validated performance/compatibility improvement, or new feature for a confirmed use case
  • P3 — Low: Experimental feature, optional enhancement, refactoring, or cleanup with no urgent user impact

Module

  • Transfer Engine (mooncake-transfer-engine)
  • Mooncake Store (mooncake-store)
  • Mooncake Conductor (mooncake-conductor)
  • Reshard (mooncake-reshard)
  • Mooncake EP (mooncake-ep)
  • Mooncake PG (mooncake-pg)
  • Integration (mooncake-integration)
  • P2P Store (mooncake-p2p-store)
  • Python Wheel (mooncake-wheel)
  • Common (mooncake-common)
  • Mooncake RL (mooncake-rl)
  • CI/CD
  • Docs
  • Other

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Breaking change
  • Documentation update
  • Performance improvement
  • Other

How Has This Been Tested?

Test commands:

# Example: bash scripts/run_ci_test.sh

Test results:

  • Unit tests pass
  • Integration tests pass (if applicable)
  • Manual testing done (describe below)

Checklist

  • Every commit I contribute includes my Signed-off-by trailer certifying the DCO
  • I have performed a self-review of my own code
  • I have formatted my code using ./scripts/code_format.sh
  • I have run pre-commit on the files changed in this PR and all hooks pass
  • I have updated the documentation (if applicable)
  • I have added tests to prove my changes are effective
  • For changes >500 LOC: I have filed an RFC issue

AI Assistance Disclosure

  • No AI tools were used
  • AI tools were used (specify below)

Copilot AI balanced review requested due to automatic review settings November 3, 2026 16:18
@github-actions github-actions Bot added size/L 1001+ changed lines (additions + deletions) documentation Improvements or additions to documentation run-ci Mooncake EP Tests labels Nov 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Comment on lines +181 to +184
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);
Comment on lines +251 to +253
qp_ = ibv_create_qp(device_.pd_, &init);
XPU_EP_CHECK(qp_,
"ibv_create_qp on " + device_.name_ + ": " + errnoText(errno));
Comment on lines +281 to +282
if (a.src_gpu >= static_cast<int>(gpus.size()) ||
dst_gpu >= static_cast<int>(gpus.size()))
Comment on lines +822 to +838
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,
)
@zxue2
zxue2 force-pushed the xpu_ep_multinode branch 2 times, most recently from e70dbc5 to 76e0eb2 Compare November 4, 2026 13:43
@zxue2 zxue2 changed the title Enable XPU EP Multi-node [EP] Enable the native XPU EP over RDMA Nov 4, 2026
@zxue2
zxue2 force-pushed the xpu_ep_multinode branch 3 times, most recently from 446a893 to 47463fc Compare November 6, 2026 08:03
@zxue2

zxue2 commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

[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).

MC_EP_RANKS_PER_NODE=1 python python/tests/ep/test_mooncake_ep_xpu.py --num-ranks 8

...
I20261106 14:57:56.847707 808440 xpu_ep_proxy.cpp:56] [EP XPU] rank 1 reaches other nodes through mlx5_1 (GID index 3)
I20261106 14:57:56.851339 808446 xpu_ep_proxy.cpp:56] [EP XPU] rank 7 reaches other nodes through mlx5_7 (GID index 3)
I20261106 14:57:56.851362 808439 xpu_ep_proxy.cpp:56] [EP XPU] rank 0 reaches other nodes through mlx5_0 (GID index 3)
I20261106 14:57:56.853020 808441 xpu_ep_proxy.cpp:56] [EP XPU] rank 2 reaches other nodes through mlx5_2 (GID index 3)
I20261106 14:57:56.859012 808444 xpu_ep_proxy.cpp:56] [EP XPU] rank 5 reaches other nodes through mlx5_5 (GID index 3)
I20261106 14:57:56.861195 808443 xpu_ep_proxy.cpp:56] [EP XPU] rank 4 reaches other nodes through mlx5_4 (GID index 3)
I20261106 14:57:56.864048 808442 xpu_ep_proxy.cpp:56] [EP XPU] rank 3 reaches other nodes through mlx5_3 (GID index 3)
I20261106 14:57:56.864246 808445 xpu_ep_proxy.cpp:56] [EP XPU] rank 6 reaches other nodes through mlx5_6 (GID index 3)
round 0: tokens=0 fp8=False hook=False weights_at_dispatch=False ok
round 1: tokens=1 fp8=True hook=False weights_at_dispatch=False ok
round 2: tokens=128 fp8=False hook=True weights_at_dispatch=False ok
round 3: tokens=113 fp8=True hook=True weights_at_dispatch=False ok
round 4: tokens=30 fp8=False hook=False weights_at_dispatch=True ok
round 5: tokens=2 fp8=True hook=False weights_at_dispatch=True ok
round 6: tokens=24 fp8=False hook=True weights_at_dispatch=True ok
round 7: tokens=9 fp8=True hook=True weights_at_dispatch=True ok
round 8: tokens=22 fp8=False hook=False weights_at_dispatch=False ok
round 9: tokens=26 fp8=True hook=False weights_at_dispatch=False ok
round 10: tokens=91 fp8=False hook=True weights_at_dispatch=False ok
round 11: tokens=61 fp8=True hook=True weights_at_dispatch=False ok
round 12: tokens=5 fp8=False hook=False weights_at_dispatch=True ok
round 13: tokens=8 fp8=True hook=False weights_at_dispatch=True ok
round 14: tokens=5 fp8=False hook=True weights_at_dispatch=True ok
I20261106 14:59:44.575368 808442 xpu_ep_proxy.cpp:56] [EP XPU] rank 3 reaches other nodes through mlx5_3 (GID index 3)
I20261106 14:59:44.578131 808445 xpu_ep_proxy.cpp:56] [EP XPU] rank 6 reaches other nodes through mlx5_6 (GID index 3)
I20261106 14:59:44.580003 808440 xpu_ep_proxy.cpp:56] [EP XPU] rank 1 reaches other nodes through mlx5_1 (GID index 3)
I20261106 14:59:44.580379 808439 xpu_ep_proxy.cpp:56] [EP XPU] rank 0 reaches other nodes through mlx5_0 (GID index 3)
I20261106 14:59:44.580489 808441 xpu_ep_proxy.cpp:56] [EP XPU] rank 2 reaches other nodes through mlx5_2 (GID index 3)
I20261106 14:59:44.580972 808446 xpu_ep_proxy.cpp:56] [EP XPU] rank 7 reaches other nodes through mlx5_7 (GID index 3)
I20261106 14:59:44.581346 808444 xpu_ep_proxy.cpp:56] [EP XPU] rank 5 reaches other nodes through mlx5_5 (GID index 3)
I20261106 14:59:44.581902 808443 xpu_ep_proxy.cpp:56] [EP XPU] rank 4 reaches other nodes through mlx5_4 (GID index 3)
I20261106 14:59:44.638283 808442 xpu_ep_proxy.cpp:56] [EP XPU] rank 3 reaches other nodes through mlx5_3 (GID index 3)
I20261106 14:59:44.642408 808445 xpu_ep_proxy.cpp:56] [EP XPU] rank 6 reaches other nodes through mlx5_6 (GID index 3)
I20261106 14:59:44.643896 808441 xpu_ep_proxy.cpp:56] [EP XPU] rank 2 reaches other nodes through mlx5_2 (GID index 3)
I20261106 14:59:44.644484 808439 xpu_ep_proxy.cpp:56] [EP XPU] rank 0 reaches other nodes through mlx5_0 (GID index 3)
I20261106 14:59:44.645294 808440 xpu_ep_proxy.cpp:56] [EP XPU] rank 1 reaches other nodes through mlx5_1 (GID index 3)
I20261106 14:59:44.645443 808444 xpu_ep_proxy.cpp:56] [EP XPU] rank 5 reaches other nodes through mlx5_5 (GID index 3)
I20261106 14:59:44.645462 808443 xpu_ep_proxy.cpp:56] [EP XPU] rank 4 reaches other nodes through mlx5_4 (GID index 3)
I20261106 14:59:44.645900 808446 xpu_ep_proxy.cpp:56] [EP XPU] rank 7 reaches other nodes through mlx5_7 (GID index 3)
PASSED: 15 rounds + 2 empty-rank rounds + 4 two-batch rounds + duplicate experts + reused src_info + rejected handle + cross-stream + fallback agreement + dead-rank timeout on 8 ranks (hidden=7168, experts=64, topk=8)

MC_EP_RANKS_PER_NODE=4 python python/tests/ep/test_mooncake_ep_xpu.py --num-ranks 8

...
I20261106 15:00:16.615023 809889 xpu_ep_proxy.cpp:56] [EP XPU] rank 0 reaches other nodes through mlx5_0 (GID index 3)
I20261106 15:00:16.644410 809894 xpu_ep_proxy.cpp:56] [EP XPU] rank 5 reaches other nodes through mlx5_5 (GID index 3)
I20261106 15:00:16.666280 809892 xpu_ep_proxy.cpp:56] [EP XPU] rank 3 reaches other nodes through mlx5_3 (GID index 3)
I20261106 15:00:16.670405 809896 xpu_ep_proxy.cpp:56] [EP XPU] rank 7 reaches other nodes through mlx5_7 (GID index 3)
I20261106 15:00:16.670410 809891 xpu_ep_proxy.cpp:56] [EP XPU] rank 2 reaches other nodes through mlx5_2 (GID index 3)
I20261106 15:00:16.670710 809890 xpu_ep_proxy.cpp:56] [EP XPU] rank 1 reaches other nodes through mlx5_1 (GID index 3)
I20261106 15:00:16.672021 809893 xpu_ep_proxy.cpp:56] [EP XPU] rank 4 reaches other nodes through mlx5_4 (GID index 3)
I20261106 15:00:16.672076 809895 xpu_ep_proxy.cpp:56] [EP XPU] rank 6 reaches other nodes through mlx5_6 (GID index 3)
round 0: tokens=0 fp8=False hook=False weights_at_dispatch=False ok
round 1: tokens=1 fp8=True hook=False weights_at_dispatch=False ok
round 2: tokens=128 fp8=False hook=True weights_at_dispatch=False ok
round 3: tokens=113 fp8=True hook=True weights_at_dispatch=False ok
round 4: tokens=30 fp8=False hook=False weights_at_dispatch=True ok
round 5: tokens=2 fp8=True hook=False weights_at_dispatch=True ok
round 6: tokens=24 fp8=False hook=True weights_at_dispatch=True ok
round 7: tokens=9 fp8=True hook=True weights_at_dispatch=True ok
round 8: tokens=22 fp8=False hook=False weights_at_dispatch=False ok
round 9: tokens=26 fp8=True hook=False weights_at_dispatch=False ok
round 10: tokens=91 fp8=False hook=True weights_at_dispatch=False ok
round 11: tokens=61 fp8=True hook=True weights_at_dispatch=False ok
round 12: tokens=5 fp8=False hook=False weights_at_dispatch=True ok
round 13: tokens=8 fp8=True hook=False weights_at_dispatch=True ok
round 14: tokens=5 fp8=False hook=True weights_at_dispatch=True ok
I20261106 15:02:01.364485 809890 xpu_ep_proxy.cpp:56] [EP XPU] rank 1 reaches other nodes through mlx5_1 (GID index 3)
I20261106 15:02:01.364678 809892 xpu_ep_proxy.cpp:56] [EP XPU] rank 3 reaches other nodes through mlx5_3 (GID index 3)
I20261106 15:02:01.364929 809896 xpu_ep_proxy.cpp:56] [EP XPU] rank 7 reaches other nodes through mlx5_7 (GID index 3)
I20261106 15:02:01.367147 809891 xpu_ep_proxy.cpp:56] [EP XPU] rank 2 reaches other nodes through mlx5_2 (GID index 3)
I20261106 15:02:01.367419 809894 xpu_ep_proxy.cpp:56] [EP XPU] rank 5 reaches other nodes through mlx5_5 (GID index 3)
I20261106 15:02:01.368656 809889 xpu_ep_proxy.cpp:56] [EP XPU] rank 0 reaches other nodes through mlx5_0 (GID index 3)
I20261106 15:02:01.369187 809893 xpu_ep_proxy.cpp:56] [EP XPU] rank 4 reaches other nodes through mlx5_4 (GID index 3)
I20261106 15:02:01.369866 809895 xpu_ep_proxy.cpp:56] [EP XPU] rank 6 reaches other nodes through mlx5_6 (GID index 3)
I20261106 15:02:01.421362 809896 xpu_ep_proxy.cpp:56] [EP XPU] rank 7 reaches other nodes through mlx5_7 (GID index 3)
I20261106 15:02:01.421906 809890 xpu_ep_proxy.cpp:56] [EP XPU] rank 1 reaches other nodes through mlx5_1 (GID index 3)
I20261106 15:02:01.421919 809892 xpu_ep_proxy.cpp:56] [EP XPU] rank 3 reaches other nodes through mlx5_3 (GID index 3)
I20261106 15:02:01.422879 809891 xpu_ep_proxy.cpp:56] [EP XPU] rank 2 reaches other nodes through mlx5_2 (GID index 3)
I20261106 15:02:01.423252 809893 xpu_ep_proxy.cpp:56] [EP XPU] rank 4 reaches other nodes through mlx5_4 (GID index 3)
I20261106 15:02:01.423416 809894 xpu_ep_proxy.cpp:56] [EP XPU] rank 5 reaches other nodes through mlx5_5 (GID index 3)
I20261106 15:02:01.423866 809895 xpu_ep_proxy.cpp:56] [EP XPU] rank 6 reaches other nodes through mlx5_6 (GID index 3)
I20261106 15:02:01.423946 809889 xpu_ep_proxy.cpp:56] [EP XPU] rank 0 reaches other nodes through mlx5_0 (GID index 3)
PASSED: 15 rounds + 2 empty-rank rounds + 4 two-batch rounds + duplicate experts + reused src_info + rejected handle + cross-stream + fallback agreement + dead-rank timeout on 8 ranks (hidden=7168, experts=64, topk=8)

python python/tests/ep/test_mooncake_ep_xpu.py --num-ranks 8

...
round 0: tokens=0 fp8=False hook=False weights_at_dispatch=False ok
round 1: tokens=1 fp8=True hook=False weights_at_dispatch=False ok
round 2: tokens=128 fp8=False hook=True weights_at_dispatch=False ok
round 3: tokens=113 fp8=True hook=True weights_at_dispatch=False ok
round 4: tokens=30 fp8=False hook=False weights_at_dispatch=True ok
round 5: tokens=2 fp8=True hook=False weights_at_dispatch=True ok
round 6: tokens=24 fp8=False hook=True weights_at_dispatch=True ok
round 7: tokens=9 fp8=True hook=True weights_at_dispatch=True ok
round 8: tokens=22 fp8=False hook=False weights_at_dispatch=False ok
round 9: tokens=26 fp8=True hook=False weights_at_dispatch=False ok
round 10: tokens=91 fp8=False hook=True weights_at_dispatch=False ok
round 11: tokens=61 fp8=True hook=True weights_at_dispatch=False ok
round 12: tokens=5 fp8=False hook=False weights_at_dispatch=True ok
round 13: tokens=8 fp8=True hook=False weights_at_dispatch=True ok
round 14: tokens=5 fp8=False hook=True weights_at_dispatch=True ok
PASSED: 15 rounds + 2 empty-rank rounds + 4 two-batch rounds + duplicate experts + reused src_info + rejected handle + cross-stream + fallback agreement + dead-rank timeout on 8 ranks (hidden=7168, experts=64, topk=8)

@zxue2

zxue2 commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

[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.

  • IPC: the default. Peers on the host pull data from each other over PCIe P2P.
  • RDMA: MC_EP_RANKS_PER_NODE=1. Every peer is reached over RDMA, so all traffic goes NIC → switch → NIC.
[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]

python/tests/ep/test_mooncake_ep_xpu.py passes on 8 ranks over both paths.

Summary

  • From 16 tokens per rank up, a dispatch-plus-combine round trip over RDMA is 2.4–4.0× faster than over IPC in BF16, and 2.3–3.0× faster in FP8.
  • At 1 token per rank, the two paths are even, or IPC is ahead by up to 66 µs.

Steady state, BF16 (--pipelined)

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

@zxue2

zxue2 commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

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.

@UNIDY2002 UNIDY2002 self-assigned this Nov 6, 2026
@UNIDY2002

Copy link
Copy Markdown
Collaborator

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:

  1. Can the proxy scheduling/progress layer be factored into a platform-independent component, with the XPU/RDMA details kept behind a backend interface?
  2. Could we support a TCP transport backend, initially with correctness as the goal and host staging/device copies where needed?

These two questions are open for discussion.

@zxue2

zxue2 commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

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:

  1. Can the proxy scheduling/progress layer be factored into a platform-independent component, with the XPU/RDMA details kept behind a backend interface?
  2. Could we support a TCP transport backend, initially with correctness as the goal and host staging/device copies where needed?

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 UNIDY2002 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@UNIDY2002
UNIDY2002 merged commit 0ff7151 into kvcache-ai:main Nov 6, 2026
16 checks passed
zxue2 added 5 commits November 6, 2026 23:22
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>
jfeng18 added a commit to jfeng18/Mooncake that referenced this pull request Nov 9, 2026
* 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)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation Mooncake EP run-ci size/L 1001+ changed lines (additions + deletions) Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants