vllm.utils.cpu_resource_utils
¶
Functions:
-
check_cgroup_memory_available–Log cgroup memory headroom for an upcoming allocation.
-
get_available_memory–Return available host memory, honoring cgroup limits.
-
get_cgroup_memory_limit–Return the cgroup memory limit in bytes, or None.
-
get_cgroup_memory_usage–Return the current cgroup memory usage in bytes, or None.
-
get_visible_memory_node–Memory nodes visible to this process.
-
get_worker_memory_nodes–get_visible_memory_node for a CPU worker. Raises a clear error when
-
parse_id_list–Parses strings like '0-2,4,7-8' into [0, 1, 2, 4, 7, 8].
_synthesize_cpu_list()
cached
¶
Synthesize a flat CPU list: each logical CPU is its own core on NUMA node 0. Used when lscpu output is unavailable or unparsable (e.g. macOS, RISC-V).
check_cgroup_memory_available(required_bytes, allocation_name)
¶
Log cgroup memory headroom for an upcoming allocation.
Parameters:
-
(required_bytes¶int) –Bytes required by the allocation.
-
(allocation_name¶str) –Human-readable name used in log messages.
Low headroom logs a warning, but does not reject the allocation because cgroup usage can include reclaimable memory. If the cgroup limit or usage cannot be read, the check is skipped.
get_available_memory()
¶
Return available host memory, honoring cgroup limits.
get_cgroup_memory_limit()
cached
¶
Return the cgroup memory limit in bytes, or None.
Supports both cgroup v2 (unified) and v1. Returns None when
not running under a constrained cgroup (e.g. bare metal, or limit
reported as max/an unrealistically large value).
get_cgroup_memory_usage()
¶
Return the current cgroup memory usage in bytes, or None.
The usage value is intentionally read on every call because cgroup memory usage changes while the process is running.
get_visible_memory_node(assigned_node_ids=None)
¶
Memory nodes visible to this process.
assigned_node_ids is the per-DP-rank list of NUMA node ids from parallel_config.assigned_physical_gpu_ids. It takes priority over the CPU_VISIBLE_MEMORY_NODES env var, which still applies when it is None.
get_worker_memory_nodes(assigned_node_ids)
¶
get_visible_memory_node for a CPU worker. Raises a clear error when none of the NUMA nodes assigned to the worker exists on this host.
parse_id_list(raw_str)
¶
Parses strings like '0-2,4,7-8' into [0, 1, 2, 4, 7, 8].