Skip to content

feat(eval): give the in-process API a typed rollout outcome - #5595

Merged
iguehring-nvidia merged 11 commits into
mainfrom
iguehring/in-process-outcome
Nov 9, 2026
Merged

iguehring-nvidia merged 11 commits into
mainfrom
iguehring/in-process-outcome

Conversation

@iguehring-nvidia

@iguehring-nvidia iguehring-nvidia commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Gives the in-process API a typed outcome per rollout, so a caller outside Gym reads one stable shape instead of the raw keys of /run responses. A failed /run comes back as an outcome too, instead of raising.

What changed

  • run_task runs one rollout per task (num_repeats is gone) and returns its RolloutOutcome: reward, failure, masked, prompt, output and raw, Gym's /run response (left out of repr and comparison). TaskResult is gone.
  • reward is None when none exists, as for a failed /run. A masked rollout keeps the reward the verifier returned; masked says it is not a valid measurement, and a caller that computes scores must leave it out.
  • TaskFailure reports what Gym observed: kind, source, delivery, stage, terminal, reason, http_status, exception_type. domain (the layer) and evaluation_side (an evaluation fault, or the model's own outcome) are properties derived from kind. kind is always set: the named cause, else environment_server_failed or agent_request_failed.
  • run_task uses run_outcomes, so a failed /run no longer raises. run_outcomes takes max_num_tries and connect_grace_s; run_task passes the bounds of gym eval run (2 tries, 60 s).
  • plan_benchmark, serve_benchmark, TaskRunner and run_task carry @experimental (a warning once per process), and the docs say the in-process API is experimental.

Decisions

  • Gym reports, the caller decides: whether to retry, or to count a failure in a score, is not Gym's call here. delivery is the evidence for a retry decision; terminal is only the reporter's statement.
  • delivery is Gym's inference from the status and the connection evidence, not something the agent server reports.
  • failure follows failure_kind, as before: a result with a kind and a reward carries both.

Behavior changes

Validation

  • Unit tests: tests/unit_tests/environment, test_public_api.py, rollouts/test_rollout_recovery.py (including the refused-connection and dropped-connection paths of run_outcomes), utils and core/test_failure_kinds.py: 1269 passed. One test, test_benchmarks.py::...test_every_repo_benchmark_appears_in_listing, fails here and on the base because it needs a host name this machine cannot resolve. ruff is clean.
  • Run against real Gym servers with the environment server killed: the refused-connection path ends as not_sent after the grace. Not run: the full suite, import-linter.

@copy-pr-bot

copy-pr-bot Bot commented Nov 4, 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.

@svcnvidia-nemo-ci svcnvidia-nemo-ci 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.

SHIP

LGTM — no concerns found. I inspected all seven changed files and traced the outcome mapping through the collector and verifier response contracts. The new fields preserve reward/result alignment, and the public exports and documentation match the additive API change.

Static review only; I did not execute tests.

Note: formal approval is not available for this request, so this review is posted as a comment only.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

…and the raw result

A task is always run once, so run_task drops num_repeats and the repeat suffix of the rollout id, and TaskResult holds the typed outcome and the raw /run result instead of parallel lists.

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

A task runs one rollout, so TaskResult only wrapped the outcome, the task id the caller already has, and the raw /run response. The raw response is now a field of RolloutOutcome that is left out of repr and comparison.

Signed-off-by: Ingo Guehring <[email protected]>
… which exceptions propagate

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

Copy link
Copy Markdown
Contributor Author

/review

@svcnvidia-nemo-ci svcnvidia-nemo-ci 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.

SHIP

No qualifying findings in this follow-up. I checked single-rollout dispatch and cleanup, the outcome and failure contracts, and the public exports against the documentation and regression assertions. One delegated report wasn't available; I inspected its outcome-mapping topic directly.

The previous review was clean, so there were no unresolved findings to verify. Its reviewed tree isn't mounted, and the supplied diff is the full PR diff, not the inter-review delta. I couldn't independently establish that delta and found no qualifying regression proven introduced since the previous review. This approval is limited to the follow-up scope.

Static review only; I did not execute tests.

Review generated by codex. This was a findings-only review. Request a full review with /review reset=true.

run_outcomes takes max_num_tries and connect_grace_s and forwards them; run_task passes 2 and 60 s, the bounds of gym eval run. A dead environment server now fails the trial as a typed failure after a minute instead of being retried for ever, and the failure record can say not_sent. Found by killing the environment server during an end-to-end run.

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

@AdamRajfer AdamRajfer 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.

Verdict: no formal blockers, but I would fix findings 1 to 3 before merge, because they decide whether a caller can tell a model result from an evaluation fault. The direction is good: a failed /run no longer raises, reward=None for it is the right choice (not a zero), raw is kept out of the contract, and the retry bound on the connection mirrors gym eval run. I checked out the head (deffb89), ran the PR's tests plus test_failure_kinds and the run_outcomes test (201 passed), and called _outcome directly with Gym's own lost_session_verification(...) result. Not verified: a live failed /run, the connect-grace loop against a real refused connection (the tests only check that the bounds are forwarded), the full suite, import-linter.

Lens tags: [contract] failure handling, [day-0] genericity and docs, [quality] general.

  1. [contract] A masked, evaluation-side result still surfaces reward=0.0. nemo_gym/environment/in_process.py:337-358. lost_session_verification() (server_runtime/base_resources_server.py, "a reward of 0 would read as a policy that solved nothing") returns reward 0.0, mask_sample True, failure_kind session_lost. _outcome passes it through as RolloutOutcome(reward=0.0, masked=True, failure=session_lost). I ran this. The docs example is print(outcome.reward) and the docstring says "an infrastructure failure is not a score of zero", but a caller that averages .reward and ignores .masked counts a lost session as a model zero. The new test case for session_lost (test_in_process.py:126) has no mask_sample, so it does not cover the realistic shape. Suggest either reward=None when mask_sample is true (the verifier says that reward is not a measurement), or keep the value but document it loudly and add a single scored property (reward is not None and not masked) used in the example. Add a test with mask_sample: True.

  2. [contract] domain is not a fault-side signal, and the docs tell callers to group by it. in_process.py:129-137, index.mdx:135. model_request_error (the model's own outcome, in MODEL_FAULT_KINDS) and model_transport_error (a server fault, evaluation-side) are both domain model. agent_timeout (model fault) and agent_run_error / agent_request_failed (evaluation-side) are both agent. Gym already has the classification (core/failure_kinds.py: is_evaluation_side, MODEL_FAULT_KINDS), but the outcome does not expose it. A caller that wants to retry environment faults and keep model results has to re-derive this, and grouping by domain will retry model-caused failures or count evaluation faults as the model's. Suggest a field or property on TaskFailure such as evaluation_side: bool | None (None for unregistered or namespaced kinds), and rewrite the "group by domain" sentence so it does not imply domain is a fault class.

  3. [contract] The retry-relevant evidence is dropped. in_process.py:360-369, PR description "ignores delivery". For a failed /run, delivery (not_sent / possibly_delivered / delivered) is the only thing that says whether resending could start a second episode. run_task itself now produces not_sent after the 60 s grace. With it removed, and terminal=False as the default, a caller cannot distinguish "the reporter did not say" from "safe to retry", so a retry decision can go wrong in either direction. Suggest exposing delivery on TaskFailure (it is already on the record), or at least making terminal tri-state / documenting that False is not a retry hint. Also, masked is False for a failed /run even though it has no usable sample, while the same fault reported by the environment is masked=True; a caller counting masked rows misses these. Document it or derive it.

  4. [quality] Backward compatibility. index.mdx and in_process.py previously promised additive-only changes with deprecation first (from #5593); this PR removes TaskResult and num_repeats and rewrites that promise as experimental. It is disclosed, and fine if #5593 has not shipped in a release (not verified), but please say so in the description. Stale text remains in tests/unit_tests/test_public_api.py:83 and :115 ("needs a deprecation first"). The refused-connection bound (2 tries, 60 s) is also a behaviour change for run_task (it used run_examples, unbounded), but it is not in the "Behaviour change" list.

  5. [quality] Tests prove shape, not behaviour of the new retry path. test_rollout_recovery.py only checks that run_outcomes forwards _max_num_tries and _connect_grace_s; nothing exercises the loop at rollout_collection.py:5252-5280 (refused until grace ends gives not_sent; connected then dropped gives possibly_delivered) through run_task. A small fake server or patched server_client.post raising ClientConnectorError would cover it.

  6. [day-0] Docs are readable for a newcomer, but two things are missing. (a) kind values are only described by example; link to nemo_gym/core/failure_kinds.py as the vocabulary and say that <server>:<kind> kinds are an environment's own. (b) prompt and output are JSON text of responses_create_params.input and response.output; say they are None for environments that do not use that shape (native episode results), as the code does. Style: the long unwrapped lines in index.mdx (the failed-/run paragraph and the raw paragraph) and the oddly wrapped module docstring at in_process.py:29-33 should be reflowed.

  7. [quality] Minor. @experimental on plan_benchmark, serve_benchmark and TaskRunner.__init__ prints a stderr warning on every call; run_task, the method that changed, does not warn. If the point is to mark the API, consider warning once per process. The __qualname__ change in utils/decorators.py is fine and affects only methods.

No internal or sensitive material seen in the diff; nothing here changes the training or evaluation reward path (run_examples is untouched).

TaskFailure exposes evaluation_side and delivery, and the docs say that domain is a layer, not a fault class, and that terminal is not a retry hint. A masked rollout keeps the reward the verifier returned and the docs tell a caller that computes scores to leave masked rollouts out. Tests send a refused and a dropped connection through run_outcomes. The in-process API warns once per process through experimental(once=True), which leaves the other experimental commands warning on every call. The docs, the pins and the module docstring are corrected and reflowed.

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

Copy link
Copy Markdown
Contributor Author

@AdamRajfer thank you for the thorough review. All of it is in one commit, 288d78b16, which replaces the head you reviewed (deffb89).

  1. Masked reward. I kept the reward the verifier returned and did not set it to None. masked says the reward is not a valid measurement, and the RolloutOutcome docstring and the API page now say that a caller that computes scores must leave masked rollouts out. The test cases now include the lost-session shape (mask_sample plus session_lost). I did not add a scored property; I can if you prefer one.
  2. Fault side. TaskFailure.evaluation_side is True for an evaluation-side kind, False for a model fault, and None for a kind outside the vocabulary (built on is_evaluation_side and is_registered). The docs no longer imply that domain is a fault class.
  3. Delivery. TaskFailure.delivery is exposed. The docs say it is the evidence for a retry decision and that terminal=False is not a retry hint. masked for a failed /run is documented (no sample: masked is False and reward is None) rather than derived.
  4. Compatibility. The description now lists the behavior changes, including the connection bound, and says the additive-only promise is dropped for the experimental API. I have not checked whether feat(eval): plan a benchmark, serve it and run single tasks in-process #5593 shipped in a release. The stale "needs a deprecation first" comments in test_public_api.py are reworded.
  5. Retry path. Two tests send a refused and a dropped connection through run_outcomes with a patched post: a refused one is resent within the grace and ends not_sent; a dropped one ends possibly_delivered and is not resent.
  6. Docs. The kind vocabulary is named, prompt and output are documented as None for native results, and the long lines and the module docstring are reflowed.
  7. Decorator. experimental takes once=True, and plan_benchmark, serve_benchmark, TaskRunner and run_task use it. I first made the shared decorator warn once per process, which failed test_the_experimental_warning_goes_to_stderr in CI, so the default stays one warning per call.

Not run: the full suite, import-linter, a live exporter.

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

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

This branch was previously deployed

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

Labels

area:evaluation Evaluation, rollout collection, reward profiling, comparison, and exporters feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants