Skip to content

Conversation

njhill
Copy link
Member

@njhill njhill commented Feb 26, 2025

The engine core client starts an engine core proc per dp rank and load balances requests between them. A dummy request is sent to idle ranks when the global req count goes from 0->1, and when each engine finishes all requests it will continue in an idle forward loop.

Working for single node:

vllm serve -dp 2 ...

I aimed to keep the data parallel logic isolated as much as possible (in subclasses of the core engine and client) to avoid adding complexity/overhead to the more common default dp=1 case.

Follow-on after this PR:

  • Multi-node
  • Balance based on waiting queue lengths rather than in-flight counts
  • Make it work with API server scale-out

Copy link

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can either: Add ready label to the PR or enable auto-merge.

🚀

@mergify mergify bot added the v1 label Feb 26, 2025
Signed-off-by: Nick Hill <[email protected]>
Signed-off-by: Nick Hill <[email protected]>
Signed-off-by: Nick Hill <[email protected]>
Signed-off-by: Nick Hill <[email protected]>
Signed-off-by: Nick Hill <[email protected]>
Signed-off-by: Nick Hill <[email protected]>
Signed-off-by: Nick Hill <[email protected]>
Signed-off-by: Nick Hill <[email protected]>
Signed-off-by: Nick Hill <[email protected]>
Signed-off-by: Nick Hill <[email protected]>
Signed-off-by: Nick Hill <[email protected]>
Signed-off-by: Nick Hill <[email protected]>
Signed-off-by: Nick Hill <[email protected]>
@v-lmn
Copy link

v-lmn commented Mar 3, 2025

how to test,I mean how to run the server,I think we need two command right?
terminal 1 command 1
terminal 2 command 2
can you complete the command line

Copy link

mergify bot commented Mar 3, 2025

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @njhill.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify bot added the needs-rebase label Mar 3, 2025
Copy link
Member

@youkaichao youkaichao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the DP-related part looks good to me.

cc @robertgshaw2-redhat I'm not familiar with the frontend processing part, maybe Robert can take a look?

@njhill
Copy link
Member Author

njhill commented Mar 3, 2025

how to test,I mean how to run the server,I think we need two command right?
terminal 1 command 1
terminal 2 command 2
can you complete the command line

@v-lmn no for single node you can run a single command, with --data-parallel=N. Multi-node isn't added yet but when it is, that will require a different command to be run on the other node(s).

…gine

# Conflicts:
#	vllm/v1/core/scheduler.py
#	vllm/v1/engine/core.py
#	vllm/v1/engine/core_client.py
@mergify mergify bot removed the needs-rebase label Mar 3, 2025
njhill added 2 commits March 3, 2025 08:12
Signed-off-by: Nick Hill <[email protected]>
Signed-off-by: Nick Hill <[email protected]>
Copy link

mergify bot commented Mar 3, 2025

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @njhill.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify bot removed the needs-rebase label Mar 27, 2025
@njhill
Copy link
Member Author

njhill commented Mar 27, 2025

Thanks @tlrmchlsmth! Have addressed those comments. Also had to make some additional adjustments to ensure compatibility with @youkaichao's offline multi-node scenario added in #15484.

njhill added 2 commits March 27, 2025 09:45
Signed-off-by: Nick Hill <[email protected]>
Copy link

mergify bot commented Mar 27, 2025

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @njhill.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify bot added the needs-rebase label Mar 27, 2025
njhill added 2 commits March 27, 2025 10:59
Signed-off-by: Nick Hill <[email protected]>
# Conflicts:
#	vllm/v1/core/sched/scheduler.py
@mergify mergify bot removed the needs-rebase label Mar 27, 2025
@simon-mo simon-mo merged commit 15dac21 into vllm-project:main Mar 27, 2025
53 of 59 checks passed
@njhill njhill deleted the multi-engine branch March 28, 2025 00:32
local_dp_rank = vllm_config.parallel_config.data_parallel_rank_local

assert dp_size > 1
assert 0 <= local_dp_rank <= dp_rank < dp_size
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this check?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not strictly needed, I just thought it might be good here to verify that the config is in a coherent state.

from vllm.platforms import current_platform
if current_platform.is_cuda_alike():
from vllm.platforms.cuda import device_id_to_physical_device_id
tp_size = vllm_config.parallel_config.tensor_parallel_size
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use world_size to be general, not just tp_size

@simon-mo simon-mo mentioned this pull request Mar 29, 2025
66 tasks
Alex4210987 pushed a commit to LeiWang1999/vllm-bitblas that referenced this pull request Apr 5, 2025
lulmer pushed a commit to lulmer/vllm that referenced this pull request Apr 7, 2025
Signed-off-by: Nick Hill <[email protected]>
Signed-off-by: Louis Ulmer <[email protected]>
@Co1lin
Copy link

