Skip to content

refactor(rollouts): move environment server routing helpers to global_config - #6446

Merged
ananthsub merged 0 commit into
ananthsub/dataset-row-checkfrom
ananthsub/share-dispatch-routing
Nov 19, 2026
Merged

ananthsub merged 0 commit into
ananthsub/dataset-row-checkfrom
ananthsub/share-dispatch-routing

Conversation

@ananthsub

@ananthsub ananthsub commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Stack 2 of 5. #6418 → this PR → #6447 → #6448 → #6449. This PR does not depend on #6418, so it can be retargeted to main if it should merge first.

Before and after

Before: the rules that pick the environment server for a row live in nemo_gym/rollouts/rollout_collection.py. Data tooling sits below nemo_gym.rollouts in the import layers, so collation cannot use them and would have to copy them.

After: the rules live in nemo_gym/config/global_config.py, and rollout collection calls them from there. Collation can route rows with the same functions (#6449).

flowchart LR
    OLD["Before: rollout_collection.py holds the routing rules"] -->|"moved, behavior unchanged"| NEW["After: global_config.py holds environment_servers_by_agent, environment_server_for_agent, environment_server_for_row"]
    NEW --> RC["rollout collection"]
    NEW --> COL["collation, in a later PR"]
    classDef bad fill:#fde2e1,stroke:#c0392b,color:#000
    classDef good fill:#dff5e3,stroke:#1e8449,color:#000
    class OLD bad
    class NEW good
Loading

What changed and why

  • environment_servers_by_agent and environment_server_for_agent move to nemo_gym.config.global_config unchanged, as public functions.
  • environment_server_for_row holds the routing rule that _environment_server_for_config_row applied: a task row routes by its taskset's environment_server_routes entry, and a flat row follows environment_routing_mode. It takes the row's taskset instead of the row, because nemo_gym.config cannot import nemo_gym.core, which defines what a task row is. _environment_server_for_config_row now computes the taskset and calls it.
  • The old private names stay importable from rollout_collection as aliases. _moved_paths.py records the two exception classes rollout_collection no longer imports, so old imports through nemo_gym.rollout_collection still resolve.
  • Callers in benchmarks/gdpval, resources_servers/gdpval, resources_servers/long_transduction, responses_api_agents/hermes_agent, scripts/harness_conformance and the unit tests import from global_config.

Behavior does not change.

Issue

None filed. A preparatory refactor for #6449, so collation and rollout collection route rows with one implementation.

Validation

pytest -n 12 tests/unit_tests/config tests/unit_tests/tooling tests/unit_tests/environment tests/unit_tests/rollouts/test_rollout_collection.py tests/unit_tests/test_moved_paths.py tests/unit_tests/test_public_api_facades.py
pre-commit run --files <changed files>

The existing routing tests, now calling the moved functions, cover the behavior. The moved-paths test checks that every old name still resolves.

Rollout evidence

N/A. A refactor with no behavior change.

Compatibility

Old imports keep working through the aliases and _moved_paths.py.

@ananthsub ananthsub added the area:data Datasets, preparation, task formats, and materialization label Nov 19, 2026
@copy-pr-bot

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

I found no blocking correctness issues. The routing branches match the base behavior, and the old helper aliases and exception imports still resolve. One non-blocking API-maintenance NOTE is inline.

I reviewed all 17 changed files and traced the affected preprocessing, dispatch, aggregation, and import-compatibility paths. I did not execute tests in this read-only review.

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.

TASK_INDEX_KEY_NAME,
TASK_SOURCE_KEY_NAME,
)
from nemo_gym.config.global_config import environment_server_for_agent, environment_servers_by_agent

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.

NOTE · suggestion: export the externally used routing helpers through the config API

These helpers now have public names and external callers, but neither appears in the config package's public API. By source inspection, from nemo_gym.config import environment_server_for_agent, environment_servers_by_agent cannot resolve them, while this deep import works. This is an API-maintenance gap, not a runtime routing regression: external callers should use the package API without depending on the implementation module.

Could you add these entries to the config initializer?

         ModelCallSamplingConfig,
+        environment_server_for_agent,
+        environment_servers_by_agent,
         find_open_port,

And add the matching _PUBLIC_API entries:

     "TOKEN_CAPTURE_PATH_SEGMENT": "config_types",
+    "environment_server_for_agent": "global_config",
+    "environment_servers_by_agent": "global_config",
     "find_open_port": "global_config",

Then replace this import with from nemo_gym.config import environment_server_for_agent, environment_servers_by_agent, and make the same replacement in the changed NOOA recipe test, long-transduction test, Hermes recipe test, and conformance test. Both changes are needed because the existing external-import check rejects deep imports once a name is exported.

Keep library code and core tests importing the defining module. Keep the helper implementations, private rollout aliases, and exception shims unchanged.

Acceptance, not executed here: package imports should return the identical objects defined by global_config; the existing facade tests should retain their identity, lazy-loading, and matching type-checking declarations. The external-import check should find none of these five deep imports, and old private aliases should still resolve to the same functions through both rollout module paths. Verify the suggested patch before adopting it.

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 a1c0e0a: environment_server_for_agent and environment_servers_by_agent are exported from nemo_gym.config, and the five callers outside the library import them from there. Library code keeps importing global_config, and the rollout aliases and exception shims are unchanged.

@svcnvidia-nemo-ci svcnvidia-nemo-ci added the needs-review PR is ready for code review and waiting on a reviewer label Nov 19, 2026
@yaoyu-33
yaoyu-33 requested a review from marcromeyn November 19, 2026 07:07
@ananthsub
ananthsub force-pushed the ananthsub/dataset-row-check branch from 1435e14 to f9cf1bf Compare November 19, 2026 18:23
@ananthsub
ananthsub force-pushed the ananthsub/share-dispatch-routing branch from 4954c57 to a1c0e0a Compare November 19, 2026 18:23
@ananthsub ananthsub closed this Nov 19, 2026
@ananthsub
ananthsub force-pushed the ananthsub/share-dispatch-routing branch from a1c0e0a to 78b0d96 Compare November 19, 2026 19:17
@ananthsub
ananthsub merged commit 78b0d96 into ananthsub/dataset-row-check Nov 19, 2026
@ananthsub
ananthsub force-pushed the ananthsub/dataset-row-check branch from f9cf1bf to 1ef8502 Compare November 19, 2026 19:17
@ananthsub
ananthsub deleted the ananthsub/share-dispatch-routing branch November 19, 2026 19:17
@ananthsub
ananthsub restored the ananthsub/share-dispatch-routing branch November 19, 2026 19:18
@ananthsub

Copy link
Copy Markdown
Contributor Author

This PR was not merged into main. While the stack was being reordered so that this change could land first, its commit ended up below its base branch ananthsub/dataset-row-check, and GitHub marked it merged into that branch. A merged pull request cannot be reopened, so the same commit continues in #6499, which targets main directly. The earlier review threads here stay for reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:data Datasets, preparation, task formats, and materialization needs-review PR is ready for code review and waiting on a reviewer risk:high Autobot PR risk: high support User questions, support, or maintenance requests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants