Repository navigation
refactor(eval): move the recovery planner out of orchestration - #6228
Conversation
…m/eval/recovery Pure renames, so history follows the files: the planner (orchestration/recovery.py) becomes eval/recovery/planner.py, the evidence collector (orchestration/collect_evidence.py) becomes eval/recovery/evidence.py, and the 27 test modules that test only these two move to tests/unit_tests/eval/recovery/. The next commit updates the imports; this one alone does not import. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Adam Rajfer <[email protected]>
No behaviour change. This commit touches only imports, one constants module, two moved-path entries and the layer contract. - The planner reads nine chain-marker strings that the chain scripts write. They move unchanged from orchestration/executors/resume_script.py to eval/recovery/markers.py. resume_script imports them from there, so the planner no longer imports orchestration at all. - import-linter: the eval layer is split into its children, and the recovery package is a layer of its own below orchestration. The executors keep calling the planner, and the contract now forbids the planner from importing orchestration. - The old paths nemo_gym.orchestration.recovery and .collect_evidence are recorded in nemo_gym/_moved_paths.py, since 0.8.0 like the other moves there, and in the import-surface fixture. They are the same module objects and warn on use. - Two scripts run inside a run's pinned install: the remote Store reader and the follow-up's continuation admission. That install may predate the move, so they import the new path and fall back to the old one. - Every other import of the two modules, in code, tests and the skills, uses the new path. Signed-off-by: Adam Rajfer <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
…answers No behaviour change. Every top-level definition moves unchanged, with the comment lines above it and in its original order, from the 5,800-line planner into the module that answers its question: - evidence: the collected-evidence model and the Store selection, beside the collector script; - decision: identity states, run-level actions, the decision and outcome records; - budgets: retry, attempt and walltime budgets; - policy: the recovery outcome policy and the failure kind it selects on; - grading: saved grading artifacts and the re-verification cause; - rows: per-identity classification; - trials: trial observations and fault classes; - gate: health, metric coverage, MLflow delivery and the gate summary; - planner: decide_from_collected; - continuation: the chain's continuation admission and allocation accounting. The modules import in that order and no module imports a later one. The package docstring names the entry points. Callers import each name from the module that defines it. The old path nemo_gym.orchestration.recovery keeps serving every name it had: the moved-path registry lists each split name under it, and the planner's __getattr__ serves them with a deprecation warning. The scripts that run inside a run's pinned install now import the module that holds their function (evidence for the Store reader, continuation for the admission), still falling back to the old path on an older install. Tests that patch a function now patch the module whose code calls it; no assertion changes. Signed-off-by: Adam Rajfer <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
No behaviour change. The recovery planner had defined values a second time that already had a home elsewhere: - the failure-row keys (_ng_failure_class, _ng_failure_terminal, _ng_failure_counts_as_zero, _ng_failure_max_attempts) now all live in artifacts/rollout_rows.py, beside the failure class key that was already there. rollout_collection imports them from there. The planner's short names bind to them. - _ng_failure_events and _ng_failure_id come from FailureReportRow, which owns the failure report keys. - _ng_task_index and _ng_rollout_index come from config/global_config. - the chain's accounting file names (.gym_infra_retries, .gym_infra_retry_extension and .gym_accumulated_walltime) live in eval/recovery/markers.py, which the chain scripts and the recovery reader both import. They keep resume_script's existing names. The job script's walltime file is now rendered from the constant: the rendered prologue and epilogue are byte-identical. The planner's three duplicate names stay importable from the old module path through the moved-path registry. Signed-off-by: Adam Rajfer <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
…althy run Five fixtures were full copies of a recorded healthy run that differ from it only in the values their case changes: the reward, the grading binding, and the ids and digests that follow from them. Each is now a patch file that names its base and lists the values it sets, one per line (2,220 lines down to 142). `recorded_run` rebuilds the run. A patched run equals the file it replaces exactly; this was checked for each one before the files were removed. The repeats and verifier-error runs differ from the base in whole subtrees, so they stay full files. The detect-secrets baseline moves the entries of the removed files to their patch files. Its other entries are unchanged. Signed-off-by: Adam Rajfer <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
…urm package Pure renames, so history follows: executors/slurm.py becomes executors/slurm/executor.py and executors/judge_profile.py moves beside it. The next commit splits the executor by part and keeps the import path nemo_gym.orchestration.executors.slurm; this one alone does not import. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Adam Rajfer <[email protected]>
No behaviour change. The 2,945-line executor becomes the executors/slurm package, keeping its import path nemo_gym.orchestration.executors.slurm (the package exports SlurmExecutor): - executor.py: SlurmExecutor itself, which renders a run's job scripts, submits them with sbatch and records the submission (run, stage, dry run, export); - chain.py: recovery of a run's auto-resume chain (recovery_evidence, resubmit, walltime_plan and the journaled extension, raise, repin and operator-continuation steps), as the ChainRecovery mixin; - judge_job.py: judge-only jobs (reverify_judge_failures) as the JudgeJobs mixin, with judge_profile.py beside it; - reader.py: the remote Store reader; - scheduler.py: the Slurm commands these parts share (sbatch and its reply, partition limits, live checks). Every definition and method keeps its text, comments and order. The moved methods form the two mixins, and SlurmExecutor inherits them, so no method body changes. No scheduler-agnostic interface is added: only Slurm implements resubmit today. The executor capabilities give resubmit its seam when a second scheduler needs one. Names the old one-file module exported stay importable from the package through the moved-path registry, and executors.judge_profile is recorded as moved. Tests that patched a name on the old module now patch it on each package module that uses it; no assertion changes. Signed-off-by: Adam Rajfer <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
No behaviour change. chain.py and judge_profile.py each defined the same HH:MM:SS formatter; scheduler.py, which holds the Slurm formats the executor parts share, now defines it once. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Adam Rajfer <[email protected]>
…queued No behaviour change. reverify_judge_failures and _queue_judge_job each defined the same closure that stops the decision with a reason; a module-level _stopped(decision, reason) replaces both, called with the decision each closure read. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Adam Rajfer <[email protected]>
Brings in the recovery accounting fix (#5594) and the managed-environment locks (#4837). Resolutions: - The planner split is regenerated from the merged planner with the same mechanical split. The only change to the split modules is #5594's: RecoveryDecision.accounting_unknown, set on the two unknown-accounting stops, and the operator continuation keying on it instead of on the reason text. - import-linter layers: main's new orchestration layer entry (the two locked-environment CLI modules) keeps its place, and the recovery layer stays below it. - The test #5594 added imports OperatorBudget from its new module. - The old module path keeps serving the two unknown-accounting reasons, which the planner no longer imports. Signed-off-by: Adam Rajfer <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brings in the Store-backed run records and run-folder shards (#5443). #5443 does not touch the recovery planner, so the planner split is unchanged. Its edits to executors/judge_profile.py are carried into executors/slurm/judge_profile.py, where that module now lives. Its rollout_collection changes are untouched. Signed-off-by: Adam Rajfer <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brings in the unit test tree that mirrors the nemo_gym packages (#5589), with the rest of main. Resolutions, following the layout #5589 adds to AGENTS.md (a test sits with the package of the module it is named for): - The 24 recovery test modules that #5589 placed in tests/unit_tests/orchestration/ go to tests/unit_tests/eval/recovery/, beside the package they now test. The export receipt, grading result binding and saved-judge rejudge tests stay where #5589 put them (artifacts/, trajectory/, eval/): each is named for a module outside the recovery package. They keep this branch's imports. - Test-to-test imports follow both moves, and the moved tests keep #5589's path changes. - The five recorded-run fixtures this branch keeps as patches are removed from tests/unit_tests/orchestration/fixtures/, where #5589 moved them, and their patches move there, beside their healthy base and the loader that reads them. The secrets baseline follows: main's entries, without the five full fixtures, with the patch files at their new paths. - No moved test has an entry in the core shard durations. Signed-off-by: Adam Rajfer <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
main changed two files this branch moves (#5601). Its hunks are carried to their new homes: - the failed-judge-job progress rule (_judge_job_unsettled) to nemo_gym/eval/recovery/decision.py - the failed judge job note (judge_job_note) to nemo_gym/eval/recovery/gate.py - the host-collected unresolved_rejudgments field to nemo_gym/orchestration/executors/slurm/reader.py Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Adam Rajfer <[email protected]>
…tion outside the CLI entrypoint Signed-off-by: Tomasz Grzegorzek <[email protected]>
… and the test message Signed-off-by: Tomasz Grzegorzek <[email protected]>
…ration imports Signed-off-by: Tomasz Grzegorzek <[email protected]>
…asses and can only shrink Signed-off-by: Tomasz Grzegorzek <[email protected]>
…utils/gym_commit Signed-off-by: Tomasz Grzegorzek <[email protected]>
… H2 ping sidecar out of orchestration Signed-off-by: Tomasz Grzegorzek <[email protected]>
…importing orchestration Signed-off-by: Tomasz Grzegorzek <[email protected]>
…al/recovery/markers Signed-off-by: Tomasz Grzegorzek <[email protected]>
… slurm executor package Signed-off-by: Tomasz Grzegorzek <[email protected]>
…or directly Signed-off-by: Tomasz Grzegorzek <[email protected]>
Brings in tgrzegorzek/orchestration-boundary-moves (the boundary test and the moves of the supervisor, server_venv, sidecar, installed_gym_commit, eval status lookup and the failure kind writer), which includes current main. Conflict resolution: - main's changes to orchestration/recovery.py and collect_evidence.py are ported into the eval/recovery modules, symbol by symbol (28 changed, 9 added, 2 removed). - eval/recovery/markers.py keeps the chain markers and gains DRIVER_FAILURE_ENV and record_failure_kind; eval/recovery/__init__.py keeps the longer docstring. - the slurm executor modules import installed_gym_commit from utils.gym_commit. - the server tests that imported nemo_gym.orchestration.recovery import from the modules that define the names, so KNOWN_VIOLATIONS in the boundary test is empty. Signed-off-by: Tomasz Grzegorzek <[email protected]>
…yout main's new recovery tests patch and call names that now live in gate and evidence, and the old-path tables in _moved_paths.py and the import-surface fixture still listed names main moved or removed (installed_gym_commit, GRADING_WITHOUT_VERDICT, fault_class). Signed-off-by: Tomasz Grzegorzek <[email protected]>
main now contains the orchestration boundary test and the move of the server startup code (#5749, #5882), which this branch carried in an older form. This merge uses the old stack tip as its base, so only this PR's own changes remain against main: - main's later changes to orchestration/recovery.py and executors/slurm.py are ported symbol by symbol into the eval/recovery modules and the executors/slurm package (23 changed and 55 added symbols in the recovery code, 6 hunks in the judge-job code); the new helper _continuation_options and the two constants it needs live in planner.py so planner and gate do not import each other. - GUARDED_DRIVER_FAILURE_KINDS moves to eval/recovery/markers.py with the other chain markers, and the move of record_failure_kind and DRIVER_FAILURE_ENV there is re-applied (main reverted it from the stack because it belongs here). - The eval and eval.recovery layers return to the layering contract. - KNOWN_VIOLATIONS is empty: the remaining orchestration.recovery importers (five newer server tests and a miniswe test) import from the eval.recovery modules. - .secrets.baseline keeps main's entries and the .patch.json fixture entries of this branch. Signed-off-by: Tomasz Grzegorzek <[email protected]>
Signed-off-by: Tomasz Grzegorzek <[email protected]>
…ts main added The operator-verdict, repetition-stop, task-selection, judge-job and attempt-extension tests that main gained since the relocation was first written import from nemo_gym.orchestration.recovery and from helper test modules that moved to tests/unit_tests/eval/recovery/. Signed-off-by: Tomasz Grzegorzek <[email protected]>
…tests/unit_tests/eval/recovery path Signed-off-by: Tomasz Grzegorzek <[email protected]>
…he code they test Signed-off-by: Tomasz Grzegorzek <[email protected]>
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP
I found no BLOCKER or RISK in the relocation. The inline NOTE suggests restoring two Gymnasium integration tests removed by the refactor.
I rechecked the previous compatibility concern. The cited names still lack shims, but they are absent from the pre-existing compatibility fixture, and the in-tree callers now use their defining modules. I found no demonstrated supported-API break, so I have not repeated that blocker. This is a revised assessment, not a verified fix; I could not independently verify the author's v0.7.0 claim.
I reviewed the changes statically and did not execute tests or independently verify CI. One parallel review report was unavailable, so I inspected its compatibility and integration scope directly.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
| return base | ||
|
|
||
|
|
||
| @pytest.mark.asyncio |
There was a problem hiding this comment.
NOTE: Restore the Gymnasium collector-to-health checks
This file is now empty, so pytest no longer collects either integration test. The base tests exercise a recorded agent row through capture enrichment, the real collector and recovery health. The surviving agent-side fixture check verifies row production, not that downstream handoff. This is a coverage loss, not a demonstrated runtime failure.
Could you restore the base file, replacing its obsolete recovery and helper imports with:
from nemo_gym.eval.recovery.evidence import CollectedEvidence
from nemo_gym.eval.recovery.gate import trial_verdict
from nemo_gym.eval.recovery.planner import decide_from_collected
from tests.unit_tests.eval.recovery.test_verifier_recorded_trial_coverage import _gateKeep both test bodies and fixture paths unchanged. The invariant is that a finished episode's recorded reward is observed as healthy, while a cut-off answer is attributed to the model rather than the evaluation infrastructure.
Proposed acceptance checks, not executed here:
- Run
pytest --collect-only -q tests/unit_tests/orchestration/test_gymnasium_agent_handoff.py; expect both original tests to be collected rather than none. - Run that file. For
finished, retainenvironment_reward == 1.0, response IDs["resp-1"], nomodel_call_reference_unmatchedorconversation_unavailablegaps,covered is True,passed is True, and zero unobserved trials. - For
cut_off, retainpassed is True,exact is True, evaluation-side failure count zero, and model kinds{"truncated_answer": 1}. Keep the agent-side fixture comparison passing for both cases.
The import replacement is suggested source code and needs verification when restoring the tests.
There was a problem hiding this comment.
good catch, my split emptied it. Restored in f2e4b97 with the new import paths, both tests collect and pass again.
Signed-off-by: Tomasz Grzegorzek <[email protected]>
…ckage Signed-off-by: Tomasz Grzegorzek <[email protected]>
Signed-off-by: Tomasz Grzegorzek <[email protected]>
…commit emptied Signed-off-by: Tomasz Grzegorzek <[email protected]>
…hey test Signed-off-by: Tomasz Grzegorzek <[email protected]>
Signed-off-by: Tomasz Grzegorzek <[email protected]>
Signed-off-by: Tomasz Grzegorzek <[email protected]>
…h tests/helpers Signed-off-by: Tomasz Grzegorzek <[email protected]>
|
/ok to test 9791466 |
|
/review |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP WITH CARE
I found one RISK introduced since the previous review: the unreadable-artifact test split drops its permission-related skip guard, so both extracted cases fail when run as root.
The previous Gymnasium NOTE is fixed in source. Both restored integration tests keep the original reward, capture-binding and failure-attribution assertions.
I reviewed changes since 31d4df57aa3be0fa7c6fbb11a5f383e9423ba171, covering the Kubernetes package relocation, recovery test/helper splits and their directly affected consumers. I reviewed source statically; I did not execute tests or independently verify CI.
Review generated by codex. This was a findings-only review. Request a full review with /review reset=true.
| assert decision.action == RecoveryAction.STOP | ||
| assert decision.reason == f"saved rows are unreadable ({name}), so what they hold is unknown" | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("name", ["rollouts_aggregate_metrics.json", "quality_summary.json"]) |
There was a problem hiding this comment.
RISK: Keep the permission-test skip guard on the extracted cases
Running this file as root on a standard Linux system now fails both parameterized cases before they exercise the operator verdict. The imported _run helper uses chmod(0), but root can still read the artifact, so collected.unreadable_files is empty and the assertion at line 31 fails. These cases should skip where their permission-based setup cannot work.
The split introduced this regression. Both cases previously lived under the module-level skip guard. The current recovery test module still has it, but importing _run does not apply that module's marker to tests here.
Could you add import os and place the same guard above this decorator?
pytestmark = pytest.mark.skipif(
not hasattr(os, "geteuid") or os.geteuid() == 0,
reason="root reads a file whatever its mode",
)This restores the invariant that permission-based tests run only where their setup can make the artifact unreadable. Keep both metric and summary cases running for a non-root Unix user, with the existing NOOP decision, FAILED task status and exact operator verdict directing the user to make the files readable rather than submit a fresh run. Leave the companion collector tests and their existing guard unchanged.
Proposed acceptance checks, not executed: run pytest -q tests/unit_tests/orchestration/test_recovery_unreadable_artifacts.py as root and expect two skips, not failures; run it as a non-root Unix user and expect both cases to pass with their assertions unchanged. Verify the suggested marker before adopting it.
There was a problem hiding this comment.
yep, that was my split. Guard is back in 5c9dea1 (same pytestmark as the original). It was also the 2 red tests in CI shard 2.
Signed-off-by: Tomasz Grzegorzek <[email protected]>
|
/ok to test 5c9dea1 |
AdamRajfer
left a comment
There was a problem hiding this comment.
Checked it as a move, looks good. recovery + slurm defs come out identical and the rendered job scripts match main except the admission import, allocation-cut fix is still there. thanks for bringing back the gymnasium handoff test.
two nits, fine for a follow-up:
executors/slurm/judge_job.py~242: thereceipt =line and its comment are duplicatedrollouts/rollout_recovery.py: the comment aboveCOLLECTED_MODEL_CALLS_KEYsaysCOLLECT_SCRIPTis in the planner, it lives in evidence now
skipping the extra compat entries is fine. LGTM
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/44085858896 |
Main moved slurm_script to executors/slurm/script (#6228); the test imports the new path. Signed-off-by: Wojciech Prazuch <[email protected]>
Main moved the Slurm executor, the resume script and the recovery planner (#6228). Carries this branch's node-local support, its restore-failure kind and remedy, and its tests to the new modules. Signed-off-by: Wojciech Prazuch <[email protected]>
Brings #6217's merge of main (#6228 moved the Slurm executor, resume script and recovery planner); node_local keeps this branch's stop-wait import. Signed-off-by: Wojciech Prazuch <[email protected]>
Summary
Continues #5596 (closed), brought up to date with
mainafter #5749 and #5882 landed. It moves the recovery code out ofnemo_gym.orchestrationso that core packages stop importing orchestration, and emptiesKNOWN_VIOLATIONSin the boundary test (12 entries).orchestration/recovery.pyandcollect_evidence.pybecome thenemo_gym.eval.recoverymodules (budgets,continuation,decision,evidence,gate,grading,markers,planner,policy,rows,trials).executors/slurm.pybecomes theexecutors/slurm/package, andresume_script.pyandslurm_script.pymove into it.record_failure_kind,DRIVER_FAILURE_ENVandGUARDED_DRIVER_FAILURE_KINDSlive ineval/recovery/markers.py, the contract between the chain scripts and the recovery code.eval.recoverybeloworchestration(the executors call it) and the rest ofevalabove it. No issue: code moves only.The commits of #5596 keep their original authorship.
Compatibility
Old paths (
orchestration.recovery,collect_evidence,executors.resume_script,slurm_script,slurm) resolve through_moved_paths.pyto the new modules, and the import-surface fixture is updated.For reviewers
mainchangedorchestration/recovery.py(23 symbols changed, 55 added, mostly the operator verdict),executors/slurm.pyandjudge_profile.pyafter the split was written. I ported those changes into the new modules symbol by symbol._continuation_optionsand the two constants it needs are inplanner.py, soplannerandgatedo not import each other.orchestration/recovery.pyorexecutors/slurm.pywill need a rebase onto this layout.Validation
pre-commitand the boundary test pass.main's lockfile, so about 690 tests fail locally onmaintoo. I ran every failing test that exists onmainagainst pristinemain: all but 11 fail identically there. Those 11 were new tests onmainthat import the old module path; they are fixed here and pass.Rollout evidence: N/A, code moves only.