Skip to content

[TransferEngine] Add opt-in high-priority HIP copy streams - #5005

Merged
ShangmingCai merged 1 commit into
kvcache-ai:mainfrom
dorado269:yihou/hip-copy-stream-priority-20261027
Nov 12, 2026
Merged

ShangmingCai merged 1 commit into
kvcache-ai:mainfrom
dorado269:yihou/hip-copy-stream-priority-20261027

Conversation

@dorado269

@dorado269 dorado269 commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Description

Add opt-in MC_HIP_STREAM_PRIORITY=high for HIP transfer streams. A transfer stream at the normal priority can wait behind compute work; high priority requests the device's greatest supported stream priority while preserving nonblocking semantics. Unset/default retains today's behavior, and invalid values warn and use the default. This is a scheduling hint, not a guarantee of preemption.

Rebased the yihou M02 patch onto Mooncake main 72e267f4 on 2026-11-02. The original HIP validation below was performed at 13df6a68; the stream-pool implementation and its test source are unchanged by this rebase. Historical isolated peer-copy experiments R039/R043 reported a roughly 200 ms to 11 ms stall reduction behind long kernels. The prepared priority image was never used for an end-to-end serving run, and that historical number is not a measurement of this new revision. No simulated-acceptance or combined-stack throughput is claimed.

#4953 changes HIP asynchronous batch submission; it does not add this stream-priority selection. #4340 is an independent IPC correctness fix owned by its author, tracked separately.

Suggested Merge Priority

  • P3 — Optional performance enhancement requiring workload qualification.

Module

  • Transfer Engine (mooncake-transfer-engine)

Type of Change

  • Performance improvement
  • Documentation update

How Has This Been Tested?

On an allocated MI355X with ROCm 7.2:

cmake -S . -B /data/yihou/glm52-upstream-20261027/mooncake-build \
  -DUSE_HIP=ON -DUSE_CUDA=OFF -DWITH_STORE=OFF -DWITH_STORE_RUST=OFF \
  -DBUILD_UNIT_TESTS=ON -DBUILD_EXAMPLES=OFF
cmake --build /data/yihou/glm52-upstream-20261027/mooncake-build --target hip_stream_pool_test -j 8
ctest --test-dir /data/yihou/glm52-upstream-20261027/mooncake-build \
  -R hip_stream_pool_ --output-on-failure

4/4 registered CTest cases pass: default/high/invalid/unset, each with priority/flags/round-robin/byte-copy and zero-count tests. Direct compilation with hipcc -std=c++17 -Wall -Wextra -Werror also passes. With the unmodified main stream-pool implementation, the high-priority test fails (observed priority 0, expected -1), while the zero-count control passes.

All applicable PR-scoped pre-commit hooks pass with clang-format 20. make -C docs html succeeds and the new environment option appears in the generated page. Initial full configure required initializing the existing extern/pybind11 submodule; configure/build/CTest then succeeded.

  • Unit tests pass
  • End-to-end peer-copy/serving tests under concurrent compute

Checklist

  • Code/diff reviewed by the preparing agent
  • Human submitter's line-by-line review completed
  • C/C++ formatting and PR-scoped pre-commit pass
  • Documentation updated and built
  • Regression tests added

AI Assistance Disclosure

  • AI tools were used: Codex assisted with rebasing, tests, validation and this PR text. No assistant or co-author commit trailers were added.

Follow-up, 2026-11-02

The old Python 3.10 wheel failure was ModuleNotFoundError: mooncake._structured_ranges, introduced in the base by #3954 and fixed by merged #5030. This branch now includes that fix. The packaging source regression python -m pytest -q python/tests/packaging/test_project.py::test_structured_object_storage_has_one_authoritative_source passes (1 test), and all applicable PR-scoped pre-commit hooks pass. Upstream CI is rerunning; a complete wheel rebuild was not performed locally.

The current #4953 revision (35c488e9) still acquires streams through stream_pool_.getNextStream(device_id) and does not change the stream pool's priority creation. Source review finds no competing priority implementation; combined runtime qualification is not claimed. #4953 is coordination work, not an established mandatory merge dependency for this opt-in.

Review and validation status

  1. Human submitter review remains pending. At the submitter's explicit request, this PR is Ready for Review so they can review the rebased diff. The unchecked checklist remains accurate; the preparing agent does not certify human review.
  2. Maintainer CI and review after this rebase. Copy/compute-interference measurements are workload qualification before enabling the option for a serving workload; they are not a blanket prerequisite for reviewing this default-preserving option. Historical microbenchmark claims remain historical and no production speedup is claimed.

