Repository navigation
Conversation
Sleep mode maps new physical pages for the KV cache at the same addresses, so a transport registration of that memory goes stale. The worker now releases the KV connector before the KV cache is unmapped and restores it after it is mapped again; Mooncake implements both over RDMA. A connector that does not support sleep mode is refused at startup with sleep mode. Signed-off-by: aoshen02 <aoshen@inferact.ai> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- Connectors support sleep mode by default; NIXL and Mooncake over a protocol other than RDMA are refused, as they hand the KV cache to a peer and cannot re-register it. - Mooncake release: an expired send no longer holds the release, only pulls that write local blocks are waited for, and a wedged transfer loop fails at the deadline instead of hanging. - Drop the EngineCore handshake re-publish; Mooncake publishes none. - Tests: the expandable-segments sleep test uses a supported connector, the config gate gets a model-free test, and the NIXL MNNVL doc no longer suggests sleep mode. Signed-off-by: aoshen02 <aoshen@inferact.ai> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MooncakeStoreConnector registers the KV cache with RDMA once. After a sleep/wake cycle the cache lives in new physical pages, but the store keeps the old registration, so transfers silently return wrong outputs. Report supports_sleep_mode() = False so the config check refuses the combination up front; re-registering on wake is left for a follow-up. Signed-off-by: aoshen02 <aoshen@inferact.ai> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Documentation preview: https://vllm--59934.org.readthedocs.build/en/59934/ |
- Refuse sleep mode with MoRIIOConnector: like NIXL, its peers keep the RDMA registration of the KV cache, which a sleep makes stale. - A timed-out Mooncake release now always raises the builtin TimeoutError with its message, also when the future wait times out (Python 3.10 too). - Name the configured connector in the sleep mode refusal. - Tests: cover pull counting through the bootstrap path, pin the timeout message, and drop tests duplicated by the config table. Signed-off-by: aoshen02 <aoshen@inferact.ai> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MooncakeStoreConnector registers the GPU KV cache with the store, and over RDMA the registration pins the physical pages. Sleep mode unmaps them and wake maps new pages at the same addresses, so puts and gets kept using the old pages and returned wrong outputs without errors. Before the KV cache is unmapped, wait for queued puts and gets and then unregister the device KV regions; after it is mapped again, register the same addresses and lengths. Both steps are all or nothing: a failed call undoes the ones already made. Host-resident (HiSparse) regions are not touched by sleep and stay registered. Sleep mode is accepted for the rdma and tcp protocols of the Mooncake config, unless MC_FORCE_MNNVL or MC_INTRANODE_NVLINK makes Mooncake install an nvlink transport instead. Signed-off-by: aoshen02 <aoshen@inferact.ai> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
aoshen02
force-pushed
the
mooncake-store-sleep
branch
from
October 4, 2026 12:58
8df5f98 to
5d7a2b2
Compare
5 of 20 tasks
Contributor
|
This pull request has merge conflicts that must be resolved before it can be |
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.
Purpose
Stacked on #59625; only the last commit is new.
MooncakeStoreConnector registers the GPU KV cache with the Mooncake store (
register_buffer). Over RDMA, that registration pins the physical pages. Sleep mode unmaps the KV cache, and wake maps new pages at the same virtual addresses. The store keeps using the old pages, so puts and gets read and write memory the model no longer uses.Evidence on main (GB300, Qwen3-8B, two instances sharing one store; instance A sleeps at level 1, instance B never sleeps):
With #59625 alone, this combination is refused at startup ("MooncakeStoreConnector does not support sleep mode").
This PR implements the #59625 hooks for MooncakeStoreConnector:
release_kv_caches()runs before the KV cache is unmapped. It waits until the put queue and the shared get queue have no queued or running tasks, then callsunregister_bufferon each device KV region. All store puts and gets run on those queues; lookups only query keys.VLLM_MOONCAKE_ABORT_REQUEST_TIMEOUT(480 s by default), the same boundMooncakeConnectoruses for its release in [KV Connector] Support sleep mode with MooncakeConnector over RDMA #59625. That is well above Mooncake's 60 s per-transfer timeout, so a slow queue does not fail the sleep. On timeout it raisesTimeoutErrorand keeps the registration. The wait shares one helper withclose().restore_kv_caches()runs after the KV cache is mapped again. It registers the same addresses and lengths.supports_sleep_mode()reads the protocol from the Mooncake config file (MOONCAKE_CONFIG_PATH). The workers use the same file to set up the store. It acceptsrdmaandtcpand refuses other configured protocols. The check runs only when sleep mode is enabled, and it does not import mooncake. If the config is missing, startup fails with the existing "MOONCAKE_CONFIG_PATH is not set" error.cudaMemcpyon the virtual address, and nothing is pinned.MC_FORCE_MNNVLorMC_INTRANODE_NVLINKis set. Mooncake then installs an nvlink transport even withprotocol: rdma. Like Mooncake, it checks only that the variable is set, not its value.Test Plan
threading.Eventis set. A timeout keeps the registration.MC_FORCE_MNNVL(also=0) andMC_INTRANODE_NVLINKrefused; missing config. Mooncake is blocked from import.pytest tests/v1/kv_connector/unit/{test_config,test_mooncake_store_*,test_mooncake_connector,test_multi_connector}.py tests/v1/worker/test_sleep_mode_backend.py. The store tests were also run 5 times. pre-commit was run on the changed files.mooncake_master, Qwen3-8B):/sleep?level=1+/wake_up; 1× level-1 sleep then/wake_up?tags=weightsand/wake_up?tags=kv_cache; 1×/pause+/release_kv_cache_memory+/wake_up?tags=kv_cache./reset_prefix_cache?reset_external=trueat the same points. This performs the same store wipe as sleep, without unmapping anything.Test Result
test_config,test_mooncake_store_worker,test_mooncake_connector,test_multi_connector,test_sleep_mode_backend): 407 passed, 2 failed. The 2 failures are intest_multi_connector.pyand are unrelated to this change: one needs the gatedmeta-llama/Llama-3.2-1B-Instruct, the other needsray, which is not installed. They fail the same way on [KV Connector] Support sleep mode with MooncakeConnector over RDMA #59625 alone. Alltest_mooncake_store_*files: 332 passed in each of the 5 runs.release_kv_cache_memoryElines,ERRORlines, and tracebacks were all 0 on A and B).Not covered:
TRANSFER_FAILeven without sleep, with both P2PHANDSHAKE and the HTTP metadata server. An earlier H200 run of main with TCP and sleep returned 8/8 with memory fully freed, but it was not repeated with this commit.VLLM_ENABLE_V1_MULTIPROCESSING=0). The drain insiderelease_kv_cachesis what covers it there.Known limitations:
release_kv_cache_memoryreset the connector before the release. On rank 0 that reset waits for the put queue with no bound, so a stuck put hangs there, not in the bounded release.tryinKVCacheStoreRecvingThread._handle_requestnever callstask_done. The drain then never sees an empty queue, and every later sleep fails withTimeoutError. We found no scheduler input that reaches it. A fix needs a load-error report too, so it is left for a follow-up./sleep?mode=wait(and/pause?mode=wait) while connector loads are in flight returns 500 "Failed to reset KV cache ...", and the scheduler stays paused until/resume. UnderPAUSED_NEWthe scheduler counts only running requests, so requests holding blocks for an async load look idle. Usemode=abort, or call/resumeand retry.Known separate issue, not fixed here: sleep at level ≥ 1 resets the connector, which runs
remove_all(force=True)on the Mooncake master. One instance's sleep therefore deletes the KV of every instance that shares the master. It should be scoped by tenant.Additional Test Result: stress run
store_tp_size=2, so TP2 and TP1 share keys. 20 cycles. After each wake: get of keys another server put while it was asleep, own put read back, and cross-server read-back of its post-wake puts./reset_prefix_cache?reset_external=trueat the same points). Every hit read 2032/2048 tokens from the store.weights, thenkv_cache), andrelease_kv_cache_memory. 400/400 identical to control./sleep?mode=wait, with puts in flight: 64/64 complete, 0 timeouts, and requests not yet scheduled run after the wake.mode=abort: all aborted, and sleep takes 0.5 s.release_kv_cache_memorycycles: device memory returns to the same value every cycle, and store hits read 4160+ tokens. Exact-retrieval accuracy on store hits after a release equals an interleaved control on the same prompts (72/96 vs 72/96, with 140/144 per-request outcomes equal). Level-1 sleep was not run on this model: it would back up about 704 GB of weights to host RAM.This PR contains AI-assisted code (Claude Code); commits carry a
Co-authored-bytrailer.🤖 Generated with Claude Code