Skip to content

vllm.v1.utils

Classes:

Functions:

APIServerProcessManager

Manages a group of API server processes.

Handles creation, monitoring, and termination of API server worker processes. Also monitors extra processes to check if they are healthy.

Methods:

  • __init__ –

    Initialize and start API server worker processes.

  • shutdown –

    Shutdown API server processes with configurable timeout

__init__(listen_address, sock, args, num_servers, input_listeners, output_listeners, target_server_fn=None, stats_update_address=None, tensor_queue=None)

Initialize and start API server worker processes.

Parameters:

  • target_server_fn

    (Callable | None, default: None ) –

    Override function to call for each API server process

  • listen_address

    (str) –

    Address to listen for client connections

  • sock

    (Any) –

    Socket for client connections

  • args

    (Namespace) –

    Command line arguments

  • num_servers

    (int) –

    Number of API server processes to start

  • input_listeners

    (list[ZmqListener]) –

    Input listeners for each API server

  • output_listeners

    (list[ZmqListener]) –

    Output listeners for each API server

  • stats_update_address

    (str | None, default: None ) –

    Optional stats update address

  • tensor_queue

    (Queue | None, default: None ) –

    Optional tensor IPC queue for sharing MM tensors

shutdown(timeout=None)

Shutdown API server processes with configurable timeout

CpuGpuBuffer

Buffer to easily copy tensors between CPU and GPU.

Methods:

  • copy_to_cpu –

    NOTE: Because this method is non-blocking, explicit synchronization

copy_to_cpu(n=None)

NOTE: Because this method is non-blocking, explicit synchronization is needed to ensure the data is copied to CPU.

RustFrontendProcessManager

Manages a single Rust frontend subprocess.

Launches the Rust vllm-rs binary in 'frontend' mode, passing the HTTP and ZMQ listener file descriptors. Provides the same interface as APIServerProcessManager for process monitoring.

_SubprocessWrapper

Wraps subprocess.Popen to provide the BaseProcess-like interface needed by wait_for_completion_or_failure.

_decisions_read_strategy(model_config)

The class name of the Decisions API read strategy Python serves this model with, or None where Python answers 501.

The Rust frontend refuses to start with a strategy it does not implement, so which ones it implements is known to Rust alone.

_shutdown_subprocesses(procs, timeout=None)

Shutdown subprocess wrappers (mirrors the shutdown() function).

get_engine_client_zmq_addr(local_only, host, port=0)

Return an IPC path (local_only=True) or tcp://host:port.

port=0 lets the kernel assign the port at bind() time; the caller must recover it via getsockopt(zmq.LAST_ENDPOINT).

report_usage_stats(vllm_config, usage_context=UsageContext.ENGINE_CONTEXT)

Report usage statistics if enabled.

run_api_server_worker_proc(listen_address, sock, args, client_config=None, **uvicorn_kwargs)

Entrypoint for individual API server worker processes.

shutdown(procs, timeout=None)

Shutdown processes with timeout.

Parameters:

  • procs

    (list[BaseProcess]) –

    List of processes to shutdown

  • timeout

    (float | None, default: None ) –

    Maximum time in seconds to wait for graceful shutdown

tensor_data(tensor)

Get the raw data of a tensor as a uint8 memoryview, useful for serializing and hashing.

Parameters:

  • tensor

    (Tensor) –

    The input tensor.

Returns:

  • memoryview –

    A memoryview of the tensor data as uint8.

wait_for_completion_or_failure(api_server_manager, engine_manager=None, coordinator=None)

Wait for all processes to complete or detect if any fail.

Raises an exception if any process exits with a non-zero status.

Parameters: