[ROCm] Implement GPU-to-NUMA-node detection (#40015)
Signed-off-by: Patrick Schlangen <pschlan@amd.com> Co-authored-by: TJian <tunjian.tan@embeddedllm.com>
This commit is contained in:
@@ -155,9 +155,9 @@ switch to `--physcpubind=<cpu-list> --membind=<node>`.
|
|||||||
|
|
||||||
These `--numa-bind*` options only apply to GPU execution processes. They do not
|
These `--numa-bind*` options only apply to GPU execution processes. They do not
|
||||||
configure the CPU backend's separate thread-affinity controls. Automatic
|
configure the CPU backend's separate thread-affinity controls. Automatic
|
||||||
GPU-to-NUMA detection is currently implemented for CUDA/NVML-based platforms;
|
GPU-to-NUMA detection is currently implemented for CUDA/NVML-based as well as
|
||||||
other GPU backends must provide explicit binding lists if they use these
|
ROCM-based platforms; other GPU backends must provide explicit binding lists if
|
||||||
options.
|
they use these options.
|
||||||
|
|
||||||
`--numa-bind-nodes` takes one non-negative NUMA node index per visible GPU, in
|
`--numa-bind-nodes` takes one non-negative NUMA node index per visible GPU, in
|
||||||
the same order as the GPU indices.
|
the same order as the GPU indices.
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ try:
|
|||||||
amdsmi_init,
|
amdsmi_init,
|
||||||
amdsmi_shut_down,
|
amdsmi_shut_down,
|
||||||
amdsmi_topo_get_link_type,
|
amdsmi_topo_get_link_type,
|
||||||
|
amdsmi_topo_get_numa_node_number,
|
||||||
)
|
)
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
logger.warning("Failed to import from amdsmi with %r", e)
|
logger.warning("Failed to import from amdsmi with %r", e)
|
||||||
@@ -955,3 +956,30 @@ class RocmPlatform(Platform):
|
|||||||
rms_norm = default
|
rms_norm = default
|
||||||
|
|
||||||
return IrOpPriorityConfig.with_default(default, rms_norm=rms_norm)
|
return IrOpPriorityConfig.with_default(default, rms_norm=rms_norm)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
@with_amdsmi_context
|
||||||
|
def get_all_device_numa_nodes(cls) -> list[int] | None:
|
||||||
|
"""Get NUMA nodes for all visible GPU devices."""
|
||||||
|
try:
|
||||||
|
handles = amdsmi_get_processor_handles()
|
||||||
|
numa_nodes = []
|
||||||
|
for device_id in range(cls.device_count()):
|
||||||
|
physical_device_id = cls.device_id_to_physical_device_id(device_id)
|
||||||
|
try:
|
||||||
|
numa_node = amdsmi_topo_get_numa_node_number(
|
||||||
|
handles[physical_device_id]
|
||||||
|
)
|
||||||
|
except AmdSmiException as e:
|
||||||
|
logger.warning(
|
||||||
|
"Could not detect NUMA node for GPU %d, "
|
||||||
|
"disabling automatic NUMA binding: %s",
|
||||||
|
device_id,
|
||||||
|
e,
|
||||||
|
)
|
||||||
|
return None
|
||||||
|
numa_nodes.append(numa_node)
|
||||||
|
return numa_nodes
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning("Failed to get NUMA nodes for GPUs: %s", e)
|
||||||
|
return None
|
||||||
|
|||||||
Reference in New Issue
Block a user