From 1d4f77aade1c35301e17f48e4ca785a3147096ab Mon Sep 17 00:00:00 2001 From: aoshen02 Date: Thu, 4 Jun 2026 04:15:42 +0000 Subject: [PATCH] fix(test): update vllm_generate_endpoint to the post-#68 launch_server_process API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `test_vllm_generate_endpoint.py` still called the pre-#68 multi-kwarg `launch_server_process(bind_host=, server_port=, args=, rank=, visible_devices=, model_path=)` form. PR #68 (multi-node rollout topology) refactored `launch_server_process` to take a single `server_args` dict built by `_compute_server_args(...)`, so the test raised at runtime: TypeError: launch_server_process() got an unexpected keyword argument 'bind_host' i.e. the test has been failing since #68 and never caught (the unit/e2e job is gated behind pre-commit, which currently fails on every PR). Fix the test to mirror how `VLLMEngine` itself launches the server: build a `server_args` dict via `_compute_server_args(args, rank=0, dist_init_addr=None, host, port)` then call `launch_server_process(server_args)`. The `args` Namespace is expanded with the attrs that `_compute_server_args` / `build_vllm_cmd_and_env` / `get_base_gpu_id` read (`num_gpus_per_node`, `hf_checkpoint`, `vllm_enable_sleep_mode`, `vllm_dp_size`, and a single-colocate placement: `colocate`, `actor_num_nodes`, `actor_num_gpus_per_node`, `use_critic`, `debug_rollout_only`). This lets the GPU base be derived through the real `get_base_gpu_id()`/`_to_local_gpu_id()` path — identical to `VLLMEngine` — so the launched server tracks `CUDA_VISIBLE_DEVICES` rather than a hardcoded base id. Drop the now-unused `_visible_devices` helper. No production code change. Verified: `test_qwen3_0_6b_vllm_inference_generate_endpoint` passes on a single GPU (1 passed, ~100s, Qwen3-0.6B, real vLLM server + /inference/v1/generate). Co-Authored-By: Claude Opus 4.8 (1M context) --- tests/test_vllm_generate_endpoint.py | 43 ++++++++++++++++++---------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/tests/test_vllm_generate_endpoint.py b/tests/test_vllm_generate_endpoint.py index 63325b544..01a53595d 100644 --- a/tests/test_vllm_generate_endpoint.py +++ b/tests/test_vllm_generate_endpoint.py @@ -13,7 +13,7 @@ from dataclasses import dataclass import vime.utils.external_utils.command_utils as U -from vime.backends.vllm_utils.vllm_engine import _wait_server_healthy, launch_server_process +from vime.backends.vllm_utils.vllm_engine import _compute_server_args, _wait_server_healthy, launch_server_process from vime.rollout import vllm_rollout from vime.utils import http_utils from vime.utils.types import Sample @@ -65,13 +65,6 @@ def _free_port() -> int: return sock.getsockname()[1] -def _visible_devices(num_gpus: int) -> str: - visible_devices = os.environ.get("CUDA_VISIBLE_DEVICES") - if visible_devices: - return ",".join(visible_devices.split(",")[:num_gpus]) - return ",".join(str(i) for i in range(num_gpus)) - - def _stop_process_tree(process) -> None: if not process.is_alive(): return @@ -113,24 +106,44 @@ def _execute_case(case: VLLMGenerateCase): U.exec_command(f"hf download {case.hf_repo} --local-dir {case.model_path}") server_port = _free_port() - server_args = Namespace( + args = Namespace( rollout_num_gpus_per_engine=case.num_gpus, + num_gpus_per_node=case.num_gpus, + hf_checkpoint=case.model_path, seed=1234, vllm_gpu_memory_utilization=0.9, vllm_async_scheduling=False, vllm_enforce_eager=False, + vllm_enable_sleep_mode=False, rollout_max_context_len=case.max_model_len, use_rollout_routing_replay=case.use_rollout_routing_replay, + vllm_dp_size=1, + # Placement attrs so _compute_server_args derives the GPU base through the + # real get_base_gpu_id() path rather than a hardcoded id. A single + # colocate engine at rank 0 -> local base 0, and the child server's + # CUDA_VISIBLE_DEVICES is computed exactly as the production VLLMEngine + # does (honoring an externally set CUDA_VISIBLE_DEVICES instead of always + # grabbing physical GPU 0). + colocate=True, + actor_num_nodes=1, + actor_num_gpus_per_node=case.num_gpus, + use_critic=False, + debug_rollout_only=False, ) - process = launch_server_process( - bind_host="127.0.0.1", - server_port=server_port, - args=server_args, + # ``launch_server_process`` consumes a single ``server_args`` dict built by + # ``_compute_server_args`` since the PR #68 multi-node topology refactor + # (this test predates it). Let it derive GPU placement via + # get_base_gpu_id()/_to_local_gpu_id() — identical to VLLMEngine — so the + # launched server tracks CUDA_VISIBLE_DEVICES. + server_args = _compute_server_args( + args, rank=0, - visible_devices=_visible_devices(case.num_gpus), - model_path=case.model_path, + dist_init_addr=None, + host="127.0.0.1", + port=server_port, ) + process = launch_server_process(server_args) try: _wait_server_healthy(f"http://127.0.0.1:{server_port}", process)