Skip to content

refactor(server_runtime): move the server runtime modules into nemo_gym/server_runtime - #5214

Merged
ananthsub merged 1 commit into
mainfrom
ananthsub/layout-server-runtime
Oct 30, 2026
Merged

ananthsub merged 1 commit into
mainfrom
ananthsub/layout-server-runtime

Conversation

@ananthsub

@ananthsub ananthsub commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Moves what runs inside every Gym server into a new nemo_gym/server_runtime/ package: the resources and environment server bases, the episode and turn types they exchange, request handling, and partial-rollout checkpoints. server_utils.py is split in the next PR, so this one moves whole modules only.

Where this PR sits

The stack lands bottom-up; each PR's base is the branch of the PR before it, so each diff shows only that PR's change.

flowchart LR
  compat["#5167<br/>Old import paths<br/>keep working"]
  linter["#5168<br/>import-linter<br/>layer contract"]
  prep["#5169<br/>Remove path and<br/>name couplings"]
  config["#5189<br/>Move config/"]
  utils["#5195<br/>Move utils/"]
  core["#5203<br/>Move core/"]
  client["#5206<br/>Move client/,<br/>start telemetry/"]
  trajectory["#5209<br/>Move trajectory/"]
  verification["#5210<br/>Move verification/"]
  metrics["#5211<br/>Move metrics/"]
  artifacts["#5212<br/>Move artifacts/"]
  srmods["#5214<br/>Move server_runtime/<br/>modules"]
  su["#5215<br/>Split server_utils"]
  model["#5224<br/>Move models/<br/>modules"]
  modelbase["#5225<br/>Split model<br/>call capture"]
  agents["#5228<br/>Move agents/"]
  data["#5229<br/>Move data/"]
  harbor["#5230<br/>Split the<br/>Harbor task CLI"]
  rollouts["#5231<br/>Move rollouts/"]
  rsplit["#5232<br/>Split the<br/>rollout collector"]
  testing["#5233<br/>Dissolve testing/"]
  orch["#5234<br/>Move orchestration/<br/>modules"]
  sup["#5235<br/>Split the<br/>server supervisor"]
  eval["#5244<br/>Move eval/"]
  env["#5298<br/>Move environment/<br/>registries"]
  cli["#5300<br/>Retire the<br/>cli_setup_command shim"]
  docs["#5385<br/>Describe the<br/>package layout"]
  owners["next<br/>CODEOWNERS:<br/>per-package groups"]
  remove["0.10.0<br/>Remove the<br/>old paths"]
  compat --> linter
  linter --> prep
  prep --> config
  config --> utils
  utils --> core
  core --> client
  client --> trajectory
  trajectory --> verification
  verification --> metrics
  metrics --> artifacts
  artifacts --> srmods
  srmods --> su
  su --> model
  model --> modelbase
  modelbase --> agents
  agents --> data
  data --> harbor
  harbor --> rollouts
  rollouts --> rsplit
  rsplit --> testing
  testing --> orch
  orch --> sup
  sup --> eval
  eval --> env
  env --> cli
  cli --> docs
  docs --> owners
  owners --> remove
  classDef this fill:#fde68a,stroke:#b45309,stroke-width:2px,color:#1f2937
  classDef later fill:#f3f4f6,stroke:#9ca3af,color:#4b5563,stroke-dasharray: 4 3
  class srmods this
  class owners,remove later
Loading

Where the package sits

flowchart TD
  cli["cli/"]
  eval["eval/"]
  environment["environment/"]
  testing["testing/"]
  orchestration["orchestration/"]
  rollouts["rollouts/"]
  data["data/"]
  agents["agents/"]
  model["models/"]
  server_runtime["server_runtime/"]
  artifacts["artifacts/"]
  metrics["metrics/"]
  verification["verification/"]
  trajectory["trajectory/"]
  sandbox["sandbox/"]
  client["client/"]
  telemetry["telemetry/"]
  core["core/"]
  utils["utils/"]
  config["config/"]
  cli --> eval
  cli --> environment
  cli --> orchestration
  eval --> rollouts
  environment --> data
  testing --> rollouts
  orchestration --> data
  rollouts --> data
  rollouts --> agents
  rollouts --> model
  data --> server_runtime
  data --> artifacts
  agents --> server_runtime
  model --> server_runtime
  server_runtime --> metrics
  server_runtime --> verification
  server_runtime --> trajectory
  artifacts --> trajectory
  artifacts --> utils
  metrics --> utils
  verification --> sandbox
  trajectory --> core
  sandbox --> client
  client --> telemetry
  client --> utils
  telemetry --> core
  core --> config
  utils --> config
  classDef this fill:#fde68a,stroke:#b45309,stroke-width:2px,color:#1f2937
  classDef done fill:#d1fae5,stroke:#047857,color:#1f2937
  classDef todo fill:#f3f4f6,stroke:#9ca3af,color:#4b5563
  class server_runtime this
  class config,utils,core,telemetry,client,trajectory,verification,metrics,artifacts done
  class cli,eval,environment,testing,orchestration,rollouts,data,agents,model,sandbox todo
