Repository navigation
feat(genrm_model): serve external GenRM vLLM pools without Ray - #6056
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. |
3a21ea8 to
24ef1fb
Compare
faeb682 to
8d3c418
Compare
24ef1fb to
872ad2c
Compare
8d3c418 to
0d0716f
Compare
4ac1bf4 to
7fb129b
Compare
43b7b27 to
adc86e8
Compare
GenRMModel declares ray_enabled = True, and Gym reads that from the entrypoint's source before any config exists. Production recipes point genrm_model at an external GenRM vLLM pool through an injected base_url, so that server still makes Gym start or join Ray, joins it itself, and imports Ray and vLLM, though it never launches anything. Add external_app.py, a sibling entrypoint for that case, built on local_vllm_model's external_app.py. It declares ray_enabled = False, imports neither Ray nor vLLM, requires base_url, accepts every app.py key with the launch settings optional, and supports num_workers > 1. The GenRM role handling and config move to common.py so external_app.py can load them without app.py; app.py imports them from there, so existing imports keep working. Signed-off-by: Ananth Subramaniam <[email protected]>
GenRMModelMixin had no base class but called super(), so it worked only when listed before a VLLMModel subclass, and nothing declared that. With the bases swapped, or the mixin used alone, super() reached object and every request failed. Its get_converter repeated VLLMModel.get_converter. The role handling becomes append_genrm_roles in common.py, a plain function on the request body. GenRMModel and GenRMExternalModel each call it after the base preprocessing. The tests exercise the function on plain dicts, drop the stand-in base class, and run the role handling through each real server class. Signed-off-by: Ananth Subramaniam <[email protected]>
- Document in the README that external_app.py supports num_workers > 1, and that a launcher which injects base_url should also set entrypoint=external_app.py there, keeping app.py for the local launch. - Require both Ray and vLLM to be installed in the import test, so an entrypoint that imports vLLM behind a try/except cannot pass it. Signed-off-by: Ananth Subramaniam <[email protected]>
6475371 to
22bec46
Compare
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP
LGTM — no concerns found.
I reviewed all eight changed files and traced the affected request, configuration, startup, multiworker, and proxy-route contracts. The shared helper preserves the existing GenRM role handling. The external entrypoint retains GenRM configuration and preprocessing while using the Ray-free external base.
This was static inspection only; I didn't execute tests or start a model server.
Note: formal approval is not available for this request, so this review is posted as a comment only.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
zyzhou5
left a comment
There was a problem hiding this comment.
Overall LGTM. Left some non-blocking comments.
|
|
||
| See `configs/genrm_model.yaml`. Config key under `responses_api_models` is `genrm_model` with `entrypoint: app.py`. | ||
|
|
||
| To use a GenRM vLLM pool that runs elsewhere, set `base_url` to that pool and `entrypoint: external_app.py`. That entrypoint launches no vLLM and doesn't use Ray, so Gym doesn't start or join a Ray cluster for it. It accepts the same keys as `app.py`, with `vllm_serve_kwargs` and `vllm_serve_env_vars` optional. `external_app.py` also supports `num_workers > 1`, which `app.py` does not. `app.py` still accepts `base_url` and skips the local launch, but it joins Ray regardless, because Gym decides whether a server uses Ray from its entrypoint before reading the config. |
There was a problem hiding this comment.
nit, nonblocking: regarding "before reading the config", Gym has already read the config when it decides on Ray (supervisor, server); it reads the class's ray_enabled and ignores base_url by design.
There was a problem hiding this comment.
|
|
||
| # LocalVLLMExternalModelConfig comes first so its required `base_url` and optional launch settings win over the | ||
| # local-launch defaults that GenRMModelConfig inherits. | ||
| class GenRMExternalModelConfig(LocalVLLMExternalModelConfig, GenRMModelConfig): |
There was a problem hiding this comment.
Pydantic takes a field both bases share from the first base (LocalVLLMExternalModelConfig), even one it only inherited. So a default GenRMModelConfig later sets for an inherited field (e.g. uses_reasoning_parser: bool = True) would apply under app.py but be silently ignored here. Nothing is affected today; worth noting in this comment.
There was a problem hiding this comment.
Good catch, fixed in d6b9139. The comment now says Pydantic takes every field both bases have from LocalVLLMExternalModelConfig, so a default GenRMModelConfig sets for an inherited field has to be redeclared on GenRMExternalModelConfig. A new test in test_external_app.py checks that both configs have the same default for every field except base_url, vllm_serve_kwargs and vllm_serve_env_vars. Adding debug: bool = True to GenRMModelConfig makes it fail.
- Say that Gym decides whether a server uses Ray from its entrypoint class's ray_enabled, not from base_url, in the GenRM README, the local vLLM docs page and local_vllm_model/app.py. The config is already loaded when that decision is made, so "before reading the config" was wrong. - Note that GenRMExternalModelConfig takes every field both bases have from LocalVLLMExternalModelConfig, so a default GenRMModelConfig sets for an inherited field must be redeclared there, and test that both configs agree on every default apart from the launch settings. Signed-off-by: Ananth Subramaniam <[email protected]>
Stacked on #6039. This PR's base is that PR's branch, so the diff shows only the
genrm_modelchange.What changed and why
genrm_modeldeclaresray_enabled = True. Gym reads that flag from the entrypoint's source before any config exists. Production RL recipes pointgenrm_modelat an external GenRM vLLM pool by injectingbase_url, and that server still pays for Ray, though it launches nothing:local_vllm_model/app.py, which loads Ray and vLLM.The NeMo RL launchers inject that
base_urlatgenrm_model.responses_api_models.genrm_model.base_url. They launch GenRM locally instead when no pool URL is set.This PR adds
responses_api_models/genrm_model/external_app.py, a second entrypoint for the external case. It builds on thelocal_vllm_modelexternal entrypoint from #6039:ray_enabled = Falseand imports neither Ray nor vLLM, so the supervisor starts no Ray cluster on its account.response_1,response_2andprincipleroles taken frommetadata, andsupports_principle_role.base_url. It accepts everyapp.pykey, withvllm_serve_kwargsandvllm_serve_env_varsoptional. A config switches between a local launch and an external pool by changingentrypointandbase_url./get_inner_vllm_configroute and supportsnum_workers > 1.base_urlandentrypointtogether.The GenRM role handling and
GenRMModelConfigmove fromapp.pytocommon.py, which imports neither Ray nor vLLM.app.pyimportsGenRMModelConfigfrom there, sofrom responses_api_models.genrm_model.app import GenRMModelConfigkeeps working. The external config inheritsGenRMModelConfig, so a GenRM field added there also reaches the external entrypoint.The second commit replaces
GenRMModelMixinwithappend_genrm_roles, a plain function on the request body. The mixin had no base class but calledsuper(), so it worked only when listed before aVLLMModelsubclass, and nothing declared that. Itsget_converterrepeatedVLLMModel.get_converter.GenRMModelandGenRMExternalModelnow each run the base preprocessing and then call the function. Code that importedGenRMModelMixinmust callappend_genrm_rolesinstead; nothing in Gym or on NeMo RLmainimports it.A later commit corrects the reason the docs give for
app.pyjoining Ray with an externalbase_url: Gym decides from the entrypoint class'sray_enabled, not frombase_url, and the config is already loaded at that point. The same wording came in with #6039, so the fix also touchesfern/versions/latest/pages/model-server/local-vllm.mdxand a comment inlocal_vllm_model/app.py. The commit also notes thatGenRMExternalModelConfigtakes every field both bases have fromLocalVLLMExternalModelConfig, and adds a test that both configs agree on every default apart from the launch settings.Issue
No issue. This applies the #6039 approach to
genrm_model, the other model server that production recipes point at an external pool.Compatibility
Existing configs behave exactly as before:
app.pystill acceptsbase_urland skips the local launch. To opt in, a config setsentrypoint: external_app.py.The NeMo RL launchers that inject
base_urlfor GenRM areexamples/nemo_gym/nemotron-3.5-lightning/lightning35_launch.shandexamples/nemo_gym/nemotron-3-ultra/ultra_launch.sh. For them, opting in is one more override in the branch that setsbase_url. The local-launch fallback keeps usingapp.py:Validation
Run locally on a workstation. The
genrm_modeltests ran in this worktree's owngenrm_modelserver venv (vLLM 0.29.0, Ray 2.58.0), because bothapp.pyand the import check need vLLM installed:RAY_TMPDIR=/tmp responses_api_models/genrm_model/.venv/bin/python -m pytest -o addopts="" responses_api_models/genrm_model/testsThe core checks ran in a worktree venv with the
devandrayextras:The new tests check that:
external_app.pyin a subprocess loads neitherraynorvllm. The check first requires Ray and vLLM to be installed, so an entrypoint that imports them behind atry/except ImportErrorcan't pass it;ray_enabled = False. The supervisor leaves it out of the Ray server list while still listing anapp.pyserver in the same run;base_url, inherits everyGenRMModelConfigfield and its default, and accepts the shippedconfigs/genrm_model.yamlblock oncebase_urlis added;metadata, with and withoutsupports_principle_role, and consumesmetadata;/get_inner_vllm_configreports the external pool.The
test_app.pytests checkappend_genrm_roleson plain request bodies, and run the role handling through a realGenRMModeland a realGenRMExternalModel. Replacing either server'sappend_genrm_rolescall withreturn body_dictfails that server's role test. Thegenrm_compareresources server tests also pass.Rollout evidence
N/A: no model run for this PR. The external entrypoint changes only how the server starts. Request handling is the same
append_genrm_rolescall thatapp.pymakes, on the externallocal_vllm_modelbase that #6039 smoke-tested against a real vLLM server withnum_workers: 2. The unit tests cover the GenRM role handling through the external server.Like
local_vllm_model, thegenrm_modelvenv still installs vLLM and Ray, because a venv belongs to the server directory and not the entrypoint.Docs
responses_api_models/genrm_model/README.mddescribes the external entrypoint.