Repository navigation
feat(nemo_gym): health-check the Gym actors while rollouts are awaited - #4447
alexandery-nvidia wants to merge 31 commits into
Conversation
|
/ok to test 7ff47f4 |
|
/ok to test 55450c0 |
7ff47f4 to
55450c0
Compare
|
/ok to test 0fa8e1d |
55450c0 to
0fa8e1d
Compare
…ws lost to infrastructure A NeMo-Gym /run that fails ends every rollout still in flight, because the aiohttp exception cannot cross the Ray actor boundary (its headers are a CIMultiDictProxy that cloudpickle cannot serialize) and the actor's stream ends with it. The driver then classifies the failure from a bare RayTaskError, and one dead engine costs the whole step. The NemoGym actor now asks Gym's rollout collector for a failure row instead of an exception (route_failures_to_sidecar=True). The row carries the failure's class, HTTP status, type, message, and response body as plain values, so _typed_gym_failure classifies it on the actor side with the same http_status_is_infra rule the driver applies: a 5xx, a retriable 4xx, or a row without a status is a GymTransportError, any other status a RolloutDataFailure. A data failure still ends the batch at once. An infrastructure failure is yielded in place of the result as a one-key marker row (GYM_INFRA_FAILURE_KEY), so the other rows keep running. On the driver, run_async_nemo_gym_rollout dispatches a marked row again as a fresh single-row stream on the instance its route picks, up to env.nemo_gym.max_infra_attempts_per_rollout attempts in total; the last failure raises GymTransportError with the failure's detail, as an unretried failure does. The default of 1 keeps today's single attempt. The accumulator keeps the per-row budget and reports nemo_gym_infra_redispatches in the final rollout metrics. The asynchronous collector leaves a marked row's slot empty so its own attempt loop dispatches it again. The setting is read by the driver only, so _build_gym_actor_config keeps it as a top-level field of the actor's configuration and out of Gym's global configuration; NemoGym.rollout_config hands it back, and the rollout function reads it there unless a caller passes it, so every caller applies the same configured value. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: alexandery <[email protected]>
…timing and failure detail Three review fixes to the typed-infra-failure path: - Re-dispatch a failure marker's row on the instance whose stream reported it instead of routing through shard_set.pick_handle, which rotates on every call and, with replicas > 1, lands the retry on a different replica. That splits the row's prompt group across instances, which the bucketing invariant forbids: a group split across instances deadlocks verifiers that buffer whole groups. The dead-engine case loses nothing, since every instance holds the same engine base_urls and Gym picks the engine per request. The shard_set parameter of _merge_nemo_gym_instance_streams goes away unused. - Let the merge own the per-instance timing dict through a record_timing callback. The actor attaches its batch timing to a stream's last tuple, which can be the failure marker the merge never yields, and the one-row retry stream shared its bucket's label and finished last, so the consumer's plain assignment replaced a bucket's totals with the retry's. Retries record under <instance_label>/retry<n>. - Record each failure marker's detail on the single-controller path (_stream_rows) and name it when a row runs out of attempts. A marker ends an attempt's stream cleanly, so the previous error claimed the stream ended before all rows arrived, with no cause attached. Also rewrite _typed_gym_failure's docstring lead: the pinned Gym already rewrites the aiohttp error into a picklable form in raise_for_status; the property only a failure row provides is that the stream survives. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: alexandery <[email protected]>
…ailure A failure row carrying a status below 400 means the reply broke after its status line: the body read or parse failed, as when a relayed multi-megabyte response is cut mid-body. That is the transport's trouble, not the request's, so the row is re-dispatched as GymTransportError instead of ending the step as RolloutDataFailure. Only a non-retriable 4xx still describes the request itself. The docstring states the rule and a test pins it across the actor boundary. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: alexandery <[email protected]>
…s behavior The test asserted that the landed row had been shaped, a side effect of the stream that main now applies only to non-receipt results; the receipt result the test streams carries reward checks instead. The test keeps the assertions that are about the marker: the marker's slot stays empty for the attempt loop, the landed row is delivered, and the failure detail is recorded. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: alexandery <[email protected]>
…failure row _typed_gym_failure takes the failure row Gym's rollout collector returns for a failed /run, not the exception, since the typed-failure change; the retained-media test in the nemo_gym lane still passed a ClientResponseError and failed with AttributeError on failure_row.get. It now builds the row the collector produces for Gym's 500 (the status line as the message, the body the collector read beside it). Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: alexandery <[email protected]>
…00 too The actor-side rule for a failure row carrying a status below 400 (a reply that broke after its status line) lived beside http_status_is_infra instead of inside it, so the predicate the driver applies and the one the actor applies had drifted, and the test that pins "one rule, not two" never visited a status where they differ. The sub-400 case now lives in http_status_is_infra, the actor calls the predicate alone, and the test walks 0, 200 and 302 as well. The failure row's detail names the failure type in the status branch too, because the type (a payload or JSON decode error) is the diagnosis when the status says success; the sub-400 test builds the ClientPayloadError Gym's collector records for a cut body. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: alexandery <[email protected]>
…ross a re-dispatch A failure marker ends an attempt's stream cleanly, so a re-dispatch now produces a second timing payload for the same prompt group, and the plain assignment in _run_rollouts kept the one-row retry's numbers as the group's. The first payload stays under the instance label and every later one is reported under <instance label>/retry<n>, the rule the driver path's stream merge applies. Tests pin the surviving group timing and the final error for a group that ends with both a marked row and a row that never arrived. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: alexandery <[email protected]>
…ields no timing record_infra_failure and record_timing defaulted to None, which re-opened the mode the re-dispatch change removed: a merge without the first yields a failure marker the consumer cannot tensorize, and one without the second drops the timing a marker carries. The actor always returns a failed /run as a marker, so no caller wants that mode; both callbacks are now required keyword arguments and the callback is the merge's only timing channel, so the yielded tuple no longer carries a timing slot. A test pins that a retry stream which fails again is dispatched a third time on the same instance under its own retry label. The budget accessor's docstring names the single-controller path, not the asynchronous collector, as the component with its own attempt loop, and the timing roll-up's docstring states that a re-dispatched row adds a retry label on an unsharded step. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: alexandery <[email protected]>
…ts describe the marker The exemplar YAML and the design doc carry the new env.nemo_gym key with its default. The max_row_attempts comments in the single-controller config and its two exemplars said Gym's stream dies on its first failing row; a row whose /run fails at the infrastructure level now comes back as a marker and is re-sent by itself, which is what the knob budgets. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: alexandery <[email protected]>
While the driver waits for NeMo-Gym rows, a Gym server process that has died goes unnoticed: the rows it owned never arrive, and the step waits on them until the walltime guard ends the job. NemoGym already has a health_check method that raises when one of its server processes has exited; nothing called it during collection. With env.nemo_gym.health_check_interval_seconds set, the merged stream of actor rows waits at most that long for the next row; when the interval passes without a row, every actor of the shard set is health-checked, and a failed check ends the rollout with GymTransportError, which the driver classifies as an infrastructure failure. The default (absent or null) keeps today's unbounded wait. The setting is a driver-side key: it stays out of Gym's global configuration, NemoGym.rollout_config hands it back, and the rollout function reads it there unless a caller passes it. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: alexandery <[email protected]>
…ability knobs NemoGym is an asyncio actor, so a live actor whose event loop is blocked, or whose process is stopped, never resolves a health_check call: the unbounded gather turned the watchdog into the hang it exists to end, and in the asynchronous collector it also stopped consumption of groups from healthy shards. Bound the probe with asyncio.wait_for using the poll interval as the timeout, the same way the single-controller watchdog bounds _check_env_health, and report an unanswered probe like a failing one. A scripted never-answering actor pins the bound. Document the driver-side reliability knobs where the sibling env.nemo_gym keys live: a commented block in examples/nemo_gym/grpo_nanov3.yaml (off by default, so copying the example does not enable polling) and the design doc's env.nemo_gym block. Correct the rollout docstring to say the probe runs only after an interval with no completed row, and list GymTransportError in run_nemo_gym_rollout_sync's raises: its callers have no retry, so the error ends the run. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: alexandery <[email protected]>
|
/ok to test 76e11d1 |
0fa8e1d to
76e11d1
Compare
…failures-and-redispatch RL #4435 merged on main as c30bbd4 and appended a test to the rollouts unit-test file where this branch had appended its own; both sides stay. Two redispatch tests stubbed `_compute_rollout_metrics` with a positional-only lambda; main's #4435 passes the aligned Gym results to it by keyword (`full_results`), so the stubs now accept keyword arguments. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: alexandery <[email protected]>
…andery/gym-health-check-during-collection Brings #4446's merge of main after RL #4435's squash (c30bbd4): main's appended rollouts test and this stack's appended tests both stay, and the redispatch tests' metric stubs accept the keyword argument main now passes. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: alexandery <[email protected]>
|
Merged #4446's new head (9be9fec, which carries |
|
/ok to test da35484 |
|
/ok to test ec4590a |
…xandery/gym-rollout-metrics-hook Picks up #4447's and #4446's review follow-ups and their merge of main. Two conflicts: the design doc, where both branches extended the knob comment and added prose after the configuration block (both kept, the reliability paragraphs before the hook paragraphs, the comment naming all three knobs), and test_rollouts.py, where tests were appended at the same place (both kept). Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: alexandery <[email protected]>
…path too The driver path reports nemo_gym_infra_redispatches on every rollout, zero included. The single-controller rollout manager did not report it, so the nemo_gym CI lane's parity test, which requires every driver metric key from the manager, failed, and the lane's driver test, which lists the driver's metric keys, lacked the new key. The manager's _run_rollouts now counts the rows it sends again across its later attempts and reports them under the same key, and both lane tests carry the key. Two CPU tests pin the count: one row sent again counts one, and a clean group reports zero. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: alexandery <[email protected]>
…andery/gym-health-check-during-collection
|
The Gate on 82210b2: |
|
/ok to test 82210b2 |
…failures-and-redispatch main gained #4481, #4771, #4458, #4770, #4640, #4765, #4525 and #4670 since the previous merge. #4640 (rubric-mean and fixed-baseline GenRM scoring) rewrote the metric assertions in tests/unit/experience/test_rollouts.py that this branch also edits for nemo_gym_infra_redispatches: the resolution keeps main's per-key assertions and adds the redispatch count beside them, and the expected rollout_metrics dict carries both sides' new keys. test_rollouts.py, test_rollout_manager.py and test_nemo_gym.py pass locally on the merged tree. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: alexandery <[email protected]>
…andery/gym-health-check-during-collection Carries the stack root's merge of main (8338530: #4481, #4771, #4458, #4770, #4640, #4765, #4525 and #4670) forward so this head stays current with main. No conflicts; test_rollouts.py, test_rollout_manager.py and test_nemo_gym.py pass locally on the merged tree. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: alexandery <[email protected]>
|
/ok to test 56a03ca |
…failures-and-redispatch
…rked re-dispatches The driver's stream merge gave every re-dispatch of a row its own <instance>/retry<n> timing label, so the number of timing keys grew with the failure rate and a one-row retry's postprocessing percentage could become the step's. The retry streams of one instance now add up into a single <instance>/retry payload: the time keys are summed and the percentage is recomputed from the sums, and the roll-up keeps a retry label's percentages out of the maximum. The timing tests script the payload keys the actor really emits. On the single-controller path nemo_gym_infra_redispatches counted every row sent again after an attempt ended without it, stream death included, while the driver path counts only the rows a failure marker named. Both paths now count marked rows only; a stream-death re-send is still counted by the attempt counter. The unread failure-class key is removed, the two tests of the one failure-row membership rule are one parametrized test, and the actor's timing read is typed as the float the sum reduction yields. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: alexandery <[email protected]>
…lout id On the single-controller path under token capture, a row whose /run failed at the infrastructure level was dispatched again as the same row dict, so the second session ran under the first session's gate rollout id. The capture ledger is keyed by that id and admits a second root under a live id, and the receipt builder cannot tell the two chains apart: without a witness its heuristic walks the root admitted first, the failed session's, and a failure row of either session poisons the receipt of the other. A row that carries a gate rollout id is now never dispatched again inside the attempt loop. Under sibling recovery the stream drains so the siblings that land are sealed, and the marked row ends the attempt with the transport error the recovery loop retries; that retry mints a fresh attempt, and with it a fresh gate rollout id, for every sibling that did not seal, which is the only place an attempt can be bumped. Prompt-group recovery already dispatched once per attempt and keeps ending the attempt at the first marker, since the whole cohort is replaced. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: alexandery <[email protected]>
…-check-during-collection
…ing label once The metric key nemo_gym_infra_redispatches and the retry timing label were spelled on both rollout paths. The key is now a constant in rollouts.py and the label comes from one helper there, both used by the driver's stream merge and by the single-controller attempt loop. One label means one payload, so the single-controller path now adds its later attempts' timing up under <instance>/retry the way the driver's stream merge does. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: alexandery <[email protected]>
…andery/gym-health-check-during-collection
|
Pushed a merge of main and of the updated #4446 base (stack refresh, no commit of its own). Tests: test_rollouts.py 105, test_rollout_manager.py 71, test_rollout_generation_failures.py 44, test_nemo_gym.py 57, test_failures.py 60, test_nemo_gym_router.py 18, test_nemo_gym_health.py 9 passing locally. |
|
/ok to test 408ff6e |
Brings in the raised nightly GPU-hour cap (#4802) so L0_Unit_Tests_Other passes; no change of this branch's own code. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: alexandery <[email protected]>
Brings the base branch forward, which carries main's raised nightly GPU-hour cap (#4802) so L0_Unit_Tests_Other passes; no change of this branch's own code. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: alexandery <[email protected]>
|
/ok to test 96f0d1b |
main gained #4472 (Super video RL data and model loading), which added an import of verify_static_video_media_alignment to rollouts.py at the line where this branch imports GymTransportError; the resolution keeps both imports in module order. The other files #4472 and this branch both touch (nemo_gym.py, rollout_manager.py, test_nemo_gym.py, test_rollouts.py) merged without conflict, and the rollout, rollout-manager, failure, router and Gym environment unit tests pass locally on the merged tree. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: alexandery <[email protected]>
…andery/gym-health-check-during-collection Carries the base branch's merge of main, which brought in #4472 (Super video RL data and model loading). The only textual conflict, two imports added at the same line of rollouts.py, was resolved on the base branch; this merge applied cleanly, and the rollout, rollout-manager, failure, router and Gym environment unit tests pass locally on the merged tree. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: alexandery <[email protected]>
|
/ok to test fc2d619 |
linj-glitch
left a comment
There was a problem hiding this comment.
Reviewed at fc2d619. No blocking correctness or logic issues found. Reviewed the full diff, including the inherited typed-failure/redispatch stack. The health probe and configuration-read timeouts are bounded, and the retry/capture paths retain their intended safeguards.
Validation: 370 targeted tests passed. No new model-training or inference integration run was performed. Required CI checks passed on this head.
Stacked on
alexandery/gym-typed-failures-and-redispatch; review the commits after that branch only.What does this PR do?
While the driver waits for NeMo-Gym rows, a Gym server process that has died goes unnoticed: the rows it owned never arrive, and the step waits on them until the walltime guard ends the job.
NemoGymalready has ahealth_checkmethod that raises when one of its server processes has exited; nothing called it during collection.With
env.nemo_gym.health_check_interval_secondsset, the merged stream of actor rows (_merge_nemo_gym_instance_streamsinnemo_rl/experience/rollouts.py) waits at most that long for the next row. When the interval passes without a completed row, every actor of the shard set is health-checked (_check_nemo_gym_health), with the same interval as the probe's own bound:NemoGymis an asyncio actor, so a live actor whose event loop is blocked, or whose process is stopped, never resolves the call, and an unbounded probe would be the hang this check exists to end. A failed or unanswered check ends the rollout withGymTransportError, which the driver already classifies as an infrastructure failure. A healthy check resumes the wait.Design note
env.nemo_gym.health_check_interval_seconds(optional, default absent or null = today's unbounded wait; a set value must be positive) is a driver-side key:_build_gym_actor_configkeeps it out of Gym's global configuration (it joinsDRIVER_ROLLOUT_KEYS),NemoGym.rollout_confighands it back, andrun_async_nemo_gym_rolloutreads it there unless a caller passeshealth_check_interval_seconds, so every caller of the rollout function polls the same way. For the synchronous callers (grpo.py,ppo.py,distillation.py) the error ends the run, since they have no retry around the rollout;run_nemo_gym_rollout_sync's raises section says so.health_check_interval_secondsandmax_infra_attempts_per_rollout) are documented, off by default, as comments inexamples/nemo_gym/grpo_nanov3.yamland in theenv.nemo_gymblock ofdocs/design-docs/nemo-gym-integration.md.Issue
No issue filed; observed when a Gym verifier process died mid-step and the step waited on its rows until the job's walltime guard fired.
Validation
tests/unit/experience/test_rollouts.py,tests/unit/experience/test_rollout_manager.py,tests/unit/environments/test_nemo_gym_actor_config.py: 116 passed on this branch. Tests: healthy polls keep the wait going until the row completes (two checks counted), a failing check ends the rollout withGymTransportErrorafter one check, a probe that never answers ends it withGymTransportErrorfromTimeoutErrorafter the interval, the accessor's validation, the actor-config split, and both reliability knobs read from the actor's configuration together.pre-commit run --files <changed files>: ruff, ruff-format, end-of-file, trailing-whitespace, and the recipe minimize check pass; thepyreflyhook cannot build its environment in this checkout (no submodules), sopyrefly checkwas run directly on the touched modules with the project interpreter: the same 9 pre-existing findings asmain, none new.🤖 Generated with Claude Code