Skip to content

refactor(orchestration): move core code out of orchestration - #5882

Merged
prokotg merged 13 commits into
tgrzegorzek/orchestration-boundary-testfrom
tgrzegorzek/orchestration-boundary-moves
Nov 10, 2026
Merged

prokotg merged 13 commits into
tgrzegorzek/orchestration-boundary-testfrom
tgrzegorzek/orchestration-boundary-moves

Conversation

@prokotg

@prokotg prokotg commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Stacked on #5749. Moves code that doesn't belong in nemo_gym.orchestration out of it (rows 1 to 5 of #5749's table) and drops the matching KNOWN_VIOLATIONS entries. The failure-kind writer and the recovery planner go with #5596. No issue: code moves only.

  • Server startup (server_supervisor, server_venv, the H2 ping sidecar and its Go sources, plus cli/_locked_env.py and cli/_prepare_worker.py) now lives in nemo_gym/server_runtime/supervisor/. It has its own public API (get_venv_path, run_command, setup_env_command, sync_environment), which nemo_gym.server_runtime no longer exports. The layering contract puts it above the rest of server_runtime, so nothing inside a server can import it.
  • installed_gym_commit moved to utils/gym_commit.py.
  • gym eval status takes its job-ID lookup as a required keyword; cli/main.py passes it, so cli/eval.py no longer imports orchestration.
  • The "sidecar" key-name constant now lives in config/global_config.py.