Co1lin commented Apr 21, 2025

@njhill @youkaichao Hi, I tried to use dp as what you showed above with the latest dev version of vllm. However, the error below occurred. Do you have any clue on this? In the same shell environment, I can run without dp, e.g. with tp=2, and there are 8 usable GPUs on the machine. Thanks!

$  uv run vllm serve /path/to/model --port 8088 --served-model-name xxx --data-parallel-size 2
...
myhost:2292596:2292596 [0] init.cc:943 NCCL WARN Duplicate GPU detected : rank 0 and rank 1 both on CUDA device 53000
myhost:2292597:2292597 [0] init.cc:943 NCCL WARN Duplicate GPU detected : rank 1 and rank 0 both on CUDA device 53000
...
(EngineCore_1 pid=2292597)   File "/ephnvme/colin/code/prizetrain/.venv/lib/python3.12/site-packages/vllm/distributed/device_communicators/cuda_communicator.py", line 39, in __init__
(EngineCore_0 pid=2292596)     self.NCCL_CHECK(self._funcs["ncclCommInitRank"](ctypes.byref(comm),
(EngineCore_1 pid=2292597)     self.pynccl_comm = PyNcclCommunicator(
(EngineCore_0 pid=2292596)   File "/ephnvme/colin/code/prizetrain/.venv/lib/python3.12/site-packages/vllm/distributed/device_communicators/pynccl_wrapper.py", line 256, in NCCL_CHECK
(EngineCore_1 pid=2292597)                        ^^^^^^^^^^^^^^^^^^^
(EngineCore_0 pid=2292596)     raise RuntimeError(f"NCCL error: {error_str}")
(EngineCore_1 pid=2292597)   File "/ephnvme/colin/code/prizetrain/.venv/lib/python3.12/site-packages/vllm/distributed/device_communicators/pynccl.py", line 99, in __init__
(EngineCore_1 pid=2292597)     self.comm: ncclComm_t = self.nccl.ncclCommInitRank(
(EngineCore_1 pid=2292597)                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
(EngineCore_0 pid=2292596) RuntimeError: NCCL error: invalid usage (run with NCCL_DEBUG=WARN for details)
(EngineCore_1 pid=2292597)   File "/ephnvme/colin/code/prizetrain/.venv/lib/python3.12/site-packages/vllm/distributed/device_communicators/pynccl_wrapper.py", line 277, in ncclCommInitRank
(EngineCore_1 pid=2292597)     self.NCCL_CHECK(self._funcs["ncclCommInitRank"](ctypes.byref(comm),
(EngineCore_1 pid=2292597)   File "/ephnvme/colin/code/prizetrain/.venv/lib/python3.12/site-packages/vllm/distributed/device_communicators/pynccl_wrapper.py", line 256, in NCCL_CHECK
(EngineCore_1 pid=2292597)     raise RuntimeError(f"NCCL error: {error_str}")
(EngineCore_1 pid=2292597) RuntimeError: NCCL error: invalid usage (run with NCCL_DEBUG=WARN for details)

@youkaichao
Copy link
Member

@Co1lin I tested vllm serve meta-llama/Llama-3.2-1B-Instruct -dp 2 --port 8989 on the main branch, it works well.

can you create a separate issue with detailed environment?

@liunn01
Copy link

liunn01 commented Apr 23, 2025

vllm serve /local/models/Qwen2___5-32B -dp 8 --dtype half ,卡在图片所示不动,该如何正确执行呢
1111

lk-chen pushed a commit to lk-chen/vllm that referenced this pull request Apr 29, 2025
shreyankg pushed a commit to shreyankg/vllm that referenced this pull request May 3, 2025
RichardoMrMu pushed a commit to RichardoMrMu/vllm that referenced this pull request May 12, 2025
local_unfinished_reqs = self.scheduler.has_unfinished_requests()

if local_unfinished_reqs:
# 2) Step the engine core.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering the presence of WAITING_FOR_REMOTE_KVS and WAITING_FOR_FSM, the condition local_unfinished_reqs = true does not necessarily imply that scheduler_output.total_num_scheduled_tokens > 0. This means that a forward pass may not actually be executed in _process_engine_step -> step -> execute_model. Meanwhile, other cores might still execute a forward or dummy forward
@njhill

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in #18559

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci/build documentation Improvements or additions to documentation ready ONLY add when PR is ready to merge/full CI is needed v1
Projects
None yet
Development

Successfully merging this pull request may close these issues.