Skip to content

feat(nemo_gym): typed /run failure rows and bounded re-dispatch - #4446

Closed
alexandery-nvidia wants to merge 20 commits into
mainfrom
alexandery/gym-typed-failures-and-redispatch
Closed

alexandery-nvidia wants to merge 20 commits into
mainfrom
alexandery/gym-typed-failures-and-redispatch

Conversation

@alexandery-nvidia

@alexandery-nvidia alexandery-nvidia commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

A NeMo-Gym /run that fails currently ends every rollout still in flight: the actor's stream raises, the driver loses the other rows of that stream, and one dead engine costs the whole step.

Two changes, both in the driver's NeMo-Gym rollout path:

  1. Typed failure rows. The NemoGym actor asks Gym's rollout collector for a failure row instead of an exception (route_failures_to_sidecar=True, the collector's existing contract), so the stream survives the failed row. The row carries the failure's class, HTTP status, type, message, and response body as plain values, and _typed_gym_failure in nemo_rl/environments/nemo_gym.py classifies it on the actor side with the one http_status_is_infra rule the driver applies: a 5xx, a retriable 4xx, a status below 400 on a request that still failed (the reply broke after its status line: the body read or parse failed, as when a relayed multi-megabyte response is cut mid-body), or a row without a status (a connection failure or a timeout before any reply) becomes GymTransportError; only a non-retriable 4xx describes the request and becomes RolloutDataFailure. The detail names the failure type, because the type (a payload or JSON decode error) is the diagnosis when the status says success. 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) while the other rows keep running. A scoreable result that only carries _ng_failure_class (Gym's judge failsafe) is still postprocessed like any result.
  2. Bounded re-dispatch. run_async_nemo_gym_rollout in nemo_rl/experience/rollouts.py dispatches a marked row again as a fresh single-row stream on the instance whose stream reported the failure, up to env.nemo_gym.max_infra_attempts_per_rollout attempts in total; the last failure raises GymTransportError with the failure's detail. The retry stays on its own instance because bucketing is by prompt group and a group split across instances deadlocks verifiers that buffer whole groups; a dead engine is not the instance's fault, since every instance holds the same engine URLs and Gym picks the engine per request. The merge of the per-instance streams requires two callbacks, the per-row budget and the timing sink, and records each stream's actor timing itself: a failure marker can be the tuple that carries a stream's timing, and a retry stream reports under its own <instance>/retry<n> label, so the timing metrics of a step with a re-dispatch are the buckets' totals. The _NemoGymStreamAccumulator keeps the per-row budget, and the final rollout metrics report nemo_gym_infra_redispatches, the number of rows dispatched again, on every rollout, zero included, so a mean over steps is a rate. The single-controller path (rollout_manager.py) leaves a marked row's slot empty so its own attempt loop dispatches it again, reports the same nemo_gym_infra_redispatches count in the rollout's metrics, reports a later attempt's actor timing under <instance>/retry<n> so a one-row re-dispatch never replaces the group's totals, and when a row runs out of attempts there, the final error names the marker's detail (and any row that never arrived) instead of reporting a stream that ended early.

