[Core] Make sleep a pure memory-state transition - #53082
Draft
aoshen02 wants to merge 1 commit into
Draft
Conversation
sleep() no longer embeds request-fate policy: the internal pause_scheduler call, the mode parameter, and the pause-future chaining are removed. Sleep now requires a completed pause and raises EngineNotPausedError otherwise; pause_generation() / resume_generation() are exposed on the offline LLM stack, which previously had no pause entry point. Implements the layering proposed in RFC vllm-project#51476. Co-authored-by: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: aoshen02 <aoshen@inferact.ai>
Contributor
|
Documentation preview: https://vllm--53082.org.readthedocs.build/en/53082/ |
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.
Implements the end state of RFC #51476 §4 ("sleep/pause layering"). Draft, and deliberately breaking — posted as the concrete artifact for the RFC discussion; whether it lands directly or behind a deprecation cycle is exactly the feedback being sought there.
Purpose
sleepwas born pure — #12987 introduced it as a memory-state transition only — and became entangled later: #33195 routed level 0 throughpause_scheduler(), #34528 completed today's shape,sleep(level, mode) = pause_scheduler(mode) + executor.sleep(level). The entanglement has concrete costs:sleepanswers "what happens to the requests" — a question that belongs topause— through a duplicatedmodevocabulary with a policy default (abort).LLM.sleep's own docstring has always said "The caller should guarantee that no requests are being processed during the sleep period" — the contract was layered from day one; the implementation just started answering the question on the caller's behalf.Change
Deleted (the core of the PR):
EngineCore.sleeploses themodeparameter, the internalpause_schedulercall, and the pause-future chaining. It is now: precondition check →_reset_caches()→executor.sleep(level). ReturnsNone, never aFuture— nothing asynchronous is left.modeis deleted from the whole client chain (LLM,LLMEngine,AsyncLLM,EngineClientprotocol, allEngineCoreClientvariants) and from the/sleepHTTP endpoint.sleep(level=0)(a pause alias) loses its meaning; callers usepause_generation().Added (what makes the deletion safe and usable):
EngineNotPausedErrorunless a pause has completed (is_scheduler_paused() and not has_work(); on DP,engines_runningalso rejects a pause whose consensus is still in flight, so kick-started ranks can never release memory early). A raise is distributively safe where a skip is not: a failed check never enters a collective — every rank either proceeds into the same protocol or errors out to the client as a retryable failure.LLM.pause_generation()/LLM.resume_generation()→LLMEngine→ sync clients (InprocClient,SyncMPClient). Pure forwarders to the existing engine-sidepause_scheduler/resume_scheduler; no new policy.Migration (breaking surface):
llm.sleep(level=1)llm.pause_generation()thenllm.sleep(level=1)llm.sleep(level=1, mode="keep")llm.pause_generation(mode="keep")thenllm.sleep(level=1)llm.sleep(level=0)/wake_up(tags=["scheduling"])llm.pause_generation()/llm.resume_generation()POST /sleep?level=1POST /pausethenPOST /sleep?level=1AsyncLLM.sleep(level, mode)pause_generation(mode=...)thensleep(level)wake_upis unchanged: a full wake still resumes the scheduler; partial wakes still keep it paused. All in-tree callers (benchmarks/throughput.py prequeue, docs, and every sleep test) are migrated in this PR.Test Plan
Three unit tests (no GPU): sleep on an un-paused engine raises and never touches the executor; sleep on a paused engine releases memory without touching request state (
finish_requests/set_pause_statenot called); sleep during an in-flight DP pause consensus (kick-startedengines_running) is refused.One DP e2e test: un-paused sleep is refused through the RPC chain; pause → sleep → wake → generate completes cleanly on DP=2+EP.
Regression:
tests/v1/distributed/test_async_llm_dp.py -k "dp_pause or dp_sleep or prefill_schedule"(the existing pause/sleep suite, including the late-request pair from #51481, migrated to the explicit flow).python -m pytest tests/v1/engine/test_engine_core.py -k sleep -v python -m pytest tests/v1/distributed/test_async_llm_dp.py -k "dp_pause or dp_sleep or prefill_schedule" -vTest Result
vllm/vllm-openai:nightly(2026-08-20 build), 2×H200 (this diffpatch -p1-ed into site-packages, branchtests/mounted):test_engine_core.py -k sleep(3 new unit tests)test_async_llm_dp.py -k "dp_pause or dp_sleep or prefill_schedule"(12 migrated existing + 1 new e2e)Essential Elements
main). The submitter has reviewed each changed line and the runs above.