[Bugfix] Account for local DP workers in startup thread allocation (#52385)
Signed-off-by: real-cpu <zhaochenrui757@gmail.com>
This commit is contained in:
@@ -11,15 +11,62 @@ import multiprocessing
|
|||||||
import os
|
import os
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from tests.utils import multi_gpu_test
|
from tests.utils import multi_gpu_test
|
||||||
from vllm.config import VllmConfig
|
from vllm.config import VllmConfig
|
||||||
from vllm.engine.arg_utils import EngineArgs
|
from vllm.engine.arg_utils import EngineArgs
|
||||||
from vllm.v1.core.sched.output import SchedulerOutput
|
from vllm.v1.core.sched.output import SchedulerOutput
|
||||||
|
from vllm.v1.executor import multiproc_executor
|
||||||
from vllm.v1.executor.multiproc_executor import MultiprocExecutor
|
from vllm.v1.executor.multiproc_executor import MultiprocExecutor
|
||||||
|
|
||||||
MODEL = "facebook/opt-125m"
|
MODEL = "facebook/opt-125m"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
("local_world_size", "data_parallel_size_local", "expected_num_local_procs"),
|
||||||
|
[(1, 4, 4), (4, 1, 4), (2, 0, 2)],
|
||||||
|
)
|
||||||
|
def test_multiproc_executor_counts_all_local_dp_workers(
|
||||||
|
monkeypatch: pytest.MonkeyPatch,
|
||||||
|
local_world_size: int,
|
||||||
|
data_parallel_size_local: int,
|
||||||
|
expected_num_local_procs: int,
|
||||||
|
):
|
||||||
|
"""All colocated DP workers share the node's startup CPU budget."""
|
||||||
|
executor = object.__new__(MultiprocExecutor)
|
||||||
|
executor.world_size = local_world_size
|
||||||
|
executor.local_world_size = local_world_size
|
||||||
|
executor.parallel_config = type(
|
||||||
|
"ParallelConfig",
|
||||||
|
(),
|
||||||
|
{"data_parallel_size_local": data_parallel_size_local},
|
||||||
|
)()
|
||||||
|
|
||||||
|
monkeypatch.setattr(
|
||||||
|
executor,
|
||||||
|
"_get_parallel_sizes",
|
||||||
|
lambda: (local_world_size, 1, 1),
|
||||||
|
)
|
||||||
|
|
||||||
|
class StopExecutorInit(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def capture_num_local_procs(num_local_procs: int):
|
||||||
|
assert num_local_procs == expected_num_local_procs
|
||||||
|
raise StopExecutorInit
|
||||||
|
|
||||||
|
monkeypatch.setattr(
|
||||||
|
multiproc_executor,
|
||||||
|
"set_multiprocessing_worker_envs",
|
||||||
|
capture_num_local_procs,
|
||||||
|
)
|
||||||
|
|
||||||
|
with pytest.raises(StopExecutorInit):
|
||||||
|
executor._init_executor()
|
||||||
|
executor._finalizer.detach()
|
||||||
|
|
||||||
|
|
||||||
def create_vllm_config(
|
def create_vllm_config(
|
||||||
tensor_parallel_size: int = 1,
|
tensor_parallel_size: int = 1,
|
||||||
pipeline_parallel_size: int = 1,
|
pipeline_parallel_size: int = 1,
|
||||||
|
|||||||
@@ -130,7 +130,10 @@ class MultiprocExecutor(Executor):
|
|||||||
f"_parallel_size ({pcp_size}). "
|
f"_parallel_size ({pcp_size}). "
|
||||||
)
|
)
|
||||||
|
|
||||||
set_multiprocessing_worker_envs(self.local_world_size)
|
num_local_procs = self.local_world_size * max(
|
||||||
|
1, self.parallel_config.data_parallel_size_local
|
||||||
|
)
|
||||||
|
set_multiprocessing_worker_envs(num_local_procs)
|
||||||
|
|
||||||
if aiter_requires_tcp_store():
|
if aiter_requires_tcp_store():
|
||||||
distributed_init_method = get_distributed_init_method(
|
distributed_init_method = get_distributed_init_method(
|
||||||
|
|||||||
Reference in New Issue
Block a user