Skip to content

vllm.utils.cpu_resource_utils

_synthesize_cpu_list cached

_synthesize_cpu_list() -> list[LogicalCPUInfo]

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
@cache
def _synthesize_cpu_list() -> list[LogicalCPUInfo]:
    """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)."""
    cpu_count = os.cpu_count()
    assert cpu_count
    return [LogicalCPUInfo(i, i, 0) for i in range(cpu_count)]

parse_id_list

parse_id_list(raw_str: str) -> list[int]

Parses strings like '0-2,4,7-8' into [0, 1, 2, 4, 7, 8]

Source code in vllm/utils/cpu_resource_utils.py
def parse_id_list(raw_str: str) -> list[int]:
    """Parses strings like '0-2,4,7-8' into [0, 1, 2, 4, 7, 8]"""
    result: list[int] = []
    if not raw_str:
        return result

    for part in raw_str.split(","):
        if "-" in part:
            start, end = map(int, part.split("-"))
            result.extend(range(start, end + 1))
        else:
            result.append(int(part))
    return sorted(list(set(result)))