Skip to content

feat(telemetry): count finished rollouts by outcome, class and reason - #3638

Merged
iguehring-nvidia merged 1 commit into
mainfrom
iguehring/rollout-outcomes
Oct 10, 2026
Merged

iguehring-nvidia merged 1 commit into
mainfrom
iguehring/rollout-outcomes

Conversation

@iguehring-nvidia

@iguehring-nvidia iguehring-nvidia commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Second split of #2935 agreed with @oyilmaz-nvidia: the rollout outcome counter, consolidated with the failure-class counter from the orchestrator branch. Reworked after review by @yuhezhang-ai and @ananthsub.

What

One counter, gym.rollout.completed_total, incremented in the collection driver's result-writing loop right after it writes the attempt or decides to omit it:

Outcome (nemo.gym.rollout.outcome) Recorded after
scored the result was written to the main output. Includes masked and forced-zero results, which are written but not necessarily scored.
failed the failure was written to the failures sidecar
omitted a no-persist result (e.g. kill-shaped) was written to neither file

Rows drained by the dispatch budget never ran and are not counted. This differs from the progress metrics, whose dropped groups failed with an omitted that includes drained rows.

Attributes, all bounded:

Attribute Set on Source
nemo.gym.rollout.dispatch.name every point the environment server, or the agent when rows name none
nemo.gym.failure_class attempts with a failure class the driver's _ng_failure_class (infrastructure_error, agent_request_failed, agent_run_error, judge_failed, ...)
nemo.gym.failure_kind attempts with a failure class the record's failure_kind if registered in nemo_gym.failure_kinds or <server>:<kind> namespaced; any other value is recorded as unregistered. The shared validator is unchanged.
nemo.gym.failure_type attempts with a failure class _ng_failure_type, the exception class name

Failure fields on a scored row are ignored, so a value echoed back through a verifier can't label it. Free-text failure reasons never become attributes.

Terminal Bench 4 now sets _ng_failure_type from the trial's exception_info.exception_type (or MissingOfficialReward) when the official reward is missing. The infrastructure-error branch carries free text from the termination detail and stays without a type.

Attempt semantics and scope. An attempt is one dispatch of one row in one collection run: a retry on a later resume run is another attempt, and an HTTP-level re-send of /run inside one dispatch is not. Coverage comes from the output files, not this counter. Only run_from_config (gym eval run with serving) records it; --no-serve, run_examples callers, reverification and the GDPVal multistage driver do not. A failed /run is a failed attempt with class agent_request_failed only with route_failures_to_sidecar on; otherwise it aborts the run.

Gated by the rollout span group, which is in Gym's default set. No-op without telemetry. Documented in observability/metrics.mdx.

Why

Dashboards could not show "how many rollouts did this run lose, and to what": the agent answers /run with 200 whether or not the rollout scored, the gym.rollout span carries no status, and the driver's classification went only to the rollouts_failures.jsonl sidecar and a log line. On a degraded sandbox provider a full Terminal-Bench 4 run lost 60 of 66 rollouts to SandboxApiException; that number should be a panel, not a grep.

Why at the verdict and not around the HTTP call. #2935 recorded gym.rollout.completed_total{outcome=success|timeout|failure} in a finally around the /run request. That measures the transport: a /run that returns 200 carrying an infrastructure-error row counts as a success there. In the run above, all 60 sandbox failures came back as HTTP 200. Recording where the driver writes its verdict sees the real outcome.

Not done here, and worth a follow-up in Gym's telemetry code: marking the gym.rollout span itself with an error status for failed rollouts, so they are findable in the trace backend too. The span lives in the agent server; the verdict is taken in the driver, so it needs a small protocol addition.

