-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Frontend] Pass API server count to each process #23717
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
Merged
DarkLight1337
merged 27 commits into
vllm-project:main
from
DarkLight1337:api-server-count-cli
Sep 19, 2025
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
d52aa96
[Frontend] Pass API server count to each process
DarkLight1337 5ff210d
Tests
DarkLight1337 ed76170
Update
DarkLight1337 90703bd
Update and fix tests
DarkLight1337 3f97be4
Update docstring
DarkLight1337 91ea959
Optimize
DarkLight1337 6d0c040
Comment
DarkLight1337 69c9ff0
Improve error message
DarkLight1337 8e3ea32
Update docstring
DarkLight1337 1dd5894
Fixture
DarkLight1337 d06434f
Address comments in serve.py
DarkLight1337 dac1170
Rename attributes to internal and validate
DarkLight1337 3f62e0e
Fix
DarkLight1337 df9f9cb
Update
DarkLight1337 0ec4e66
Push down
DarkLight1337 e500a9b
Update
DarkLight1337 36fb875
Fix
DarkLight1337 e08e7b7
Try deepcopy
DarkLight1337 875c7e3
No print
DarkLight1337 d9a5c81
Simplify
DarkLight1337 dabe421
Fix
DarkLight1337 fdc9b6e
Update
DarkLight1337 94ec51d
Type checking
DarkLight1337 3b5db2d
Merge branch 'main' into api-server-count-cli
DarkLight1337 6cb2566
Merge branch 'main' into 'api-server-count-cli'
DarkLight1337 6aa51a2
Merge branch 'main' into api-server-count-cli
DarkLight1337 c29495d
Merge branch 'main' into api-server-count-cli
DarkLight1337 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
import openai # use the official client for correctness check | ||
import pytest | ||
import pytest_asyncio | ||
import requests | ||
|
||
from tests.utils import RemoteOpenAIServer | ||
from tests.v1.test_utils import check_request_balancing | ||
|
@@ -92,6 +93,8 @@ def start_server(node: int, sargs: list[str]): | |
sargs, | ||
auto_port=False, | ||
env_dict={ | ||
"VLLM_SERVER_DEV_MODE": | ||
"1", | ||
current_platform.device_control_env_var: | ||
",".join( | ||
str( | ||
|
@@ -150,12 +153,20 @@ def default_server_args(): | |
|
||
|
||
@pytest.fixture(scope="module", params=[1, 4]) | ||
def servers(request, default_server_args): | ||
def server_manager(request, default_server_args): | ||
api_server_count = request.param | ||
with HybridLBServerManager(MODEL_NAME, DP_SIZE, api_server_count, | ||
default_server_args, DP_SIZE_LOCAL, | ||
TP_SIZE) as server_list: | ||
yield server_list | ||
server_manager = HybridLBServerManager(MODEL_NAME, DP_SIZE, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comment |
||
api_server_count, | ||
default_server_args, DP_SIZE_LOCAL, | ||
TP_SIZE) | ||
|
||
with server_manager: | ||
yield server_manager | ||
|
||
|
||
@pytest.fixture | ||
def servers(server_manager): | ||
return server_manager.servers | ||
|
||
|
||
@pytest_asyncio.fixture | ||
|
@@ -168,6 +179,39 @@ async def clients(servers: list[tuple[RemoteOpenAIServer, list[str]]]): | |
] | ||
|
||
|
||
def _get_parallel_config(server: RemoteOpenAIServer): | ||
response = requests.get(server.url_for("server_info?config_format=json")) | ||
response.raise_for_status() | ||
|
||
vllm_config = response.json()["vllm_config"] | ||
return vllm_config["parallel_config"] | ||
|
||
|
||
def test_hybrid_dp_server_info(server_manager): | ||
servers = server_manager.servers | ||
api_server_count = server_manager.api_server_count | ||
|
||
for i, (server, _) in enumerate(servers): | ||
print(f"Testing {i=}") | ||
|
||
# Each request will hit one of the API servers | ||
# `n_reqs` is set so that there is a good chance each server | ||
# receives at least one request | ||
n_reqs = 2 * api_server_count * api_server_count | ||
parallel_configs = [ | ||
_get_parallel_config(server) for _ in range(n_reqs) | ||
] | ||
api_process_counts = [ | ||
c["_api_process_count"] for c in parallel_configs | ||
] | ||
api_process_ranks = [c["_api_process_rank"] for c in parallel_configs] | ||
|
||
assert all(c == api_server_count | ||
for c in api_process_counts), api_process_counts | ||
assert all(0 <= r < api_server_count | ||
for r in api_process_ranks), api_process_ranks | ||
|
||
|
||
@pytest.mark.asyncio | ||
@pytest.mark.parametrize( | ||
"model_name", | ||
|
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks a bit weird to have the same variable name as method name here (any particular reason for introducing intermediate var here?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is because
__enter__
returns the server list rather than the manager itselfThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can change the return value of
__enter__
if you want