Repository navigation
Conversation
c537c01 to
f1b1689
Compare
| SLOT_BYTES = 64 << 10 | ||
|
|
||
|
|
||
| def _require_mooncake() -> None: |
There was a problem hiding this comment.
Please check that mooncake_master comes from the same pinned distribution as the client, and record both versions in the run log. Beyond the current cases, the real-pool run should also cover a TRANSFER_FAIL get (access stays unproven), a lease-expired reread, a master kill, freeze and restart, a store-side freeze during a put, and process exit while a call is blocked.
There was a problem hiding this comment.
Version part done: the master must be shipped by one of the pinned distributions and report 0.3.13, every installed pinned client build must be 0.3.13, and both versions are printed and recorded as a test-suite property. Of the extra cases, the real pool covers a put stuck past the discard timeout. A TRANSFER_FAIL get and a lease-expired reread are covered only over the fake SDK (test_mooncake_driver.py). Master kill/freeze/restart, a store-side freeze during a put, and process exit during a blocked call are not in this PR.
There was a problem hiding this comment.
Follow-up on the real-pool cases: I added test_real_keys_whose_put_start_timed_out_are_never_started_again (0c963ef; f91b0e1 widens its discard timeout). It SIGSTOPs a real 0.3.13 master while the writer's start times out (MC_RPC_TIMEOUT_MS=1000, so the start answers RPC_TIMEOUT). After SIGCONT the master runs that start for the writer's client: its log shows BatchPutStart success=4 about 1 ms after the resume.
- A get then answers REPLICA_IS_NOT_READY, and another client's start answers OBJECT_ALREADY_EXISTS.
- The writer's republish makes only
BatchExistKeyand is DECLINED. - Past the discard timeout another client writes the keys. The writer's put is then READY on the existence check, and the reader gets exactly those bytes.
The real-pool conformance run now also covers main's check that a put keeps its access open while the store still reads the source.
Master kill/restart, a store-side freeze during a put, a TRANSFER_FAIL get, a lease-expired reread and process exit during a blocked call stay out of this PR: they need fault injection inside the SDK or the master. The driver's handling of each of those SDK answers is pinned over the fake SDK in test_mooncake_driver.py. The lease-expired reread test now also checks that each reread lands in its own slot.
7f29395 to
f2d736b
Compare
f2d736b to
6b51a8c
Compare
… of NVIDIA#20473 The backend now hands each call to the driver as one RowBatch and learns of it through on_change, with no queue or worker threads of its own; the copied files match 15c9491 apart from batch registration, cutting a call at a repeated key, the extent check and the example's cleanup. The tests, the README and the KVCR-shaped driver follow. Signed-off-by: Tingfeng Xian <[email protected]>
15c9491 to
47456bd
Compare
|
/bot run |
|
PR_Github #82688 [ run ] triggered by Bot. Commit: |
eopXD
left a comment
There was a problem hiding this comment.
Changes look good.
Nit: Explicitly state in document that only the pin version will be accepted or else rejected at startup.
|
/bot run |
|
PR_Github #82750 [ run ] triggered by Bot. Commit: |
|
PR_Github #82688 [ run ] completed with state
|
|
PR_Github #82750 [ run ] completed with state
|
MooncakeDriver implements the StoreDriver protocol over a set-up MooncakeDistributedStore from SDK 0.3.13, zero copy from and into the lender's registered host slots. A put starts a put session per key, writes every row in one scatter (batch_put_from_multi_buffer_ranges), ends the sessions of rows written whole and revokes the rest; a get is one batch_get_into. The module docstring cites the 0.3.13 sources each rule was read from. - put and get run on the executor loop's thread: a few comparisons whatever the batch's size (one span per row, at most 2 GiB a row, inside one live registration), then the operation is recorded and queued whole. Admitting one costs the same for any number of rows or parts. - A fixed pool of worker threads, started with the driver and ending when it drains, cuts parts off the queued operations, at most rows_per_call rows and bytes_per_call bytes each, and makes each part's SDK calls. Gets go first; once GETS_BEFORE_PUT_IS_DUE gets have gone ahead of a waiting put, that put goes next once a put may run, and puts take at most workers - 1 threads, so a get never waits behind puts alone. - on_change is called once an operation is done or turned unprovable, outside the driver's lock. A cancel ends the rows no worker took, and a drain those of every operation; the running parts run to their end. A worker an exception stops faults its part with access unproven and the others go on; once none is left, the rows no worker took fault and new operations are rejected. - Access end differs by call. The put scatter waits, without a timeout, until every task it posted finished, so its return ends access whatever it answers. batch_get_into can answer TRANSFER_FAIL for a future that gave up while its transfer still runs, so a get ends access only when no row answers TRANSFER_FAIL. A raise or a wrong answer count leaves access unproven. An operation whose access cannot be proven keeps its region from being unregistered and makes drain answer False at once. - Put sessions are per key and client. The driver never starts a session for a key one of its puts holds (that row is NOT_READY without asking the SDK) and ends only rows written whole. A session it cannot see ended or revoked stays in one ledger: left for drain to revoke (an end whose outcome is unknown, a start or put that raised or miscounted, a failed revoke), or left to the master when the target may still write into the object (TRANSFER_FAIL, a scatter that raised or miscounted). A key whose session is left open is never put again: it is READY when the master shows its object complete. - Codes become row results here and nowhere else: OBJECT_NOT_FOUND is a MISS; a key with no complete replica, a key held by this driver's put and an uncommitted object are NOT_READY; a full pool is DECLINED; an existing object is READY once the master confirms it; a read whose lease expired is read once more, READY or FAULT; the rest are FAULTs with their codes. Skipped rows are counted by reason in stats() and named in the part's warning. - Capabilities: absent_is_miss, host memory only, one span per row, cancel, no probe and no row limit of its own. close() closes the SDK client once a drain returned True and every region is unregistered. fake_mooncake.py implements only the SDK calls the driver may make, with 0.3.13's answers over real bytes; test_mooncake_driver.py pins the code mapping, sessions, access-end rules, scheduling, drain and close, a backend round trip, and that fetch and publish build no store key or RowIO per row and start no thread on the calling thread. The shared driver_conformance checks run over the fake SDK with every scenario it can stage. An exception escaping a thread fails the test; the tests that end a worker thread on purpose assert it ended by SystemExit. Signed-off-by: Chuang Zhu <[email protected]>
A deployment describes its store in a config file of its own, while the backend needs a MooncakeDriver over a set-up SDK client and a BlobConfig. mooncake_setup turns the one into the other. load_store_config reads the store config, a YAML file or the mapping parsed from one: a blob section for the caller's reader (BlobConfig for the blob backend), and a mooncake section read into MooncakeConfig, which also sets the driver's workers, rows_per_call and bytes_per_call (defaults measured on GB200 over RDMA). Unknown sections and keys, and values of the wrong type, are refused with their section; so are an unreadable file, a YAML error and a master address that is not one host:port. open_sdk refuses TCP's legacy framing, the local hot cache and the newer transfer engine (MC_USE_TENT, MC_USE_TEV1), whose behaviour the driver's rules were not read for; logs the Mooncake environment before setup; imports mooncake.store only when called, and refuses it unless every installed distribution that lists the module is a pinned 0.3.13 build; waits for the master; resolves the RDMA devices and the local address; and closes a client whose setup failed. open_mooncake_driver reads both sections before it opens the SDK, closes the client again when the driver cannot start its workers, and returns the driver with what the caller's reader returned. A client in service is never closed here. test_mooncake_setup.py covers config errors, setup arguments, device detection, a master that comes up late, the refused settings and SDK builds, a missing SDK, a half-open client, the opened driver working through its client, and the blob package's import layering. Signed-off-by: Chuang Zhu <[email protected]>
The fake SDK shows what the driver asks for; only a real master shows whether the SDK answers that way. test_mooncake_real.py runs the shared driver_conformance checks over a real pool, one fresh client per check, with the scenarios a real master can stage (a key another client is still writing, a get or put held inside the SDK), and runs the backend between real clients for what the fake models beyond them: a full pool that declines rows, a get that lands a shorter object's bytes and refuses a longer one, a second publish of keys whose sessions the same client still holds, also once the first put is stuck past the master's put_start_discard_timeout_sec, and four workers moving 2000 rows byte for byte. The clients give the pool no segment and keep no local buffer, so every object sits in another process's segment (running_segment_provider in test_common/mooncake_utils.py) and nothing falls back to the SDK's copying path. The file runs only with TRTLLM_MOONCAKE_REAL=1 and fails unless mooncake_master and the client are both a pinned 0.3.13 build; it records both versions as test-suite properties. An exception escaping a thread fails the test. Signed-off-by: Chuang Zhu <[email protected]>
… the blob backend The CPU and real-pool tests drive the backend with host slots of their own; none shows that what the staging lender lends is what the backend moves. test_blob_backend_round_trip.py does it end to end on a GPU: one real KV cache manager publishes a request's blocks through its lender's staging slots, another fetches them into a request of its own, and a test lease holder drives the lender as the runtime will (lend, wait for the view, submit it as it stands, wait for quiescence, mark what arrived, release). - Pages come back byte for byte and resume_bounds covers the prompt's three whole blocks, over the in-memory store and, with TRTLLM_MOONCAKE_REAL=1, a real Mooncake pool. Each driver moves every row separately, several at once: the in-memory driver takes one row per operation, each on a thread of its own; Mooncake cuts each operation into one-row parts on two workers. - A fetch whose later blocks fault marks only the delivered prefix, so resume_bounds stops at the first gap. Its in-memory driver ignores cancels: the rows run in any order, and the cancel a later row's fault forwards could otherwise end the first row before it started. The test builds each backend itself, as a factory will: it opens the driver, takes the lender's hold, registers the regions with RegionBinding, starts BlobBackend, and gives the hold back once the backend shut down. The lender's MemoryRegion names no memory kind, which SlotRegion requires, so the test registers host-memory SlotRegions made from the lender's regions, as a runtime must until the lender's regions name their memory kind. An exception escaping a thread fails the test. Signed-off-by: Chuang Zhu <[email protected]>
… makes no SDK call drain revoked the put sessions left open once it had drained, in one batch_put_session_revoke outside its budget. A slow or hung revoke then held up drain(0.0) on the backend's progress thread, and with it the revocation of the registrations and the lender's hold, although no access remained. close, the owner's last step under the blob backend's rule, now tries the revocation once before it closes the SDK client; close already waits on the master for the unmount. These sessions hold no lender memory, so nothing waits for them, and one whose revocation fails is freed by the master after put_start_release_timeout_sec. drain makes no SDK call and returns within its budget. The ledger's FOR_DRAIN becomes FOR_CLOSE, and the stats key put_sessions_left_for_close. close's docstring and open_mooncake_driver's say who closes: the caller that opened the driver, last, off the executor loop's thread. The setup and round-trip tests close their drivers that way, and the round trip keeps drivers rather than SDK clients for its fallback close. A new test holds a revoke inside the SDK and checks that drain returns at once without calling it; the session tests check that close revokes what drain left. Signed-off-by: Chuang Zhu <[email protected]>
…T_READY departs The blob backend cuts a group at a repeated object key, so no operation names a key twice; the driver keys a part's results by store key and relies on that. A test over the fake SDK publishes and fetches a view naming one key twice: two calls, no fault, both slots fetched. 0.3.13 cannot always confirm the hold that NOT_READY stands for: -703 also answers a complete replica it cannot read, batch_is_exist answers 0 for one too, and a session left open after a start that raised may not exist. The driver keeps NOT_READY for them, since the usual cause is a write in progress and a FAULT would stop every fetch that races a writer and count toward isolation; _SKIP_RESULTS now says so. Comments also say why a failed register_buffer certifies nothing was registered, and when the last worker's on_change may come after a drain returned True. The round trip's open_driver says how each driver moves its rows one by one. Signed-off-by: Chuang Zhu <[email protected]>
…, and pin the order What the review of the drain and close change found: - close closes the SDK client in a finally, so a BaseException from the revocation no longer leaves the client open behind a driver that already counts as closed. - Nothing pinned that close revokes before it closes the client. A closed 0.3.13 client answers every batch call with an empty list, which the driver would take as a failed revocation. The fake SDK now answers so too, and the session tests then fail if the order flips. - close's docstring: the revocation waits on the master without the GIL; only closing the client holds it through the unmount. - A put stopped by a raise is unprovable, so close never comes for its sessions; the class docstring says the master frees them. - The NOT_READY note names its one lasting case: a key whose left-open session the master freed stays NOT_READY, as it is never put again. - The worker-exit comment says when a drain returns True before the last worker's on_change, instead of when rows are left queued. - test_drain_leaves_the_session_of_an_unprovable_put_to_the_master is now test_an_unprovable_put_leaves_its_session_to_the_master, since drain revokes nothing. - The round trip's fallback close skips a driver a failed build never drained, so the clients after it still close, and its open_driver says Mooncake runs puts one at a time. Signed-off-by: Chuang Zhu <[email protected]>
…put of a key left open What the review of the NOT_READY departure settled: - RowStatus.NOT_READY now covers an object of the key that the store reports without a readable complete replica, as while a write has not finished or when no complete replica can be read, with the row memory of a get left untouched; and another put of the same driver, still running, that writes the key. RPC, transfer and integrity errors stay FAULT. README rule 4 says the same, and both say these statuses charge the row no fault rather than that nothing went wrong. - So Mooncake's first-read -703 and a put start's -705 with no complete object are NOT_READY under the rule itself, and the departure note in mooncake.py goes. - A put of a key whose session this driver left open, with no complete object behind it, is DECLINED with its own reason and counter (rows_declined_held_by_session_left_open), instead of NOT_READY under held_by_own_put. The driver never writes such a key again, and the put that left the session open already concluded FAULT, so a FAULT here would count that one failure again on every later put of the key. Beyond a store's own refusal, RowStatus.DECLINED covers only this case. - held_by_own_put keeps its name and counter but now means only another put of this driver writing the key now. - The probe docstring follows NOT_READY: a key a get would find NOT_READY is NOT_READY there too. Signed-off-by: Chuang Zhu <[email protected]>
…nswered The master matches a session end or revoke to an object by key and client alone, and an end answered RPC_FAIL or RPC_TIMEOUT may still run later, after a retry on another connection ended the session. If the object is then evicted and this driver puts the key again, the late end marks the new, unwritten object complete. Reproduced on a real 0.3.13 master. - A reserved key is now resolved only when the SDK refused its start or all its session calls had a known outcome and left no session. An end whose first answer was RPC_FAIL or RPC_TIMEOUT leaves the key open for close even when the retry ends the session; the row stays READY. A later put of the key is READY while the master shows its object complete, DECLINED once it does not. - A start refused with RPC_FAIL or RPC_TIMEOUT still resolves its key; leaving such keys open would bar every key a master outage met from ever being put again. The class docstring says what a late start can do. - Renames: _sessions_left_open to _keys_left_open, the per-part closed set to resolved, the skip reason held_by_session_left_open to left_open_by_own_put (counter rows_declined_left_open_by_own_put), and the stats put_sessions_left_* to put_keys_left_*. - RowStatus.DECLINED: the driver will not write the key again, as an earlier put of its own may still hold the key or act on a new write of it. Signed-off-by: Chuang Zhu <[email protected]>
… returns The Mooncake scatter reads the lender's slots directly, so a put whose access reads as ended while the scatter still runs lets the lender reuse memory the store is still reading. Until now only the conformance suite's blocked-put check caught that. NVIDIA#21314 drops that assertion from the suite, since a driver that stages the payload in memory of its own may truthfully end access early. This driver test keeps the property pinned for Mooncake: with the scatter held inside the SDK, the put's access has not ended, and once it returns the row is READY and access has ended. Signed-off-by: Chuang Zhu <[email protected]>
…thread The 0.3.13 binding's close holds the GIL through the whole client teardown, so calling MooncakeDriver.close off the executor loop's thread stalls the loop all the same. close and open_mooncake_driver now say the owner closes the driver at shutdown, once the executor loop stopped, and how long closing stalls: up to a few seconds while the SDK's threads stop and any segment is unmounted, and the SDK's RPC timeouts while the master does not answer. The revocation before it runs without the GIL. open_sdk says the same of setup. Measured on a real master: about 0.7 s with no segment, 1.7 s with a 256 MiB segment, 62 s with the master stopped. Signed-off-by: Chuang Zhu <[email protected]>
A put start answered RPC_FAIL or RPC_TIMEOUT may still reach the master after the client stopped waiting. The master lets a start replace an object whose put started over put_start_discard_timeout_sec ago, and matches an end to an object by key and client alone. So a late start may replace this driver's next put of the key with an unwritten object, which that put's end then makes readable. Reproduced on a real 0.3.13 master. - Such a start now leaves its key open for close, like an end answered RPC_FAIL or RPC_TIMEOUT: the driver never starts a session of the key again, and a later put of it only checks its existence (READY if the object is complete, DECLINED if not, FAULT if the check fails). The start's row stays FAULT. - The cost: every key whose start fails during a master outage is barred from this driver's puts, and kept in memory, until close, even one whose start RPC_FAIL answered without sending it. The class docstring says so, and says who frees what a late start reserved. - _END_OUTCOME_UNKNOWN becomes _OUTCOME_UNKNOWN, shared by start and end. Signed-off-by: Chuang Zhu <[email protected]>
…ands late The new opt-in test stops a real master with SIGSTOP while a writer with a 1 s RPC timeout puts four rows, so each start answers RPC_TIMEOUT. Once resumed, the master runs those starts for the writer's client: a reader finds the objects unwritten, and another client's start answers OBJECT_ALREADY_EXISTS. The writer's next put of the keys only checks their existence and is DECLINED. Past put_start_discard_timeout_sec another client writes the keys; the writer's put is then READY without a start, and the reader gets that client's bytes. _running_pool now returns the LaunchedMaster, so a test can reach its process. Signed-off-by: Chuang Zhu <[email protected]>
…ment size before setup open_sdk keyed its transport checks on the configured protocol, not on the transport 0.3.13 installs, and MooncakeConfig accepted values that failed only inside setup. - MC_TCP_PROTO=1 is refused whatever the protocol: under MC_FORCE_TCP an rdma client also uses TCP toward a segment served over it. - The client names its transport, so SDK transport discovery is refused: MC_MS_AUTO_DISC unless unset or 0, device_name "auto-discovery", and rdma with no device named and no active InfiniBand device, which now raises before the SDK import and the master wait instead of handing the SDK an empty device list. With discovery on, a host with no HCA visible ran on TCP, or on NVLink on the arm64 wheels. The NVLink variables stay allowed: they act only under discovery and are process-wide, so another engine in the process may need them. - master_server_address must be host:port, an IPv6 host in brackets, the port in 1..65535. An empty address crashed the process in setup, and one without a host or a port held the GIL for about 90 s before setup failed. - global_segment_size must be 0 or at least 16 MiB, the smallest segment the SDK's default allocation mounts; setup refused a smaller one only after reaching the master. - The setup log adds MC_FORCE_TCP and MC_MS_AUTO_DISC, and drops the refused TENT variables, which always printed unset. Signed-off-by: Chuang Zhu <[email protected]>
…aults - Both conformance suites stage a put whose source is still to be read, so main's check that such a put keeps its access open runs over the fake SDK and the real pool instead of skipping. - Four driver behaviors no test held: a reread after LEASE_EXPIRED lands in its own slot; a row that started behind one that did not is written from its own slot; drain cancels a queued put; a put runs after an unprovable put. - The fake raises on a get or an existence check after close, where the 0.3.13 binding crashes the process; only its session calls answer nothing. - The worker-stop test raced on which worker reached the fake first. B's get now waits behind a gate until A's worker exited, and the gate opens in a finally. - _running_pool stops its master when the segment provider fails to start, which left mooncake_master running past pytest. - The master-freeze test has its own 5 s discard timeout, so the observer's start lands within it on a slow host. Signed-off-by: Chuang Zhu <[email protected]>
The driver docstring cited only the path where a later start replaces a stale put. The master also frees one through its reaper, DiscardExpiredProcessingReplicas; either way it waits put_start_release_timeout_sec from the put's start. Signed-off-by: Chuang Zhu <[email protected]>
open_sdk raises ImportError for any other Mooncake SDK version or build before it connects to the master; say so in the blob README and the setup module's docstring. Signed-off-by: Chuang Zhu <[email protected]>
f24d818 to
75a7623
Compare
|
/bot run |
|
@eopXD Thanks. Done in |
|
PR_Github #83036 [ run ] triggered by Bot. Commit: |
|
PR_Github #83036 [ run ] completed with state |
Summary
This PR adds the Mooncake driver for RI-08D's blob backend, which is on main through #20884.
MooncakeDrivermaps [None][feat] Add the blob store driver boundary and an in-memory test driver #20217's privateStoreDriverboundary onto the pinned Mooncake 0.3.13 SDK.open_mooncake_driveropens the driver from the store's own config file.The factory that RI-02's TransferManager calls is left to a follow-up on top of #20266, whose
BackendFactoryshape (cleanup dispatcher,FactoryRejected) is still in review. Nothing is wired into the executor yet, so the path stays off until a runtime assembles it.The initial profile follows the design: KVCM v2, TP1/DP1/PP1/CP1, one pool, host staging from the #19722 lender, and
Nonehints only. Names like RI-08D are items of the Runtime Integration design; M1–M5 are milestones of the Store Backend design. Both documents are linked below.What changed since the last review
Since the last update (
262e6fe019b). The branch is rebased onto mainb1c638a96a, so every hash below is new.a861c05778, thread from @Shixiaowei02). Such a start may still reach the master after the client stopped waiting. Pastput_start_discard_timeout_secit replaces the object of this driver's next put of the key with an unwritten one, and that put's end, which the master matches by key and client alone, then makes it readable. The key is now left open for close, like an end whose outcome is unknown: the driver never starts it again, and a later put of it only checks existence. This reverses the earlier choice to free such a key. The cost: every key whose start fails during a master outage is barred from this driver's puts, and kept in memory, until close.b954680728): an opt-in test stops a real master with SIGSTOP so the writer's start times out, then shows the start landing once the master resumes and the writer never starting those keys again.c1c3782f4a:open_sdkchecks the transport 0.3.13 installs, not the configured protocol.MC_TCP_PROTO=1is refused for any protocol, and so is the SDK's own transport discovery:MC_MS_AUTO_DISC,device_name: auto-discovery, and rdma with no device named or found, which only logged a warning. With discovery on, a host with no HCA visible ran on TCP, or on NVLink on the arm64 wheels.MooncakeConfigchecks the master address, since an empty one crashed setup and one without a host or a port held the GIL for about 90 s. It also refuses a segment between 1 B and 16 MiB.2fec499371: both conformance suites now run main's check that a put keeps its access open while the store reads its source. Four driver behaviors no test held are pinned. Four test faults are fixed: the fake's answer after close, a racy worker test, a master left running when a segment provider fails, and the freeze test's discard margin.c2eb27f712: the docstring cites both ways the master frees an unfinished put.75a7623a7a, @eopXD's nit): the blob README and themooncake_setupdocstring say that only Mooncake SDK 0.3.13, from the three listed builds, is accepted, and thatopen_sdkraisesImportErrorfor any other version or build before it connects to the master.Earlier in this review. The backend moved to main. #20884 (merged as
b351c407bba) copiedblob/backend.py,keys.py,store.py, thetestingpackage and their tests verbatim from this PR's head15c9491ba4a. It then added:RegistersRegionsTogether);MemoryDriverfixes and new conformance checks;This PR was rebuilt on main
a9be7004c71and now holds only the Mooncake driver, its setup and their tests. The review threads on the backend and the boundary have replies, and that code is unchanged on main in those respects.New in this PR since that head:
drainmakes no SDK call (thread from @chienchunhung). It used to revoke the put sessions left open, in a blocking RPC outside its budget, which could hold updrain(0.0)and with it the backend's revocation and the lender's hold.close, the owner's last step under main's rule, now does that revocation before it closes the SDK client. A test sets up a gate that would hold a revoke inside the SDK, and checks thatdrainreturns at once without reaching it.open_mooncake_driversays what main's README says: the caller that opened the driver closes it last.closeadds that this happens at shutdown, once the executor loop stopped: closing the SDK client holds the GIL, so every Python thread waits whichever thread closes (thread from @JunyiXu-nv). The tests close their drivers last.RowStatus.NOT_READYnow covers an object of the key that the store reports without a readable complete replica, with a get's slot untouched, and another put of the same driver, still running, that writes the key; RPC, transfer and integrity errors stay FAULT. README rule 4 now defers toRowStatusfor these conditions. So Mooncake's first-read -703 and a put start's -705 with no complete object are NOT_READY under the rule, and the departure note is gone.rows_declined_left_open_by_own_put), when no complete object stands behind the key (thread from @nv-xtf, agreed). The driver never writes such a key again, and a FAULT here would count the earlier put's outcome again on every later put of the key. Beyond a store's own refusal,RowStatus.DECLINEDcovers only this case: the driver will not write the key again, as an earlier put of its own may still hold the key or act on a new write of it._keys_left_open,put_keys_left_for_close,put_keys_left_to_master).The previous head is kept as
backup/pr20473-before-rebase-onto-20884in the fork.Design
BlobBackend(RegionBinding(regions, driver, hold), wake, config)from main, over the driveropen_mooncake_driverreturnsmooncakesection of the store config:workers(default 4),rows_per_call(256),bytes_per_call(128 MiB), each counted per SDK call. Gets go first; once four gets have gone ahead of a waiting put, that put goes next. Puts take at mostmax(1, workers − 1)threads, so with two workers or more a get never waits behind puts alonehints, so main's backend refuses a hinted fetch before the driver is calleddrainanswer Falsebatch_is_existsees it committedblob/mooncake.py; see "Mooncake mapping" belowtest_mooncake_real.py;test_blob_backend_round_trip.py, with a real lender on GPU; main'sdriver_conformancesuite run againstMooncakeDriverover the fake SDK and over the real poolkv_sharing.backends: [{type: mooncake, config: <path>}], with store parameters in the store's own fileblob/mooncake_setup.pyreads a YAML file withblob(key prefix) andmooncakesections; no LLM args are addedDepartures
Mooncake mapping
put calls the session API, one SDK call per step for a part of up to
rows_per_callrows:batch_put_session_start, thenbatch_put_from_multi_buffer_ranges(one scatter for the part), thenbatch_put_session_endfor the rows written whole. The rest getbatch_put_session_revoke, except a key whose session calls did not all have a known outcome, which is left open (see "Put sessions" below).wait()has no timeout. It returns only once every fragment has physically finished.batch_put_from, by contrast, a transfer that times out after 60 s is revoked at once while RDMA writes may still be in flight. A late write could then land in space the master has already given to another object.get is one
batch_get_intoper part.batch_get_into.Put sessions are per key and per client.
put_start_release_timeout_sec;closeto revoke: a session start that raised, miscounted, or answered RPC_FAIL or RPC_TIMEOUT, an end whose first answer was RPC_FAIL or RPC_TIMEOUT (even when the retry ended the session) or that raised or miscounted, a failed revoke, or a put stopped by a raise. They hold no lender memory, sodrainleaves them; one whose revocation fails is freed by the master. A put stopped by a raise is unprovable, soclosenever comes and the master frees its sessions too.Results:
batch_is_exist0)batch_is_exist0)batch_is_exist1Access-end evidence:
batch_get_intoanswers every row and no answer is TRANSFER_FAIL.access_unprovable: a TRANSFER_FAIL on a get, an exception, or a wrong answer count. It keeps its region from being unregistered and makesdrainanswer False. The backend keeps the attempt's slots for good.Capabilities:
get,putandcancel. Cancel ends the rows no worker has taken; the SDK cannot stop a running call.absent_is_miss: the master answers OBJECT_NOT_FOUND for a key it does not hold, before any transfer.device_memory=False). Main's backend refuses a row in any other region withInvalidSubmission, and a lender with no such region withConstructionRejected.multi_span=False):batch_get_intoreads each object into one buffer.max_rows_per_op=None), since the driver cuts parts itself.RegistersRegionsTogether.Shutdown:
draincancels the rows no worker took, ends the worker threads and waits for the running parts, and makes no SDK call.close, once a drain returned True and every region is unregistered, revokes the sessions left for it and then closes the SDK client, even if the revocation raised. The revocation waits on the master without the GIL. Closing the client holds the GIL throughout, so every Python thread waits, whichever thread closes: measured on a real master, about 0.7 s with no segment, 1.7 s with a 256 MiB segment, and 62 s with the master stopped (each pending call waits out the SDK's 30 s RPC timeout). The owner therefore closes the driver at shutdown, once the executor loop stopped; nothing in the tree closes one while serving.Scope
26a2f87108Add the Mooncake store drivermooncake.py12663203acOpen a Mooncake store driver from a store configmooncake_setup.py850a0fb5ecRun the blob backend over a real Mooncake poolTRTLLM_MOONCAKE_REAL=1) againstmooncake_masterand a segment provider, plus the conformance suite on the real store39d4d355edRound-trip KV blocks between two staging lenders through the blob backend0d36ef1fdfRevoke the Mooncake sessions left open in close, so drain makes no SDK calldrain,closeeeb407e0c4Pin a repeated object key over Mooncake and say where NOT_READY departs784303f6cdClose the Mooncake client even when its revocation raises, and pin the orderclosea08df88adcWiden NOT_READY to what the store reports, and decline a put of a key left openRowStatuswording (NOT_READY, DECLINED, the class and probe docstrings), README rule 4, the left-open reason inmooncake.pyb81970da4bLeave a Mooncake key open when its first put end went unanswered_end_sessions(the first end answer decides the key), the ledger renamed to keys, main'sRowStatus.DECLINEDwording978671ad13Pin that a Mooncake put holds its slot until its scatter returnsmake_put_still_reading_the_source, which2fec499371implements for both Mooncake suites, since the Mooncake scatter reads the lender's slots directlyddcf9ffca7Say that closing the Mooncake client stalls every Python threadclose,open_mooncake_driverandopen_sdkdocstringsa861c05778Leave a Mooncake key open when its put start went unanswered_put_reserved,_OUTCOME_UNKNOWNshared by start and end, the class docstringb954680728Freeze a real Mooncake master so a timed-out put start lands latec1c3782f4aCheck Mooncake transport settings, master address and segment size before setupopen_sdk,MooncakeConfig2fec499371Cover more Mooncake driver behaviors and fix four test faultsc2eb27f712Cite both ways the Mooncake master frees an unfinished putmooncakemodule docstring75a7623a7aState that the Mooncake driver accepts only SDK 0.3.13mooncake_setupdocstringThe first two commits add the Mooncake modules to
blob/__init__.py; the first three list them in main'sblob/README.md.Production code: +1563 / −12 lines, of which main's
store.pyis +15 / −11, plus +17 / −3 in the README. Tests: +3472 / −2 lines. Each commit passes the CPU tests present at it.Verification
75a7623a7a, over main's backend: run on the previous baseec8797b9fcwith the same PR files, as the local build predates a C++ op main added since; CI covers the new base.l0_cpu.b954680728: 88 mutants overmooncake.pyandmooncake_setup.py. Every survivor that changed a slot's bytes, a row status, an access end or a queued operation got a test that kills it (2fec499371). Each checkc1c3782f4aadds was run against a mutant that drops or loosens it.drain/closetests were checked against mutants: revoking indrainagain, revoking after the client is closed, and closing without thefinallyeach fail them.c2eb27f712: 31 passed, 20 skipped, including the master freeze and main's check that a put keeps its access open while the store reads its source; the three batch-registration checks are skipped, as Mooncake registers one region at a time.f2d736b023d.pyexecutor/kv_cache/sharing, inl0_a10; main moved it there fromexecutor/in [TRTLLM-14849][chore] Rename tests/unittest/_torch/executor to pyexecutor and split out its connector tests #20669), written against main's backend: passed in CI'sA10-PyTorch-2stage (L0 pipeline 66862), on the same diff before the rebase ontoa9be7004c71. It moves each row on its own: the in-memory driver takes one row per operation on a thread of its own, and Mooncake cuts each operation into one-row parts for two workers.Objects of the wrong size. Both cases are checked.
real_client.cpp:5134-5141).real_client.cpp:5169-5180). The driver reports FAULT, its access ends normally, and nothing outside the row is touched.Performance
Driver-owned concurrency against the previous design, on CPU. These numbers were measured at
15c9491ba4a, before the rebase, againstf2d736b023d, and have not been re-run. The backend part of what they measure is now main's; main has since moved the repeated-key check into the call cut, and nothing else on the measured path.Mean submission to settle, torch-like executor:
The executor's own cost, pure-Python executor:
fetch/publish) p99Worker CPU per submission is less than half of what it was. Settle with the pure-Python executor stays as before for 1 × 256, improves for 1 × 4096 (p50 56.7–57.0 → 52.3–52.4 ms), and is slower for 4 × 256 (p50 20.3–20.6 → 24.8–25.0 ms); see "Known limitations".
Throughput on two GB200 nodes over RDMA, measured on
f2d736b023d, not yet on this branch.A row is one KV block (32 tokens) across all layers of a layer group, holding this rank's heads. With TP the rows shrink, so realistic rows are 0.25–2.5 MiB: Llama-3.1-8B at TP4 1 MiB, Llama-3.3-70B at TP4 2.5 MiB, DeepSeek-V3 (MLA) 2.1 MiB.
Please confirm
batch_get_into. SDK 0.3.13 answers TRANSFER_FAIL alike for a failed slice, a status-query error, a partly submitted batch and its 60 s timeout. In the last three cases the transfer may still be running, and the answer does not say which case it is (transfer_task.cpp:746-805, 813-905, 1239-1258).batch_get_intoand asks for a containment profile that is not executor-fatal for a store fetch, since the request can recompute instead.driver_call_limit(region)returns None. One driver call is then a layer group of a submission, cut only where it names an object key twice, and a holder bounds what one unprovable call holds by the size of its leases.b81970da4b), and now so is a key whose put start went unanswered (a861c05778, after @Shixiaowei02's thread). That reverses the earlier choice to free such a key; the thread says why.Known limitations
list[int], so it converts an array element by element, measured 30 times slower thantolist().TLLM_NUMA_AWARE_WORKER_AFFINITY) does this.probe=False.batch_is_existcould back one later, but in 0.3.13 it answers 0 both for an absent key and for one still being written, takes no timeout, and renews the object's read lease on a hit.MemoryRegionaddsmemory_kind, whoever builds the backend handsRegionBindinghost-memorySlotRegions; the GPU round trip does this.open_sdkrefusesMC_STORE_LOCAL_HOT_CACHE_SIZEother than empty or 0, TCP's legacy framing (MC_TCP_PROTO=1, whatever the protocol), the newer transfer engine, and the SDK picking its own transport (MC_MS_AUTO_DISC,device_name: auto-discovery, or rdma with no device named or found).MooncakeConfigrefuses a master address that is nothost:portand a segment between 1 B and 16 MiB.on_changefor the rows still queued after it stopped counting. A drain returns True before that call only once every worker died of a BaseException that left no operation unprovable, which only anon_changeraising against the protocol does; underBlobBackendthe owner cannot close the driver before that call is recorded.Notes
The base is main
b1c638a96a, which contains #20117, #20217, #20884 and #21314.🤖 Generated with Claude Code
Dev Engineer Review
MooncakeDriveradds a host-memory implementation for Mooncake SDK 0.3.13. It supports batched transfers, session management, access tracking, cancellation, and shutdown.open_mooncake_driverloads the store’s configuration and opens the driver. Runtime factory and executor wiring remain out of scope, so the driver is not active unless a runtime assembles it.The driver retains access slots when it cannot prove an operation has ended. This can prevent a successful drain.
closerequires a successful drain and unregistered regions, then revokes eligible sessions and closes the SDK client. The initial supported profile is limited; verify its settings and assumptions against deployment needs.The supplied author-reported tests apply to earlier revisions and do not establish current test status. CI comments report pipeline failures attributed to the paused
L40S-PyTorch-2stage and agent or node issues; they do not identify specific failing tests.QA Engineer Review
The changes add CPU-only fake-SDK driver and setup tests, opt-in real-Mooncake tests, and CUDA-gated blob-backend round trips. The driver suite covers status mapping, transfers, session cleanup, access outcomes, scheduling, cancellation, drain, close, callbacks, and registration. The setup suite covers configuration, SDK and environment checks, networking, failure cleanup, and import boundaries. The real-pool tests cover declines, object-size handling, concurrent transfers, and duplicate publishes. The backend tests cover full and partial fetches.
No changed test file appears in the scanned
tests/integration/test_lists/test-db/ortests/integration/test_lists/qa/lists. The Mooncake entries found refer to other tests. Test results for the current revision are unavailable. Coverage verdict: needs follow-up.Per-File QA Perspective
tensorrt_llm/_torch/disaggregation/blob/README.md: Documents driver behavior, setup modules, test requirements, and verdict classifications. Verify the documented conditions againstRowStatusbehavior.tensorrt_llm/_torch/disaggregation/blob/__init__.py: Clarifies driver and setup responsibilities and lazy SDK imports. Verify that importing the package does not loadmooncake.storeprematurely.tensorrt_llm/_torch/disaggregation/blob/mooncake.py: Adds transfer, scheduling, access-tracking, cancellation, and shutdown paths. Verify SDK result mapping and cleanup when access completion is unprovable.tensorrt_llm/_torch/disaggregation/blob/mooncake_setup.py: Adds configuration parsing, SDK and environment validation, master checks, and driver setup. Verify supported settings and cleanup after failures.tests/test_common/mooncake_utils.py: Adds a subprocess-backed Mooncake segment provider with readiness and cleanup handling. No matching entry was found in the scanned CI or manual-QA lists.tests/unittest/_torch/disaggregation/blob/fake_mooncake.py: Adds a scripted fake SDK for driver tests. Verify that its session and buffer behavior represents the SDK cases under test. No matching entry was found in the scanned lists.tests/unittest/_torch/disaggregation/blob/test_mooncake_driver.py: Covers driver conformance, transfer limits and scheduling, result mapping, access tracking, and lifecycle behavior. No matching entry was found in the scanned lists.tests/unittest/_torch/disaggregation/blob/test_mooncake_real.py: Adds opt-in tests for real-pool transfers, concurrency, and duplicate publishes. No matching entry was found in the scanned lists.tests/unittest/_torch/disaggregation/blob/test_mooncake_setup.py: Covers configuration, SDK setup, networking, failure cleanup, and import boundaries. No matching entry was found in the scanned lists.tests/unittest/_torch/executor/kv_cache/sharing/test_blob_backend_round_trip.py: Adds CUDA-gated full and partial fetch tests. No matching entry was found in the scanned lists.tensorrt_llm/_torch/disaggregation/blob/store.py: ClarifiesNOT_READYandDECLINEDsemantics. Verify that callers handle concurrent or unresolved puts as documented.