Repository navigation
feat(eval): write a completion file per agent as soon as its rollouts are settled - #5386
Conversation
… are scored Signed-off-by: Frankie Siino <[email protected]>
Signed-off-by: Frankie Siino <[email protected]>
Signed-off-by: Frankie Siino <[email protected]>
Signed-off-by: Frankie Siino <[email protected]>
…agent-complete Signed-off-by: Frankie Siino <[email protected]>
…agent-complete Signed-off-by: Frankie Siino <[email protected]> # Conflicts: # nemo_gym/rollout_collection.py
…5042 Since #5042, data preparation writes each task once whenever a run-level num_repeats is set, so the run-level value replaces each dataset's own. The Core recipe listed only APEX (16) and LMArena (3) with a default of 1, so every other member dropped from 8, 10 or 16 attempts per task to 1 (23,801 rollouts before, 9,427 now). The SWE recipe's run-level 1 did the same to its 3 attempts (2,400 rollouts before, 800 now). List every Core member's intended count in the run-level num_repeats, set num_repeats: 3 in swe.yaml, and update the matching expectations in test_super35_batch_launcher.py. num_repeats_add_seed is unchanged. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Frankie Siino <[email protected]>
…agent-complete Signed-off-by: Frankie Siino <[email protected]>
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
HOLD
One BLOCKER can publish a partial benchmark score as complete. Four RISK findings cover unscored results, colliding artifact filenames, inconsistent aggregate labels, and stale repeat-count instructions.
I inspected all eight changed files and traced the affected routing, persistence/resume, aggregation, and data-preparation contracts. The ordinary alpha/beta completion, repeat ordering, aggregation-error recording, and write-failure isolation have targeted regression coverage. I couldn't execute tests in this read-only review; the acceptance checks below are proposed.
Note: formal approval is not available for this request, so this review is posted as a comment only.
Inline comments (escaped v1):
-
nemo_gym/rollout_collection.pyline 4775: BLOCKER — Track completion by aggregation identity, not dispatch spelling.A supported mixed batch can contain a materialized task routed to
env_aand a flat row naming agentalpha, whereenv_afrontsalpha. The adapter accepts both forms, but_dispatch_namegroups them separately asenv_aandalpha. Both groups subsequently aggregate into the same environment and writealpha.json.If the native task scores 1 while the flat task remains blocked, the first file declares
1/1complete prematurely. If the flat task later scores 0, its writer replaces that file with another one-row aggregate. Neither matches the final mean of 0.5. Adding a third benchmark makes this a multi-benchmark batch; without it, the split also incorrectly enables completion files for a single aggregation group. The base aggregator already combined these rows.Correction: give
_agent_completion_planthe resolved server map and group with_metrics_group, then use that same identity in the success trigger. For example, buildcompletion_servers_by_agent = _environment_servers_by_agent(identity_client.global_config_dict)once, pass it into the plan, replace this grouping assignment withdispatch_name = _metrics_group(row, lambda: completion_servers_by_agent), and replace the success lookup with:completion_name = _metrics_group(row, lambda: completion_servers_by_agent) pending_keys = agent_pending_keys.get(completion_name) if pending_keys is not None: pending_keys.discard((row[TASK_INDEX_KEY_NAME], row[ROLLOUT_INDEX_KEY_NAME])) if not pending_keys: del agent_pending_keys[completion_name] start_agent_complete(completion_name)
Keep progress/logging dispatch names unchanged. The invariant is one expected inventory per final aggregation environment, regardless of input representation. Preserve separate inventories for different environments fronting the same agent, including the existing distinct-server labels, and retain rollout-order sorting.
Proposed acceptance, not executed: mix native and flat alpha tasks through the same
single_agent_turn_legacyserver, plus blocked beta. Assert no alpha file after only the native task finishes; after both finish, assert one file with counts2/2, mean0.5, and equality with alpha's final entry. Cover both retention modes and resume with the native success already persisted. With only those two alpha tasks, assert no completion directory. Retain ordinary alpha/beta early completion and distinct files for two different environments binding one agent. -
nemo_gym/rollout_collection.pyline 4842: RISK — A persisted success isn't necessarily a scored rollout.The new pending-set calculation and this check count every selected success as scored. However, normalization explicitly permits native results without
rewardand legacy{"execute_only": true, "response": {}}results. Store coverage records these as unscored.For example, alpha can return one reward-1 result and one execute-only result while beta remains blocked. Alpha's file then claims
completed_rollouts: 2,expected_rollouts: 2, andaggregation_status: "complete", although one rollout has no score. Resume publishes the same false completion from saved unscored successes.Correction: retain those valid results in persistence, recovery, and final aggregation, but suppress the scored-completion artifact when any selected result is unscored. After the key-equality check and before aggregation, this small guard matches the store's reward distinction:
if any(type(result.get("reward")) not in (int, float) for result in results): return None
Preserve numeric zero rewards and numeric masked results; don't reject execute-only or reward-less native results from collection or turn them into zeros.
Proposed acceptance, not executed: collect alpha with one scored and one execute-only result, plus beta; assert both alpha results persist, coverage reports one unscored rollout, and no alpha completion file appears. Repeat with a reward-less native result and with that result already persisted before resume. A neighboring case containing
reward: 0.0and a numeric masked result should still produce a file equal to its final aggregate. Retain the execute-only progress test's two 100% reward assertions. -
nemo_gym/rollout_collection.pyline 2770: RISK — Distinct agent names can overwrite the same completion file.alpha betaandalpha_betaboth map toalpha_beta.json. When both benchmarks finish, the atomic writer replaces the earlier file, silently removing one benchmark's early artifact. Names are strings without this character restriction in the instance contract; the collector's fixtures also include names with spaces. Run-wide metrics remain intact, but the per-agent artifact guarantee fails.Correction: use an injective filename encoding. A small suggested replacement here, with
from urllib.parse import quoteadded to the imports, is:return agent_complete_dir_for(output_fpath) / (quote(label, safe="._-") + ".json")
This preserves ordinary alphanumeric/underscore/dot/hyphen filenames while keeping spaces, literal percent signs, and path separators distinct. Document the encoding in the completion-file docs for consumers constructing filenames. Verify the suggestion before adopting it.
Proposed acceptance, not executed: run one-rollout agents named
alpha betaandalpha_beta; assert two files remain, with the correct identities and aggregates matching their respective final entries. Check thata/b,a_b, anda%2Fbproduce distinct basenames within the completion directory. Retain the existingalpha.json/beta.jsonnames and the assertion that alpha's complete JSON is visible while beta is still blocked. -
nemo_gym/rollout_collection.pyline 4801: RISK — Failed sibling groups can make early and final labels disagree.Let stamped environments
env_aandenv_bfront the same agentalpha. This resolver includes both materialized inventories, so a successfulenv_acompletion is labelledenv_a. If everyenv_brollout fails and failures aren't counted as zero, the final aggregation contains onlyenv_a's results. It then recomputes labels from those results and labels the same entryalpha. The early filename/payload therefore doesn't identify the entry as the final aggregate does, contrary to the documented equality contract. This differs from the mixed-routing defect: the environments here really are distinct.Correction: resolve the competing contracts explicitly. If exact early/final entry equality is required, compute one inventory-based label map for collection and pass it through
_call_aggregate_metricsinto_aggregate_entriesfor the final pass too; update affected overrides/tests to accept the optional mapping. Preserve result-only default labeling for direct/offline callers without that inventory, and document the changed final labels for partial multi-environment runs. If unchanged final labeling is mandatory instead, the completion schema/docs must stop promising an identical final-labelled entry and provide a stable environment-based join contract. I haven't supplied a patch because preserving both current promises is impossible when final labels depend on which sibling results eventually arrive.Preserve ordinary one-server-per-agent names, distinct names when both servers succeed, and the existing direct-call error persistence/rethrow behavior.
Proposed acceptance, not executed: two stamped environments bind alpha; one scores a task and the other returns a typed failure, without failure-to-zero scoring. Assert that the completed file follows the chosen documented identity contract and that the failed environment gets no file. If equality is retained, compare the complete entry with the corresponding final entry, including
agent_ref. Repeat with both environments successful and retain the existing distinct-label assertions. -
benchmarks/nemotron_3.5_super/README.mdline 83: RISK — The SWE instructions undo the repeat-count correction.This paragraph still tells users to override collection with
num_repeats=1, whereas the updated SWE recipe now correctly sets 3. When a run-level value is present, preparation emits each source task only once. Following this instruction therefore gives one attempt per task, not three, recreating the under-count this PR fixes.Correction: replace this paragraph with:
The SWE recipe sets `num_repeats=3` and `num_repeats_add_seed=false`. With a run-level repeat setting, preparation writes each task once and collection creates the three attempts. Use `num_repeats=1` only when collecting separately prepared inputs that already contain all three copies; don't apply that override to the end-to-end batch recipe.Also qualify the nearby multiplication statement: collection multiplies copies actually present in supplied input, but end-to-end preparation suppresses dataset-level duplication when a run-level value is set. Preserve that distinction rather than recommending 3 for every pre-expanded
--no-serveinput.Proposed acceptance, not executed: prepare two synthetic one-task SWE members whose dataset repeat count is 3 using the recipe's run-level value. Assert preparation yields one row per member and collection materializes three attempts per member, six total, without added seeds. Separately retain the valid pre-expanded-input case: three supplied copies with collection repeats 1 must remain three, not nine.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
Signed-off-by: Frankie Siino <[email protected]>
…cored agents Signed-off-by: Frankie Siino <[email protected]>
Replacing every character outside letters, digits and . _ - with an underscore made names such as 'alpha beta' and 'alpha_beta' share one completion file, so the later write silently replaced the earlier agent's file. Percent-encode the name instead, which keeps ordinary names unchanged, keeps distinct names distinct, and cannot leave the completion directory. Document the encoding for consumers that build the filename, and note how the completion label differs from the run-wide label for an agent behind several environment servers. Signed-off-by: Frankie Siino <[email protected]>
|
Addressed the 5 issues raised above:
|
…agent-complete Signed-off-by: Frankie Siino <[email protected]> # Conflicts: # nemo_gym/rollouts/rollout_collection.py
|
/review reset=True |
|
/ok to test 15210cc |
…agent-complete Signed-off-by: Frankie Siino <[email protected]> # Conflicts: # tests/unit_tests/orchestration/test_masked_infrastructure_recovery.py
Signed-off-by: Frankie Siino <[email protected]>
…agent-complete Signed-off-by: Frankie Siino <[email protected]>
|
/ok to test d466091 |
|
@fsiino-nvidia could you please address the main conflicts? |
…agent-complete Signed-off-by: Frankie Siino <[email protected]> # Conflicts: # nemo_gym/cli/eval.py # tests/unit_tests/eval/test_judge_only_settle_receipt.py # tests/unit_tests/eval/test_rejudge_complete_only.py
…agent-complete Signed-off-by: Frankie Siino <[email protected]>
|
/ok to test eb848fa |
|
@adil-a I've resolved the conflicts in
|
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/44630358439 |
What does this PR do?
Writes a completion file for each agent in a multi-benchmark (batch) run as soon as every rollout of that agent is settled, so a finished benchmark's numbers are available while other benchmarks in the same run are still running, stuck, or killed.
Today a batch run (several benchmarks in one
gym evaljob, such as the Nemotron 3.5 Super Core and SWE batches) aggregates once, after the whole dispatch loop ends, into<stem>_aggregate_metrics.json. One benchmark that never finishes therefore withholds every other benchmark's score, even when those finished hours earlier. This blocks the picking up of finished benchmarks' scores.How it works
The collection changes are in
nemo_gym/rollouts/rollout_collection.py;nemo_gym/rollouts/rollout_records.pyandnemo_gym/rollouts/rollout_store.pygain the settled-rollout rule.(task, rollout)keys. An agent here is the environment server that scores its rows, as the run-wide aggregate groups them (_metrics_group), so a task routed to a server and a row naming the agent behind it are one agent. Its pending keys are the expected keys minus the rollouts already settled, so a resumed job counts what an earlier job finished. Other runs stop here and behave as before.RolloutRecords.settled, the complement of the rule that decides what a resume runs again. A success masked by infrastructure, or a failure a resume will retry, stays pending. When a set empties, a background task starts for that agent. Agents already finished by an earlier job start before dispatch.count_failure_classes_as_zerocounts as zero (the same helpers as the end-of-run pass), sorts by(task, rollout), calls the environment server's/aggregate_metricswhile servers are still up, and writes<stem>_agent_complete/<agent>.jsonatomically (forresults/rollouts.jsonl,results/rollouts_agent_complete/)._call_aggregate_metricsis split into_aggregate_entries(results, rows, *, labels=None)plus a thin wrapper, and both paths label entries through one helper (_server_agents), with labels computed over the full run so a per-agent call labels its entry as the full run does.<stem>_aggregate_metrics.jsonis written exactly as before. A fresh run deletes the completion directory.The file holds
schema_version,agent_ref,_ng_environment_server,expected_rollouts,completed_rollouts(scored),failed_rollouts,completed_at,aggregation_status(completeorerror) andaggregate(the agent's entry from the run-wide aggregate). The filename percent-encodes characters other than letters, digits,.,_and-, so distinct agent names never share a file.Behavior to know:
_ng_run_health_metrics, the run-level health summary Gym adds to the first run-wide entry after the run./aggregate_metricserror, or a call that gives no answer within 30 minutes (AGENT_COMPLETE_AGGREGATION_TIMEOUT_S), is recorded in the file (aggregation_status: "error"), so a hung environment server cannot hold up the run-wide aggregate. Any other failure writing the file is logged and no file is written. A run that stops early cancels and waits for its completion tasks and their in-flight/aggregate_metricsrequests.nemo_gym/rollouts/batch_status.py,nemo_gym/eval/comparison/loading.py,benchmarks/nemotron_3.5_super/export_to_csv.py) treat it as final. A latergym eval aggregaterepair rewrites it but not the completion files, so after a repair the run-wide entry wins over a file that recorded an aggregation error.gym eval runand the judge-only recovery job can then grade that answer again and recompute the run-wide aggregate in place. Both now refresh each completion file to its agent's recomputed entry and counts (refresh_agent_complete_files), and remove the files when that fails, or when a run that requires every rollout stays incomplete after the pass and so gets no recomputed metrics.completed_atbecomes the resuming job's time. It deletes the file of an agent it still has rollouts to run for, until they settle.Files:
nemo_gym/rollouts/rollout_collection.py,nemo_gym/cli/eval.py(re-judge refresh),nemo_gym/rollouts/rollout_records.py,nemo_gym/rollouts/rollout_store.py,nemo_gym/utils/path_utils.py(agent_complete_dir_for),tests/unit_tests/rollouts/test_rollout_collection.py,tests/unit_tests/eval/test_rejudge_complete_only.py,tests/unit_tests/eval/test_judge_only_settle_receipt.py,benchmarks/nemotron_3.5_super/README.md,fern/versions/latest/pages/evaluation/aggregate-metrics.mdx.Validation
On the current head:
Result: pre-commit clean, 3,669 tests passed. One timing-sensitive case in
tests/unit_tests/rollouts/test_legacy_deadline_collection.pyfailed once under parallel load and passed on rerun, with and without this change.tests/unit_tests/artifacts/test_exporters.pyandtest_live_export_receipt.pyneedmlflow, which the local environment lacks.The completion-file tests in
tests/unit_tests/rollouts/test_rollout_collection.pycover:(task, rollout)order even when the store hands rows back reversed, so metrics over a task's first repeats match the final aggregate.completed_at, and a file with no recomputed entry is removed; the end-of-run pass and the judge-only job remove the files when the recompute or the refresh fails, and a strict run left incomplete removes them.disable_aggregation; an/aggregate_metrics500 is recorded in the file; a failed file write is logged and the run-wide aggregate is still written./aggregate_metricscall that never answers is recorded as aTimeoutErrorwhile the run-wide aggregate is still written; a cancelled run stops its completion tasks and their requests before it returns.Rollouts
Cluster runs with the Super 3.5 step-120 checkpoint, through the NeMo Evaluator Factory benchmark runner, whose
batch-statusreads the files. Run 1 is ona850e8dd9, which has this review round's changes (grouping by environment server, settled rollouts, filename encoding). Runs 2 and 3 are onb1b8f0d28; runs 4 to 6 are on earlier commits (c11ceb6c6and08d13588f).a850e8dd9, all 11 agents, 190 rollouts (Slurm 8798318, 46 min, exit 0). The same small Core recipe as run 2. All 11 completion files were written during the job, between 02:56:30 (tau2) and 03:21:26 (IFBench), while the run-wide aggregate was written at 03:21:35. Every file carriesfailed_rollouts(0 here). Ten files are identical to their entries in the final run-wide aggregate. The eleventh, AA-LCR, has identical scores; its final entry adds only_ng_run_health_metrics, the run-level health summary Gym attaches to the first run-wide entry after the run.batch-statusshows all 11 accepted. No tracebacks.b1b8f0d28, 43 min, exit 0). A small version of the real Core recipe: a few tasks per agent, repeats above 1 on several agents, and 40 LMArena tasks x 3 so LMArena's own failure-rate check passes. All 11 completion files were written during the job, between 19:55:55 (tau2) and 20:21:38 (IFBench), while the job ended at 20:23:36. All 11 are identical to their entries in the final run-wide aggregate, including the multi-repeat benchmarks, andbatch-statusshows all 11 accepted. HLE completed with its current judge. No tracebacks.b1b8f0d28, 32 min). Verified's file was written at 18:15:29 and Multilingual's at 18:33:05, and the job ended at 18:34. Both files are identical to the final aggregate, andbatch-statusaccepted both. No tracebacks.batch-statusaccepted Verified then. Both files later matched the final aggregate field for field.batch-statusnine finished benchmarks' scores that would otherwise all have beenpending. HLE never finished because its judge at the time (azure/openai/gpt-4o) returned 403, which is unrelated to this change and since replaced in the recipe. It made HLE a natural stuck benchmark.Not exercised: a full-size Core run on the current head, and a benchmark whose rollouts hang forever (the unit tests cover a blocked
/run).Compatibility and benchmark impact
Additive. The new files go in a new
<stem>_agent_complete/directory next to the existing outputs. No config key or CLI flag was added, and the run-wide aggregate, its format and its readers are unchanged. Benchmark results are unaffected.nemo_gym/rollouts/batch_status.pydoes not read the new files. Outside consumers such as the EFB runner'sbatch-statusdo, and fall back to the run-wide aggregate when they are absent.The early scores are not written into
batch_status.json: that file exists only when a run is givenbatch_manifest_fpath, which the EFB batches do not use, and it is a progress and status file rather than a place for scored results. The completion files need no manifest, so they work for any multi-agent run.The Core and SWE batch repeat-count restore (needed since #5042) first landed here and has moved to its own PR, #6095, so this PR no longer changes any recipe.
Checklist
pre-commit run --all-files) (so CI lint/format checks pass).git commit -s) (so the DCO check passes).🤖 Generated with Claude Code