Design note

  • env.nemo_gym.max_infra_attempts_per_rollout (optional, default 1 = today's single attempt) 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 (DRIVER_ROLLOUT_KEYS); NemoGym.rollout_config hands it back, and the rollout function reads it there unless a caller passes it, so every caller of the rollout function (synchronous GRPO, the asynchronous trajectory collector, PPO, distillation) applies the same configured value. The single-controller path keeps its own RolloutRetryPolicy.max_gym_row_attempts, whose comments in the single-controller config and its two exemplars now describe the marker. The key is NotRequired on the NemoGymConfig TypedDict; an absent key means the default; the exemplar examples/nemo_gym/grpo_nanov3.yaml and docs/design-docs/nemo-gym-integration.md carry it.
  • Relation to Gym's own contracts: Gym's collector gained a dispatch budget and an opt-in failure-retry contract, and its verify response carries failure_kind/failure_reason. Those act inside one Gym collection. This change is the NeMo-RL-side counterpart: it consumes the typed failure row the collector already produces and decides, on the driver, whether a row lost to infrastructure is dispatched again as a new session. The driver budget, the single-controller RolloutRetryPolicy.max_gym_row_attempts, and its max_attempts_per_prompt stay separate knobs; the docstring of get_nemo_gym_max_infra_attempts says why.

Issue

No issue filed; observed in multi-engine training runs where one engine process died mid-step and every rollout pinned to it failed with a 5xx, which ended the step for the other rollouts too.

Validation

  • tests/unit/environments/test_nemo_gym.py, tests/unit/environments/test_nemo_gym_health.py, tests/unit/environments/test_nemo_gym_actor_config.py (new), tests/unit/experience/test_rollouts.py, tests/unit/experience/test_rollout_manager.py, tests/unit/experience/test_failures.py, tests/unit/experience/test_nemo_gym_router.py, tests/unit/experience/test_rollout_generation_failures.py: 302 passing on this branch rebased onto main e1a2e9a; tests/unit/data/test_captured_media.py (the nemo_gym lane), whose retained-media test now hands _typed_gym_failure the failure row the collector produces, passes with --nemo-gym-only. Tests cover the failure-row classification on both sides of the pickling boundary for statuses 0 through 503 (one rule below 400 as well), the marker row yielded by _stream_rollouts for a 5xx and the data failure raised for a 4xx, the class-annotated judge row that is still scored, the accumulator's budget, re-dispatch through run_async_nemo_gym_rollout (the metric, the exhausted-budget error, a two-replica shard set whose retry goes back to the failing replica, a bucket's timing surviving a one-row retry that finishes last, and a retry stream that fails again and is dispatched a third time under its own retry label), the actor-config split, and the single-controller path re-dispatching only the failed row, counting it in nemo_gym_infra_redispatches (and reporting zero for a clean group), keeping the group's timing across the re-dispatch, and naming the failure detail and the rows that never arrived when the budget runs out. The nemo_gym CI lane's GPU tests pin the metric on both paths: test_run_async_nemo_gym_rollout lists it among the driver's metric keys, and test_async_nemo_gym_rollout_manager_matches_original requires every driver key, this one included, from the manager.
  • pre-commit run --files <changed files>: ruff, ruff-format, and the recipe minimize check pass; the pyrefly hook needs the submodules, which this checkout lacks, so the type check is CI's lint job.
  • Rollout evidence: this change has run for weeks in a downstream fork's GRPO training with NeMo-Gym agent environments on Slurm clusters; with a budget of 3, rows lost to dead engines were dispatched again and the steps completed instead of failing. Those runs were unsharded, which is why the replica split did not show.

🤖 Generated with Claude Code

@copy-pr-bot

copy-pr-bot Bot commented Oct 3, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@terrykong terrykong left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asolergi-nv can you help review?

@terrykong
terrykong requested a review from asolergi-nv October 6, 2026 23:52
@alexandery-nvidia alexandery-nvidia changed the title feat(nemo_gym): typed /run failure rows and bounded re-dispatch of rows lost to infrastructure feat(nemo_gym): typed /run failure rows and bounded re-dispatch Oct 10, 2026
@alexandery-nvidia
alexandery-nvidia marked this pull request as ready for review October 10, 2026 08:13
@alexandery-nvidia alexandery-nvidia added the CI:L0 Run doctests and unit tests label Oct 12, 2026
@alexandery-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test ebffc0e

@alexandery-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test 04c6fbd

@alexandery-nvidia
alexandery-nvidia force-pushed the alexandery/gym-typed-failures-and-redispatch branch from ebffc0e to 04c6fbd Compare October 12, 2026 19:52
@github-actions github-actions Bot added the Documentation Improvements or additions to documentation label Oct 12, 2026
@alexandery-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test e0b2859

