Skip to content

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

Open
ananthsub wants to merge 1 commit into
mainfrom
ananthsub/share-dispatch-routing
Open

ananthsub wants to merge 1 commit into
mainfrom
ananthsub/share-dispatch-routing

Conversation

@ananthsub

@ananthsub ananthsub commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Stack 1 of 5. This PR → #6418 → #6447 → #6448 → #6449. It sits directly on main and depends on no other part of the stack, so it can merge first. It replaces #6446, which GitHub marked merged into a stack branch while the stack was reordered.

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.
  • environment_server_for_row refuses a flat row under environment_routing_mode: legacy without environment_server_name, and under an unknown mode such as Legacy. Rollout collection's config validation already refuses both configs before any row routes. Collation in fix(data): check collated rows against the server that receives them #6449 passes raw config values, so without this guard it would check such rows as agent mode does, or report a taskset-routing error.
  • _moved_paths.py records the old private names _environment_servers_by_agent and _environment_server_for_agent, and the two exception classes rollout_collection no longer imports. Old imports through rollout_collection resolve to the same objects with a DeprecationWarning, and scripts/migrate_imports.py can rewrite them.
  • 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.

Rollout collection behaves as before.

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. New tests check that a task row routes by its taskset in every mode, that a flat row follows the mode, and that a flat row under legacy without a server name or under an unknown mode is refused. The moved-paths test checks that every old name still resolves.

Rollout evidence

N/A. A refactor; rollout collection's behavior does not change, and the new refusals cover configs it already rejects.

Compatibility

Old imports keep working through _moved_paths.py, with a DeprecationWarning and removal in 0.10.0. Open PRs that call _environment_servers_by_agent inside rollout_collection.py need the new name when they rebase.

@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 18 changed files and traced the affected routing through preprocessing, dispatch and aggregation. The extracted helpers keep the existing routing behavior. I found no regression in the public exports or legacy import compatibility.

Static review only. I did not execute tests or verify the validation reported in the PR.

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.

@yaoyu-33
yaoyu-33 requested a review from marcromeyn November 19, 2026 21:07
athitten
athitten previously approved these changes Nov 19, 2026

@athitten athitten 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.

Approving. I checked that behavior is unchanged: the two moved functions are identical to the originals, and the old and new routing code return the same server or raise the same error in 220 config and row cases. The PR's tests pass at this commit and merged with current main, as do the gdpval, long_transduction and harness_conformance tests it touches. Each routed row costs about 50 ns more. The five failing conformance checks also fail on main or on other PRs today. The comments below are non-blocking.

optional Heads-up on open PRs that use the old names. #6040 merges cleanly but then calls _environment_servers_by_agent in test_environment_scaffold.py, which this PR no longer imports there (ruff F821). #6037 and #5538 add the same call to files whose imports this PR rewrites. #5983, #5984 and #5010 import the private names from rollout_collection, and #5386 and #3819 call them inside it. Those keep working through the aliases, but could move to the new public names.

Comment thread nemo_gym/_moved_paths.py Resolved
Comment thread nemo_gym/config/global_config.py Resolved
Comment thread nemo_gym/config/global_config.py Resolved
…_config

environment_server_for_row, environment_servers_by_agent and
environment_server_for_agent decide which environment server receives
a row. They lived in rollout_collection, where data tooling cannot
import them, because nemo_gym.data sits below nemo_gym.rollouts. They
now live in nemo_gym.config.global_config, so collation can route rows
with the same rules. environment_server_for_row takes the row's
taskset instead of the row, because nemo_gym.config cannot import
nemo_gym.core.

Behavior does not change. The old private names stay importable from
rollout_collection, and _moved_paths records the two exception classes
it no longer imports.

Signed-off-by: Ananth Subramaniam <[email protected]>
@ananthsub
ananthsub force-pushed the ananthsub/share-dispatch-routing branch from 78b0d96 to 661151e Compare November 19, 2026 22:34
@nemo-automation-bot
nemo-automation-bot Bot requested a review from a team November 19, 2026 22:35
@ananthsub
ananthsub requested a review from athitten November 19, 2026 22:36
@github-actions

Copy link
Copy Markdown
Contributor

@ananthsub
ananthsub requested review from marta-sd and removed request for a team and marcromeyn November 19, 2026 23:48

@marta-sd marta-sd 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.

approving with one nit comment

return routes[taskset]
except KeyError as error:
raise ValueError(f"No environment server route is configured for taskset {taskset!r}") from error
if routing_mode == "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.

nit, non-blocking: it would be nice to have routing modes extracted as contants / enums

@github-actions github-actions Bot removed the sla:review-overdue Review response is over the one-business-day SLA label Nov 23, 2026

This branch has not been deployed

No deployments
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.

4 participants