Repository navigation
[EP] Enable MACA legacy EP with shared P2P and IBGDA device paths - #4091
Merged
Merged
Conversation
UNIDY2002
requested review from
alogfans,
chestnut-Q,
doujiang24,
staryxchen,
ympcMark and
yuechen-sys
as code owners
September 13, 2026 16:17
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved critical MACA ordering and async-completion issues, along with moderate build and runtime concerns, block approval.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds MACA/C500 support for the legacy Mooncake EP Buffer API using shared P2P and IBGDA transport paths.
Changes:
- Adds MACA build/runtime, allocation, synchronization, and FP8 support.
- Adapts legacy split SEND/RECV and IBGDA QP handling.
- Removes native phase ACK and unsupported zero-copy paths.
File summaries
| File | Reviewed changes and final comments |
|---|---|
python/tests/ep/test_mooncake_ep.py |
Updates legacy EP tests and removes unsupported zero-copy cases. |
python/tests/ep/test_ep_grid.py |
Updates the EP test grid and removes zero-copy cases. |
python/mooncake/mooncake_ep_buffer.py |
Adds MACA dispatch/combine handling. critical (1 vote): async completion may signal before the internally triggered RECV finishes. moderate (1 vote): the phase fence can hang on inactive peers. nit (1 vote): MACA FP8 remains untested by the matrices. |
mooncake-transfer-engine/src/transport/device/p2p_device_transport.cpp |
Documents MACA fine-grained allocation requirements. |
mooncake-transfer-engine/include/transport/device/maca/maca_ops.cuh |
Adds MACA memory-ordering helpers. |
mooncake-transfer-engine/include/transport/device/ibgda_device.cuh |
Adds MACA QP locking behavior. |
mooncake-transfer-engine/include/gpu_vendor/maca.h |
Adds CUDA-runtime compatibility aliases. |
mooncake-pg/src/CMakeLists.txt |
Integrates MACA PG device compilation. |
mooncake-ep/src/mooncake_ep_kernel.cu |
Adds MACA IBGDA synchronization and serialization. critical (2 votes): add a system-scope fence before posting combine WQEs. critical (2 votes): guard the added fence from CUDA/MUSA hot paths. |
mooncake-ep/src/mooncake_ep_buffer.cpp |
Removes native phase-ACK orchestration. |
mooncake-ep/src/ep_py.cpp |
Excludes Elastic EP bindings on MACA. moderate (1 vote): make the unavailable Python ElasticBuffer API fail explicitly. |
mooncake-ep/src/CMakeLists.txt |
Builds and links the MACA legacy kernel. moderate (1 vote): add header dependencies or a depfile to prevent stale incremental MACA kernels. |
mooncake-ep/include/mooncake_ep_device.h |
Adds MACA FP8 storage and conversion. nit (2 votes): add automated MACA FP8 coverage. |
mooncake-ep/include/mooncake_ep_configs.cuh |
Removes MACA phase-ACK configuration. |
mooncake-ep/include/mooncake_ep_buffer.h |
Removes phase epoch state. |
mooncake-ep/include/mooncake_ep_api.cuh |
Removes phase-ACK declarations. |
Review details
Suppressed comments (7)
mooncake-ep/src/CMakeLists.txt:131
- This custom command depends only on the
.cusource, so CMake will not rebuild_maca.owhen an included EP/transport header changes (for examplemooncake_ep_device.hormaca_ops.cuh). Incremental builds can therefore silently keep a stale MACA kernel; generate and attach a compiler depfile (as the MUSA path does) or list the transitive headers.
DEPENDS "${_ep_device_source}"
mooncake-ep/src/ep_py.cpp:61
- Excluding the native class here leaves the high-level
mooncake.mooncake_elastic_buffer.ElasticBufferconstructible, but its constructor still unconditionally callsep.ElasticBuffer(python/mooncake/mooncake_elastic_buffer.py:418-453). On a MACA wheel this now fails with an attribute error rather than an explicit unsupported-feature error. Add a MACA capability check/clear exception in the Python wrapper or otherwise make this API's unavailability explicit.
#if !defined(MOONCAKE_EP_USE_MACA)
py::class_<MooncakeElasticBuffer>(m, "ElasticBuffer")
mooncake-ep/src/mooncake_ep_kernel.cu:200
- This does not actually serialize the MACA pseudo-warps:
kNumWarpsPerGroupis 4, so sub-warps 0 and 2 both satisfy(sub_warp_id & 1) == 0and can entermc_rdma_putconcurrently on the same QP channel. That defeats the ordering this MACA workaround is intended to provide; iterate over eachsub_warp_id(or otherwise admit one leader at a time) instead of grouping by parity.
for (int half = 0; half < 2; ++half) {
if ((sub_warp_id & 1) == half) {
mooncake-ep/src/mooncake_ep_kernel.cu:577
- The same parity condition leaves two of the four combine pseudo-warps able to post to the same QP at once: sub-warps 0 and 2 run together in the first iteration, and 1 and 3 in the second. The comment says these leaders are being serialized, so this should admit one
sub_warp_idper iteration (or use another mechanism that guarantees one WQE/doorbell update at a time).
for (int half = 0; half < 2; ++half) {
if ((sub_warp_id & 1) == half) {
python/mooncake/mooncake_ep_buffer.py:653
- The same event-ordering issue applies to combine: MACA forces
runtime_return_recv_hook, so the native event is recorded before the wrapper's phase-fence/RECV hook runs. A caller usingasync_finish=Trueand waiting only on the returned event can observecombined_xbefore the combine receive/reduction has completed. Return an event recorded after the internally-triggered receive phase, or otherwise tie the event to that phase.
native_async_finish = async_finish and not (
_USE_SPLIT_SEND_RECV and runtime_return_recv_hook
)
python/mooncake/mooncake_ep_buffer.py:499
- This internally-forced receive hook always wraps the MACA phase fence, but the fence has no
active_ranksmembership and sends/receives with every peer. The legacy EP tests still exercise failed-rank cases; if a peer has exited or is inactive, dispatch waits on that peer before the receive kernel can run, so timeout/fault-tolerant execution can hang. Thread the active-rank mask through the hook/fence and skip inactive peers, or use a failure-aware control-plane fence.
# The MACA split path requests the native receive hook even when
# the caller did not. Native EP forbids async+hook together;
# the wrapper owns completion through the phase-fence hook.
native_async_finish = async_finish and not (
_USE_SPLIT_SEND_RECV and runtime_return_recv_hook
)
python/mooncake/mooncake_ep_buffer.py:410
- Removing the MACA FP8 rejection exposes a new supported path, but the official correctness matrices still force MACA to BF16-only (
dispatch_use_fp8/fp8_optionsremain[False]). The new__maca_fp8_e4m3conversion is therefore not exercised by the automated EP tests; enable MACA FP8 in the matrices or add a MACA-specific FP8 case before treating this support as covered.
if use_fp8 is None:
use_fp8 = not _USE_MACA
# MUSA and MACA use split SEND/RECV launches because they do not expose
# CUDA cooperative-grid synchronization. Only MACA adds a phase fence.
- Files reviewed: 16/16 changed files
- Comments generated: 4
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
UNIDY2002
force-pushed
the
feature/maca-ep-functional-clean
branch
from
September 14, 2026 12:18
47b4e13 to
d7cdeb4
Compare
5 of 32 tasks
UNIDY2002
force-pushed
the
feature/maca-ep-functional-clean
branch
from
September 15, 2026 04:22
bd983aa to
1a20e01
Compare
alogfans
approved these changes
Sep 15, 2026
8 of 36 tasks
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.
Description
Enable Mooncake's legacy low-latency Expert Parallelism (EP)
BufferAPI on MetaX MACA devices by reusing the existing CUDA/MUSA EP and mlx5 IBGDA paths. The public legacy EP API remains unchanged: users constructBuffer, then calldispatchandcombinewith BF16 or FP8 payloads.Motivation
MACA deployments need both intra-node P2P EP and GPU-initiated RDMA EP. The shared Mooncake transport already contains the required QP lifecycle, WQE, doorbell, signal, remote atomic, and CQ logic. This change supplies the MACA compiler/runtime integration and device-ordering adaptations needed on C500 hardware, without introducing a second EP implementation or an MXSHMEM-specific kernel.
Implementation
MACA build and runtime integration
nvcc.BufferAPI.Shared IBGDA path
Legacy EP protocol
async_finish && return_recv_hookcombination.__maca_fp8_e4m3type.Scope
This PR targets the legacy EP
BufferAPI. The newer elastic kernel is not compiled for MACA in this change. Performance tuning beyond the validated functional path, including QP sharding and active-QP auto-tuning, remains a follow-up.Module
mooncake-ep)mooncake-pg)mooncake-transfer-engine)mooncake-wheel)Type of Change
How Has This Been Tested?
Validation focused on MACA C500 devices and the actual legacy EP communication paths. The tests use the standard workload shape where noted (
tokens=128, hidden=7168, experts=288, top-k=8) and exclude zero-copy.Test commands:
Test results:
tokens=8, hidden=7168, experts=8, top-k=1) with zero maximum error. A matched native run reports approximately667--760 usdispatch+combine latency.tokens=128, hidden=7168, experts=288, top-k=8, P2P disabled) passes dispatch and combine correctness on all ranks withmax_abs_error=0. The native loop reports approximately2.09--2.11 GB/sdispatch+combine effective bandwidth and13.9--14.0 msaverage latency. NCCL/MCCL is used for device metadata and a separate Gloo control group supplies the MACA phase fence.For context, the prebuilt MXDeepEP low-latency benchmark on the same MACA family reports approximately
12.3 GB/sper-rank effective dispatch+combine bandwidth for the formal eight-rank workload. From the human author's perspective (@UNIDY2002), Mooncake's2 GB/sper-rank result is already close to saturating the two 100-Gbps data-plane ports:2 GB/s * 8 ranks = 16 GB/s, versus2 * 100 Gbps / 8 = 25 GB/sof raw link bandwidth. The same calculation applied to the MXDeepEP number gives12.3 GB/s * 8 ranks = 98.4 GB/s, which appears to exceed that RDMA limit.Codex's interpretation is that this comparison is too high because the printed figures are per-rank effective all-to-all rates and can count overlapping or duplicated traffic; they are not aggregate wire-rate measurements. The MXDeepEP result is therefore retained as a useful baseline, while the apparent 98.4-GB/s aggregate should not be read as physical link utilization. Mooncake's current native MACA result is a functional baseline; QP/CQ scheduling and communication overlap are follow-up performance targets.
Compatibility and Operational Notes
MOONCAKE_EP_MACA_ALLOC=finefor the pure-IBGDA route; the default allocator remains unchanged for ordinary P2P users.MOONCAKE_EP_DEVICE_FILTERto the actual InfiniBand device names for the allocated node (for example,mlx5_10,mlx5_11). Do not use a network bond name or the pluralMOONCAKE_EP_DEVICE_FILTERS; verify the selected HCA in the[EP IBGDA] Initialized on ...log before interpreting results.Checklist
./scripts/code_format.shThe task-local validation harness, temporary recovery-test bypass, and raw hardware logs are maintained outside the upstream source tree.
AI Assistance Disclosure