@alexandery-nvidia
alexandery-nvidia force-pushed the alexandery/gym-typed-failures-and-redispatch branch from 04c6fbd to e0b2859 Compare October 12, 2026 20:10
alexandery-nvidia and others added 9 commits October 12, 2026 17:40
…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]>
@alexandery-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test 1592ea4

@alexandery-nvidia
alexandery-nvidia force-pushed the alexandery/gym-typed-failures-and-redispatch branch from e0b2859 to 1592ea4 Compare October 13, 2026 00:47
@terrykong terrykong added CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) and removed CI:L0 Run doctests and unit tests labels Oct 13, 2026
…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]>
@alexandery-nvidia

Copy link
Copy Markdown
Contributor Author

Merged main after #4435's squash (c30bbd4) as 9be9fec: both sides had appended tests to tests/unit/experience/test_rollouts.py (and, where this branch touches it, the neighboring file), and both 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. A merge commit, not a rebase, so the review history stands and the head is current with main. Local gate on the merge head: pre-commit clean on the changed files; tests/unit/experience (rollouts, rollout_manager, failures, nemo_gym_router), tests/unit/environments (nemo_gym, actor config, health) and tests/unit/data/test_captured_media.py: 263 passed.

@alexandery-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test 9be9fec

alexandery-nvidia added a commit that referenced this pull request Oct 15, 2026
…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]>

@yaoyu-33 yaoyu-33 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. Keeping the other rows of a stream alive when one /run dies is a real improvement, and consuming Gym's existing route_failures_to_sidecar failure-row contract is the right way to do it. I checked the contract against the pinned Gym (da9f671): the key names match _agent_request_failure_row, only ClientError/JSONDecodeError/TimeoutError become rows, _rowidx survives, and the status rule (including below 400) matches what the collector produces. Re-dispatch index alignment, attempt counting, the per-label timing and the finally cancellation all behaved correctly in a stubbed run of the merge and accumulator. The merge of main (9be9fec) matches git's own merge apart from the test conflict, and #4749 applies cleanly on top.

Inline: the failure-row check (_ng_failure_type is also stamped by a verifier), the single-controller marker path with cohort verifiers, and data failures being masked by a later budget exhaustion.

