-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[CPU] Bind threads and numa node for each TP rank #6549
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
chunyuan-w
wants to merge
14
commits into
sgl-project:main
Choose a base branch
from
chunyuan-w:chunyuan/pr_core_bind
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chunyuan-w
commented
May 23, 2025
105b412
to
7ea2474
Compare
…numa-dev` (sgl-project#74) * port utils.cpp for numa binding from vllm into sglang * fix build * add pybind for init_cpu_threads_env * use conda prefix to find libnuma # how to ensure libnuma is installed via conda * replace init_cpu_threads_env in vllm with that in sgl-kernel * add vllm into srt_cpu * fix format
sgl-project#77) * set local_omp_cpuid automatically * set self.local_omp_cpuid in __init__ * refine warning message * add more comments for example output of util functions * add try except for lscpu * refine warning message
…ot have tensor input
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
This PR binds threads and numa node for each TP rank when device is CPU, which will improvement the performance on CPU.
For example, when running
--tp 6
on a machine with 6 sub-numa nodes, with this PR, rank 0 will be bound to core 0-39 on node 0, rank 1 to core 40-79 on node 1, etc.Modifications
init_cpu_threads_env
is added insgl-kernel/csrc/cpu/numa_utils.cpp
to bind threads and numa node. UT for this OP is added intest/srt/cpu/test_binding.py
.sgl-kernel/csrc/cpu/CMakeLists.txt
is updated to link the numa lib.conda install -y libnuma numactl
is needed as a pre-requisite, which will be added in the Dockerfile for Xeon ([CPU] enable CI for PRs, add Dockerfile and auto build task #6458).python/pyproject.toml
.python/sglang/srt/model_executor/model_runner.py
, we add the threads and numa node binding according to thetp_size
. WhenSGLANG_CPU_OMP_THREADS_BIND
is not set, we only support tp_size to be smaller than the number of sub-numa nodes on the current machine and we will bind each tp rank to one sub-numa node. We only bind to physical cores while logical cores are excluded. If this is not satisfied, an error message will be thrown.