Repository navigation
feat(core): servers run without Ray unless they declare ray_enabled = True - #4307
Merged
Merged
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. |
ananthsub
force-pushed
the
ananthsub/ray-default-disabled
branch
from
October 9, 2026 17:17
d73d433 to
c6f8108
Compare
ananthsub
force-pushed
the
ananthsub/ray-servers-request-extra
branch
from
October 9, 2026 17:17
13087fa to
5ae24f8
Compare
ananthsub
marked this pull request as ready for review
October 9, 2026 18:17
Contributor
hemildesai
previously approved these changes
Oct 9, 2026
ananthsub
force-pushed
the
ananthsub/ray-default-disabled
branch
from
October 9, 2026 18:56
c6f8108 to
b61bda2
Compare
ananthsub
force-pushed
the
ananthsub/ray-servers-request-extra
branch
from
October 9, 2026 18:56
5ae24f8 to
352a1d6
Compare
… True `ray_enabled` now defaults to False. Servers that don't declare `ray_enabled = True` never connect to Ray, and the compatibility warning for undeclared servers is gone (#3669, step 6). - `gym` starts or joins Ray only for servers whose entrypoint class literally declares `ray_enabled = True`. A True inherited from another module no longer counts; such a server fails at startup with the existing error asking it to declare `ray_enabled = True` itself. - Servers that don't declare Ray are launched with RAY_ENABLE_AUTO_CONNECT=0. If one calls Ray anyway, the call fails with "Ray has not been started yet" instead of starting a private cluster in each of its processes and workers. - Update the FAQ and system design pages. Signed-off-by: Ananth Subramaniam <[email protected]>
ananthsub
force-pushed
the
ananthsub/ray-default-disabled
branch
from
October 9, 2026 20:05
b61bda2 to
d8783ce
Compare
This was referenced Oct 9, 2026
pachmu
pushed a commit
to pachmu/Gym
that referenced
this pull request
Oct 13, 2026
…A-NeMo#4470) ## What changed `ray_enabled` defaults to `False` since NVIDIA-NeMo#4307, so only servers that use Ray need to declare it. - **Server classes:** removes the explicit `ray_enabled = False` from the 212 classes that set it, across resources, agent, model and environment servers. The 18 servers that use Ray keep `ray_enabled = True`. - **Scaffold:** the templates for new resources and agent servers no longer emit `ray_enabled = False`. - **Audit (`tests/unit_tests/test_ray_opt_out.py`):** checks that a server class declares `ray_enabled = True` exactly when it uses Ray. It still accepts an explicit `False`, so syncing this change into a branch that still has those lines doesn't fail. - **Docs:** the deployment topology and system design pages say "servers that don't declare `ray_enabled = True`" instead of "servers declaring `ray_enabled = False`". ## Why The explicit declarations were needed while an undeclared server still defaulted to using Ray. Now they're noise, and the scaffold kept copying them into new servers. The only declaration that carries information is `ray_enabled = True`. Part of NVIDIA-NeMo#3669. ## Validation - **No behavior change:** before removing each line, I followed every affected class up through its base classes, across modules, to confirm none declared `False` to override a parent that declares `True`. All 212 inherit `False`. Seventeen of them inherit through the `GymnasiumServer`, `AviaryResourcesServer` and `LangGraphAgentAdapter` base classes, which I checked directly. - **The audit still catches mistakes:** - deleting `True` from `code_gen` fails it with "uses Ray but doesn't declare `ray_enabled = True`"; - adding `True` to `mcqa` fails it with "declares `ray_enabled = True` but doesn't use Ray". - **Unit tests:** the full `tests/unit_tests/` run with `-m "not sandbox"` in the core CI job's environment (with `--extra ray`) passes. - **Compilation and lint:** every changed Python file compiles. One file with CRLF line endings keeps them. - `fern check` passes. - `pre-commit run` on the changed files. ## Rollout evidence **Smoke run:** `gym env start` with `example_single_tool_call` and `openai_model`. All four servers (resources, simple agent, legacy agent environment server and OpenAI model) no longer mention `ray_enabled`. All four reached ready without starting Ray and without warnings. No model requests were sent. Declarations only; this doesn't change prompts, trajectories, verification or rewards. ## Compatibility None. Servers that don't declare `ray_enabled` already get `False`. External servers that still declare `ray_enabled = False` keep working. Signed-off-by: Ananth Subramaniam <[email protected]>
github-merge-queue Bot
pushed a commit
that referenced
this pull request
Oct 14, 2026
Closes #4316. ## What changed `ray[default]` and its `jinja2` pin move out of nemo-gym's core dependencies and live only in the `ray` extra (also part of `all`). A plain `pip install nemo-gym` no longer installs Ray. - **Packaging:** `pyproject.toml` and `uv.lock`. The lockfile change is metadata only; Ray and `jinja2` stay locked through the extra, and no package versions move. - **CI:** - `scripts/ci/core_unit_tests.sh`, plus the unit-test and full-test-suite syncs, add `--extra ray`, so Ray code paths stay tested and stay in the coverage gate. - The wheel smoke test still installs the plain wheel, which now also covers the path without Ray. - Server-test setup stays without the extra, because each Ray server's own venv requests it. - **Docker:** the image builds add `--extra ray`. The `ray_dist.jar` removal for the CVE is unchanged. - **Tests:** two tests skip when Ray isn't installed: - `tests/unit_tests/test_ray_serve_gateway.py`, because the gateway imports Ray Serve at module level; - the Super 3.5 launcher's prebuilt-environment check, because its generated dependency check imports Ray, which the evaluation image provides. - **Docs:** the installation and development-setup pages explain when to add the `ray` extra, and the FAQ no longer says Ray is a core dependency. ## Why This is the last step of #3669. Earlier changes made Gym run without Ray (#4300), had Ray servers request the extra (#4301), and made servers run without Ray unless they declare `ray_enabled = True` (#4307). The only remaining reason every install got Ray was nemo-gym's own core dependency. ## Validation - **Package metadata:** `uv build --wheel` gives `Requires-Dist: ray[default]>=2.58.0; extra == "ray"` and `Requires-Dist: jinja2>=3.1; extra == "ray"`, with no unconditional Ray requirement. - **Without the extra:** `uv sync --locked --extra dev` gives an environment where neither `ray` nor `jinja2` is importable, and `gym --version` reports `"ray": "not installed"`. - **Full `tests/unit_tests/` run, `-m "not sandbox"` as in the core CI job.** I built the core CI job's environment (`dev`, `telemetry`, `mlflow`, `wandb`) twice: - With `--extra ray`, everything passes. - Without it, only the Ray-specific tests above skip. One timing-sensitive OpenSandbox cleanup test failed once under parallel load, and passed three times out of three on its own. - `fern check` passes. - `pre-commit run` scoped to the changed files. ## Rollout evidence N/A. This changes which packages a default install includes. It doesn't change prompts, model requests, trajectories, verification or rewards. #4300 smoke-tested `gym env start` with Ray uninstalled. ## Compatibility This is a breaking packaging change and needs a release note (#4317): - **Ray-backed servers after a plain install:** anyone running a server that declares `ray_enabled = True` (such as `local_vllm_model`, `genrm_model` or the SWE agents) needs `pip install "nemo-gym[ray]"`, or `uv sync --extra ray`, where `gym` runs. Without it, `gym env start` stops before launching anything and says so. - **Built-in Ray servers' own venvs:** they keep getting Ray through their manifests, pinned to the version where `gym` runs. - **NeMo RL:** brings its own Ray, so nothing changes there. - **External servers that use Ray:** should request `nemo-gym[ray]` in their manifests. Signed-off-by: Ananth Subramaniam <[email protected]>
8 of 26 tasks
This branch was previously deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #4315.
What changed
ray_enablednow defaults toFalse. A server uses Ray only if it declaresray_enabled = True.SimpleServer.ray_enabledisClassVar[bool] = False. A server that doesn't declareTruenever connects to Ray, even when the run has a cluster. The compatibility path and its warning for undeclared servers are removed.gymstarts or joins Ray only for servers whose entrypoint class literally declaresray_enabled = True.Truethe source reader can't see, such as one inherited from another module. If such a server runs alone, it fails at startup with the existing error asking it to declareray_enabled = Trueon its own class. If Ray is already running for other servers, it joins as before.RAY_ENABLE_AUTO_CONNECT=0. Ray reads this at import. With it set, any implicit Ray call fails withRay has not been started yet, instead of quietly starting a private local cluster in each server process and Uvicorn worker. An explicitray.init()is unaffected.Why
This is step 6 of #3669: after the compatibility window,
Nonemeans "no Ray". All built-in servers already declareray_enabledexplicitly, which the audit enforces. So this mainly affects external servers that never declared it: they now run without Ray instead of joining or starting a cluster.The auto-connect setting covers the risky case. That's an undeclared external server that does call Ray. Without the setting, Ray's automatic initialization would start a separate cluster in every process of that server, silently. With it, the server fails on its first Ray call, and the fix is to declare
ray_enabled = True.Validation
pytest tests/unit_tests/test_ray_opt_out.py tests/unit_tests/test_cli.py tests/unit_tests/test_server_utils.pyUpdated tests:
RAY_ENABLE_AUTO_CONNECTsetting is present for non-Ray servers and absent for Ray servers;SimpleServerwithout a declaration never connects and logs nothing;The new cases fail on the previous code.
Full
tests/unit_tests/run: the same set of tests fails on this branch and on its base commit. All of them come from optional extras missing in the local venv (sandbox,wandb,mlflow).Ray behavior: with
RAY_ENABLE_AUTO_CONNECT=0, calling a@ray.remotefunction withoutray.init()raisedRaySystemError: System error: Ray has not been started yet, andray.is_initialized()stayedFalse.fern checkpasses.pre-commit runscoped to the changed files.Rollout evidence
Smoke run:
gym env startwithexample_single_tool_callandopenai_modelreachedAll 4 / 4 servers readywithout starting Ray. Reading/proc/<pid>/environof the four running server processes showedRAY_ENABLE_AUTO_CONNECT=0in each:No model requests were sent. This changes whether servers connect to Ray, not prompts, trajectories, verification or rewards.
Compatibility
ray_enabledexplicitly.Ray has not been started yet. Fix: declareray_enabled = Trueon the class the entrypoint runs.ray_enabled = Truefrom a class in another module: if no other server in the run needs Ray, they fail at startup with an error asking them to declare it on their own class.