Skip to content

feat(core): servers run without Ray unless they declare ray_enabled = True - #4307

Merged
ananthsub merged 1 commit into
mainfrom
ananthsub/ray-default-disabled
Oct 9, 2026
Merged

ananthsub merged 1 commit into
mainfrom
ananthsub/ray-default-disabled

Conversation

@ananthsub

@ananthsub ananthsub commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Closes #4315.

What changed

ray_enabled now defaults to False. A server uses Ray only if it declares ray_enabled = True.

  • Server side: SimpleServer.ray_enabled is ClassVar[bool] = False. A server that doesn't declare True never connects to Ray, even when the run has a cluster. The compatibility path and its warning for undeclared servers are removed.
  • Supervisor: gym starts or joins Ray only for servers whose entrypoint class literally declares ray_enabled = True.
    • Undeclared servers no longer count, even when Ray is installed.
    • Neither does a True the 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 declare ray_enabled = True on its own class. If Ray is already running for other servers, it joins as before.
  • Launch environment: servers that don't declare Ray are launched with RAY_ENABLE_AUTO_CONNECT=0. Ray reads this at import. With it set, any implicit Ray call fails with Ray has not been started yet, instead of quietly starting a private local cluster in each server process and Uvicorn worker. An explicit ray.init() is unaffected.
  • Docs: the FAQ and system design pages describe the new default and the failure mode.

Why

This is step 6 of #3669: after the compatibility window, None means "no Ray". All built-in servers already declare ray_enabled explicitly, 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.py

  • Updated tests:

    • the supervisor decision across declarations and Ray availability;
    • the RAY_ENABLE_AUTO_CONNECT setting is present for non-Ray servers and absent for Ray servers;
    • a server subclassing SimpleServer without a declaration never connects and logs nothing;
    • an undeclared server doesn't join a configured cluster.

    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.remote function without ray.init() raised RaySystemError: System error: Ray has not been started yet, and ray.is_initialized() stayed False.

  • fern check passes.

  • pre-commit run scoped to the changed files.

Rollout evidence

Smoke run: gym env start with example_single_tool_call and openai_model reached All 4 / 4 servers ready without starting Ray. Reading /proc/<pid>/environ of the four running server processes showed RAY_ENABLE_AUTO_CONNECT=0 in each:

  • the resources server
  • the simple agent
  • the legacy agent environment server
  • the OpenAI model server

No model requests were sent. This changes whether servers connect to Ray, not prompts, trajectories, verification or rewards.

Compatibility

  • Built-in servers: unchanged. Every one declares ray_enabled explicitly.
  • External servers that use Ray without declaring it: they no longer get Ray. Their first Ray call fails with Ray has not been started yet. Fix: declare ray_enabled = True on the class the entrypoint runs.
  • External servers that inherit ray_enabled = True from 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.
  • External servers that don't use Ray: they stop connecting to Ray and stop logging the undeclared-server warning.

@copy-pr-bot

copy-pr-bot Bot commented Oct 9, 2026

Copy link
Copy Markdown

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
ananthsub force-pushed the ananthsub/ray-default-disabled branch from d73d433 to c6f8108 Compare October 9, 2026 17:17
@ananthsub
ananthsub force-pushed the ananthsub/ray-servers-request-extra branch from 13087fa to 5ae24f8 Compare October 9, 2026 17:17
@ananthsub
ananthsub marked this pull request as ready for review October 9, 2026 18:17
@nemo-automation-bot
nemo-automation-bot Bot requested review from a team October 9, 2026 18:18
@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

hemildesai
hemildesai previously approved these changes Oct 9, 2026
@ananthsub
ananthsub force-pushed the ananthsub/ray-default-disabled branch from c6f8108 to b61bda2 Compare October 9, 2026 18:56
@ananthsub
ananthsub force-pushed the ananthsub/ray-servers-request-extra branch from 5ae24f8 to 352a1d6 Compare October 9, 2026 18:56
@nemo-automation-bot
nemo-automation-bot Bot requested a review from a team October 9, 2026 18:57
@yaoyu-33 yaoyu-33 added area:core Shared APIs, servers, telemetry, health, and registries complexity:high Cross-component or shared-contract change with a large review surface feature New capabilities, enhancements, or enablement work ready-to-merge PR is approved, current, and waiting for final CI or merge labels Oct 9, 2026
Base automatically changed from ananthsub/ray-servers-request-extra to main October 9, 2026 19:58
@ananthsub
ananthsub dismissed hemildesai’s stale review October 9, 2026 19:58

The base branch was changed.

@ananthsub
ananthsub requested a review from a team as a code owner October 9, 2026 19:58
… 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
ananthsub force-pushed the ananthsub/ray-default-disabled branch from b61bda2 to d8783ce Compare October 9, 2026 20:05
@ananthsub
ananthsub merged commit a23071b into main Oct 9, 2026
49 of 51 checks passed
@ananthsub
ananthsub deleted the ananthsub/ray-default-disabled branch October 9, 2026 20:26
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]>
@linear-code linear-code Bot mentioned this pull request Nov 12, 2026
8 of 26 tasks

This branch was previously deployed

1 inactive deployment
public — d8783cea Deployed Oct 9, 2026 by copy-pr-bot[bot] via release / finalize / notify #4915
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core Shared APIs, servers, telemetry, health, and registries complexity:high Cross-component or shared-contract change with a large review surface feature New capabilities, enhancements, or enablement work ready-to-merge PR is approved, current, and waiting for final CI or merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Default ray_enabled to False

3 participants