Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions tests/distributed/test_multiproc_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,62 @@
import os
import socket

import pytest

from tests.utils import multi_gpu_test
from vllm.config import VllmConfig
from vllm.engine.arg_utils import EngineArgs
from vllm.v1.core.sched.output import SchedulerOutput
from vllm.v1.executor import multiproc_executor
from vllm.v1.executor.multiproc_executor import MultiprocExecutor

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(
tensor_parallel_size: int = 1,
pipeline_parallel_size: int = 1,
Expand Down
5 changes: 4 additions & 1 deletion vllm/v1/executor/multiproc_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ def _init_executor(self) -> None:
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():
distributed_init_method = get_distributed_init_method(
Expand Down
Loading