Validation

  • tests/unit_tests/telemetry/test_rollout_outcomes.py, against a real in-memory OTel reader: outcomes and bounded attributes; an unregistered kind is bucketed while registered and namespaced kinds pass; failure fields on a scored row are ignored; the helper is gated on the rollout span group specifically.
  • tests/unit_tests/test_rollout_collection.py: through the real dispatch loop, one omitted, one failed (HTTP 200 carrying the environment server's class and exception type) and one scored attempt, read back from the meter; the sidecar test asserts the transport failure's class and type; the dispatch-budget test asserts drained rows are not counted.
  • resources_servers/terminal_bench_4/tests/test_verified_response.py: the type is set from the exception type and for a missing reward, and never from the free-text detail.
  • Mutation checks: removing the omitted call, recording it as failed, gating on another span group, dropping the unregistered bucket, or reading the type on scored rows each fails a test.
  • Rollout collection, the telemetry test file and Terminal Bench 4 tests: 552 passed. pre-commit on the changed files: pass.

Rollout evidence

This revision (job-side Gym at this PR's code), Slurm cluster, Terminal-Bench 4 (mini-SWE) on OpenSandbox, Nano 3.5 on one node, metrics exported through the per-job OTLP collector. The counter's final values are compared with the driver's own output files, which are the ground truth, and with the values in the metrics backend.

Run Series Counter (job dir) Backend Files
8 tasks scored 7 7 7 lines in rollouts.jsonl (all reward 0: a wrong answer is still scored)
8 tasks failed, infrastructure_error / VerifierTimeoutError 1 1 1 line in rollouts_failures.jsonl, same class and type
2 tasks, invalid sandbox key failed, infrastructure_error / SandboxApiException 2 2 2 lines in rollouts_failures.jsonl, same class and type

Every point carries nemo.gym.rollout.dispatch.name="terminal_bench_4_miniswe". No failure_kind appears because Terminal Bench 4 sets none. Both types come from Terminal Bench 4's own trial result, which this revision now carries as _ng_failure_type; before it, these points had no type.

An earlier revision of this PR (labels outcome / failure_class / failure_reason, same recording point) matched the files exactly on a 66-task run (60 scored, 6 dropped across SandboxTimeoutException, VerifierTimeoutError and RewardFileNotFoundError) and an 8-task run (8 scored).

Compatibility

Additive; one new instrument, no config change. Supersedes the gym.rollout.completed_total in #2935 (different recording site and attribute set; drops out on its rebase) and the never-opened gym.rollout.failures proposal.

🤖 Generated with Claude Code

@copy-pr-bot

copy-pr-bot Bot commented Sep 22, 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.

@iguehring-nvidia iguehring-nvidia added the area:core Shared APIs, servers, telemetry, health, and registries label Sep 22, 2026
@iguehring-nvidia iguehring-nvidia self-assigned this Sep 22, 2026
@iguehring-nvidia
iguehring-nvidia force-pushed the iguehring/rollout-outcomes branch from f432649 to 3dd46bb Compare September 23, 2026 08:05
@copy-pr-bot

copy-pr-bot Bot commented Sep 23, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@iguehring-nvidia
iguehring-nvidia force-pushed the iguehring/sandbox-telemetry branch from 878fa72 to ae7d23d Compare September 23, 2026 08:13
@iguehring-nvidia
iguehring-nvidia force-pushed the iguehring/rollout-outcomes branch from 3dd46bb to 09f7dff Compare September 23, 2026 08:13
@iguehring-nvidia
iguehring-nvidia force-pushed the iguehring/sandbox-telemetry branch from ae7d23d to 950e42b Compare September 23, 2026 09:00
@iguehring-nvidia
iguehring-nvidia force-pushed the iguehring/rollout-outcomes branch from 09f7dff to 44c2c9c Compare September 23, 2026 09:00
@iguehring-nvidia
iguehring-nvidia force-pushed the iguehring/sandbox-telemetry branch from 950e42b to 22351ab Compare September 23, 2026 10:15
@iguehring-nvidia
iguehring-nvidia force-pushed the iguehring/rollout-outcomes branch from 44c2c9c to 21f274a Compare September 23, 2026 10:15
Base automatically changed from iguehring/sandbox-telemetry to main September 23, 2026 10:39
@iguehring-nvidia
iguehring-nvidia force-pushed the iguehring/rollout-outcomes branch from 21f274a to 4496177 Compare September 23, 2026 12:04
@iguehring-nvidia
iguehring-nvidia marked this pull request as ready for review September 23, 2026 12:25
@nemo-automation-bot
nemo-automation-bot Bot requested review from a team September 23, 2026 12:26
@yuhezhang-ai

Copy link
Copy Markdown
Contributor

Thanks for adding this visibility. This overlaps with #3302’s result-writing loop, so I’d suggest merging #3302 first and then rebasing this onto its RolloutStore flow.

A few things to address during that adaptation:

  • Failure labels: _record_rollout_outcome() reads failure_reason, but driver-generated transport failures store the exception name in _ng_failure_type, so timeouts currently lose that label. After feat(eval): persist failures and resume unfinished evaluations #3302, normalized failures also no longer have a top-level failure_reason.
  • Label cardinality: failure_kinds.py explicitly excludes free-form failure reasons from metric labels. The identifier regex doesn’t bound distinct values. Prefer an explicit exception-type attribute and preserve producer exception types through normalization.
  • Recording point and semantics: Record after store.record_outcome() / record_omission() succeeds, and document this as an attempt counter. A failed attempt followed by a successful retry contributes both dropped and scored; final rollout coverage comes from the store.
  • Masked results and omissions: Document that scored includes persisted masked results, which aren’t necessarily included in scoring. Intentional omissions should follow the store’s classification rather than introduce no_persist as a failure class.
  • Tests: Please assert the reason/type label through the actual driver for transport failures and normalized infrastructure failures. The current driver assertion checks only outcome and class.

The telemetry addition can stay separate from #3302; it just needs to follow the new persistence and failure contracts.

@iguehring-nvidia

iguehring-nvidia commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks @yuhezhang-ai for the quick review! Happy to wait until #3302 is merged and refactor. Do you have an idea when we can merge #3302 ? I see its already two weeks old.

@yaoyu-33 yaoyu-33 added blocked Work cannot move forward until an external dependency is cleared complexity:low Localized change in one scope with a small, straightforward review surface feature New capabilities, enhancements, or enablement work labels Sep 23, 2026
@yuhezhang-ai

Copy link
Copy Markdown
Contributor

Thanks @yuhezhang-ai for the quick review! Happy to wait until #3302 is merged and refactor. Do you have an idea when we can merge #3302 ? I see its already two weeks old.

Thanks. I think it will be merged soon. Wanted to get a final approval from @ananthsub

@github-actions github-actions Bot added the sla:review-overdue Review response is over the one-business-day SLA label Sep 24, 2026
@iguehring-nvidia
iguehring-nvidia force-pushed the iguehring/rollout-outcomes branch from 4496177 to e3a1094 Compare October 5, 2026 15:09
@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

…ind and type

One counter, `gym.rollout.completed_total`, incremented in the collection driver
right after it wrote the attempt or decided to omit it: `scored` after a success
reaches the main output, `failed` after a failure reaches the failures sidecar,
`omitted` for a no-persist result such as a kill-shaped failure. Rows drained by
the dispatch budget never ran and are not counted. It counts attempts: a failed
attempt followed by a successful retry on a later resume run contributes one of
each; coverage comes from the output files.

Every point carries the dispatch name. Attempts with a failure class also carry
three bounded attributes: the driver's `_ng_failure_class`, the `failure_kind`
when registered or namespaced (any other value is recorded as `unregistered`),
and `_ng_failure_type`, the exception class name. Failure fields on a scored row
are ignored. Free-text failure reasons are never attributes.

Terminal Bench 4 now sets `_ng_failure_type` from the trial's exception type
when the official reward is missing, so its infrastructure failures keep the
type label. The free-text termination detail stays out of it.

Supersedes the recording around the `/run` HTTP call in #2935: a 200 whose body
carries an infrastructure error is a failed attempt, which only the driver's
verdict knows.

Signed-off-by: Ingo Guehring <[email protected]>
@iguehring-nvidia

Copy link
Copy Markdown
Contributor Author

Thanks @yuhezhang-ai. Both points are addressed: the metric now only emits a registered or : namespaced failure_kind and buckets anything else as unregistered (the shared validator is unchanged), and Terminal-Bench 4 sets _ng_failure_type from exception_info.exception_type. The rollout-evidence section is re-run on this revision: Terminal-Bench 4 failures now arrive with their type (VerifierTimeoutError, SandboxApiException), and the counter matches the output files exactly.

@ananthsub ananthsub 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 the thorough follow-up @iguehring-nvidia! I've added a couple nits inline but these are not blcoking

"""The kind as a bounded label: registered or namespaced names pass, anything else is one bucket."""
if not isinstance(failure_kind, str):
return None
validate_failure_kind(failure_kind)

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.

Nit: this call is only here for its once-per-name warning, and its return value is discarded. Producers already ran the validator at their own boundary, so the warning has normally fired by now, and the label is bounded by the bucketing below. The one thing it adds is feeding every distinct unregistered value from a result row into the validator's process-wide warned-once set (_WARNED_UNKNOWN), which has no bound, so a producer that puts per-occurrence text in failure_kind grows it for the life of the run. Dropping the call (and validate_failure_kind from the import above) would remove that without changing any label.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks @ananthsub ! I will address all three non-blocking comments in a follow-up.

import nemo_gym.batch_status
import nemo_gym.rollout_collection
import nemo_gym.token_id_capture.delivery
from nemo_gym import rollout_collection

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.

Nit: this file already has import nemo_gym.rollout_collection on line 38, and the new tests now use both spellings (rollout_collection. in one, nemo_gym.rollout_collection. in the others) for the same patching. Using the existing spelling everywhere would let this import go.

_INSTRUMENTS.clear()


ROLLOUT_COMPLETED_INSTRUMENT = "gym.rollout.completed_total"

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.

Nit: the new constants and record_rollout_completed sit after _reset_for_testing, at the end of the module, while the other instrument and attribute names are declared in the block near the top and the recorders come before the test-only helper. Moving them up next to the others would keep the file in one order. Not blocking.

@iguehring-nvidia
iguehring-nvidia added this pull request to the merge queue Oct 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/38030159069

Merged via the queue into main with commit 7321716 Oct 10, 2026
49 of 51 checks passed
@iguehring-nvidia
iguehring-nvidia deleted the iguehring/rollout-outcomes branch October 10, 2026 06:28
iguehring-nvidia added a commit that referenced this pull request Oct 10, 2026
Follow-up nits from #3638:

- Stop calling validate_failure_kind() at the metric boundary. Producers
  already validate at their own boundary and the label is bounded by the
  `unregistered` bucket; the call only added every distinct unregistered
  value to the validator's process-wide warned-once set, which has no bound.
- Use the existing `nemo_gym.rollout_collection` import in the collection
  tests instead of a second spelling of the same module.
- Declare the counter's instrument and attribute names with the others at
  the top of gym_metrics.py, and place record_rollout_completed before the
  test-only helper.

Signed-off-by: Ingo Guehring <[email protected]>

This branch was previously deployed

1 inactive deployment
public — b3e698de Deployed Oct 10, 2026 by copy-pr-bot[bot] via release / finalize / notify #4962
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core Shared APIs, servers, telemetry, health, and registries blocked Work cannot move forward until an external dependency is cleared complexity:low Localized change in one scope with a small, straightforward review surface feature New capabilities, enhancements, or enablement work sla:review-overdue Review response is over the one-business-day SLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants