vllm.utils.cpu_resource_utils
¶
Functions:
-
check_cgroup_memory_available–Log cgroup memory headroom for an upcoming allocation.
-
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.
-
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).
Source code in vllm/utils/cpu_resource_utils.py
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.
Source code in vllm/utils/cpu_resource_utils.py
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).
Source code in vllm/utils/cpu_resource_utils.py
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.
Source code in vllm/utils/cpu_resource_utils.py
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.
Source code in vllm/utils/cpu_resource_utils.py
parse_id_list(raw_str)
¶
Parses strings like '0-2,4,7-8' into [0, 1, 2, 4, 7, 8].