Skip to content

[Transfer Engine] Enable UB Transport in TENT for Kunpeng SuperNode Phase 3 - #1

Open
Le1zyCatt wants to merge 27 commits into
mainfrom
UB_TENT
Open

[Transfer Engine] Enable UB Transport in TENT for Kunpeng SuperNode Phase 3#1
Le1zyCatt wants to merge 27 commits into
mainfrom
UB_TENT

Conversation

@Le1zyCatt

@Le1zyCatt Le1zyCatt commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Description

This PR continues the phased UB transport work for Mooncake Transfer Engine on the Kunpeng SuperNode.

Phase 1 introduced the initial UbTransport and URMA endpoint implementation for the legacy Transfer Engine. Phase 2 added mock URMA support, unit tests, and CI/testing infrastructure for UB transport. This Phase 3 PR enables UB transport in TENT by adding a TENT-side UB transport adapter and the required control-plane integration.

The main goal is to make UB available as a selectable TENT transport while reusing the existing legacy UbTransport data path. Instead of rewriting the URMA data path, this PR adds an adapter layer that maps TENT transport APIs, segment metadata, memory registration, transfer batches, and status queries to the existing UB transport implementation.

Related work:

Major Changes

1. Add UB as a TENT transport type

This PR adds UB support to the TENT transport type system, including:

  • TransportType::UB
  • "ub" string parsing in the TENT selector
  • UB transport creation in the TENT transport loader
  • UB transport type exposure through pybind
  • CMake integration for the TENT UB transport target

This allows TENT to recognize UB as a selectable transport type.

2. Add UbTentTransport

This PR introduces UbTentTransport, a TENT transport adapter for the existing legacy UbTransport.

UbTentTransport implements the TENT transport interface and delegates UB data path operations to the legacy UbTransport.

It handles:

  • TENT transport installation and uninstallation
  • UB device selection
  • Local memory registration and unregistration
  • TENT buffer descriptor conversion
  • TENT batch allocation and release
  • TENT transfer request conversion
  • Transfer status query and status mapping

This keeps the existing URMA/UB data path mostly unchanged and limits this PR to the TENT integration layer.

3. Add UbTentMetadataBridge

Legacy UbTransport depends on the old TransferMetadata interface, while TENT uses SegmentManager and TENT-style segment descriptors.

This PR adds UbTentMetadataBridge to bridge the two metadata systems. The bridge is responsible for:

  • Looking up local and remote TENT segments
  • Converting TENT segment descriptors to legacy Transfer Engine segment descriptors
  • Extracting UB-specific transport attributes such as EID and remote segment information
  • Providing the metadata interface expected by legacy UbTransport

This allows the legacy UB transport logic to work under the TENT segment management model.

4. Add UB bootstrap support to the TENT control plane

UB requires endpoint bootstrap information exchange before data transfer.

This PR adds a UB bootstrap path to the TENT control plane, including:

  • RpcFuncID::BootstrapUb
  • UB bootstrap descriptor structure
  • ControlClient::bootstrapUb()
  • ControlService::onBootstrapUb()
  • Callback registration support for UB bootstrap handling

With this change, UB endpoint bootstrap can be performed through the TENT control-plane RPC path.

5. Improve URMA memory registration and cleanup behavior

During UB/TENT integration, several URMA resource lifetime issues were found and fixed.

This PR improves:

  • Page-aligned memory registration for URMA
  • Avoiding repeated registration of the same host virtual address across multiple URMA contexts
  • Reusing the primary registered segment where possible
  • Releasing local segment references before unregistering memory
  • Avoiding incorrect urma_uninit() usage during per-context teardown
  • Safer cleanup paths when initialization partially fails

These changes make UB transport more stable in real URMA environments.

6. Add tests and documentation

This PR adds TENT UB related tests and documentation, covering:

  • TENT UB transport install/uninstall path
  • Memory buffer registration and removal
  • Sub-batch allocation and release
  • Mock transfer submit and status query
  • Dual-node UB/TENT integration test entry
  • Phase 3 UB/TENT test guide

The dual-node test path is documented in:

mooncake-transfer-engine/tent/docs/ub_phase3_test_guide.md

Scope

This PR focuses on enabling UB transport inside TENT by adapting the existing UB implementation.

This PR does not redesign the full UB data path and does not introduce a unified vendor device abstraction for topology discovery. Those can be handled as follow-up refactors.

Module

  • Transfer Engine (mooncake-transfer-engine)
  • Mooncake Store (mooncake-store)
  • 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?

Build with UB and TENT enabled:

Test commands:

mkdir -p build
cd build

cmake .. \
  -DUSE_UB=ON \
  -DUSE_TENT=ON \
  -DCMAKE_BUILD_TYPE=RelWithDebInfo

cmake --build . -j$(nproc)

Run TENT UB unit tests:

ctest -R ub_tent_transport_test --output-on-failure

Run UB transport tests with mock URMA or an available URMA environment:

ctest -R ub_transport_test --output-on-failure

For real Kunpeng UB hardware, the dual-node test path is documented in:

mooncake-transfer-engine/tent/docs/ub_phase3_test_guide.md

