vllm.device_allocator.sleep_mode_backend
¶
Pluggable sleep-mode backends (RFC #34303).
vLLM's sleep/wake-up today is hard-wired to CuMemAllocator: the GPU worker
calls allocator.sleep(...) / allocator.wake_up(...) directly. RFC #34303
proposes additional mechanisms for freeing and restoring GPU state - CUDA
process checkpoint, CRIU, durable snapshot/restore - that share the dispatch
(/sleep endpoint -> engine -> executor -> worker) but differ in mechanism
and in which resources they preserve (NCCL communicators, compiled kernels,
CUDA graphs, survival across process restart).
This module introduces a thin backend abstraction so those mechanisms can be
selected by name without changing the public API. The default cumem backend
wraps today's CuMemAllocator path 1:1, so existing users see no behavior
change. The factory mirrors KVConnectorFactory and lets third-party
backends register through a vllm.general_plugins entry point at import time.
Classes:
-
CuMemBackend–Default backend.
-
SleepModeBackend–Interface for a mechanism that frees and restores GPU state.
-
SleepModeBackendFactory–Registry and resolver for sleep-mode backends.
CuMemBackend
¶
Bases: SleepModeBackend
Default backend.
Wraps the platform sleep-mode allocator, CuMemAllocator on CUDA and
XpuMemAllocator on XPU. Suspend offloads per allocation between GPU and
host, with NCCL buffers left untouched (they are outside the allocator pool).
_get_allocator()
¶
Return the platform allocator used by this backend.
Downstream subclasses may override this method to provide an allocator
that implements the MemAllocator protocol.
SleepModeBackend
¶
Bases: ABC
Interface for a mechanism that frees and restores GPU state.
A backend owns the mechanism of suspend/resume. The dispatch path
(/sleep endpoint -> engine -> executor -> worker) is shared across all
backends and lives outside this class.
Capability flags are @classmethod so callers (executor, /health,
AUTO selection) can introspect a backend without instantiating it, matching
the capability-flag convention used by attention backends.
Methods:
-
discard–Discard selected tagged allocations without preserving contents.
-
is_supported–Whether this backend can run on the current platform/driver.
-
preserves_communicators–If False, collective communicators (e.g. NCCL) are destroyed by
-
preserves_compiled_artifacts–If True, torch.compile / JIT kernels survive suspend/resume and need
-
preserves_graphs_with_communicators–If True, CUDA graphs containing collective communicators (e.g. NCCL)
-
resume–Restore previously-suspended GPU state.
-
state–Current lifecycle state. Lets
/healthdistinguish a healthy-idle -
supports_durable_storage–If True, suspended state can be persisted beyond the process
-
suspend–Free GPU state, so that
resumerestores it at the same addresses.
discard(tags)
¶
Discard selected tagged allocations without preserving contents.
is_supported()
classmethod
¶
Whether this backend can run on the current platform/driver.
preserves_communicators()
classmethod
¶
If False, collective communicators (e.g. NCCL) are destroyed by
suspend and the executor must re-initialize them on resume.
preserves_compiled_artifacts()
classmethod
¶
If True, torch.compile / JIT kernels survive suspend/resume and need not be recompiled on resume.
preserves_graphs_with_communicators()
classmethod
¶
If True, CUDA graphs containing collective communicators (e.g. NCCL) stay valid after resume. False when communicators are rebuilt (embedded comm handles go stale).
resume(tags=None)
abstractmethod
¶
Restore previously-suspended GPU state.
tags optionally limits which tagged allocations are restored
(e.g. ["weights"] or ["kv_cache"]).
state()
¶
Current lifecycle state. Lets /health distinguish a healthy-idle
(suspended) engine from a healthy-serving one (see RFC #34303).
supports_durable_storage()
classmethod
¶
If True, suspended state can be persisted beyond the process lifetime (disk or object storage) and restored in a new process.
suspend(discardable=())
abstractmethod
¶
Free GPU state, so that resume restores it at the same addresses.
discardable holds the storage addresses of the tensors the caller
rewrites after resume, so they need no backup: the parameters not
selected for preservation at level 2, nothing at level 1. A backend
doesn't need to know the level. KV cache and workspace scratch are never
restored.
SleepModeBackendFactory
¶
Registry and resolver for sleep-mode backends.
Mirrors KVConnectorFactory: lazy module/class registration and a
built-in registry populated at import time. Third-party backends register
the same way from a vllm.general_plugins entry point.
Methods:
-
create_backend–Instantiate the backend selected by
model_config. -
get_backend_class–Resolve a registered backend class by name.
-
register_backend–Register a backend with a lazy-loading module and class name.