New-head CI update: the CUDA CTest build now fails before tests in on_cuda_transport_guard_test because mooncake_te_build_config.h is not on its include path (job). The target/test/header are unchanged from main in this PR. Existing #5144 fixes this distinct base regression; it is open and tracked as the current build blocker. This is separate from the old wheel issue fixed by #5030.

Follow-up, 2026-11-12

Rebased without conflicts onto main f959efbe. Signed head b118a28e. The earlier generated-header build blocker #5144 is now merged and included (d872c349); the previous CI note above describes the historical November 2 run. The HIP stream-pool implementation and HIP test source are byte-identical to the previous PR head 8313cccb. All applicable PR-scoped pre-commit hooks and the structured-ranges packaging regression (1 test) pass locally. No new GPU or serving benchmark was run; prior scoped HIP evidence remains historical. Fresh upstream CI is requested by the push/ready transition. Human line-by-line review is still pending and is not claimed complete.

@dorado269

dorado269 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Rebased onto main 72e267f4 as signed 8313cccb, including the merged wheel staging fix #5030. The old Python 3.10 _structured_ranges import failure is attributable to the base packaging omission, not this HIP stream option. The dedicated packaging regression now passes locally (1 test); PR-scoped pre-commit also passes. Upstream CI is rerunning.

The stream-pool implementation and test source are unchanged, so the prior allocated MI355X 4/4 CTest evidence remains applicable to that delta; no new GPU run or full wheel build is claimed. Checked #4953 at 35c488e9: it uses the existing pool API and does not replace stream priority creation. The body now distinguishes optional workload qualification from the remaining human line-by-line review requirement. Keeping this PR draft until that human review is complete.

New-head CI update: the CUDA CTest build now fails before tests in on_cuda_transport_guard_test because mooncake_te_build_config.h is not on its include path (job). The target/test/header are unchanged from main in this PR. Existing #5144 fixes this distinct base regression; it is open and tracked as the current build blocker. This is separate from the old wheel issue fixed by #5030.

@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 if CI passed

@ShangmingCai
ShangmingCai merged commit d605bbc into kvcache-ai:main Nov 12, 2026
37 of 39 checks passed
jfeng18 added a commit to jfeng18/Mooncake that referenced this pull request Nov 14, 2026
* upstream/main: (95 commits)
  [Bugfix][TENT] Honor EFA protocol in classic shim (kvcache-ai#5280)
  [Doc] Add the AMD ATOM integration and homepage blog posts (kvcache-ai#5380)
  [Store-RS] Fence Store-RS eviction and delete by allocation identity (kvcache-ai#5243)
  fix: preserve integer map keys in structured non-tensor reads (kvcache-ai#4603)
  [Bugfix][TE][Store] Fix CXI transport so Mooncake Store works over Slingshot (kvcache-ai#5454)
  [Store] Coalesce removal KV events before publishing (kvcache-ai#5467)
  [CI/Build][Doc] Ship EFA in the default wheels only (kvcache-ai#5322)
  [CI/Build][Doc] Ship EFA in the default wheels only (kvcache-ai#5322)
  [Store] Shard LeaseEvictionIndex and parallelize memory eviction (kvcache-ai#5448)
  [TransferEngine] Open intra-node NVLink IPC mappings on the source buffer's device (kvcache-ai#5443)
  [Bugfix][TENT] Temporarily disable smart scheduling by default (kvcache-ai#5445)
  [TENT] Add a blocking waitTransfer entry point (kvcache-ai#5415)
  [EP] Add planned runtime scaling to ElasticBuffer (kvcache-ai#5376)
  [Store] Persist object upload and cleanup recovery records (kvcache-ai#5310)
  [TransferEngine] Add opt-in high-priority HIP copy streams (kvcache-ai#5005)
  [Store] feat: break master key count and value bytes down by configurable key groups (kvcache-ai#5393)
  [Store] Populate HugeTLB EFA segments in parallel (kvcache-ai#5457)
  [CI/Build] Prevent OOM in PR unit-tests build on GitHub-hosted runners (kvcache-ai#5420)
  [Store] Add automatic pipelined gather to ranged reads (kvcache-ai#4502)
  [Store] Add property tests for structured member byte-range plans (kvcache-ai#5328)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation run-ci size/M 100-1000 changed lines (additions + deletions) Transfer Engine

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants