Repository navigation
feat(local_vllm_model): serve external vLLM endpoints without Ray - #6039
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
a9a84ae to
b9ea447
Compare
e212731 to
101a3f0
Compare
Adopting
|
93bf045 to
3a21ea8
Compare
24ef1fb to
872ad2c
Compare
|
Looks good to me. Reading Verified locally on the PR head with a fresh root venv (dev + ray extras): Notes, none blocking:
|
|
@snivertynv Thanks for the review. All three notes are addressed in 4ac1bf4.
The import test stays as it is. It needs the server venv, like |
local_vllm_model declares ray_enabled = True, and Gym reads that flag from the entrypoint's source before any config exists. So a server whose base_url points at an external vLLM pool still makes Gym start or join Ray, joins Ray itself, and imports Ray and vLLM, even though it launches nothing. Add external_app.py, a sibling entrypoint for that case: - It declares ray_enabled = False and imports neither Ray nor vLLM. - It requires a non-empty base_url. - It accepts every app.py config key, with the vLLM launch settings optional, so a config switches between a local launch and an external pool by changing entrypoint and base_url. - It keeps the /get_inner_vllm_config route that the local vLLM proxy reads. - It supports num_workers > 1. The shared config moves to server_config.py, so external_app.py can load it without app.py. app.py re-exports it, so existing imports keep working. The test that external_app.py loads neither Ray nor vLLM first requires both to be installed. Without them, an entrypoint that imports Ray behind a try/except ImportError would pass. Signed-off-by: Ananth Subramaniam <[email protected]>
- Reject a base_url list with a blank entry, such as [""], which a launcher produces when it interpolates an unset variable. - Document that external_app.py supports num_workers > 1. - Document that a launcher which injects base_url should also set entrypoint=external_app.py there, keeping app.py for the local launch. Signed-off-by: Ananth Subramaniam <[email protected]>
4ac1bf4 to
7fb129b
Compare
What changed and why
local_vllm_modeldeclaresray_enabled = True. Gym reads that flag from the entrypoint's source before any config exists, so alocal_vllm_modelserver whosebase_urlpoints at an external vLLM pool still pays for Ray, though it launches nothing:_ray_server_names→initialize_ray()). In an evaluation run with no other Ray server, this server alone starts a private cluster. It also makes the run fail whennemo-gym[ray]is not installed wheregymruns.ray.init(address=...)inrun_webserver.app.pyhas no module-levelappfor uvicorn workers, so such a server cannot setnum_workers > 1.Production RL recipes do this for external judge pools: the NeMo RL launcher injects
base_urlatnl2bash_judge_model.responses_api_models.local_vllm_model.base_url, and launches vLLM locally instead when no pool URL is set.This PR adds
responses_api_models/local_vllm_model/external_app.py, a second entrypoint for the external case, and keeps the static source check unchanged.It has two benefits: the server no longer starts or joins Ray, and it can run with
num_workers > 1.For a busy judge, spreading request forwarding across workers can matter more than skipping Ray.
The entrypoint:
ray_enabled = Falseand imports neither Ray nor vLLM, so the supervisor launches it withRAY_ENABLE_AUTO_CONNECT=0and starts no cluster on its account.base_url, and rejects a list with a blank entry, such as[""].app.pykey;vllm_serve_kwargsandvllm_serve_env_varsbecome optional. A config switches between a local launch and an external pool by changingentrypointandbase_url, so the launcher's local fallback keeps working./get_inner_vllm_configroute thatlocal_vllm_model_proxyreads.num_workers > 1.The shared config moves from
app.pytoserver_config.py, soexternal_app.pycan load it without importing Ray or vLLM.app.pyre-exports it, sogenrm_modeland other existing imports are unchanged.Options considered
base_urlset means no Ray): the supervisor would need a per-server-type rule, and the server would have to repeat it in_connect_server_to_ray. That splits one decision across two places, and the Ray opt-out audit would no longer describe actual behavior.True, the supervisor still starts Ray, so this saves only the connect. DeclaringFalsewould launch the local path without a guaranteed cluster.vllm_model: this works for evaluation-only external judges, but it drops the launcher's local fallback and still needs a launcher change.Issue
No issue. This follows the Ray opt-out work in #4300, #4301, #4307, #4350 and #4470, which made Ray depend on each entrypoint's declaration.
Compatibility
Existing configs behave exactly as before;
app.pystill acceptsbase_urland skips the local launch. To opt in, a config setsentrypoint: external_app.py. For the NeMo RL launchers that injectbase_urlfor this judge (examples/nemo_gym/nemotron-3.5-lightning/lightning35_launch.shandexamples/nemo_gym/nemotron-3-ultra/ultra_launch.sh), that is one more override inside the branch that setsbase_url, so the local-launch fallback keeps usingapp.py:Validation
Run locally on a workstation, in a worktree venv with the
devextra plus Ray 2.58.0:The new tests check that:
external_app.pyin a subprocess loads neitherraynorvllm. The check first requires both to be installed, so an import behindtry/except ImportErrorcan't slip through. Addingimport rayto the entrypoint, guarded or not, makes it fail;ray_enabled = False, and the supervisor leaves it out of the Ray server list while still listing anapp.pyserver in the same run;base_url, including a list with a blank entry, and accepts an unchanged local-launch block;/get_inner_vllm_configreports the external endpoint and is a non-generating route.The
local_vllm_modelserver tests, including the existing ones that import vLLM, also pass in the server's own venv (Ray 2.58.0, vLLM 0.29.0), whichgym env startbuilt for the smoke run below:Measured on the workstation, for scale: starting a private Ray cluster took about 2.3 s and shutting it down about 1.1 s;
ray.initagainst a running local head took 0.05 to 0.27 s; importing vLLM took 4 to 8 s.Rollout evidence
Smoke run on a workstation (local, not Slurm), 2026-11-11. A vLLM 0.29.0 server on one RTX 6000 Ada served
Qwen/Qwen3-4B-Instruct-2507asjudge-modeland stood in for the external pool.gym env startstartedequivalence_llm_judge, the simple agent, avllm_modelpolicy and ajudge_modelinstance oflocal_vllm_modelwithentrypoint: external_app.py,base_urlpointing at that server andnum_workers: 2.gym eval run --no-servethen collected 4 rows ofresources_servers/equivalence_llm_judge/data/example.jsonl.RAY_ENABLE_AUTO_CONNECT=0, and none of them has a Ray or vLLM shared library mapped.judge_model: 3[[A=B]]and 1[[A!=B]], mean reward 0.75, no failed rows, no judgement parsing issues.GET /get_inner_vllm_configon the judge returned the externalbase_url, thedummyAPI key andjudge-model.The
local_vllm_modelvenv still installs vLLM and Ray, because a venv belongs to the server directory and not the entrypoint. Deployments that build venvs on the fly still pay that install once.Docs
fern/versions/latest/pages/model-server/local-vllm.mdxgains a section on serving an external endpoint without Ray.It says that
external_app.pysupportsnum_workers > 1, and that a launcher which injectsbase_urlshould setentrypoint=external_app.pyin the same place, keepingapp.pyon its local-launch path.