A question on the motivation. Gym's vllm_model picks the engine by hashing a fresh session id (vllm_model/app.py#L1790-L1798), and route_around_failing_endpoints defaults to False (#L357); NeMo RL sets neither it nor endpoint_file. So each re-dispatch lands on the dead engine again with probability 1/E, and with E=8 engines and a budget of 3, a step with ~256 rows on the dead engine still fails ~98% of the time. Did the downstream runs have route_around_failing_endpoints on? If so, could the design doc recommend pairing max_infra_attempts_per_rollout with it? Also, an engine that refuses connections doesn't produce a 5xx at all: without endpoint_file the connection retries are unbounded (openai_utils.py#L1545-L1551), and Gym's internal client has no deadline (server_utils.py#L397), so the row hangs rather than yielding a marker. The "no status = connection failure or timeout" wording in _typed_gym_failure may want the same caveat.

Smaller things, no action required: with a cohort verifier (genrm_compare), a single-row retry reuses the group identity, so it only recovers failures before /verify (budget > 1 can't save a cohort that already failed); each re-dispatch gets its own retry<n> timing label (a dead engine adds many wandb series); nemo_gym_infra_redispatches is emitted only when non-zero, so the async collector averages over the non-zero groups; and int(value) accepts True/2.5 for the budget.

Local validation (CPU, macOS): the changed test files under tests/unit/experience and tests/unit/environments passed (204 + 103); the --nemo-gym-only lane of test_captured_media.py was not run.

Generated by Claude Code

Comment thread nemo_rl/environments/nemo_gym.py Resolved
Comment thread nemo_rl/experience/rollout_manager.py Resolved
Comment thread nemo_rl/experience/rollouts.py Resolved
alexandery-nvidia and others added 2 commits October 16, 2026 15:32
…ast attempt at a marker

Review follow-ups on #4446.

Only Gym's _agent_request_failure_row writes _ng_failure_http_status (None when
nothing replied), while a verifier may echo _ng_failure_type on a row it scored
(Terminal-Bench does, and the sandboxed agent returns that verify JSON as the /run
result). run_rollouts now recognises a failure row by the status key, so such a
verifier row is postprocessed like any result instead of ending the step at the
default budget.

Single-controller path: a failure marker now ends the last attempt at once
(_stream_rows stop_on_infra_failure). Nothing would re-dispatch the row after that
attempt, and a verifier that scores a prompt group together would otherwise hold the
stream open in /verify until its cohort timeout. The exemplar recipes say when to use
the prompt_group granularity and rollout_timeout_s instead of row re-dispatch.

Driver merge: once a data failure has ended the rollout, markers from the other
instances are no longer re-dispatched, so an exhausted budget cannot hide the 400
behind a transport error.

Also: the budget reader refuses a bool or a float instead of truncating it,
nemo_gym_infra_redispatches is reported on every rollout (zero included) so its mean
is a rate, the _typed_gym_failure docstring says why a refused connection yields no
status-less row, and the design doc recommends pairing the budget with
route_around_failing_endpoints in the vllm_model configuration.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: alexandery <[email protected]>
…failures-and-redispatch

main gained #4745, #4542 and #4596 since the previous merge, which put this head
eleven commits behind it; the merge keeps the head within main's up-to-date rule
for CI. No conflicts.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: alexandery <[email protected]>
alexandery-nvidia added a commit that referenced this pull request Oct 16, 2026
…andery/gym-health-check-during-collection

Picks up #4446's review follow-ups (failure rows keyed on the status key, the
single-controller last attempt ending at a marker, no re-dispatch after a data
failure) and its merge of main. No conflicts.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: alexandery <[email protected]>
alexandery-nvidia added a commit that referenced this pull request Oct 16, 2026
…river-loop only

Review follow-ups on #4447.

_nemo_gym_rollout_config bounds the rollout_config call
(NEMO_GYM_ROLLOUT_CONFIG_TIMEOUT_SECONDS) and raises GymTransportError on a miss. The
read is the first thing a rollout awaits, before the health check polls, and the
asynchronous trajectory collector retries a failed batch against the same actors, so
an actor whose event loop is blocked would otherwise turn the probe's timeout into a
retry that hangs.

The design doc, the nanov3 recipe and the two docstrings say that
health_check_interval_seconds and max_infra_attempts_per_rollout belong to the driver
rollout loop (synchronous GRPO, the asynchronous collector, PPO, distillation) and
that the single-controller rollout manager reads neither: it bounds a rollout with
rollout_timeout_s and re-dispatches rows under max_row_attempts.

The health-polling test expects nemo_gym_infra_redispatches to be reported as zero,
since #4446 now reports the count on every rollout.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: alexandery <[email protected]>
@alexandery-nvidia

Copy link
Copy Markdown
Contributor Author

Thanks for the review. The three inline threads are answered; the fixes are in 19a06a5, and 907d2e7 merges main (the head had fallen eleven commits behind after today's merges; no conflicts).

On the motivation question: yes, the downstream runs set route_around_failing_endpoints: true in their vllm_model configuration, and you are right that the budget alone would mostly re-land on the dead engine. The design doc now says to pair max_infra_attempts_per_rollout with that setting, with the one-in-E arithmetic, and that an engine refusing connections yields no marker at all, because Gym's internal client retries a refused connection without bound unless an endpoint_file is configured and its session sets no total deadline; _typed_gym_failure's docstring carries the same caveat on the "no status" wording.

On the smaller things: the budget reader now refuses a bool or a float instead of truncating; nemo_gym_infra_redispatches is reported on every rollout, zero included, so its mean is a rate; the cohort-verifier limitation of a single-row retry is in the exemplar recipes next to max_row_attempts. The per-re-dispatch retry<n> timing labels are unchanged: each re-dispatch keeps its own duration attributable, and the count is bounded by the budget per row. If fewer series matter more, an attempt-indexed label is a small change.

Gate on 19a06a5: tests/unit/environments/test_nemo_gym.py 51 passed, tests/unit/experience/test_rollout_manager.py 66, test_rollouts.py 60, test_failures.py 60, test_nemo_gym_actor_config.py 2, test_nemo_gym_router.py 18, and tests/unit/data/test_captured_media.py --nemo-gym-only 73. On the merged head 907d2e7, in a venv built from the merged lock, the same files give 51, 68, 71, 60, 2 and 18; the --nemo-gym-only lane needs the Gym submodule, which that environment lacks, so CI covers it on the merged head.

@alexandery-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test 907d2e7

alexandery-nvidia added a commit that referenced this pull request Oct 16, 2026
…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]>
@alexandery-nvidia

