Repository navigation
feat(telemetry): count finished rollouts by outcome, class and reason - #3638
Conversation
f432649 to
3dd46bb
Compare
|
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. |
878fa72 to
ae7d23d
Compare
3dd46bb to
09f7dff
Compare
ae7d23d to
950e42b
Compare
09f7dff to
44c2c9c
Compare
950e42b to
22351ab
Compare
44c2c9c to
21f274a
Compare
21f274a to
4496177
Compare
|
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 A few things to address during that adaptation:
The telemetry addition can stay separate from #3302; it just needs to follow the new persistence and failure contracts. |
|
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 |
4496177 to
e3a1094
Compare
044f379 to
9d9a108
Compare
…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]>
9d9a108 to
b3e698d
Compare
|
Thanks @yuhezhang-ai. Both points are addressed: the metric now only emits a registered or : namespaced |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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.
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/38030159069 |
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]>
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:nemo.gym.rollout.outcome)scoredfailedomittedRows drained by the dispatch budget never ran and are not counted. This differs from the progress metrics, whose
droppedgroupsfailedwith anomittedthat includes drained rows.Attributes, all bounded:
nemo.gym.rollout.dispatch.namenemo.gym.failure_class_ng_failure_class(infrastructure_error,agent_request_failed,agent_run_error,judge_failed, ...)nemo.gym.failure_kindfailure_kindif registered innemo_gym.failure_kindsor<server>:<kind>namespaced; any other value is recorded asunregistered. The shared validator is unchanged.nemo.gym.failure_type_ng_failure_type, the exception class nameFailure 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_typefrom the trial'sexception_info.exception_type(orMissingOfficialReward) 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
/runinside one dispatch is not. Coverage comes from the output files, not this counter. Onlyrun_from_config(gym eval runwith serving) records it;--no-serve,run_examplescallers, reverification and the GDPVal multistage driver do not. A failed/runis afailedattempt with classagent_request_failedonly withroute_failures_to_sidecaron; otherwise it aborts the run.Gated by the
rolloutspan group, which is in Gym's default set. No-op without telemetry. Documented inobservability/metrics.mdx.Why
Dashboards could not show "how many rollouts did this run lose, and to what": the agent answers
/runwith 200 whether or not the rollout scored, thegym.rolloutspan carries no status, and the driver's classification went only to therollouts_failures.jsonlsidecar and a log line. On a degraded sandbox provider a full Terminal-Bench 4 run lost 60 of 66 rollouts toSandboxApiException; 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 afinallyaround the/runrequest. That measures the transport: a/runthat 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.rolloutspan 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 therolloutspan 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.omittedcall, recording it asfailed, gating on another span group, dropping theunregisteredbucket, or reading the type on scored rows each fails a test.pre-commiton 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.
scoredrollouts.jsonl(all reward 0: a wrong answer is stillscored)failed,infrastructure_error/VerifierTimeoutErrorrollouts_failures.jsonl, same class and typefailed,infrastructure_error/SandboxApiExceptionrollouts_failures.jsonl, same class and typeEvery point carries
nemo.gym.rollout.dispatch.name="terminal_bench_4_miniswe". Nofailure_kindappears 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 acrossSandboxTimeoutException,VerifierTimeoutErrorandRewardFileNotFoundError) and an 8-task run (8 scored).Compatibility
Additive; one new instrument, no config change. Supersedes the
gym.rollout.completed_totalin #2935 (different recording site and attribute set; drops out on its rebase) and the never-openedgym.rollout.failuresproposal.🤖 Generated with Claude Code