Repository navigation
refactor(rollouts): move rollout collection and health into nemo_gym/rollouts - #5231
Conversation
|
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
left a comment
There was a problem hiding this comment.
HOLD — one BLOCKER in executable-module compatibility, one RISK in the telemetry test migration, and one documentation NOTE.
Reviewed the changed hunks and affected import aliases, consumers, test fixtures, and conformance paths. Static source review only; tests, CLI commands, and documentation generation were not executed.
Note: formal approval is not available for this request, so this review is posted as a comment only.
Inline comments (escaped v1):
-
nemo_gym/_moved_paths.pyline 77: BLOCKER — Preserve execution through the old package name.python -m nemo_gym.harness_capabilities --helpno longer reaches the CLI. This alias routes executable-module loading ofnemo_gym.harness_capabilities.__main__throughMovedModuleFinder, which implements ordinary imports but has noget_codemethod. Executable-module loading therefore fails instead of printing help. The base entry point was a physical source module; the new canonical command still is. This affects callers retaining the advertised old CLI path, not ordinary rollout collection.Could you support code loading without importing/executing the canonical
__main__prematurely? A small suggested implementation is to addCodeTypeto the existingtypesimport and add this method toMovedModuleFinder:def get_code(self, fullname: str) -> CodeType | None: resolved = _resolve(fullname, self._moves) if resolved is None: return None _, new_name, _ = resolved spec = importlib.util.find_spec(new_name) get_code = getattr(spec.loader, "get_code", None) if spec else None return None if get_code is None else get_code(new_name)
This delegates to the canonical source loader while leaving
create_module/exec_moduleunchanged: old/new ordinary imports must remain identical objects, and relative CLI imports must still resolve through those aliases. Please verify this source-reasoned suggestion before adopting it.Proposed acceptance checks, not executed: subprocess-run both package names with
--help; both must exit 0 and listinspect/matrix. Run both against the same valid synthetic bundle with separate output directories: both must return 0 withverdict=fulfilled; removing a required request must make both return 1. Retain the existing module-identity, single-execution, and patch-through-alias assertions in the compatibility tests. -
tests/unit_tests/telemetry/test_call_sites.pyline 766: RISK — Update the remaining import of the relocated collector tests.With the telemetry extra installed,
test_materialized_dispatch_takes_its_id_from_the_row_not_the_episode_bodynow raisesImportErrorhere before exercising dispatch. This PR moves the imported module into the rollout test package, but leaves this import unchanged. The old module is absent and the package initializer supplies no alias. The core CI script installs telemetry specifically so these tests run.Could you replace this line with:
from tests.unit_tests.rollouts import test_rollout_collection as collection_testsThe relocated helpers and routing fixtures retain everything this test uses; no production or fixture changes are needed. Preserve the distinction between collector-row identity and the posted episode body rather than removing or skipping this regression case.
Proposed acceptance checks, not executed: with telemetry installed, run this case and then the complete call-site test file. This case must reach the assertions that the dispatch span has rollout ID
0-0and the posted body containsepisode_id. The neighboring standalone and embedded flat-row tests must retain their separate-trace versus caller-trace assertions. -
nemo_gym/rollouts/harness_capabilities/README.mdline 3: NOTE — Update the relocated README’s guide link.Clicking “Harness Conformance” now resolves the two parent traversals to
nemo_gym, producing a nonexistentnemo_gym/fern/...destination. Before this move, they reached the repository root. Could you preserve access to the existing guide with this replacement?The checker guide is maintained in [Harness Conformance](../../../fern/versions/latest/pages/observability/harness-conformance.mdx).Static acceptance check: resolving the replacement relative to the README directory must yield that existing root-level guide. Preserve the inspector command in lines 5–7 unchanged; only the document-relative link needs correction. No checks were executed.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
c42f580 to
8a787c5
Compare
0475d97 to
a44c92c
Compare
a44c92c to
bf51ad8
Compare
bf51ad8 to
0f2bf03
Compare
yaoyu-33
left a comment
There was a problem hiding this comment.
Thanks for this, Ananth. The move itself checks out: the moved files are identical apart from imports, the model_calls split keeps every definition unchanged, each old path still gives the same module object, lint-imports stays KEPT with one fewer exception, and the rollout outputs (JSONL fields and file names) don't change. One test import was missed, and it turns Unit tests / Test red; it's inline below.
Verdict: SHIP WITH CARE. 1 RISK and 1 NOTE inline, plus the items below.
The earlier automated review (svcnvidia-nemo-ci, at c42f580)
- Its BLOCKER on
python -m nemo_gym.harness_capabilitiesno longer applies.MovedModuleFinder.get_codefrom #5167 serves the old path, and--helpexits 0 with the same output on both paths. - Its other two points are still open at this head and are carried inline: the
test_call_sites.py:766import and the README link.
Belongs in #5230
nemo_gym/data/__init__.py:90(and:58) addsORACLE_AGENTback tonemo_gym.data's public API. That fixes #5230, which drops the entry whileenvironment_servers/harbor/app.py:115andsession.py:30still import it. As a result, the Harbor environment server fails to import at #5230's head. Could the two lines move into #5230, so main isn't broken between the two merges? If not, could the PR body mention them?
Patch targets that change with the model_calls split
#5166 asks each split PR to list these. No patch in the repo is affected, but downstream tests that patch the old module would silently stop taking effect:
| Names | Patch them on |
|---|---|
extract_token_stats, ModelCallRecord, _cache_signal, _tool_calls_and_reasoning, _as_arguments, _prompt_size, _token_count, _usage_detail_token |
nemo_gym.trajectory.model_call_record (a patch on nemo_gym.observability.model_calls or nemo_gym.rollouts.model_calls no longer reaches build_model_call_record) |
build_model_call_record, aggregate_model_call_records |
still nemo_gym.rollouts.model_calls (its readers call their own imported bindings; a patch on nemo_gym.trajectory.model_call_record doesn't reach them) |
Could this table go in the body's Compatibility section?
Smaller points (your call)
- The move changes the CLI-shim warning text.
from nemo_gym.rollout_collection import collect_rolloutsnow says "nemo_gym.rollouts.rollout_collection.collect_rolloutshas moved", which names a path that never shipped, becausemoved_attr_getter(__name__, ...)now gets the new module name. It's the same pattern raised on #5211 (metrics/reward_profile.py), and it recurs atdata/prompt.py:189(#5229). It's probably best fixed once for the whole stack: eithermoved_attr_getterresolves the old name the waymoved_names_getattrdoes since #5212, or the two names move intoMOVED_NAMES["nemo_gym.rollout_collection"]. - Is it intended that
nemo_gym.rolloutsexports the harness checker'smain(plusNAMESandjson_rows) at package level?from nemo_gym.rollouts import mainreads like the collector's entry point, and it rules out any laterrolloutsmain.
CI at 21575f5
Unit tests / Test: 1 failed, 13526 passed. The one failure is the inlinetest_call_sites.py:766import, andNemo_CICD_Testfails only because of it.- Harness conformance (non-blocking): the kilocode
model_errorprobe fails exactly as it does on #5230, so it isn't from this PR. - All eight server shards pass. Lint, secrets-detector, copyright and docs checks pass too.
- After the fix, could the Validation section be updated? It currently says the only failures are environment-specific.
What we checked
- Renames are byte-identical or identical apart from imports. All 295 rewritten imports resolve to the same object. The split's 23 definitions are body-identical. 1286 test IDs before and after.
- Old paths give the same modules, with a warning. In-repo patch targets still reach their lookups.
fern/docs.ymlredirects are complete in both forms, and the frozen v0.6.0/v0.7.0 links are already pinned. CI path filters and CODEOWNERS are updated.lint-importsis KEPT (9 ignored).- The wheel ships all 21
nemo_gym/rollouts/files. Base-era pickles load at head. - Touched server, model and agent tests pass locally.
Not verified: GPU, real sandboxes, and agents whose own dependencies (tau2, nooa, hermes, miniswe, terminus_2) aren't in the core venv; their new imports were checked to resolve.
…rollouts The observability package becomes nemo_gym/rollouts itself, with model_calls.py; the rollout collector, batch status, rollout health and outcomes, omitted rollouts, the health package, and harness_capabilities move into it. Record the eight moves in MOVED_MODULES (observability, health and harness_capabilities as packages), rewrite in-repo references with scripts/migrate_imports.py, make the contract's rollouts layer the nemo_gym.rollouts package and its testing layer nemo_gym.testing alone, and redirect the old library reference pages in fern/docs.yml. The harness capability tests move with their package to tests/unit_tests/rollouts/harness_capabilities; the conformance CI workflow, its scripts and their docs name the new test path. Tests that find the repository root look 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]>
|
Replies to the summary, as of
|
What and why
Moves rollout collection and what judges saved rollouts into a new
nemo_gym/rollouts/package: the rollout collector, batch status, rollout health and outcomes, omitted rollouts, and reading saved model calls. Theobservabilitypackage becomesrolloutsitself. The model call record splits out ofobservability/model_calls.pyintotrajectory/model_call_record.pyinstead:ModelCallRecord, building one from a saved exchange, its token counts, and totals across calls. That half depends on nothing aboveconfig/, andtrajectory_record.pyalready refers toModelCallRecord. Reading, merging, and clearing saved model calls needs the capture store, so it stays inrollouts/model_calls.py.harness_capabilitiesmoves here too: it judges an agent harness from its saved rollouts, imports the rollout health code, and nothing in the library imports it. The collector's performance and trajectory-building code is split out in the next PR.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.
Where the package sits
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:
nemo_gym/observability/__init__.pynemo_gym/rollouts/__init__.pynemo_gym/observability/model_calls.pynemo_gym/rollouts/model_calls.pynemo_gym/observability/model_calls.py (the record half)nemo_gym/trajectory/model_call_record.pynemo_gym/rollout_collection.pynemo_gym/rollouts/rollout_collection.pynemo_gym/batch_status.pynemo_gym/rollouts/batch_status.pynemo_gym/rollout_health.pynemo_gym/rollouts/rollout_health.pynemo_gym/health/nemo_gym/rollouts/health/nemo_gym/rollout_outcomes.pynemo_gym/rollouts/rollout_outcomes.pynemo_gym/omitted_rollouts.pynemo_gym/rollouts/omitted_rollouts.pynemo_gym/harness_capabilities/nemo_gym/rollouts/harness_capabilities/nemo_gym/rollout_records.pynemo_gym/rollouts/rollout_records.pynemo_gym/rollout_recovery.pynemo_gym/rollouts/rollout_recovery.pynemo_gym/rollout_store.pynemo_gym/rollouts/rollout_store.pyrollout_records.py,rollout_recovery.pyandrollout_store.pycame in with #3302 (persist failures and resume evaluations) after this stack started.mainplaced them in the rollouts layer, so they move with the rest of it and getMOVED_MODULESentries like the others.How to review
One commit. Its changes:
MOVED_MODULESinnemo_gym/_moved_paths.py.scripts/migrate_imports.py.rolloutslayer becomes thenemo_gym.rolloutspackage.fern/docs.ymlredirects the old library reference pages to the new ones.observability,health, andharness_capabilitiesare recorded as packages, so their submodules resolve too;python -m nemo_gym.harness_capabilitieskeeps working.harness_capabilities; it is part ofnemo_gym.rolloutsnow. Thetestingpackage is dissolved in a later PR.trajectory_record.pynow importsModelCallRecordfrom its own package, so the contract exception for that import goes away. 9 remain.trajectory/model_call_record.py, andModelServerRef, whichobservability/model_calls.pyimported, haveMOVED_NAMESentries, so they still resolve atnemo_gym.observability.model_callsandnemo_gym.rollouts.model_callswith one warning.tests/unit_tests/telemetry/test_call_sites.pyimports the moved test module asfrom tests.unit_tests.rollouts import test_rollout_collection, a form the test-move rewrite missed, and the checker's README links the harness conformance guide one directory further up.__init__.pybecomes a lazy public API of its own (see Public API).__getattr__rollout_collection.pygained there looked moved names up under the module's own name, which changes when the module moves.tests/unit_tests/rollouts/; the model call record tests intotests/unit_tests/trajectory/; and the harness capability tests intotests/unit_tests/rollouts/harness_capabilities/. The conformance CI workflow, its scripts, and their docs name the new test path; tests that find the repository root look one level further up.Public API
Every layout package that exists after this PR has a lazy public API in its
__init__.py: the names code outsidenemo_gym/imports from it (servers and their tests, benchmarks, scripts, and code samples in docs and skills), plus every name it already exported, each served from the submodule that defines it on first use. Code outsidenemo_gym/and its tests (servers and their tests, benchmarks, scripts, and docs) imports those names fromnemo_gym.<package>, so later moves inside a package leave it alone. Code insidenemo_gym/, and the library's tests undertests/, 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.mdstates the rule.nemo_gym.rollouts.harness_capabilitieshas a public API of its own, asnemo_gym.data.tasks.harbordoes since #5229. The checker's names, such asmain,NAMESandjson_rows, would otherwise be exported fromnemo_gym.rollouts, wherefrom nemo_gym.rollouts import mainreads like the collector's entry point. The harness conformance scripts import them fromnemo_gym.rollouts.harness_capabilities, andnemo_gym.rolloutsexports only the rollout collection and health names.Validation
pytest -n 16 tests/unit_tests, also with-W errorfor the moved paths.telemetryextra, such astests/unit_tests/telemetry/test_call_sites.py, skip without it, so locally they run only in a venv with that extra; CI's Test job runs them. That is how the stale test import above reached CI at an earlier head.lint-imports.pre-commit runon the changed files.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.rollouts.*. A logging config set onnemo_gymstill covers them.Patch targets that change with the
model_callssplit. No patch in this repo is affected, but a downstream test that patches the old module may stop taking effect:extract_token_stats,ModelCallRecord,_cache_signal,_tool_calls_and_reasoning,_as_arguments,_prompt_size,_token_count,_usage_detail_tokennemo_gym.trajectory.model_call_record. A patch onnemo_gym.observability.model_callsornemo_gym.rollouts.model_callsno longer reachesbuild_model_call_record.build_model_call_record,aggregate_model_call_recordsnemo_gym.rollouts.model_calls. Its readers call their own imported bindings, so a patch onnemo_gym.trajectory.model_call_recorddoes not reach them.Open branches: run
python scripts/migrate_imports.py <paths>.Issue
Part of #5166.