Copy link
Copy Markdown
Contributor Author

The nemo_gym CI lane on 907d2e7 failed on the always-reported nemo_gym_infra_redispatches metric (the review's no-action note, taken in 19a06a5): test_run_async_nemo_gym_rollout lists the driver's metric keys and lacked it, and the lane's parity test test_async_nemo_gym_rollout_manager_matches_original requires every driver key from the single-controller manager, which did not report it. a73688d makes the manager's _run_rollouts count the rows it sends again across its later attempts and report them under the same key, zero included, and adds the key to the lane test. Two CPU tests pin the count: one row sent again counts one, and a clean group reports zero.

Gate on a73688d: tests/unit/experience/test_rollout_manager.py and tests/unit/experience/test_rollouts.py, 140 passed; ruff and pyrefly clean on the changed module. The nemo_gym lane needs the Gym submodule and a GPU, so CI is its run. The description's bounded re-dispatch and validation bullets now say the manager reports the count as well.

@alexandery-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test a73688d

…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]>
@alexandery-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test 8fecfa2

alexandery-nvidia and others added 4 commits October 19, 2026 18:43
…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]>
…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]>
@alexandery-nvidia

Copy link
Copy Markdown
Contributor Author

Pushed a merge of main plus three commits. (1) The retry timing of an instance folds into one <instance>/retry label whose percentages are recomputed from the summed times and kept out of the max roll-up, so the key set no longer grows with the failure rate; the single-controller path counts only marked rows as re-dispatches; the unused failure-class key is gone; the timing read is typed; the driver-path timing tests use the payload keys the actor emits and the two failure-row tests are one parametrized test. (2) Under token capture a row is never dispatched again under its gate rollout id inside the attempt loop: under sibling recovery the stream drains so landed siblings seal, the marked rows end the attempt with GymTransportError, and the recovery loop retries with a fresh attempt and gate id. (3) The re-dispatch metric key and the retry-label helper are defined once. Tests: test_rollouts.py 99, 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 passing locally.

@alexandery-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test e79f66a

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]>
@alexandery-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test d67d738

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]>
@alexandery-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test de0b842

@alexandery-nvidia

Copy link
Copy Markdown
Contributor Author

#4500 (merged as d3d22f1) put typed per-row /run failures on main. I compared this pull request with main at defdaef. Its typed failure rows, its status rules and its re-dispatch of a single row on the single-controller path are all on main, so I am closing it as superseded by #4500.

What main has now:

Two things differ on main, and I am not pursuing either here:

  • A complete reply with a status below 400 whose body is not JSON is a data failure on main. This pull request treated it as an infrastructure failure. The review of feat(checkpoint): add Gym turn-level rollout recovery #4500 chose the data class for that case on purpose.
  • This pull request also sent a single failed row again on the synchronous driver loop (run_async_nemo_gym_rollout), with the key env.nemo_gym.max_infra_attempts_per_rollout. On that path main ends the instance's stream at the first failed row and retries the whole batch (rollouts.py#L2574-L2580).

#4447 and #4448 are stacked on this branch. I will rebuild them on main without these commits.

Thank you for the review of this pull request.

🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) Documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants