[sleep functionality] code refactor about sleep/wake_up (#50431)

Signed-off-by: Andy Xie <andy.xning@gmail.com>

Ning Xie committed Aug 25, 2026 at 15:45 UTC 23310bc3de530fd90ea060fcc1ef7f58501ee859
3 files changed +4 -7
vllm/entrypoints/serve/dev/sleep/api_router.py
-4
@@ -24,8 +24,6 @@ async def sleep(raw_request: Request):
24 level = raw_request.query_params.get("level", "1")
25 mode = raw_request.query_params.get("mode", "abort")
26 await engine_client(raw_request).sleep(int(level), mode)
27 - # FIXME: in v0 with frontend multiprocessing, the sleep command
28 - # is sent but does not finish yet when we return a response.
27 return Response(status_code=200)
28
29
@@ -37,8 +35,6 @@ async def wake_up(raw_request: Request):
35 tags = None
36 logger.info("wake up the engine with tags: %s", tags)
37 await engine_client(raw_request).wake_up(tags)
40 - # FIXME: in v0 with frontend multiprocessing, the wake-up command
41 - # is sent but does not finish yet when we return a response.
38 return Response(status_code=200)
39
40
vllm/v1/core/sched/scheduler.py
+1
@@ -2476,6 +2476,7 @@ class Scheduler(SchedulerInterface):
2476 return self._pause_state
2477
2478 def set_pause_state(self, pause_state: PauseState) -> None:
2479 + logger.info("setting pause state to %s", pause_state.name)
2480 self._pause_state = pause_state
2481
2482 def _free_request_blocks(self, request: Request):
vllm/v1/engine/core.py
+3 -3
@@ -15,7 +15,7 @@ from functools import partial
15 from inspect import isclass, signature
16 from logging import DEBUG
17 from multiprocessing.queues import Queue
18 -from typing import Any, TypeVar, cast
18 +from typing import Any, TypeVar, cast, get_args
19
20 import msgspec
21 import zmq
@@ -855,7 +855,7 @@ class EngineCore:
855 - ``keep``: Set PAUSED_ALL; return a Future that completes when the
856 output queue is empty.
857 """
858 - if mode not in ("keep", "abort", "wait"):
858 + if mode not in get_args(PauseMode):
859 raise ValueError(f"Invalid pause mode: {mode}")
860 if mode == "wait":
861 raise ValueError("'wait' mode can't be used in inproc-engine mode")
@@ -1933,7 +1933,7 @@ class EngineCoreProc(EngineCore):
1933 - ``keep``: Set PAUSED_ALL; return a Future that completes when the
1934 output queue is empty.
1935 """
1936 - if mode not in ("keep", "abort", "wait"):
1936 + if mode not in get_args(PauseMode):
1937 raise ValueError(f"Invalid pause mode: {mode}")
1938
1939 def engine_idle_callback(engine: "EngineCoreProc", future: Future[Any]) -> None: