Repository navigation
feat(rollout-collection): add --interleave-repeats - #3822
Conversation
Signed-off-by: Matvei Novikov <[email protected]>
yuhezhang-ai
left a comment
There was a problem hiding this comment.
This looks useful as an opt-in scheduling policy. The main issue to fix before merge is preserving the interleaved order through the default dispatcher; the second comment is a nonblocking documentation clarification.
Validation at 4d85e43: all 500 tests in tests/unit_tests/test_cli_main.py and tests/unit_tests/test_rollout_collection.py passed, along with Ruff lint and formatting checks. Focused reproductions exercised production preprocessing and dispatch with mocked server transport. No live model rollout or memory measurement was performed.
Also describe --interleave-repeats as best-effort spreading. Signed-off-by: Matvei Novikov <[email protected]>
|
Thanks for review, addressed issues! |
| | `--output`, `-o` | Output rollouts JSONL file. | | ||
| | `--limit` | Maximum number of tasks to run. | | ||
| | `--num-repeats` | Rollouts per task (for mean@k metrics). Pass an int to apply to every task, or a dict keyed by `agent_ref.name` for per-agent counts (e.g. `'{simple_agent: 32, swe_agent: 1}'`) when one input file mixes agents. In dict form, the special key `_default` is the fallback for agents not explicitly listed; without it, any unlisted row's agent raises a single consolidated error. | | ||
| | `--interleave-repeats` | Start repeats round by round (every task's first rollout, then every task's second) rather than each task's back to back. Use it when a task is heavy on the machine running it, for example when its sandbox loads large data, to spread its repeats over the run. This is best effort: repeats still overlap when the concurrency is high or rollouts are long. GDPVal's multistage orchestrator rebuilds its stage rows per task and does not keep this order. Maps to legacy `+interleave_repeats=true`. | |
There was a problem hiding this comment.
would suggest removing gpdval specific note here and put that in the gpdval readme instead
There was a problem hiding this comment.
oh i see this mightve came from comment above? happy to defer to team
|
/ok to test fae6660 |
yuhezhang-ai
left a comment
There was a problem hiding this comment.
Reviewed the latest changes at fae6660. Both earlier comments are addressed: the default dispatcher creates tasks in input order, with a request-start-order regression test, and the docs correctly explain overlap and the GDPVal multistage limitation. No remaining blocking findings.
Validation on this head: 501 tests passed across tests/unit_tests/test_cli_main.py and tests/unit_tests/test_rollout_collection.py; Ruff lint, formatting checks, and git diff --check passed. Existing lint, copyright, secrets, and DCO checks are green. Full repository CI has been requested and is still pending; this approval does not assert it has passed.
No live model rollout or production memory measurement was performed; the change concerns collector scheduling rather than agent or verifier behavior.
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/36810320804 |
…A-NeMo#4644) ## What does this PR do? Rollout collection kept every finished `/run` result in the driver's memory until the last rollout of the run finished, even with `retain_results_in_memory=false`, whose description promises that results are not retained during collection. The cause is in `_run_examples_with_metadata` in `nemo_gym/rollout_collection.py`, the dispatcher shared by `gym eval run` (through `run_from_config`) and by `run_examples`, which NeMo RL calls. When `max_resident_tasks` is unset, its inner generator `_start_in_input_order` created every rollout task up front in a list and passed that list to `tqdm.as_completed`. The list stayed alive in the generator frame for the whole run, and `tqdm.as_completed` also kept it as its `fs` argument. A finished asyncio task holds its result, so the consumer dropping a result did not free it. The fix passes a generator of tasks instead of a list. `_start_in_input_order` was added in NVIDIA-NeMo#3822 because `asyncio.as_completed` builds its tasks from a set, which would start rollouts in an arbitrary order. That property still holds: `asyncio.as_completed` iterates the generator in order (`set(aws)`) before building its set, so `asyncio.ensure_future` still creates the tasks in input order. After that, only `asyncio.as_completed`'s own bookkeeping references a task, and it lets go of a task once it hands the result to the consumer. The progress bar keeps its explicit `total`, so it is unchanged. The bounded admission path (`_BoundedCompletionIterator`, used when `max_resident_tasks` is set) already released finished tasks: it pops each task from its ready list before awaiting it, so it needed no change. NeMo RL's `run_examples` path benefits too, since it goes through the same dispatcher. No issue was filed; the bug and the fix are both contained in this PR. ## Validation - A new test, `test_dispatch_releases_a_taken_result_while_rollouts_are_pending`, runs both `run_examples` and `_run_examples_with_metadata`, with and without `max_resident_tasks`. The first rollout finishes while the others are held pending. The test takes and drops the first result, then asserts through a weak reference that the result was freed before the remaining rollouts finish. On the code before this change, the cases without `max_resident_tasks` fail and the bounded cases pass. - The existing `test_default_dispatch_starts_rollouts_in_input_order` still passes, confirming that rollouts start in input order. - `PYTHONPATH=. .venv/bin/python -m pytest -n 16 -q tests/unit_tests --ignore=tests/unit_tests/test_exporters.py` in a venv built with `uv sync --extra dev --extra telemetry`. The only failures are environment-dependent ones in `test_opensandbox_compose.py`, `test_reward_profile.py`, `test_dataset_orchestrator.py`, and `test_sandbox_stop_retry.py`, which fail identically on `main` on the same machine. - `pre-commit run --all-files`. ## Rollouts N/A: the change only affects when the driver releases results it has already handed to the consumer. It does not change which rollouts run, in what order they start, or any agent, model, or verifier decision. Memory evidence comes from a CPU capacity simulator with the production topology (simulated engine and tools, real Gym servers and driver). Each run collected 4,096 long-context rollouts (64 repeats, 80 history messages of 2,000 characters each) with 1,024 in flight, `++retain_results_in_memory=false`, and rollout observability on. The driver's `process.memory.usage` came from console metric exports every 10 seconds. The table shows the highest reading taken while rollouts were still completing, with the number of completed rollouts at that sample. | Variant | Repeat | Peak driver memory during collection | | --- | --- | --- | | `main` (974d1a9) | 0 | 4.56 GB at 3,697 of 4,096 | | `main` (974d1a9) | 1 | 4.52 GB at 3,652 of 4,096 | | this PR | 0 | 0.70 GB at 3,726 of 4,096 | | this PR | 1 | 0.82 GB at 3,235 of 4,096 | On `main`, driver memory grew steadily with the number of completed rollouts. With this change it stayed between 0.5 and 0.8 GB for the whole collection. Both variants still jump to about 5.6 GB after the last rollout, because the no-retention mode reads the output file back into memory for aggregation. That is a separate issue and is not addressed here. ## Compatibility and benchmark impact None. Results, their order of delivery, and the progress bar are unchanged. ## Checklist - [x] I have read the [contributing guidelines](https://github.com/NVIDIA-NeMo/Gym/blob/main/CONTRIBUTING.md). - [x] The change is focused; unrelated "drive-by" edits are tracked as separate issues/PRs. - [x] Tests added or updated and pass locally, or N/A for docs-only / non-code changes (so CI unit/server checks pass when applicable). - [x] Documentation added or updated, or N/A with justification. N/A: no documented behavior changes; the existing `retain_results_in_memory` description now holds. - [x] Pre-commit checks pass locally (`pre-commit run --all-files`) (so CI lint/format checks pass). - [x] New source files include the required Apache-2.0 SPDX header. N/A: no new files. - [x] All commits have DCO sign-off (`git commit -s`) (so the DCO check passes). Signed-off-by: Ananth Subramaniam <[email protected]>
What does this PR do?
Validation
Rollouts
Compatibility and benchmark impact
Checklist
pre-commit run --all-files) (so CI lint/format checks pass).git commit -s) (so the DCO check passes).