Repository navigation
[Reshard] Plan Store-backed KV cache reuse across host layouts - #4741
kunkunblueberry wants to merge 1 commit into
Conversation
9e283e3 to
d7ff9b4
Compare
|
CI status update: two separate failures, both addressed.
|
d7ff9b4 to
1930976
Compare
|
Rebased onto current |
First slice of RFC kvcache-ai#4719 (Mooncake Store KV Cache Reshard). It implements the logical planning half of the RFC -- model semantic domain, logical page keys, source layout manifests, target-driven byte-range generation and read-template caching -- as a new pure-Python subpackage next to the existing runtime-to-runtime planner. It deliberately does not touch the Store write protocol (multipart RFC kvcache-ai#4366) or the SGLang integration: those are separate slices. Why this shape: - Logical keys are the reuse contract. ModelSemanticDomain carries only what changes KV content (namespace, model identity and revision, dtype, page size, the global layer set, KV-head count and head dims); TP, PP, rank identities and physical layout are excluded, so the same token prefix maps to the same Store key across topologies. The domain digest is embedded in the page key and in the manifest key. - The source manifest is the only description of a stored layout. Parts declare the global layers and KV-head interval they cover; part byte geometry (lengths, K/V offsets, strides) is *derived* from the layout and the logical descriptor, so there is exactly one representation of byte geometry. Manifests are content-addressed: decoding recomputes the digest and rejects tampered or mismatched payloads. - Planning is target-driven. The reader's own host layout decides target offsets; the manifest decides source offsets; the two meet only at logical (layer, head) coordinates. Ranges are merged only when the merged run is contiguous on *both* sides, so a plan never reads or overwrites unrelated bytes to enlarge I/O, and a strided side simply yields more, smaller ranges. - Three host layouts are supported and tested byte-exactly: PLHD, LPHD and HPLD (SGLang page_first / page_first_direct|layer_first / page_head). The full 3x3 conversion matrix is verified element by element, including uneven PP layer subsets, head-sharded sources, and requirements whose head interval spans several Parts. Read templates cache the relative offsets of a plan keyed by the manifest digest, the target binding identity and the requirement; they hold no live addresses and never replace the Store's own readability and lease checks. Tests: 78 new cases in tests/kv_cache_store_reshard, all passing; the existing reshard suites are unchanged (884 passed, 1 environment-only failure in a native-store test that needs the compiled extension). RFC: kvcache-ai#4719
1930976 to
e16c7ae
Compare
|
CI note: the last
To get a clean signal I re-pushed the same tree (new commit hash, identical tree) so CI starts a fresh run. If the same scenario test fails again, please treat it as #4722 flakiness rather than a regression here. |
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
Hi @kunkunblueberry, sorry for missing this. I'm the author of RFC:#4719. logical plan of KV reshard have been merge into |
|
Closing this as superseded by #4762, which the RFC author (@LLLL114) has since merged and which covers this slice. I compared the merged
It also goes further than this PR (upload planning, Store binding and serde, TP/PP placement, and a Keeping a second |
Description
First slice of RFC #4719 (Mooncake Store KV Cache Reshard). This PR implements the logical planning half of the RFC: model semantic domain, logical page keys, source layout manifests, target-driven byte-range generation, and read-template caching. It is a new pure-Python subpackage (
mooncake.reshard.kv_cache.store_reshard) next to the existing runtime-to-runtime planner and changes no existing module.Deliberately out of scope, to keep review focused and to avoid colliding with in-flight work:
part_count/part_indexRPC changes here;Design
ModelSemanticDomaincarries only what changes KV content: namespace, model identity and revision, dtype, page size, the global layer set, KV-head count, and K/V head dims. TP, PP, rank identities and physical layout are excluded, so the same token prefix maps to the same Store key across topologies, and the domain digest is embedded in both the page key (<prefix>_<token hash>_<domain digest>) and the manifest key (kv/<domain>/manifests/<layout digest>).from_jsonrecomputes the digest and rejects tampered or mismatched payloads, and validation rejects layer gaps, cell overlap, non-dense part indices and head-axis gaps.ReadTemplateCachekeys relative-offset plans by (manifest digest, target binding id, requirement fingerprint); host-pool reallocation invalidates a binding's templates explicitly, and a cache hit never replaces the Store's own readability and lease checks.Supported layouts
PLHD, LPHD and HPLD (SGLang
page_first/page_first_direct|layer_first/page_head), with K before V inside each Part.Suggested Merge Priority
Module
mooncake-transfer-engine)mooncake-store)mooncake-conductor)mooncake-reshard)mooncake-ep)mooncake-pg)mooncake-integration)mooncake-p2p-store)mooncake-wheel)mooncake-common)mooncake-rl)Type of Change
How Has This Been Tested?
Test commands:
Test results:
Coverage of the new suite:
tests/test_reshard_geometry.pyis excluded from the regression run becausehypothesisis not installed in the test environment used here (pre-existing, unrelated to this PR).Checklist
./scripts/code_format.shAI Assistance Disclosure
The change was drafted with AI assistance (module decomposition, geometry derivation, planner merge algorithm, and the test suite); the human submitter reviewed every changed line and can defend the change end to end. Tests were run on a private build host.