Repository navigation
[TENT] Add asynchronous MLU host-device copies - #4720
Merged
Merged
Conversation
lhzds
requested review from
00fish0,
alogfans,
chestnut-Q,
doujiang24,
dtcccc and
staryxchen
as code owners
October 16, 2026 07:47
staryxchen
reviewed
Oct 19, 2026
staryxchen
reviewed
Oct 21, 2026
staryxchen
approved these changes
Oct 22, 2026
staryxchen
left a comment
Collaborator
There was a problem hiding this comment.
LGTM. Please do a rebase.
Signed-off-by: lepam <69680504+lhzds@users.noreply.github.com>
Restore location-only Pin requests and select the MLU allocator on the node owning the staging pool. Remove allocator hints and capability metadata while retaining asynchronous copies and NUMA fallback. Cover local and remote pool reuse, allocator selection, and legacy Pin payloads.
Signed-off-by: lepam <69680504+lhzds@users.noreply.github.com>
Signed-off-by: lepam <69680504+lhzds@users.noreply.github.com>
lhzds
force-pushed
the
codex/tent-mlu-async
branch
from
October 22, 2026 07:22
342b4a0 to
f9a0385
Compare
Contributor
Author
Done, rebased onto the latest main and pushed. Thanks for the review! |
Contributor
Author
|
@staryxchen Could you please help rerun the failed CI jobs? The EFA build failed during dependency installation because the Microsoft package repository returned HTTP 403 Forbidden, before compilation started. |
8 of 36 tasks
11 tasks done
Connor-Matthew
added a commit
to LinQuickDev/Mooncake
that referenced
this pull request
Oct 26, 2026
A staged owner holds the receiver credit for all of its chunks, and the chunks themselves are credit-exempt. If one chunk fails while a sibling's cross stage is still writing into the receiver, returning the credit at that point would let the receiver grant the same capacity to another sender while the old write is still landing. Upstream kvcache-ai#4720 made ProxyManager keep the parent PENDING until in-flight siblings drain. Add an end-to-end regression through the runtime queue and receiver-credit gate: the staged owner stays PENDING and a second credit-gated write never reaches the transport until the held cross-stage write drains; only then does the owner fail, return the credit, and let the second write complete. Reverting the upstream drain makes the test fail on all three checks. CI hosts have no device memory, so add a test-only setStagingPolicyForTest hook that forces host staging for selected requests.
15 of 21 tasks
wzy-782
added a commit
to wzy-782/Mooncake
that referenced
this pull request
Oct 29, 2026
Conflicts with upstream main, resolved: - transfer_engine_impl.cpp, planTransport (getTransportType before kvcache-ai#4378): upstream added the XPU dma-buf RDMA (kvcache-ai#4378) and same-host XPU IPC (kvcache-ai#4379) routes. A request with a TPU side always stages and never takes either route; XPU and MLU requests behave as upstream. - transfer_engine_impl.cpp, findStagingPolicy: #2's combined TPU/XPU/MLU staging block replaces the old TPU case, with upstream's note on the XPU dma-buf bypass. XPU memory is no longer called never NIC-addressable. - transfer_engine_impl.cpp, submitTransfer: upstream's progress lock (kvcache-ai#4720) around #2's prepareSubmit call with the staged route. - tent/tests/CMakeLists.txt: #1's TPU adapter tests, then #2's engine, staged-route and host-initiator tests. Known failure: EngineFailoverE2E.MergedStagingRequestsShareOneSubmission (kvcache-ai#4797). The test marks the peer buffer as MLU only in the test thread's segment cache, which is thread-local. #2 re-plans a staged request's hop on the ProxyManager thread, whose cache shows host memory, so the hop gets no route.
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
Synchronous MLU staging copies block the submitting thread until each copy finishes. This PR uses CNDRV queues and per-copy notifiers for pinned D2H copies and pinned H2D copies above 64 KiB, allowing submission to return while the copy is in flight.
Small H2D copies run synchronously when their direction queue is absent or idle; otherwise, pinned copies join the queue. Pageable copies wait for earlier work in their direction to drain before copying synchronously. Copies preserve submission order within each transport, device context, and direction. Dependencies across directions or contexts require caller synchronization.
MLU staging uses
cnrtHostMalloc, with a fallback to the normal NUMA allocator when the requestedcpu:Nplacement cannot be satisfied. Ordinary internal CPU allocations retain the engine’s existing allocator selection.The change also handles the completion and memory lifetimes required by asynchronous copies:
Suggested Merge Priority
Module
mooncake-transfer-engine)Type of Change
How Has This Been Tested?
Correctness validation —
342b4a01Validated on two MLU580-X6 hosts, each with one visible 48 GiB device and driver 6.5.42. This validation was performed on
342b4a01, before the subsequent rebase.Validation details
The 296 cases comprise 65 MLU transport, 6 platform, 153 engine, 9 process, 10 memory lifecycle, 28 progress worker, 17 runtime queue dispatch, and 8 local notification cases.
Both hosts used identical test binaries and libraries built from the tested source. Scoped formatting and pre-commit checks, and
git diff --check, passed.Historical performance measurements
Measurements on earlier revisions showed much shorter submission blocking and about 3% lower full-batch completion time for large local copies. The two-host HP TCP comparison showed lower throughput and higher tail latency.
Performance measurements on earlier revisions
The measurements below were collected on earlier revisions. Each comparison identifies its tested version and baseline.
Environment: two MLU580-X6 hosts, each with one visible 48 GiB device and driver 6.5.42.
Local copies
Versions: synchronous baseline
c3aea655versus local revisions based on10f1a673. The revised source was unpushed at measurement time; the original record does not identify a unique commit for that source snapshot.Both builds used identical pinned buffers and fixed NUMA placement, with five alternating A/B pairs, 10 warmups, and 100 samples per point. The table reports per-host medians for 4 × 64 MiB copies, or 256 MiB per batch.
The main improvement is reduced submission-thread blocking, allowing overlap with other work. Full batch completion time decreases by about 3%.
For 4–64 KiB copies, single-copy D2H completion increases by 2.7–2.9 μs (35–45%), while batch-4 completion improves by 10–15%. Small H2D stays within 2%. The local-copy validation completed 52,800 full-payload checks.
Two-host HP TCP
Versions: the same
c3aea655baseline and local revisions based on10f1a673, both with the same #4703 benchmark overlay. Both builds predate #4797; these measurements usemerge_requests=falseto avoid the existing duplicate staging submission.The workload is READ, 4 × 64 MiB per batch, one worker, 512 MiB device buffers, and 4 MiB staging chunks, with a 1-second warmup and 60 seconds per run. Each host initiates separately. Device memory was explicitly selected and checked at both endpoints; payload checks were outside the performance loop.
Each initiator ran two baseline/revised pairs. The table includes all eight runs, using medians across runs for throughput and medians of per-run latency percentiles. GB/s counts logical payload; latency covers batch submission through completion.
These runs do not establish an end-to-end performance improvement. The all-run medians show lower throughput and higher tail latency in the revised build.
Per-pair measurements and receive-CPU observations
Receive-CPU distribution was inspected after measurement. Each run had four HP TCP data connections. In pair 1 on each host, both builds had connections on four distinct receive CPUs. In the slower revised run of pair 2, two connections shared a receive CPU. This association does not establish the cause of the slowdown.
All arrows show baseline → revised.
The broader two-host validation included 16 × 120-second runs with merging enabled and these 8 × 60-second controls with merging disabled. All 24 separate 256 MiB WRITE/readback checks passed.
Small H2D copies after the ordering fix
Versions:
1b37418fversus the previous PR head,10f1a673.Measurements used SDK-pinned buffers, fixed NUMA placement, and six interleaved runs per build and host. Sizes were 4/16/64 KiB, with batch sizes 1/4; full-payload checks ran outside timing.
10f1a673The idle-queue path remained faster than submitting every small copy asynchronously. With a busy H2D queue, small copies wait for earlier work to finish, preserving submission order.
Checklist
./scripts/code_format.shAI Assistance Disclosure
OpenAI Codex assisted with implementation, regression tests, hardware validation, and this description.