Skip to content

[TENT] Add MemFabric Transport - #4682

Merged
alogfans merged 2 commits into
kvcache-ai:mainfrom
henian-Ni:develop_1012
Oct 16, 2026
Merged

alogfans merged 2 commits into
kvcache-ai:mainfrom
henian-Ni:develop_1012

Conversation

@henian-Ni

@henian-Ni henian-Ni commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR adds a MemFabric Transport backend to the TENT framework, loading the memfabric shared library (libmf_smem.so) via dlopen/dlsym at runtime.

Key design decisions:

  • Dynamic loading: No compile-time dependency on memfabric headers. A self-contained C ABI header (memfabric_types.h) re-declares all vendor types, following the same pattern as the TPU PJRT shim.
  • Protocol via environment variable: MF_PROTOCOL env var selects the transport protocol (device_rdma / device_urma/ device_sdma / ...), consistent with how ascend_direct uses env vars (not TENT JSON config).

Architecture

TENT TransferEngine
  └── MemFabricTransport (install / submit / getStatus / addMemoryBuffer)
        └── MemFabricUnderApi (dlopen wrapper, 13 function pointers)
              └── libmf_smem.so (memfabric shared library)

Files changed

Category Files
Transport memfabric_transport.h/cpp, memfabric_under_api.h/cpp, memfabric_types.h
Allocator memfabric_allocator.h/cpp
CMake common.cmake, tent/src/transport/memfabric/CMakeLists.txt, src/CMakeLists.txt
Store real_client.cpp, client_buffer_allocation.cpp (include + call site)
Tests memfabric_transport_test.cpp (mock ACL + mock UnderApi)
Docs docs/source/design/transfer-engine/memfabric_transport.md (EN), docs/source/zh_archive/memfabric_transport.md (ZH)
Config tent/config/transfer-engine.json

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)
  • CI/CD
  • Docs
  • Other

Type of Change

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

How Has This Been Tested?

Build verification was done on a two-node Ascend NPU cluster (CANN
9.0.1, aarch64) with memfabric_hybrid providing
libmf_smem.so. Mooncake was built with USE_TENT=ON and
USE_MEMFABRIC=ON. The memfabric transport was enabled in the TENT
config (transports/memfabric/enable: true), with
MF_PROTOCOL=device_xdma for inter-node RDMA transfer.

End-to-end inference validation was performed with SGLang in PD
disaggregation mode across the two nodes. The prefill node ran the
SGLang prefill worker with a Mooncake Store segment
(protocol=ascend, 200 GB hugepage-backed); the decode node ran the
decode worker and pulled KV cache from the prefill node's Store via
the memfabric transport. Multiple round-trip prefill→decode
sequences completed with correct generation output and no transfer
errors.

Unit tests also pass with mock ACL and mock UnderApi,
covering library loading, endpoint publish/resolve, memory
registration, batch submission, status polling, and uninstall
cleanup. These use no real memfabric hardware.

Test results:

  • Build succeeds with USE_MEMFABRIC=ON on Ascend NPU / CANN 9.0.1.
  • PD disaggregation with SGLang (L3 on A5) passes across
    two nodes with correct generation output.
  • Unit tests pass (mock-backed, no hardware required).
  • Changed-file pre-commit passed.

Checklist

  • 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
  • I have added tests to prove my changes are effective
  • For changes >500 LOC: I have filed an RFC issue

AI Assistance Disclosure

  • AI tools were used (Claude for code generation, refactoring, and documentation drafting; all changes reviewed and defended end-to-end by the human submitter)

@Aionw

Aionw commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

On the CI changes: the new memfabric-mock leg doesn't test the code that would actually ship, and it adds a lot of special-casing to tent-ci.

What it covers

The leg sets -DUSE_MEMFABRIC=OFF, so tent_xport_memfabric is never configured. tests/memfabric/CMakeLists.txt instead compiles ../../src/transport/memfabric/*.cpp straight into the test executables. As a result, none of the USE_MEMFABRIC=ON paths are compiled anywhere in CI:

  • the production target and its link line (dl ascendcl)
  • the USE_MEMFABRIC branches in common.cmake
  • the #ifdef USE_MEMFABRIC code in transport_loader.cpp, transfer_engine_impl.cpp, pybind.cpp, real_client.cpp and client_buffer_allocation.cpp

The existing ub-mock leg does the opposite. It turns on -DUSE_UB=ON, builds the real target with a mock adapter injected inside it, and runs the full build and full ctest with no workflow special cases.

Workflow cost

  • A whole runner leg (dependencies, sccache, full configure) is used to build two targets.
  • matrix.name != 'memfabric-mock' appears in six steps.
  • The per-test ctest -R ... --no-tests=error loop exists only because these tests are registered through a separate CMake path.
  • tent_memfabric_transport_test is defined twice, with different link setups depending on the mode.

Root cause

The transport loads libmf_smem with dlopen, but it still depends on CANN at compile time:

  • memfabric_transport.cpp includes <acl/acl.h>, and memfabric_allocator.cpp includes <acl/acl_rt.h>.
  • The target links ascendcl.
  • USE_MEMFABRIC switches platform.cpp to AscendPlatform and enables platform_ascend.

So USE_MEMFABRIC=ON can't be built on a GitHub runner, and the test setup works around that.

Suggestions

  1. Minimal: build the mock tests under BUILD_UNIT_TESTS whenever USE_MEMFABRIC is off, so the existing cuda-off leg builds them and runs them in its normal ctest -j. Drop the new leg and the ci.yml changes.
  2. Preferred: remove the compile-time ACL dependency from the transport, either by going through the platform layer or by resolving the ACL symbols at runtime the same way libmf_smem is loaded. Then -DUSE_MEMFABRIC=ON builds without CANN, and CI can cover it the way ub-mock covers UB: a leg that builds the real target and runs the full test suite.

Two smaller points:

  • tent_ascend_platform_mock_test tests ascend_probe.cpp and ascend_allocator.cpp, which belong to the Ascend platform rather than MemFabric. It would fit better in a separate PR.
  • The cmake-format reflows of unrelated comments in tests/CMakeLists.txt and src/CMakeLists.txt should be left out of this PR.

@henian-Ni henian-Ni changed the title [RFC][TENT] Add MemFabric Transport [TENT] Add MemFabric Transport Oct 15, 2026
@alogfans
alogfans enabled auto-merge (squash) October 16, 2026 03:05
@alogfans

Copy link
Copy Markdown
Collaborator

@henian-Ni Please fix merge conflicts while we have merged other PRs that may affect this.

auto-merge was automatically disabled October 16, 2026 04:03

Head branch was pushed to by a user without write access

@alogfans

Copy link
Copy Markdown
Collaborator

@ykwd Please review this code, thx

@henian-Ni

Copy link
Copy Markdown
Contributor Author

@henian-Ni Please fix merge conflicts while we have merged other PRs that may affect this.

I have fixed it.

@alogfans
alogfans merged commit 129c961 into kvcache-ai:main Oct 16, 2026
31 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.

4 participants