KNOWN_VIOLATIONS is down to 12: the 11 orchestration.recovery importers (#5596) and cli/utils.py → resume_script (the failure-kind move, reverted here and left to #5596).

Compatibility

  • orchestration.jobs.installed_gym_commit shipped in v0.7.0, so it still imports from there (same object, warns). Everything else moved here did not ship under orchestration.
  • Old paths in _moved_paths.py point at the new locations, including nemo_gym.cli._locked_env and _prepare_worker. H2_PING_SIDECAR_KEY_NAME is served from the released nemo_gym.h2_ping_sidecar.config.
  • fern/docs.yml redirects the old orchestration library pages.

#5596

It moves executors/slurm.py and resume_script.py, which this PR also touches. Its branch has the failure-kind commits this PR reverted, so re-apply them there after merging this branch in.

Validation

  • Layering contract and pre-commit pass.
  • Full core suite: 20560 passed, 161 failed, 3 errors. Every failure also fails on the unmodified base (macOS-specific).

Rollout evidence: N/A, code moves only.

@copy-pr-bot

copy-pr-bot Bot commented Nov 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.

@prokotg
prokotg marked this pull request as ready for review November 9, 2026 20:07
@prokotg
prokotg requested a review from a team as a code owner November 9, 2026 20:07
@prokotg

prokotg commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 53e5997

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

@svcnvidia-nemo-ci svcnvidia-nemo-ci left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SHIP

LGTM — no concerns found.

I reviewed all changed files and traced the affected runtime paths, compatibility aliases, CLI status lookup, commit helper, and recovery-marker consumers. I found no qualifying regressions.

This was a static review. I couldn't run tests, build a wheel, or perform cluster smoke checks in this read-only environment.

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.

@prokotg
prokotg requested a review from ananthsub November 9, 2026 20:41

@ananthsub ananthsub left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes for one compatibility break and for the shape of the move, which is cheapest to settle before 0.8.0.

nemo_gym.orchestration.jobs.installed_gym_commit shipped in v0.7.0 and no longer imports, and the import-surface fixture was edited so the import-surface test no longer catches it. The inline comment on _moved_paths.py has the entry to add.

Server startup is only partly out of orchestration: cli/_locked_env.py and cli/_prepare_worker.py still sit in the orchestration layer, and server_venv runs _locked_env.py by file path from below it. Since none of the new paths has shipped, one top-level nemo_gym/supervisor/ package holding the server supervisor, the server virtual environment setup, the HTTP/2 ping sidecar and those two modules would settle the location once. The inline comments on server_runtime/__init__.py and pyproject.toml describe it.

The four commits are independent and have different reviewers and conflicts, so splitting them would let the uncontested parts land now:

  • installed_gym_commit and the gym eval status lookup, as one small PR.
  • The server supervisor, server virtual environment and HTTP/2 ping sidecar move, after #5526 (the RunHelper → ServerSupervisor rename), so that the RunHelper deprecation entry points at the new location only once. #5553 rebases after it.
  • The eval/recovery/markers.py commit, moved into #5596, which creates the same files with a different docstring.

The branch also needs a rebase, because its base is 60 commits behind main. After the rebase, resources_servers/agentic_if_realworld (which imports installed_gym_commit from the old path) and test_benchmark_preparation.py (which imports DRIVER_FAILURE_ENV from resume_script) need their imports updated.

Comment thread nemo_gym/_moved_paths.py
),
**_names("nemo_gym.eval.eval_plan", "0.8.0", "PlanBenchmark PlanGym build_eval_plan"),
**_names("nemo_gym.orchestration.jobs", "0.8.0", "installed_gym_commit"),
**_names("nemo_gym.utils.gym_commit", "0.8.0", "installed_gym_commit"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compatibility break: installed_gym_commit was public in nemo_gym.orchestration.jobs in v0.7.0 (jobs.py), and this PR removes it from that module without a deprecation path, so from nemo_gym.orchestration.jobs import installed_gym_commit now raises ImportError. The only new MOVED_NAMES entry for it is this one under nemo_gym.cli.eval, a path that never held the name in a release.

Code on main already imports the name from the released path: resources_servers/agentic_if_realworld does (core.py), and so does the open #5134, so both break once this lands. The PR description says nothing in orchestration was released, which holds for the server supervisor, the server virtual environment setup and the HTTP/2 ping sidecar, but jobs.py, submit.py, api.py, the executors and the Ray Serve gateway all shipped in v0.7.0.

Please add an entry under the released path, add __getattr__ = moved_names_getattr(__name__) at the end of orchestration/jobs.py, and keep installed_gym_commit in that module's entry of the import-surface fixture (dropping the private _git* helpers from it is fine):

    "nemo_gym.orchestration.jobs": {
        **_names("nemo_gym.utils.gym_commit", "0.8.0", "installed_gym_commit"),
    },
Why the import-surface test (`TestImportSurface`) did not catch the removal

The import-surface test compares each module against import_surface.json, which records each module's names from before any move, so a move without a MOVED_NAMES entry fails (test_moved_paths.py). This PR also removes installed_gym_commit from the fixture's nemo_gym.orchestration.jobs entry, so the test passes. With the base branch's fixture restored, the test fails on this name.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8556d10. Entry under nemo_gym.orchestration.jobs, __getattr__ in jobs.py, name back in the fixture. You were right about my "nothing was released" line, it's corrected in the description.

Comment thread pyproject.toml Outdated
"nemo_gym.models",
# server_runtime/ (the supervisor on top, then what it starts servers with)
"nemo_gym.server_runtime.supervisor",
"nemo_gym.server_runtime.server_venv : nemo_gym.server_runtime.h2_ping_sidecar",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cli/_locked_env.py and cli/_prepare_worker.py are part of the code that starts servers, but they stay in the orchestration layer on line 889, seven layers above server_venv here. server_venv still runs _locked_env.py as a script that it finds by a file path into cli/ (server_venv.py), and import-linter cannot see a dependency on a file path. The contract therefore passes while every server virtual environment setup depends on a module in the layer this PR moves server startup out of.

environment/benchmark_preparation.py also imports both modules (line 94, line 136), so environment still depends on the orchestration layer as well. tests/unit_tests/test_orchestration_boundary.py misses both dependencies because it only matches nemo_gym.orchestration names.

Neither module imports anything from nemo_gym, so both can move without other changes. Please move them next to server_venv, have server_venv find _locked_env.py from its own package (Path(__file__).with_name(...)), and remove them from the orchestration layer on line 889. Because benchmarks/ruler/prepare_utils.py also imports nemo_gym.cli._locked_env, the old path needs a MOVED_MODULES entry.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in cf8c0a8. Both moved into server_runtime/supervisor/. server_venv finds _locked_env.py with with_name, they're out of the orchestration layer, the old cli paths have MOVED_MODULES entries, and ruler uses sync_environment from the new public API. benchmark_preparation imports them from there too.

Comment thread nemo_gym/server_runtime/__init__.py Outdated
# See the License for the specific language governing permissions and
# limitations under the License.
"""What runs inside every Gym server: the resources and environment server bases, request handling, sessions, and partial-rollout checkpoints."""
"""What runs inside every Gym server: the resources and environment server bases, request handling, sessions, and partial-rollout checkpoints. Also the supervisor that starts the servers of a run and the venvs they run in."""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The server supervisor, the server virtual environment setup and the HTTP/2 ping sidecar run only in the process that launches servers, never inside a server, yet this PR puts them in server_runtime. That changes what the package is: this docstring now has to add "Also the supervisor that starts the servers of a run and the venvs they run in", and _PUBLIC_API lists get_venv_path, run_command and setup_env_command next to the server base classes. A server author who reads nemo_gym.server_runtime then finds helpers for starting servers that no server uses.

The layer order in this PR already describes a separate package. The server supervisor imports only server_runtime, client, telemetry, core and config, and the two new layers sit directly above the rest of server_runtime.

Please make that a top-level nemo_gym/supervisor/ package directly above server_runtime, holding server_supervisor, server_venv, h2_ping_sidecar, tools/sidecar, _locked_env and _prepare_worker, and export get_venv_path, run_command and setup_env_command from it instead. Keeping the module name server_supervisor there avoids a clash with the agent sandbox's process supervisor, which the glossary already calls "the supervisor" (key-terminology.mdx). None of these paths has shipped yet, so this is the cheapest point to choose the final location, because after 0.8.0 each further move needs another _moved_paths.py entry.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went with your revised take: server_runtime/supervisor/ subpackage, not top-level (cf8c0a8). The server_runtime docstring is back as it was and the three names are out of its public API. supervisor has its own, and the layering puts it above the rest of server_runtime.

Comment thread nemo_gym/eval/recovery/markers.py Outdated
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The strings the auto-resume chain scripts and the commands they run use to leave a result for the next segment.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#5596 also creates this file and eval/recovery/__init__.py, with different content, and the two docstrings disagree on the dependency direction. This one says "the chain imports them from here", while the one in #5596 says "the planner never imports the chain" (markers.py in #5596).

Whichever PR lands second has to merge two modules with the same name and different contracts. #5596 also moves executors/slurm.py, which this commit edits, so the conflict reaches beyond these two files.

Please move this commit into #5596, which already owns eval/recovery and the nemo_gym.eval.recovery layer it adds to the import-linter contract, and until then keep the cli/utils.py → resume_script entry in KNOWN_VIOLATIONS.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted here (93cca28), it goes with #5596. The cli/utils.py → resume_script entry is back in KNOWN_VIOLATIONS until then.

Comment thread nemo_gym/_moved_paths.py Outdated
**_names("nemo_gym.orchestration.jobs", "0.8.0", "installed_gym_commit"),
**_names("nemo_gym.utils.gym_commit", "0.8.0", "installed_gym_commit"),
},
"nemo_gym.server_runtime.h2_ping_sidecar.config": {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This entry is keyed under nemo_gym.server_runtime.h2_ping_sidecar.config, a module path that this PR creates, so the deprecation message names a path that no caller has ever used. A caller who imports H2_PING_SIDECAR_KEY_NAME from the released nemo_gym.h2_ping_sidecar.config gets three warnings, and the last one says that nemo_gym.server_runtime.h2_ping_sidecar.config.H2_PING_SIDECAR_KEY_NAME moved. scripts/migrate_imports.py follows the same entry, so it rewrites the import to the server_runtime module, which still warns, instead of to nemo_gym.config.global_config.

moved_names_getattr keeps entries under a module's old path and maps the new module back to it through MOVED_MODULES (_moved_paths.py). Please key the entry under the old path, so the same name is served with a message that names what the caller wrote:

Suggested change
"nemo_gym.server_runtime.h2_ping_sidecar.config": {
"nemo_gym.h2_ping_sidecar.config": {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in cc3848c. Keyed under nemo_gym.h2_ping_sidecar.config, so one warning pointing at global_config.

Comment thread nemo_gym/cli/eval.py Outdated
target: str,
*,
json_output: bool = False,
job_artifact_dirs: Callable[[str], dict[str, Path] | None] | None = None,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the None default, a caller that leaves this argument out gets "No batch_status.json or Gym job record found for " for a valid Gym job ID (line 1996), even though no job record was looked up. cli/main.py is the only caller and always passes it, so the default gains nothing.

Please make it a required keyword-only argument, so that a new caller cannot silently lose the Gym job ID lookup.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in e894de4. Required keyword-only now.

Comment thread fern/docs.yml Outdated
@@ -554,17 +554,17 @@ redirects:
destination: "/nemo/gym/:version/nemo-gym/nemo_gym/agents/testing/agent_session_conformance"
# Library reference pages of modules moved into nemo_gym/orchestration (#5166).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment still says the pages moved into nemo_gym/orchestration, but the destinations below now point at server_runtime. The library reference built from main also published pages under /nemo_gym/orchestration/server_supervisor, /orchestration/server_venv and /orchestration/h2_ping_sidecar, and this PR adds no redirects from them, so links to those pages stop resolving.

Please update the comment, and add the plain and :version redirects from those three orchestration paths to their new pages.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in d91f835. Comment updated and the plain, :version and :path* redirects added. cf8c0a8 re-pointed them at the new supervisor/ pages.

@ananthsub

Copy link
Copy Markdown
Contributor

Revising one request from my review: the server supervisor does not need its own top-level package. The supervisor and the code that runs inside a server share one startup protocol (starting servers, health checks, the registry server, the runtime directory and Ray setup), and the registry server in server_runtime/ is already hosted only by the supervisor. Keeping them both in server_runtime/, as this PR does, matches that.

What I would still change is the boundary inside the package:

  • Put the server supervisor, the server virtual environment setup, the HTTP/2 ping sidecar, cli/_locked_env.py and cli/_prepare_worker.py in a nemo_gym/server_runtime/supervisor/ subpackage instead of beside the server base classes. server_venv then runs _locked_env.py from its own package instead of by a file path into cli/.
  • Add an import-linter contract over nemo_gym.server_runtime that puts supervisor above the other modules, so the supervisor may import the registry server and Ray support, and nothing that runs inside a server may import the supervisor.
  • Keep get_venv_path, run_command and setup_env_command out of the nemo_gym.server_runtime public API and its docstring, and give nemo_gym.server_runtime.supervisor its own public API.

Whether registry_server.py also moves into the subpackage is your call: only the supervisor hosts it, but server_status.py uses it too.

The rest of the review is unchanged, including the installed_gym_commit compatibility break, the deprecation key for the sidecar, the docs redirects and the split.

…rs in the new chain-guard test

Signed-off-by: Tomasz Grzegorzek <[email protected]>
…stration.jobs

It shipped in v0.7.0 under that path, so the old import now resolves to nemo_gym.utils.gym_commit
with a deprecation warning, and the import-surface fixture lists the name again.

Signed-off-by: Tomasz Grzegorzek <[email protected]>
… path

A caller of the released nemo_gym.h2_ping_sidecar.config now gets one warning that names
nemo_gym.config.global_config, and scripts/migrate_imports.py rewrites to it.

Signed-off-by: Tomasz Grzegorzek <[email protected]>
cli/main.py is the only caller; a default would let a new caller silently lose the Gym job ID lookup.

Signed-off-by: Tomasz Grzegorzek <[email protected]>
The server supervisor, server venv and sidecar pages published from main under
nemo_gym/orchestration now redirect to their server_runtime pages (plain and :version), and the
section comment names server_runtime.

Signed-off-by: Tomasz Grzegorzek <[email protected]>
…/recovery/markers

This belongs in the recovery relocation (#5596), which creates eval/recovery and owns its
contract. The cli/utils.py -> resume_script import returns to KNOWN_VIOLATIONS until then.
When this branch is merged into #5596, those two commits must be re-applied there.

Signed-off-by: Tomasz Grzegorzek <[email protected]>
…me/supervisor/

The server supervisor, server venv, HTTP/2 ping sidecar (with its Go sources) and the two scripts the
venv runs (_locked_env, _prepare_worker, moved from cli/) become one subpackage, so server_venv finds
_locked_env.py beside itself and nothing runs it by a path into cli/.

- The subpackage has its own public API (get_venv_path, run_command, setup_env_command,
  sync_environment); nemo_gym.server_runtime exports none of them and its docstring is back to what
  runs inside a server.
- The layering contract puts server_runtime.supervisor above the rest of server_runtime, so nothing
  that runs inside a server can import it, and drops _locked_env/_prepare_worker from the
  orchestration layer.
- Old nemo_gym.cli._locked_env and _prepare_worker paths get MOVED_MODULES entries; the docs
  redirects, the tests (now under tests/unit_tests/server_runtime/supervisor/) and the CI durations
  keys follow.

Signed-off-by: Tomasz Grzegorzek <[email protected]>
…isor.py

The supervisor module is server_runtime/supervisor/server_supervisor.py; the test, which the
telemetry extra gates, still expected supervisor.py.

Signed-off-by: Tomasz Grzegorzek <[email protected]>
Comment thread fern/docs.yml
- source: "/nemo/gym/:version/nemo-gym/nemo_gym/testing/agent_session_conformance"
destination: "/nemo/gym/:version/nemo-gym/nemo_gym/agents/testing/agent_session_conformance"
# Library reference pages of modules moved into nemo_gym/orchestration (#5166).
# Library reference pages of modules moved into nemo_gym/server_runtime (#5166).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Library reference pages of modules moved into nemo_gym/server_runtime (#5166).
# Library reference pages of modules moved into nemo_gym/server_runtime (#5882).

@prokotg
prokotg dismissed ananthsub’s stale review November 10, 2026 13:54

All threads were addressed. Main moves too quick to keep this fix. Happy to do any required follow-ups

@prokotg
prokotg added this pull request to the merge queue Nov 10, 2026
@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/42832788487

Merged via the queue into main with commit 3783d71 Nov 10, 2026
67 of 70 checks passed
@prokotg
prokotg deleted the tgrzegorzek/orchestration-boundary-moves branch November 10, 2026 14:37

This branch was previously deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants