Repository navigation
refactor(rollouts): split rollout performance and trajectory building out of the collector - #5232
Merged
Merged
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. |
ananthsub
marked this pull request as ready for review
October 28, 2026 22:36
35 of 41 tasks
ananthsub
force-pushed
the
ananthsub/layout-rollouts-split
branch
from
October 28, 2026 23:10
e786d38 to
08794c8
Compare
ananthsub
force-pushed
the
ananthsub/layout-rollouts-split
branch
from
October 29, 2026 00:55
08794c8 to
594c35a
Compare
ananthsub
force-pushed
the
ananthsub/layout-rollouts-split
branch
from
October 29, 2026 16:27
fb6b98f to
4fc4df5
Compare
ananthsub
force-pushed
the
ananthsub/layout-rollouts-split
branch
from
October 29, 2026 16:45
4fc4df5 to
dd4d099
Compare
ananthsub
force-pushed
the
ananthsub/layout-rollouts-split
branch
from
October 29, 2026 17:01
dd4d099 to
a9b8cb5
Compare
ananthsub
force-pushed
the
ananthsub/layout-rollouts-split
branch
from
October 29, 2026 18:25
a9b8cb5 to
0dcbb02
Compare
yaoyu-33
reviewed
Nov 2, 2026
yaoyu-33
left a comment
Contributor
There was a problem hiding this comment.
Reviewed at 38b9e95. No blockers. The split itself checks out: no behaviour change, no new import cycle, and old paths still resolve. What's left is two small inline notes and a few text fixes below.
What we checked
- Moved code is unchanged. All 11 items that leave
rollout_collection.pyare AST-identical inrollout_perf.py/trajectory_builder.py, docstrings included, and every collector definition that stays is unchanged. Every name the moved code reads binds to the same object as before. - Outputs are byte-identical. We ran the collector end to end on base and head with the same inputs.
ng_trajectory,ng_perf, the output JSONL rows (key order included), the failures sidecar and the aggregate metrics file match byte for byte. That covers both dialects, error attempts, observation gaps, verifier-owned calls, and forced_build_*failures. Trajectory is still attached beforeng_perf. - Compat and layering. Every moved name resolves at both
nemo_gym.rollout_collectionandnemo_gym.rollouts.rollout_collectionto the same object.lint-importskeeps the contract. Neither new module importsrollout_collection.test_moved_paths.py,test_import_linter_coverage.pyandtest_public_api_facades.pypass. - Tests.
tests/unit_tests/rollouts,test_dispatch_latency.py,server_runtime/test_verifier_observability.pyandtest_moved_paths.pyall pass locally with the telemetry extra installed (1409 passed);test_rollout_collection.pyreally runs that way. The touched server and agent tests pass locally or in CI. Every hunk outsidenemo_gym/is a one-name retarget to the defining module.
Notes not tied to a diff line
tests/unit_tests/rollouts/test_trajectory_builder.py(pure rename, so there's no line to comment on) testsnemo_gym.models.token_capture.builder, not the newnemo_gym.rollouts.trajectory_builder; it only shares the name. Could it stay where it was, or go totests/unit_tests/models/next to the other token-capture tests (for example astest_token_capture_builder.py)? Underrollouts/it reads as the new module's test file, and per-package CODEOWNERS would route it to the wrong group.responses_api_agents/terminus_2_sandboxed_agent/app.py:185still says "_trajectory_identityinrollout_collection"; it now lives innemo_gym.rollouts.trajectory_builder.
PR text
- Compatibility section. "Every moved name resolves … with one warning" and "A patch through
rollout_collectionof a moved function has no effect" don't hold for the five names the collector imports back:DispatchLatencyTracker,NG_PERF_KEY,_attach_ng_perf,_attach_trajectory_recordand_has_observation_gap.- They resolve from
rollout_collectionwith no warning. - A patch on
rollout_collectionstill reaches the collector's call sites, and a patch onrollout_perf/trajectory_builderdoes not. - Since #5166 asks each split PR to list the patches that stop taking effect, could the section say instead:
- Patches through
rollout_collectionthat no longer reach anything:_build_ng_perf,_build_trajectory_record,_trajectory_identity,_turn_content,_turns_from_model_callsand_nonnegative_int. - Same for the globals the moved code looks up, such as
maybe_rollout_id_from_run_body,TASK_ID_FIELDS,_strip_capture_payloadsand thetrajectory_recordmodels. - The five imported-back names are the exception: patch them on
rollout_collectionto affect collection.
- Patches through
- Nothing in this repo patches any of these through the wrong module today.
- They resolve from
- Commit message. It still says the three join functions move from
trajectory/trajectory_record.pytotrajectory_builder.py, that the contract drops the trajectory→rollouts exception ("9 remain"), and that code outsidenemo_gym, "tests included", is pointed atnemo_gym.<package>. None of that is in this diff:trajectory_record.pyandpyproject.tomlare untouched, and the PR body correctly says the join functions stay. Since the PR lands as one squashed commit, could the message be brought in line before merge? - For anyone with log filters: the three warning lines from trajectory building and
ng_perfnow log undernemo_gym.rollouts.trajectory_builder/nemo_gym.rollouts.rollout_perf, as the body says.
CI at 38b9e95
Unit tests / Test: one failure, inherited from #5231 with the identical failure on its head:tests/unit_tests/telemetry/test_call_sites.py::test_materialized_dispatch_takes_its_id_from_the_row_not_the_episode_body.- Harness conformance: only the non-blocking kilocode
model_errorprobe fails, the same as on #5231. - Server suites: all shards pass.
yaoyu-33
previously approved these changes
Nov 2, 2026
yaoyu-33
left a comment
Contributor
There was a problem hiding this comment.
Approving at 38b9e957a059. The team review found no blockers or risks; the remaining inline notes are optional and can be handled here or in a follow-up.
Contributor
Author
|
Replies to the summary, as of
|
… out of the collector rollout_collection.py loses the per-rollout performance numbers, which move to rollouts/rollout_perf.py, and the code that builds a rollout's trajectory record from its model calls, which moves to rollouts/trajectory_builder.py, along with a small helper only that code used. The join functions in trajectory/trajectory_record.py stay where they are, and the import-linter contract does not change. The collector imports back the five names it still calls: DispatchLatencyTracker, NG_PERF_KEY, _attach_ng_perf, _attach_trajectory_record and _has_observation_gap. The split names are recorded in MOVED_NAMES under the old module paths. In-repo references are rewritten with scripts/migrate_imports.py, and test patches and attribute accesses point at the new modules. The token capture builder test moves to tests/unit_tests/models/test_token_capture_builder.py, next to the other token capture tests, because it tests nemo_gym.models.token_capture.builder, not the new trajectory_builder module. The public API of each layout package that exists here is regenerated from what code outside the library imports. Code outside nemo_gym and its tests imports from nemo_gym.<package>, and the library's tests import from the module that defines each name. Signed-off-by: Ananth Subramaniam <[email protected]>
7 tasks done
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Splits two parts out of the rollout collector: its performance numbers and building a rollout's trajectory record.
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.
What moves
flowchart LR subgraph RC["rollouts/rollout_collection.py"] C["The collector"] P["ng_perf numbers,<br/>DispatchLatencyTracker"] T["Building a rollout's<br/>trajectory record"] end subgraph TR["trajectory/trajectory_record.py"] M["The record models"] J["Joining model calls<br/>into observations"] end P --> P2["rollouts/rollout_perf.py"] T --> T2["rollouts/trajectory_builder.py"] T2 -->|"imports"| M classDef this fill:#fde68a,stroke:#b45309,stroke-width:2px,color:#1f2937 class P2,T2 thistrajectory/trajectory_record.py. They transform records only, take no rollout state, and enforce identity rules that the trajectory record defines._nonnegative_int, a helper only the trajectory builder used, moves with it.What stays importable from the old paths
nemo_gym.rollout_collectionandnemo_gym.rollouts.rollout_collection. A name the collector no longer uses resolves with one warning.DispatchLatencyTracker,NG_PERF_KEY,_attach_ng_perf,_attach_trajectory_recordand_has_observation_gap. They are ordinary attributes ofrollout_collection, so they resolve there with no warning.rollout_collection:_build_ng_perf,_build_trajectory_record,_trajectory_identity,_turn_content,_turns_from_model_callsand_nonnegative_int, and the globals the moved code looks up, such asmaybe_rollout_id_from_run_body,TASK_ID_FIELDS,_strip_capture_payloadsand thetrajectory_recordmodels. Patch them onnemo_gym.rollouts.rollout_perfornemo_gym.rollouts.trajectory_builder.nemo_gym.rollouts.rollout_collectionto affect collection. A patch of them onrollout_perfortrajectory_builderdoes not reach the collector's call sites.How to review
One commit: the split with its
MOVED_NAMESentries, rewritten references, retargeted test patches and attribute accesses, andtest_trajectory_builder.py, which testsnemo_gym.models.token_capture.builder, moving totests/unit_tests/models/test_token_capture_builder.pynext to the other token capture tests. By hand:rollout_perfandtrajectory_buildersit in the top import block, apart from the CLI shims at the end of the module, whose comment describes only them._strip_capture_payloadsis grouped in_moved_paths.pywith the names the collector no longer imports._attach_ng_perferror test builds a trajectory that does produceng_perfand checks that the patched_build_ng_perfran, so it fails if the patch targets a module the code does not read.terminus_2_sandboxed_agentnamesnemo_gym.rollouts.trajectory_builderfor_trajectory_identity.History of split files
The repository squash-merges, so this PR lands as one commit. Whole-module moves still show as renames. A split file does not: its old path stays with less in it, so the new file starts its own history.
git blame -C -C <new file>follows the moved lines back to the old file, andgit log --followdoes not.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.Validation
pytest -n 16 tests/unit_tests, also with-W errorfor the moved names._attach_ng_perferror test passes as written and fails with its patch moved torollout_collection.lint-imports.pre-commit runon the changed files.Rollout evidence: N/A. The code moves unchanged; rollout rows and trajectory records are written as before.
Compatibility
nemo_gym.rollouts.trajectory_builderandnemo_gym.rollouts.rollout_perf.python scripts/migrate_imports.py <paths>.Issue
Part of #5166.