Skip to content

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

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.

Methods:

  • discard –

    Discard selected tagged allocations without preserving contents.

  • is_supported –

    Whether this backend can run on the current platform/driver.

  • resume –

    Restore previously-suspended GPU state.

  • suspend –

    Free GPU state, so that resume restores 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.

resume(tags=None) abstractmethod

Restore previously-suspended GPU state.

tags optionally limits which tagged allocations are restored (e.g. ["weights"] or ["kv_cache"]).

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(model_config) classmethod

Instantiate the backend selected by model_config.

get_backend_class(name) classmethod

Resolve a registered backend class by name.

register_backend(name, module_path, class_name) classmethod

Register a backend with a lazy-loading module and class name.