Loading

An arrow means "imports"; each package imports only packages below it. Yellow: created by this PR. Green: created by an earlier PR in the stack. Grey: still to come.

What moves

Whole modules, unchanged:

Old path New path
nemo_gym/base_resources_server.py nemo_gym/server_runtime/base_resources_server.py
nemo_gym/base_environment_server.py nemo_gym/server_runtime/base_environment_server.py
nemo_gym/episode_types.py nemo_gym/server_runtime/episode_types.py (moved on to nemo_gym/core/episode_types.py by #5536)
nemo_gym/single_agent_turn_types.py nemo_gym/server_runtime/single_agent_turn_types.py
nemo_gym/tool_access.py nemo_gym/server_runtime/tool_access.py
nemo_gym/runtime_dir.py nemo_gym/server_runtime/runtime_dir.py
nemo_gym/server_status.py nemo_gym/server_runtime/server_status.py
nemo_gym/mcp_auto_exposure.py nemo_gym/server_runtime/mcp_auto_exposure.py
nemo_gym/observability/verifiers.py nemo_gym/server_runtime/verifier_observability.py
nemo_gym/session_routing.py nemo_gym/server_runtime/request_handling/session_routing.py
nemo_gym/rollout_correlation.py nemo_gym/server_runtime/request_handling/rollout_context.py
nemo_gym/_checkpoint/ nemo_gym/server_runtime/_checkpoint/
nemo_gym/_checkpoint/model.py nemo_gym/models/_checkpoint.py
nemo_gym/_checkpoint/model_workers.py nemo_gym/models/_checkpoint_workers.py

How to review

One commit. Its changes:

  1. Renames, with no content changes.
  2. Everything else:
    • The moves are recorded in MOVED_MODULES in nemo_gym/_moved_paths.py.
    • In-repo references are rewritten by scripts/migrate_imports.py.
    • The contract's server_runtime layer becomes the nemo_gym.server_runtime package.
    • fern/docs.yml redirects the old library reference pages to the new ones.
    • The checkpoint package's two model-server modules go straight to nemo_gym/models/, their place in the proposal, so they move only once. Longer MOVED_MODULES entries send nemo_gym._checkpoint.model and nemo_gym._checkpoint.model_workers there, and the rest of nemo_gym._checkpoint to server_runtime/_checkpoint/. The server_utils.checkpoint_settings entry from refactor(client): move the HTTP and server clients into nemo_gym/client #5206 now points at server_runtime/_checkpoint/settings.py directly, so it warns once rather than twice.
    • rollout_correlation.py now holds only the rollout context middleware, after refactor(core): move shared definitions into nemo_gym/core #5203 moved its episode tracking to core/, so it moves whole as request_handling/rollout_context.py. Its old names keep resolving through the feat(compat): keep old import paths working across the package reorganization #5167 fix for modules that move after serving moved names.
    • By hand: the lazy exports in nemo_gym/__init__.py point at server_runtime.base_resources_server, and the contract's server runtime layer is nemo_gym.server_runtime next to nemo_gym.server_utils until the split.
  3. Tests: the server runtime and checkpoint tests move into tests/unit_tests/server_runtime/, and the two checkpoint model-server test files into tests/unit_tests/models/. Tests that import helpers from moved test files follow them.

Public API

Every layout package that exists after this PR has a lazy public API in its __init__.py: the names non-test code outside nemo_gym/ imports from it (servers, benchmarks, scripts, and code samples in docs and skills), each served from the submodule that defines it on first use. Code outside nemo_gym/ and its tests (servers and their tests, benchmarks, scripts, and docs) imports those names from nemo_gym.<package>, so later moves inside a package leave it alone. Code inside nemo_gym/, and the library's tests under tests/, import from the module that defines each name, so the import-linter contract sees every dependency and a test reads what it patches. A patch target names the module the code under test looks the name up in. AGENTS.md states the rule.

Validation

  • pytest -n 16 tests/unit_tests, also with -W error for the moved paths. The only failures are environment-specific and unrelated to the move: this machine's hostname resolves to 127.0.1.1, which the sandbox host check refuses (the Harbor run summary tests and the benchmark listing test), and two Docker PTY tests.
  • lint-imports.
  • pre-commit run on the changed files.
  • Server and agent tests run in CI.

Rollout evidence: N/A. The modules move unchanged.

Compatibility

  • Old paths work until 0.10.0, with one warning each, and give the same module objects.
  • Logger names follow the module path, so these modules now log under nemo_gym.server_runtime.*. A logging config set on nemo_gym still covers them.
  • Open branches: run python scripts/migrate_imports.py <paths>.

Issue

Part of #5166.

@ananthsub
ananthsub added this pull request to stack #5170 October 28, 2026 19:09
@copy-pr-bot

copy-pr-bot Bot commented Oct 28, 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.

@svcnvidia-nemo-ci svcnvidia-nemo-ci added area:core Shared APIs, servers, telemetry, health, and registries feature New capabilities, enhancements, or enablement work labels Oct 28, 2026
@ananthsub ananthsub changed the title ananthsub/layout server runtime refactor(server_runtime): move the server runtime modules into nemo_gym/server_runtime Oct 28, 2026
@ananthsub
ananthsub requested a review from yaoyu-33 October 28, 2026 19:09
@ananthsub ananthsub added the needs-review PR is ready for code review and waiting on a reviewer label Oct 28, 2026
@ananthsub
ananthsub marked this pull request as ready for review October 28, 2026 19:10
@ananthsub
ananthsub requested review from a team as code owners October 28, 2026 19:10
@ananthsub
ananthsub requested a review from a team as a code owner October 28, 2026 19:10
@nemo-automation-bot
nemo-automation-bot Bot requested review from a team October 28, 2026 19:11
@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

@ananthsub
ananthsub force-pushed the ananthsub/layout-server-runtime branch from b94c96b to 941ff93 Compare October 28, 2026 21:56
@ananthsub
ananthsub force-pushed the ananthsub/layout-server-runtime branch from 941ff93 to a64b596 Compare October 28, 2026 22:26
@ananthsub
ananthsub force-pushed the ananthsub/layout-server-runtime branch from a64b596 to ae5e530 Compare October 28, 2026 23:10
@ananthsub
ananthsub force-pushed the ananthsub/layout-server-runtime branch from ae5e530 to ef86e9b Compare October 29, 2026 00:55
…ym/server_runtime

The resources and environment server bases, episode and turn types, tool
access, the runtime directory, server status, MCP auto-exposure and
verifier observability move into nemo_gym/server_runtime; session
routing and the rollout context middleware (rollout_correlation.py) into
server_runtime/request_handling; and the checkpoint package into
server_runtime/_checkpoint, except its two model-server modules, which
go straight to nemo_gym/models so they move only once.

Record the moves in MOVED_MODULES (the checkpoint package as a whole,
with longer entries for its two model-server modules), rewrite in-repo
references with scripts/migrate_imports.py, point the lazy exports at
server_runtime.base_resources_server, make the contract's server runtime
layer the nemo_gym.server_runtime package next to server_utils until
server_utils is split, and redirect the old library reference pages in
fern/docs.yml.

The checkpoint model-server tests go to tests/unit_tests/models with
their modules. Tests that import helpers from the moved files follow
them, and the checkpoint declaration test finds the repository root one
level further up.

Regenerate the public API of each layout package that exists here from
what non-test code outside nemo_gym imports, and point code outside
nemo_gym, tests included, at nemo_gym.<package>.

Signed-off-by: Ananth Subramaniam <[email protected]>

This branch was previously deployed

1 inactive deployment
public — 07be4668 Deployed Oct 30, 2026 by copy-pr-bot[bot] via release / finalize / notify #8795
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 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.

2 participants