Skip to content

Commit 4ab34f6

Browse files
authored
Add NUMA node validation for CPU thread binding (vllm-project#28555)
Signed-off-by: Bradley <[email protected]>
1 parent c33b87e commit 4ab34f6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

csrc/cpu/utils.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ std::string init_cpu_threads_env(const std::string& cpu_ids) {
4545
// Memory node binding
4646
if (numa_available() != -1) {
4747
int mem_node_id = numa_node_of_cpu(omp_cpu_ids.front());
48+
// Verify all CPUs are on the same NUMA node
49+
for (size_t i = 1; i < omp_cpu_ids.size(); ++i) {
50+
int node_id = numa_node_of_cpu(omp_cpu_ids[i]);
51+
TORCH_CHECK(node_id == mem_node_id, "CPU ", omp_cpu_ids[i],
52+
" is on NUMA node ", node_id, ", but CPU ",
53+
omp_cpu_ids.front(), " is on NUMA node ", mem_node_id,
54+
". All CPUs should be on the same NUMA node for optimal "
55+
"performance. Memory will be bound to NUMA node ",
56+
mem_node_id, ".");
57+
}
4858
bitmask* mask = numa_parse_nodestring(std::to_string(mem_node_id).c_str());
4959
bitmask* src_mask = numa_get_membind();
5060

0 commit comments

Comments
 (0)