Repository navigation
[Store] Support sparse attention replay with aligned tensor I/O - #5581
Draft
zxpdemonio wants to merge 3 commits into
Draft
zxpdemonio wants to merge 3 commits into
zxpdemonio wants to merge 3 commits into
Conversation
zxpdemonio
force-pushed
the
feat/registered-tensor-buffer-leases
branch
4 times, most recently
from
November 17, 2026 10:03
4f8bcd4 to
8d5db6b
Compare
zxpdemonio
force-pushed
the
feat/registered-tensor-buffer-leases
branch
4 times, most recently
from
November 28, 2026 15:26
4750931 to
733c86d
Compare
Reuse registered range transfers for caller-owned tensor destinations and strict device-source chunks. Keep direct alignment opt-in and preserve ordinary structured fields. Signed-off-by: Cruz Zhao <CruzZhao@linux.alibaba.com>
Register caller-owned memory through the existing pool and retain its owner until lease release. Opaque byte-range borrows reuse the lease export count without exposing device memory through the Python buffer protocol. Retain failed cleanup for retry and quarantine ambiguous registration outcomes. Use the existing caller-owned Store lifetime: drain transfers and consumers, release borrows and leases, then close the pool before closing or resetting the Store. No global interception of raw registration or close is added. Share tensor row range planning across payload-only and encoded readers and validate the current destination layout against schema requirements and native registration bounds. Signed-off-by: Cruz Zhao <CruzZhao@linux.alibaba.com>
Keep one case per direct-read path, keep the direct-destination docs to ownership and lifecycle, and remove the prefer_pool plumbing that only changed an internal allocation path. Signed-off-by: Cruz Zhao <CruzZhao@linux.alibaba.com>
zxpdemonio
force-pushed
the
feat/registered-tensor-buffer-leases
branch
from
November 28, 2026 15:40
733c86d to
85b66be
Compare
This branch has not been deployed
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
Sparse attention replay stores rollout token/block selections for training to reuse. This PR lets Mooncake deliver those tensors into aligned, reusable buffers. Router replay can use the same byte-storage interface.
FieldSchema.direct_alignmentselects strict, payload-only reads into a registered CPU/CUDATensorDestination. Layout, dtype, shape, alignment, bounds and aliases are checked. Other schemas retain ordinary behavior.BufferPool.register_external_region()returns the existingBufferLease. Opaque borrows retain its allocation and prevent lease release. Confirmed unregister failures can be retried; ambiguous registration errors retain the owner without blind cleanup.The framework owns replay semantics and CUDA consumer scheduling. Mooncake reuses its pool, registration and range-transfer paths. Drain consumers and release borrows/leases/pool before closing or reconfiguring the Store or sleeping its allocator; raw operations on managed regions are unsupported. External registration requires a private classic engine without NoF. Strict CUDA I/O rejects unsupported paths, including TCP and TENT.
Rebased onto
d936855e3. Cumulative against that base: +2262/-144 — production +1142/-114, tests +1097/-30, docs +23. The revision removes the global RealClient ownership state machine and shares row planning and test setup. The tests keep one case per contract instead of one per parameter combination, and behaviour this PR does not touch is no longer re-tested here.Related overlaps: #5384 (pool release/retry), #5379 (registered source members); reconcile before merge.
Contribution: Cruz Zhao — implementation, tests and documentation.
Suggested Merge Priority
Module
mooncake-store)mooncake-integration)mooncake-wheel)Type of Change
How Has This Been Tested?
Rebuilt from source on this commit (Release, current nanobind bindings) and run on one CPU-only host.
test_dataproto_helper_reads_rows_with_real_store_ranges(ragged member) andtest_dataproto_helper_same_stage_append_reads_rows_with_real_store(object evicted, -704) also fail when the whole base test file is run on this host, both against the base build and against this branch's build; each passes when run on its own, so neither is introduced here.scripts/ci/tests110 tests OK (1 skip),mooncake-wheel/tests/test_testpypi_wheel_gate.py6 passed, clang-format 20 clean on all nine changed C++ files, ruff 0.6.9 clean on the changed Python files, andgit diff --checkpasses.This Draft still needs GPU/RDMA validation on the rebased tree and independent final review. Earlier GPU builds do not validate this tree; no end-to-end performance claim is made.
Checklist
AI Assistance Disclosure
OpenAI Codex assisted with implementation, review, tests and drafting. Assistant review is not presented as human review.