[Rust Frontend] Expose gRPC port in Python vllm serve (#59659)
Co-authored-by: Bugen Zhao <i@bugenzhao.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Alec Flowers <aflowers@nvidia.com> Signed-off-by: Bugen Zhao <i@bugenzhao.com>
This commit is contained in:
co-authored by
Bugen Zhao
Claude Opus 5.5
parent
b558f160a2
commit
9d2a6f52b2
@@ -28,7 +28,7 @@ assert CHATML_JINJA_PATH.exists()
|
||||
|
||||
def _build_vllm_parsers():
|
||||
vllm_parser = FlexibleArgumentParser()
|
||||
subparsers = vllm_parser.add_subparsers()
|
||||
subparsers = vllm_parser.add_subparsers(dest="subparser")
|
||||
serve_parser = subparsers.add_parser("serve")
|
||||
make_arg_parser(serve_parser)
|
||||
return {"vllm": vllm_parser, "vllm serve": serve_parser}
|
||||
@@ -173,6 +173,75 @@ def test_multiple_valid_inputs(serve_parser):
|
||||
|
||||
|
||||
### Tests for serve argument validation that run prior to loading
|
||||
@pytest.mark.parametrize(
|
||||
"port, extra_args",
|
||||
[
|
||||
(50051, []),
|
||||
(0, ["--port", "0"]),
|
||||
(50051, ["--port", "50051", "--uds", "/tmp/vllm.sock"]),
|
||||
],
|
||||
)
|
||||
def test_rust_grpc_port_accepts_frontend_launch(
|
||||
vllm_parser, monkeypatch, port, extra_args
|
||||
):
|
||||
monkeypatch.setenv("VLLM_USE_RUST_FRONTEND", "1")
|
||||
args = vllm_parser.parse_args(
|
||||
[
|
||||
"serve",
|
||||
"--grpc-port",
|
||||
str(port),
|
||||
"--data-parallel-size",
|
||||
"8",
|
||||
"--data-parallel-size-local",
|
||||
"4",
|
||||
"--data-parallel-start-rank",
|
||||
"4",
|
||||
"--data-parallel-hybrid-lb",
|
||||
*extra_args,
|
||||
]
|
||||
)
|
||||
validate_parsed_serve_args(args)
|
||||
assert args.grpc_port == port
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"rust_enabled, extra_args, port",
|
||||
[
|
||||
(False, [], 50051),
|
||||
(False, ["--grpc"], 50051),
|
||||
(True, ["--grpc"], 50051),
|
||||
(True, ["--headless"], 50051),
|
||||
(True, ["--api-server-count", "0"], 50051),
|
||||
(True, ["--api-server-count", "-1"], 50051),
|
||||
(True, ["--data-parallel-multi-port-external-lb"], 50051),
|
||||
(True, ["--port", "50051"], 50051),
|
||||
(True, [], -1),
|
||||
(True, [], 65536),
|
||||
],
|
||||
)
|
||||
def test_rust_grpc_port_rejects_incompatible_launch(
|
||||
vllm_parser, monkeypatch, rust_enabled, extra_args, port
|
||||
):
|
||||
monkeypatch.setenv("VLLM_USE_RUST_FRONTEND", "1" if rust_enabled else "0")
|
||||
args = vllm_parser.parse_args(["serve", "--grpc-port", str(port), *extra_args])
|
||||
error = (
|
||||
"--grpc and --grpc-port are mutually exclusive"
|
||||
if "--grpc" in extra_args
|
||||
else "--grpc-port"
|
||||
)
|
||||
with pytest.raises(ValueError, match=error):
|
||||
validate_parsed_serve_args(args)
|
||||
|
||||
|
||||
def test_rust_grpc_port_requires_serve_subcommand(monkeypatch):
|
||||
"""Direct Python render/API entrypoints must reject a Rust-only listener."""
|
||||
monkeypatch.setenv("VLLM_USE_RUST_FRONTEND", "1")
|
||||
parser = make_arg_parser(FlexibleArgumentParser())
|
||||
args = parser.parse_args(["--grpc-port", "50051"])
|
||||
with pytest.raises(ValueError, match="--grpc-port requires"):
|
||||
validate_parsed_serve_args(args)
|
||||
|
||||
|
||||
def test_enable_auto_choice_passes_without_tool_call_parser(serve_parser):
|
||||
"""Ensure validation fails if tool choice is enabled with no call parser."""
|
||||
# If we enable-auto-tool-choice, explode with no tool-call-parser
|
||||
@@ -265,13 +334,21 @@ def launch_render_parser():
|
||||
return _build_launch_render_parser()
|
||||
|
||||
|
||||
def test_launch_render_validates_serve_args(launch_render_parser):
|
||||
@pytest.mark.parametrize(
|
||||
"cli_args, error",
|
||||
[
|
||||
(["--enable-auto-tool-choice"], TypeError),
|
||||
(["--grpc-port", "50051"], ValueError),
|
||||
],
|
||||
)
|
||||
def test_launch_render_validates_serve_args(
|
||||
launch_render_parser, monkeypatch, cli_args, error
|
||||
):
|
||||
"""`vllm launch render` reuses the serve parser, so it gets the serve checks"""
|
||||
args = launch_render_parser.parse_args(
|
||||
args=["launch", "render", "--enable-auto-tool-choice"]
|
||||
)
|
||||
monkeypatch.setenv("VLLM_USE_RUST_FRONTEND", "1")
|
||||
args = launch_render_parser.parse_args(args=["launch", "render", *cli_args])
|
||||
assert args.subparser == "launch"
|
||||
with pytest.raises(TypeError):
|
||||
with pytest.raises(error):
|
||||
validate_parsed_serve_args(args)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user