Mooncake/mooncake-transfer-engine/tests
王鹤男 268622fa70
[TE] fix(efa): short-circuit same-process GPU loopback to avoid libfabric SHM segfault (#2298)
* fix: route EFA same-process loopback transfers through local copy

The EFA provider's SHM intra-node path performs a host memcpy into
FI_HMEM_CUDA device buffers and segfaults on the first same-host
transfer (loopback self-transfer), e.g. checkpoint-engine P2P weight
update on a single TP=8 node. See ofiwg/libfabric#12328.

Detect same-process self-loopback in EfaContext::submitPostSend (peer
NIC path equals our own nicPath(), whose server_name embeds the
per-process RPC port, so the match guarantees the peer is this very
process on this device) and satisfy the copy locally with a GPU-aware
cudaMemcpy (cudaMemcpyDefault), bypassing EFA entirely. Same-host
cross-process peers carry a different port, never match, and still go
through EFA.

The copy direction honors the slice opcode, mirroring fi_read/fi_write:
WRITE copies source_addr -> dest_addr, READ copies dest_addr ->
source_addr (the two are distinct local buffers, so it is not a
symmetric self-copy).

This mirrors how the RDMA transport already treats loopback as a
special case (rdma_endpoint.cpp self-connected QP); RDMA relies on NIC
hardware loopback and is unaffected by the libfabric SHM bug.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* test: add EFA GPU loopback test for FI_HMEM_CUDA same-host transfers

Add efa_gpu_loopback_test.cpp, the CUDA-device-memory counterpart of
efa_transport_test.cpp (which only covers host/numa loopback). It
reproduces the EFA SHM intra-node segfault on FI_HMEM_CUDA buffers
(ofiwg/libfabric#12328) and validates EfaContext::tryLoopbackCopy:

  * GpuLoopbackWrite       — same-host GPU WRITE must not crash.
  * GpuLoopbackWriteThenRead — WRITE then READ with byte-accurate
    verification, exercising both copy directions.
  * GpuLoopbackMultiWrite  — batched GPU writes through the per-slice
    loopback short-circuit.

Self-skips when no EFA device or no CUDA GPU is present. Registered
under `USE_EFA AND USE_CUDA`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* efa: log fabric name and document same-host GPU loopback segfault

Add fabric_attr->name to the EFA device init log so the active fabric
(efa-rdm vs efa-direct) is visible at runtime — both share the same
provider name, FI_EP_RDM type, and <device>-rdm domain name, so the
fabric name is the only field that distinguishes them.

Revise the "Single-host loopback" doc section:
- Correct the same-host fast-path attribution: the memcpy fast path is
  supplied by the SHM provider (FI_EFA_ENABLE_SHM_TRANSFER, default on),
  not by FI_EFA_USE_DEVICE_RDMA. Confirmed at runtime: a default
  (device-RDMA-enabled) config still reports "Opened fabric: shm".
- Add a warning that the default SHM path host-memcpy's into FI_HMEM_CUDA
  destinations and segfaults on GPU buffers (ofiwg/libfabric#12328);
  document the same-process tryLoopbackCopy short-circuit and the
  FI_EFA_ENABLE_SHM_TRANSFER=0 workaround for cross-process GPU peers.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-04 11:17:17 +08:00
..
fault-tolerant [Test] add fault tolerant CI (#418) 2025-06-04 00:43:12 +08:00
CMakeLists.txt [TE] fix(efa): short-circuit same-process GPU loopback to avoid libfabric SHM segfault (#2298) 2026-06-04 11:17:17 +08:00
ascend_direct_transport_test.cpp refactor ascend direct transport (#1720) 2026-03-24 21:51:58 +08:00
common_test.cpp [TE][Store] Fix IPv6 address parsing in connection endpoints (#2184) 2026-06-01 15:27:08 +08:00
config_test.cpp [TE] fix: improve auto gid selection and retry (#2269) 2026-06-03 20:52:24 +08:00
cxl_transport_test.cpp code format & enable code format checking in ci (#677) 2025-08-02 15:50:25 +08:00
efa_c_api_test.cpp [TE] PTE-aware auto-split large MR registration for EFA transport (#1912) 2026-04-20 15:04:49 +08:00
efa_gpu_loopback_test.cpp [TE] fix(efa): short-circuit same-process GPU loopback to avoid libfabric SHM segfault (#2298) 2026-06-04 11:17:17 +08:00
efa_single_nic_large_mr_test.cpp [TE] PTE-aware auto-split large MR registration for EFA transport (#1912) 2026-04-20 15:04:49 +08:00
efa_transfer_test.cpp [TE] PTE-aware auto-split large MR registration for EFA transport (#1912) 2026-04-20 15:04:49 +08:00
efa_transport_test.cpp [TE] EFA SRD shared-endpoint refactor: drop per-peer fid_ep model (#1944) 2026-04-23 16:52:27 +08:00
endpoint_store_integration_test.cpp [TENT] Add rule-based transport and device selection (#2079) 2026-05-27 10:41:57 +08:00
endpoint_store_test.cpp [transfer_engine] fix: drain endpoint waiting list via periodic reclaim (#1952) 2026-04-27 10:32:34 +08:00
memory_location_test.cpp [TransferEngine] Speedup RDMA Register for Large Size Memory (#875) 2025-09-28 12:31:27 +08:00
mp_transport_test.cpp [TE] Add Multi-Protocol Support for DRAM-CXL-SSD tiered storage (#1832) 2026-04-09 10:36:14 +08:00
nvlink_transport_test.cpp [TE]: Add HIP transport for AMD GPUs support (#1208) 2025-12-16 19:27:47 +08:00
nvmeof_transport_test.cpp code format & enable code format checking in ci (#677) 2025-08-02 15:50:25 +08:00
rdma_context_reprobe_test.cpp [TE] fix: improve auto gid selection and retry (#2269) 2026-06-03 20:52:24 +08:00
rdma_endpoint_reestablish_test.cpp [TE] fix: improve auto gid selection and retry (#2269) 2026-06-03 20:52:24 +08:00
rdma_gid_probe_test.cpp [TE] fix: improve auto gid selection and retry (#2269) 2026-06-03 20:52:24 +08:00
rdma_loopback_test.cpp code format & enable code format checking in ci (#677) 2025-08-02 15:50:25 +08:00
rdma_transport_test.cpp [Build] Fix compile warnings across multiple components (#2193) 2026-05-26 12:28:53 +08:00
rdma_transport_test2.cpp [TE] Enabling UB Transport on the Kunpeng SuperNode Phase 2 (#1855) 2026-04-15 00:15:34 +08:00
rpc_communicator_test.py [TE][1/N] add RPC based data transfer (#1104) 2025-12-09 22:19:26 +08:00
tcp_transport_test.cpp [] feat: add Hygon DCU/DTK and Iluvatar CoreX platform support (#2118) 2026-05-18 10:26:56 +08:00
topology_test.cpp [Feature] support auto-detect topo for both GPUs and CPUs (#244) 2025-04-16 16:14:30 +08:00
transfer_metadata_test.cpp [TransferEngine] implement closeLocalSegment by segment name (#286) 2025-04-25 17:35:16 +08:00
transport_uint_test.cpp Suppress gtest type cast compile warning and fix some trivial bugs (#115) 2025-02-23 13:29:34 +08:00
ub_transport_test.cpp [TE] Enabling UB Transport on the Kunpeng SuperNode Phase 2 (#1855) 2026-04-15 00:15:34 +08:00
ubshmem_transport_test.cpp [TE] Ubshmem transport support ipc memory and build allocator when set USE_UBSHMEM=ON (#1519) 2026-02-14 19:30:06 +08:00