Skip to content

feat(te): pick transports at runtime in EFA builds, keep EFA NICs out of RDMA - #4355

Merged
whn09 merged 1 commit into
kvcache-ai:mainfrom
whn09:feat/efa-runtime-transport-selection
Oct 12, 2026
Merged

whn09 merged 1 commit into
kvcache-ai:mainfrom
whn09:feat/efa-runtime-transport-selection

Conversation

@whn09

@whn09 whn09 commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Step 2 of folding AWS EFA support into the default wheels (step 1 is #4354). This removes the behavioral #ifdef USE_EFA in transport selection and makes GPU handling in the EFA transport a runtime decision.

  1. Keep EFA NICs out of RDMA auto-discovery in all builds.
    • Topology::discover() gets an exclude_efa flag (driver efa in sysfs), and TransferEngineImpl's auto-discovery sets it.
    • EFA NICs are verbs devices, but they only expose SRD, so the RDMA transport's RC QPs fail on them. Today the default wheel on an AWS EFA host picks RDMA on the EFA NICs and hangs on Failed to create QP. It now finds no HCA and takes the normal fallback: TCP, or NVLink when configured.
    • Hosts without EFA NICs are unaffected. Explicit EFA setups (bench, probe, C API, store) keep calling discover() without the flag.
  2. EFA builds select transports like other builds. Only protocol=efa is set up by hand. Every other protocol goes through auto-discovery instead of always installing TCP, so the EFA wheel behaves like the default wheel on IB/RoCE. This supersedes fix(efa): honor protocol=rdma in EFA builds #4353.
  3. Request FI_HMEM only with a GPU. FI_HMEM/FI_MR_HMEM are requested only when a CUDA/HIP device is present. Otherwise the transport uses FI_HMEM=system, as CPU builds already do, and loopback treats memory as host memory. GPU builds on hosts without a visible GPU used to fail fi_getinfo with -FI_ENODATA.

Behavior notes:

  • On IB/RoCE, EFA-wheel users passing protocol=tcp now get the same transport as the default wheel, which ignores the protocol for auto-discovery. Use MC_FORCE_TCP to force TCP.
  • get_local_topology() reports the RDMA auto-discovery topology, so it no longer lists EFA NICs. Neither SGLang nor vLLM calls it.

Related: vllm-project/vllm#55635, sgl-project/sglang#40995.

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?

Two wheels were built from this branch: EFA-cuda13 and the default cuda13. They were tested on 2x p5en.48xlarge (16 EFA NICs, H200) inside lmsysorg/sglang:latest with the AWS EFA userspace under /opt/amazon. IB/RoCE was emulated with Soft-RoCE on the system rdma-core.

Test commands:

sudo rdma link add rxe0 type rxe netdev enp71s0   # on both hosts
# 2-node transfer: write 64 MiB, read back and compare, then 1-256 MiB bandwidth
python3 mc_gpu_test.py {target|initiator} <ip> <efa|rdma> <cuda|cpu> [device]
# no visible GPU
CUDA_VISIBLE_DEVICES= python3 mc_gpu_test.py ... efa cpu

Test results:

  • Unit tests pass
  • Integration tests pass (if applicable)
  • Manual testing done (describe below)
Case Before After
Default wheel, rdma, AWS with only EFA NICs transfer hangs, readback never completes TCP fallback, readback OK
Default wheel, rdma, rxe0 + 16 EFA NICs — RDMA on rxe0 only, readback OK
EFA wheel, rdma, device rxe0 TCP (1.19 GB/s) RDMA (1.97 GB/s, rxe limit), readback OK
EFA wheel, rdma, rxe0 + 16 EFA NICs TCP RDMA on rxe0; 16x "Skipping EFA device for RDMA"
EFA wheel, efa, no visible GPU (DRAM) fi_getinfo failed: No data available on all NICs readback OK, ~24 GB/s
EFA wheel, efa, GPU memory ~24 GB/s ~24 GB/s, readback OK

Checklist

  • I have performed a self-review of my own code
  • I have formatted my code using ./scripts/code_format.sh. I used the same tool it runs: clang-format 20 with the repo .clang-format.
  • 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 (validated manually; the EFA/RDMA paths need hardware)
  • For changes >500 LOC: I have filed an RFC issue

AI Assistance Disclosure

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

Claude Code (Claude Opus 5.5) helped draft the code, run the validation on the p5en instances, and write this description. I reviewed the changes and the test results.

… of RDMA

Step 2 of folding EFA support into the default wheels.

- Topology::discover() gets an exclude_efa flag, and RDMA auto-discovery
  sets it. EFA NICs are verbs devices too, but only expose SRD, so the RDMA
  transport (RC QPs) cannot use them. Before this, the default wheel on an
  AWS EFA host picked RDMA on the EFA NICs and hung on "Failed to create
  QP"; it now finds no HCA and falls back as usual (TCP, or NVLink when
  configured). Hosts without EFA NICs are unaffected, and explicit EFA
  setups keep calling discover() without the flag.
- In USE_EFA builds, only protocol=efa is set up by hand. Every other
  protocol goes through the same auto-discovery as non-EFA builds instead
  of always falling back to TCP, so the EFA wheel behaves like the default
  wheel on IB/RoCE hosts. This supersedes the rdma special case in kvcache-ai#4353.
- The EFA transport requests FI_HMEM / FI_MR_HMEM only when a GPU device is
  present, and treats all memory as host memory otherwise. GPU builds on
  hosts without a visible GPU previously failed fi_getinfo with
  -FI_ENODATA.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Comment on lines +320 to +321
engine_ = std::make_unique<TransferEngine>(!use_efa && !use_flagcx,
device_filter);

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.

@MC952-arch Does this change affect flagcx adaptor?

@whn09

whn09 commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator Author

On flagcx: no change. In EFA builds, protocol=flagcx still constructs the engine with auto_discover=false and installs the flagcx transport by hand, as before. Only the fallback for other protocols changed (auto-discovery instead of TCP). Non-EFA builds, where the flagcx adaptor is normally used, are untouched.

@alogfans @ShangmingCai @stmatengss could you take a look when you have time? It has no conflicts with current main.

@alogfans alogfans 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.

LGTM

@whn09
whn09 merged commit 5607d4a into kvcache-ai:main Oct 12, 2026
55 of 57 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants