vllm.v1.utils
¶
Classes:
-
APIServerProcessManager–Manages a group of API server processes.
-
CpuGpuBuffer–Buffer to easily copy tensors between CPU and GPU.
-
RustFrontendProcessManager–Manages a single Rust frontend subprocess.
Functions:
-
get_engine_client_zmq_addr–Return an IPC path (
local_only=True) ortcp://host:port. -
report_usage_stats–Report usage statistics if enabled.
-
run_api_server_worker_proc–Entrypoint for individual API server worker processes.
-
shutdown–Shutdown processes with timeout.
-
tensor_data–Get the raw data of a tensor as a uint8 memoryview, useful for
-
wait_for_completion_or_failure–Wait for all processes to complete or detect if any fail.
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)
¶
tensor_data(tensor)
¶
Get the raw data of a tensor as a uint8 memoryview, useful for serializing and hashing.
Parameters:
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:
-
(api_server_manager¶APIServerProcessManager | RustFrontendProcessManager) –The manager for API servers.
-
(engine_manager¶Union[CoreEngineProcManager, CoreEngineActorManager] | None, default:None) –The manager for engine processes. If CoreEngineProcManager, it manages local engines; if CoreEngineActorManager, it manages all engines.
-
(coordinator¶DPCoordinator | None, default:None) –The coordinator for data parallel.