Test results:

  • Unit tests pass
  • Integration tests pass
  • Manual testing done

Manual testing includes build verification and TENT UB unit-test coverage. Real dual-node UB/TENT validation should follow ub_phase3_test_guide.md.

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 run --all-files 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

  • No AI tools were used
  • AI tools were used

AI tools were used to help draft and polish the PR description. The implementation, testing, and final verification are the responsibility of the human submitter.

@Le1zyCatt Le1zyCatt changed the title 将UB接入TENT [Transfer Engine] Enable UB Transport in TENT for Kunpeng SuperNode Phase 3 Jul 3, 2026
@github-actions github-actions Bot added documentation Improvements or additions to documentation store labels Jul 10, 2026
Le1zyCatt pushed a commit that referenced this pull request Jul 27, 2026
kvcache-ai#3029)

* [TENT] Add transport labels to metrics for per-transport observability

Switch all 16 TENT metrics from static to dynamic yalantinglibs types to
add a `transport` label (and `from`/`to` on the failover counter), so
operators can slice read/write bytes, requests, failures, latency, and
failover paths by transport without grepping logs.

Cardinality control: label values come exclusively from the TransportType
enum closed set (11 values) via a pre-built lookup table indexed by enum.
No arbitrary strings are accepted — the closed set is enforced at the type
level. Total series upper bound ~1500, fully bounded.

Changes:
- 7 counters + 8 histograms → basic_dynamic_counter/histogram<int64_t, 1>
  with label "transport"; failover counter → <int64_t, 2> with "from"/"to"
- counters_ vector widened to metric_t* base pointers (N varies 1 vs 2)
- All record methods take TransportType; 10 call sites in
  transfer_engine_impl.cpp migrated (9 in recordTaskCompletionMetrics +
  1 failover)
- Macros and ScopedLatencyRecorder updated with transport parameter
- getSummaryString()/getJsonMetrics() sum across labels for flat totals;
  per-transport breakdown available only via Prometheus /metrics
- Label values aligned with TransportSelector::transportTypeName()

Workaround: ylt basic_dynamic_histogram::serialize() calls str.clear()
when all label combos have sum=0, wiping previously serialized content.
Each metric is serialized into a temp buffer then appended to avoid this.
ylt upstream is not modified.

Also fixes pre-existing bug: shutdown() did not reset bound_http_port_,
so httpPort() returned a stale port after a shutdown+reinitialize cycle.

Verified: full build (USE_TENT=ON, TENT_METRICS_ENABLED=ON) clean;
metrics_config_loader_test 25/25, tent_metrics_http_server_test 1/1,
tent_metrics_recording_test 10/10; label landing confirmed via real
TransferEngine path with {transport="tcp"} in Prometheus output.

Signed-off-by: staryxchen <staryxchen@tencent.com>

* docs(tent/metrics): document transport labels and per-transport queries

Add Labels column to the Available Metrics table, a new Labels subsection
explaining the TransportType closed-set scheme (11 values, from/to on
failover, cardinality bounds), and update the Prometheus example output
and Grafana queries to show per-transport filtering.

Signed-off-by: staryxchen <staryxchen@tencent.com>

* Address review: fix initialize() regression + add bounds-checked label lookup

1. initialize() regression fix: the rebase inadvertently reverted task#1's
   fix (commit 7dc87d8) that moved validateConfig before compare_exchange.
   The old order (CAS first, validate second, reset on failure) had a race
   window where concurrent callers see initialized_=true and return OK
   against an unconfigured singleton. Restored the correct order: validate
   first, CAS second, no reset needed.

2. Bounds-checked label lookup: added transportLabel(TransportType) helper
   that returns "unknown" if tp is out of range, replacing 9 direct
   kTransportLabelNames[tp] accesses. Defensive guard against memory
   corruption or a new transport type added without updating the table.

Addresses gemini-code-assist review feedback on PR kvcache-ai#3029 (items #1 high,
#2 medium). Item #3 (null check in sumCounterValues) intentionally not
addressed — the pointers are class members, not dynamically allocated.

Signed-off-by: staryxchen <staryxchen@tencent.com>

* Address review: fix docs code examples + add per-transport label test

M1: Update "Recording Transfer Metrics" and "RAII Latency Measurement"
code examples in metrics.md to use the new API signatures with
TransportType parameter. The old examples would not compile.

M2: Add PrometheusLabelsDistinguishTransports test that records with
RDMA and TCP transports, scrapes /metrics, and asserts per-transport
labels appear as separate lines plus from/to labels on the failover
counter.

Addresses general-purpose-6 review feedback on PR kvcache-ai#3029.

Signed-off-by: staryxchen <staryxchen@tencent.com>

* trigger CI with run-ci label

* Fix CI: guard kTransportLabelNames definition with TENT_METRICS_ENABLED

The definition was outside the #if TENT_METRICS_ENABLED block, so
building with TENT_METRICS_ENABLED=0 (the CI default) failed because
the declaration (inside #if in the header) was not visible. Moved the
definition inside the #if block.

Signed-off-by: staryxchen <staryxchen@tencent.com>

---------

Signed-off-by: staryxchen <staryxchen@tencent.com>
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