Skip to content

vllm.utils.numa_utils

NUMA binding utilities for vLLM worker processes.

Adapted in part from SGLang's NUMA helper implementation: https://github.com/sgl-project/sglang/blob/ba6d54d0f08f82f42b8224908ae2459a496b31b3/python/sglang/srt/utils/numa_utils.py

Functions:

_PctSku

Bases: NamedTuple

Per-SKU config used by the PCT auto-detection gate.

_can_auto_bind(parallel_config, local_rank, dp_local_rank=None)

Validate and store this launcher's automatic GPU-to-NUMA topology.

Unlike --numa-bind, this never fails startup or forces the spawn start method: any unmet requirement means starting unbound.

_get_cpu_binding(parallel_config, gpu_index, numa_nodes)

Return the CPU list a process should be pinned to (or None).

_get_enginecore_numa_nodes(parallel_config, dp_local_rank=None)

Return the sorted, unique NUMA nodes of the EngineCore's DP shard.

_get_mempolicy()

Return the current memory-policy mode, or None if it cannot be read.

_get_numactl_enginecore_args(parallel_config, local_rank, dp_local_rank=None)

Compute the numactl args for an EngineCore subprocess.

--numa-bind-cpus is deliberately ignored here: the user provides a per-worker CPU list, and binding EngineCore to any of those entries would shrink its cpus_allowed below the strict-superset that the workers' --physcpubind spawns require. We fall back to --cpunodebind=<shard nodes> instead, which is always a safe superset. PCT auto-detection still applies when the user did not pass --numa-bind-cpus (its priority-core union across the shard nodes is also a safe superset by construction).

_get_numactl_executable()

Return the fixed wrapper executable used to launch numactl.

_get_numactl_worker_args(parallel_config, local_rank, dp_local_rank=None)

Compute the numactl args for a single TP/PP worker subprocess.

_is_auto_numa_available(verbose=True, *, require_unbound_process=False)

Check whether automatic GPU-to-NUMA detection should be attempted.

Parameters:

  • verbose

    (bool, default: True ) –

    Log why detection is skipped at warning level; otherwise at debug level, for the default mode where skipping is expected.

  • require_unbound_process

    (bool, default: False ) –

    Require known unrestricted CPU affinity and the default memory policy for default automatic binding. Explicit topology discovery keeps its existing best-effort checks.

_maybe_get_pct_cpu_binding(numa_nodes)

Return the union of PCT priority cores across numa_nodes (or None).

PCT (Priority Core Turbo) lets a subset of cores boost above the rest; we want workers and the EngineCore on those cores. The Linux kernel does not expose PCT membership without root, so we use the empirical heuristic documented above _PCT_CAPABLE_SKUS: priority cores within each NUMA node satisfy cpu_id % stride in (0, 1) intersected with the node's cpulist, where stride is the SKU's logical CPUs per priority group (16 on 64-core SKUs, 18 on 72-core SKUs). Only triggers on the SKUs in _PCT_CAPABLE_SKUS with the expected CPPC highest_perf signal; on any other host it returns None and the caller falls back to the default NUMA-node bind.

Returns the sorted CPU ids as a list[int]; the caller is expected to format them for the chosen tool (e.g. comma-joined for numactl --physcpubind).

_pct_sku_config() cached

Detect a PCT-capable Granite Rapids Xeon with PCT enabled.

See the comment block above _PCT_CAPABLE_SKUS for the full context (why we hard-code SKUs, why we read CPPC highest_perf, etc.).

Returns the matching _PctSku config when both gates hold: * /proc/cpuinfo model name contains an SKU listed in _PCT_CAPABLE_SKUS. * /sys/devices/system/cpu/cpu0/acpi_cppc/highest_perf matches that SKU's expected highest_perf. Otherwise returns None and the caller falls back to the default NUMA-node bind.

_pct_sku_from_cpuinfo()

Return the _PctSku config for this host's SKU, or None.

Reads /proc/cpuinfo's model name and looks the SKU up in _PCT_CAPABLE_SKUS. Returns None when the host is not a known PCT-capable Granite Rapids Xeon (or when /proc/cpuinfo is unreadable).

_probe_numactl_args(numactl_args)

Whether numactl <args> true succeeds in this (parent) environment.

_resolve_numactl_args(numactl_args)

Drop a rejected memory policy, keeping CPU binding when possible.

configure_subprocess(vllm_config, local_rank, dp_local_rank=None, process_kind='worker')

Temporarily replace the multiprocessing executable with a numactl wrapper.

get_auto_numa_nodes()

Auto-detect NUMA nodes for all visible GPUs.

log_current_affinity_state(label)

Log the process's effective NUMA affinity state.