Skip to content

build(deps): make Ray an optional dependency - #4350

Merged
ananthsub merged 1 commit into
mainfrom
ananthsub/ray-optional-dependency
Oct 14, 2026
Merged

ananthsub merged 1 commit into
mainfrom
ananthsub/ray-optional-dependency

Conversation

@ananthsub

Copy link
Copy Markdown
Contributor

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.

@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 marked this pull request as ready for review October 10, 2026 00:53
@ananthsub
ananthsub requested a review from a team as a code owner October 10, 2026 00:53
@nemo-automation-bot
nemo-automation-bot Bot requested review from a team and anwithk October 10, 2026 00:53
@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

@yaoyu-33 yaoyu-33 added area:build Packaging, dependencies, containers, and releases complexity:medium Single-domain change with interacting parts or a moderate review surface feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer labels Oct 10, 2026
@github-actions github-actions Bot added the sla:review-overdue Review response is over the one-business-day SLA label Oct 12, 2026
@ananthsub
ananthsub force-pushed the ananthsub/ray-optional-dependency branch from cfb3737 to 9d5360e Compare October 12, 2026 13:49
@copy-pr-bot

copy-pr-bot Bot commented Oct 12, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@ananthsub

Copy link
Copy Markdown
Contributor Author

/ok to test 9d5360e

@ananthsub

Copy link
Copy Markdown
Contributor Author

/ok to test 4b25988

@ananthsub
ananthsub enabled auto-merge October 13, 2026 23:39
khazic pushed a commit to khazic/Gym-lao that referenced this pull request Oct 14, 2026
…dules (NVIDIA-NeMo#4581)

## What changed

`responses_api_agents/stirrup_agent/__init__.py` now loads the agent
module (`app.py`) only when one of the agent classes
(`StirrupAgentWrapper`, `StirrupAgentWrapperConfig`,
`StirrupRunRequest`) is accessed. Before, it imported `app.py` eagerly,
so importing any stirrup_agent helper module loaded the whole agent.
`TaskStrategy` is still imported directly, since it's lightweight.

## Why

gdpval doesn't use Ray, but it imports two stirrup_agent helper modules:
- `file_reader`, in `app.py`, to read deliverables during `verify`;
- `task_distribution`, in `multistage_elo.py`.

Because the package `__init__.py` imported the agent, and the agent
imports Ray at module level, those imports needed Ray. Every server venv
used to have Ray, so this went unnoticed. With NVIDIA-NeMo#4350, which makes Ray an
optional dependency, gdpval's venv no longer has Ray. gdpval's tests
then fail with `No module named 'ray'`, and so would `verify` for any
task with a deliverables directory. This unblocks NVIDIA-NeMo#4350.

Nothing in the repository imports the agent classes through the package;
callers import submodules directly. Accessing
`responses_api_agents.stirrup_agent.StirrupAgentWrapper` still works.

## Validation

All of the following ran on NVIDIA-NeMo#4350's head with this change applied:
- **gdpval's tests, without Ray:** in a venv built from
`resources_servers/gdpval/requirements.txt`, the `pytest tests` run
passes. With the previous `__init__.py` in the same venv, the gdpval
failures from NVIDIA-NeMo#4350's CI reproduce.
- **stirrup_agent's tests, with Ray:** in a venv built from
`responses_api_agents/stirrup_agent/requirements.txt` and its
`overrides.txt`, the `pytest tests` run passes.
- **Imports in an environment without Ray:**
- `responses_api_agents.stirrup_agent.file_reader` and
`responses_api_agents.stirrup_agent.task_distribution` import cleanly,
where they previously failed;
- with Ray installed, `from responses_api_agents.stirrup_agent import
StirrupAgentWrapper, StirrupRunRequest, TaskStrategy` still works.
- `pre-commit run` on the changed file.

## Rollout evidence

N/A. This only changes when the agent module is imported. The agent's
behavior, prompts, trajectories, verification and rewards are unchanged.

## Compatibility

None. Package-level access to the agent classes behaves as before. The
agent module now loads on first access instead of at package import.

Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>
Move `ray[default]` and its `jinja2` pin out of nemo-gym's core
dependencies into the `ray` extra, so a plain `pip install nemo-gym` no
longer installs Ray. Gym already runs without Ray, and the servers that
declare `ray_enabled = True` request the extra in their own manifests.

- CI: the core unit-test, unit-test and full-test-suite syncs add
  `--extra ray`, so Ray code paths stay tested. The wheel smoke test and
  server-test setup stay without it.
- Docker: the image builds add `--extra ray`.
- Tests: the Ray Serve gateway test and the Super 3.5 launcher's
  prebuilt-environment check skip when Ray isn't installed.
- Docs: installation, development setup and FAQ describe the extra.

Closes #4316.

Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>
@ananthsub
ananthsub force-pushed the ananthsub/ray-optional-dependency branch from 4b25988 to 7c54b11 Compare October 14, 2026 14:54
@ananthsub

Copy link
Copy Markdown
Contributor Author

/ok to test 7c54b11

@github-actions

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/38587741688

Merged via the queue into main with commit 40d7484 Oct 14, 2026
49 of 54 checks passed
@ananthsub
ananthsub deleted the ananthsub/ray-optional-dependency branch October 14, 2026 15:34
qiaochuz-nv added a commit that referenced this pull request Oct 15, 2026
… deliverables dir

The GDPVal run recipe could not work as written on main:

- The benchmark config defaults persist_deliverables_dir to the relative
  output/gdpval/deliverables, which the Stirrup agent rejects at startup.
- With an absolute PERSIST_DELIVERABLES_DIR, every task fails with
  "GDPval requires the Apptainer sandbox" because GDPVAL_CONTAINER_PATH is
  unset; the run then stops with "None of the N dispatched rollouts
  produced a result" and no aggregate metrics.
- Since Ray became an optional extra (#4350), a `uv sync --extra dev`
  install stops before the run because the Stirrup agent needs Ray.

Add a "Prerequisites for every run" section to the benchmark README and the
config's run recipe. Correct the Stirrup README, which still called
Apptainer optional, said the agent falls back to a local sandbox, and
installed Gym without Ray, and fix the aggregate-metrics filename
(<stem>_aggregate_metrics.json) in both READMEs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: qiaochuz <qiaochuz@nvidia.com>

This branch was previously deployed

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

Labels

area:build Packaging, dependencies, containers, and releases complexity:medium Single-domain change with interacting parts or a moderate review surface feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer sla:review-overdue Review response is over the one-business-day SLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move Ray out of nemo-gym's core dependencies

4 participants