vllm.v1.engine.utils
¶
Classes:
-
CoreEngine–One per data parallel rank, used to track state during handshaking.
-
CoreEngineActorManager–Utility class to handle creation, readiness, and shutdown
-
CoreEngineLaunch–Resources and startup barrier for launched engine processes.
-
CoreEngineProcManager–Utility class to handle creation, readiness, and shutdown
-
EngineHandshakeMetadata–Metadata sent to each engine process during startup handshake,
-
EngineZmqAddresses–Resolved frontend endpoints advertised to engine processes.
-
EngineZmqBindAddresses–Frontend endpoints before their owning sockets bind.
-
SignalCallback–Safely trigger a callback from signal handler context via a dedicated thread.
Functions:
-
bind_engine_zmq_listeners–Bind frontend transport listeners before launching engines.
-
get_engine_process_shutdown_timeout–Return the EngineCore process-manager shutdown timeout.
-
get_engine_zmq_bind_addresses–Create ZMQ endpoint templates for engine-client communication.
-
get_physical_gpu_ids_for_local_dp_rank–Returns list of physical GPU IDs for the specified
-
launch_core_engines–Launch engine and DP coordinator processes as needed.
-
set_assigned_physical_gpu_ids_for_dp_rank–Populate assigned_physical_gpu_ids on the config for the given DP rank.
CoreEngine
¶
One per data parallel rank, used to track state during handshaking.
CoreEngineActorManager
¶
Utility class to handle creation, readiness, and shutdown of core engine Ray actors used by the AsyncLLM and LLMEngine.
Different from CoreEngineProcManager, this class manages core engines for both local and remote nodes.
Methods:
-
add_dp_placement_groups–Add placement groups for new data parallel size.
-
create_dp_placement_groups–Create placement groups for data parallel.
CoreEngineLaunch
dataclass
¶
Resources and startup barrier for launched engine processes.
CoreEngineProcManager
¶
Utility class to handle creation, readiness, and shutdown of background processes used by the AsyncLLM and LLMEngine.
Methods:
-
finished_procs–Returns dict of proc name -> exit code for any finished procs.
-
monitor_engine_liveness–Monitor engine core process liveness.
-
shutdown–Shutdown engine core processes with configurable timeout.
EngineHandshakeMetadata
dataclass
¶
Metadata sent to each engine process during startup handshake, including addresses of the front-end ZMQ queues that they should connect to.
EngineZmqAddresses
dataclass
¶
Resolved frontend endpoints advertised to engine processes.
EngineZmqBindAddresses
dataclass
¶
Frontend endpoints before their owning sockets bind.
SignalCallback
¶
Safely trigger a callback from signal handler context via a dedicated thread.
_dp_nodes_master_first(available_resources, dp_master_ip)
¶
Live Ray nodes as (node_id, resources) with the DP master first.
The master is found through the node:<ip> resource Ray sets on every
node, so this works with the resource maps from ray._private.state.
Do not replace it with ray.util.state.list_nodes(): that API goes
through the dashboard HTTP server and only exists with ray[default]
(see #23822).
_exited_cleanly(proc)
¶
Whether proc exited with status 0, without reaping it.
Reading proc.exitcode would reap the child, racing shutdown()'s join;
WNOWAIT leaves shutdown() as the only reaper. The engine is a direct
child under both start methods get_mp_context() uses (fork and spawn).
_node_ip_from_resources(node_resources)
¶
Return the node IP encoded in a Ray per-node resource dict, or None.
Ray advertises each node's IP as a node:<ip> resource key. The head node
also carries node:__internal_head__, and placement groups add
..._group_... keys; both are ignored.
bind_engine_zmq_listeners(vllm_config, num_api_servers=1)
¶
Bind frontend transport listeners before launching engines.
get_engine_process_shutdown_timeout(request_timeout, process_timeout)
¶
Return the EngineCore process-manager shutdown timeout.
VllmConfig.shutdown_timeout controls how long in-flight requests may
drain. A value of zero therefore tells EngineCore to abort requests as soon
as it receives SIGTERM. The parent process manager still needs a separate
window in which the EngineCore can release device resources before it is
force-killed. An explicitly set VLLM_WORKER_SHUTDOWN_TIMEOUT_SECONDS
sets that window on every platform. Otherwise ROCm gets a fixed window:
its teardown can take longer than the generic best-effort window, and
force-killing during teardown can leave VRAM resident.
process_timeout may be a remaining budget computed by an outer process
manager. A zero remaining budget for a positive request timeout must not
receive a fresh grace period because EngineCore relies on that deadline to
enforce request draining. None (e.g. AsyncLLM.shutdown()) means no
budget was given, so it receives the same cleanup window as zero.
get_engine_zmq_bind_addresses(vllm_config, num_api_servers=1)
¶
Create ZMQ endpoint templates for engine-client communication.
Each TCP address is a tcp://host:0 placeholder. A single-process
MPClient binds its own ZMQ sockets. Cross-process frontends use
bind_engine_zmq_listeners so the supervisor binds raw listeners before
launching engines and transfers listener ownership to each frontend.
get_physical_gpu_ids_for_local_dp_rank(device_control_env_var, local_dp_rank, world_size, local_world_size=None, user_assigned_gpu_ids=None)
¶
Returns list of physical GPU IDs for the specified data parallel rank.
For example, if world_size=2 and local_dp_rank=1, and there are 4 devices, this will return [2, 3] for local_dp_rank=1.
If user_assigned_gpu_ids is provided (e.g. from --device-ids), this DP rank's shard is sliced from it instead of being derived from the device-control env var.
launch_core_engines(vllm_config, executor_class, collect_stats, addresses)
¶
Launch engine and DP coordinator processes as needed.
set_assigned_physical_gpu_ids_for_dp_rank(vllm_config, local_dp_rank, user_assigned_gpu_ids=None)
¶
Populate assigned_physical_gpu_ids on the config for the given DP rank.
user_assigned_gpu_ids is the full (un-sharded) --device-ids list, if the user provided one; this DP rank's shard is sliced from it. It is passed explicitly rather than read from the config because callers may reuse one config object across DP ranks, overwriting the field each time.