Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
vllm_cscc
Commits
2bd176dd
Commit
2bd176dd
authored
Dec 14, 2024
by
zhouxiang
Browse files
添加numa绑定能力
parent
988eb4e6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
1 deletion
+29
-1
requirements-rocm.txt
requirements-rocm.txt
+2
-1
vllm/executor/gpu_executor.py
vllm/executor/gpu_executor.py
+27
-0
No files found.
requirements-rocm.txt
View file @
2bd176dd
...
...
@@ -15,3 +15,4 @@ torch == 2.4.1
triton == 3.0.0
flash_attn == 2.6.1
lmslim == 0.2.0
numa
\ No newline at end of file
vllm/executor/gpu_executor.py
View file @
2bd176dd
...
...
@@ -10,12 +10,39 @@ from vllm.utils import (get_distributed_init_method, get_ip, get_open_port,
make_async
)
from
vllm.worker.worker_base
import
WorkerBase
,
WorkerWrapperBase
import
numa
,
os
# 设置当前进程绑定到 NUMA 节点
def
bind_to_numa
(
local_rank
):
env_str
=
f
"VLLM_RANK
{
local_rank
}
_NUMA"
node_count
=
numa
.
get_max_node
()
+
1
numa_node
=
int
(
os
.
getenv
(
env_str
,
-
1
))
# 未配置环境变量或配置错误则不做绑定,TODO:根据topo自动绑定方案
if
numa_node
<
0
:
logger
.
warning
(
"%s is unset or set incorrectly, vllm will not bind to numa! %s = %d"
,
env_str
,
env_str
,
numa_node
)
return
if
numa_node
>
numa
.
get_max_node
():
raise
ValueError
(
f
"NUMA node
{
numa_node
}
is not available."
)
numa
.
bind
([
numa_node
])
logger
=
init_logger
(
__name__
)
def
create_worker
(
worker_module_name
:
str
,
worker_class_name
:
str
,
worker_class_fn
:
Optional
[
Callable
[[],
Type
[
WorkerBase
]]],
**
kwargs
):
VLLM_NUMA_BIND
=
int
(
os
.
getenv
(
"VLLM_NUMA_BIND"
,
1
))
if
VLLM_NUMA_BIND
>
0
:
# 绑定当前进程到指定 NUMA 节点
bind_to_numa
(
kwargs
[
'local_rank'
])
pid
=
os
.
getpid
()
logger
.
info
(
"########## %d process(rank%s) is running on CPU(s): %s"
,
pid
,
str
(
kwargs
[
'local_rank'
]),
str
(
os
.
sched_getaffinity
(
pid
)))
logger
.
info
(
"########## %d process(rank%s) is running on memnode(s): %s"
,
pid
,
str
(
kwargs
[
'local_rank'
]),
str
(
numa
.
get_membind
()))
wrapper
=
WorkerWrapperBase
(
worker_module_name
=
worker_module_name
,
worker_class_name
=
worker_class_name
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment