Skip to content

feat(rollouts): share severe text looping assessment - #6846

Open
u-brixton wants to merge 11 commits into
mainfrom
rzayashnikov/looping-runtime-eval
Open

u-brixton wants to merge 11 commits into
mainfrom
rzayashnikov/looping-runtime-eval

Conversation

@u-brixton

@u-brixton u-brixton commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Training and evaluation need the same severe text-loop label. Add one shared text detector and use it during Gym rollout collection.

  • LoopingAssessor.assess() accepts a response mapping or None and returns bool | None: detected, checked without finding a loop, or unavailable. Saved rows carry only is_looping.
  • Run bounded checks in a persistent CPU process pool. Capacity is reserved before preparing text and remains occupied until submitted work finishes, including after caller timeout or cancellation.
  • Preserve the flag through normal writing and reverification. Report looping/rate among checked completed outputs and looping/coverage among all completed outputs. Masked completed outputs count; failed or imputed zeros do not. Combined reports sum counts before deriving fractions.

Enable with ++assess_looping=true; it is off by default. LoopingLimits holds the shared resource bounds. GDPVal multistage collection rejects this option before preprocessing or dispatch until its driver supports assessment.

Companion NRL integration: training metrics and optional reward safeguard. No separate issue: this opt-in feature and the companion PR track the work.

Validation

1,617 CPU tests passed on Python 3.13.14 across the complete collection, reverification, looping, comparison, profiling, aggregation, evaluation CLI and GDPVal multistage test modules. Full local pre-commit passed; the private guardword catalog was unavailable and its hook explicitly skipped.

PYTHONPATH="$PWD" WANDB_MODE=offline pytest \
  tests/unit_tests/rollouts/test_looping.py \
  tests/unit_tests/eval/test_comparison_pooling.py \
  tests/unit_tests/eval/test_comparison_pooling_reports.py \
  tests/unit_tests/eval/test_rollout_reverification.py \
  tests/unit_tests/rollouts/test_rollout_collection.py \
  tests/unit_tests/metrics/test_reward_profile.py \
  tests/unit_tests/metrics/test_aggregate_metrics.py \
  tests/unit_tests/cli/test_cli_eval.py \
  resources_servers/gdpval/tests/test_multistage_orchestrator.py \
  --cpu -o addopts='' -o log_cli=false -q --tb=short

The same looping, ordinary and unreadable inputs also produced matching true/false/null labels through the real Gym assessor and NRL result-processing path in both tested Forest modes. Scores remained unchanged. The regression tests cover actual verifier request filtering, saved aggregate diagnostics and bounded worker-crash cleanup.

Rollouts

N/A for model rollouts: this changes post-response assessment and reporting, with no model generation, environment interaction or verifier-rule changes. No live model evaluation or GPU training run was performed.

Compatibility and benchmark impact

Off by default. Assessment adds is_looping and diagnostic metrics without changing verifier grades or quality scores. Unknown labels reduce coverage. The detector checks assistant and visible reasoning text for severe repetition; it does not add a tool-cycle detector. Profiling uses full-input environment-server identities so masked runs retain the correct diagnostic labels.

Follow-up validation: all 9 detector tests passed after extending the existing fixtures for summary-only reasoning and the executor shutdown request. Pre-commit checks passed for the changed test file.

Checklist

  • I have read the contributing guidelines.
  • The change is focused; unrelated edits are tracked separately.
  • Tests added or updated and pass locally.
  • Documentation added or updated.
  • Pre-commit checks pass locally (pre-commit run --all-files).
  • New source files include the required Apache-2.0 SPDX header.
  • All commits have DCO sign-off (git commit -s).

@copy-pr-bot

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

@svcnvidia-nemo-ci svcnvidia-nemo-ci added risk:high Autobot PR risk: high feature New capabilities, enhancements, or enablement work area:evaluation Evaluation, rollout collection, reward profiling, comparison, and exporters labels Nov 26, 2026
@u-brixton
u-brixton force-pushed the rzayashnikov/looping-runtime-eval branch from 96473f8 to a8913a1 Compare November 30, 2026 11:42
u-brixton added a commit to NVIDIA-NeMo/RL that referenced this pull request Nov 30, 2026
Use Gym assessment before token rebuilding, preserve verifier grades and row metadata, and pool diagnostic counts across supported training paths. Keep raw dynamic sampling and make loop zeroing optional under the reward-shaping master switch.

TODO after NVIDIA-NeMo/Gym#6846 merges: replace temporary Gym pin a8913a1e7e75e1b9cbf82c9bf02c6c494259db52 with the landed squash commit. Dependency alignment and uv.lock belong to the prerequisite branch.

Signed-off-by: Renat Zayashnikov <[email protected]>
u-brixton added a commit to NVIDIA-NeMo/RL that referenced this pull request Nov 30, 2026
Use Gym assessment before token rebuilding, preserve verifier grades and row metadata, and pool diagnostic counts across supported training paths. Keep raw dynamic sampling and make loop zeroing optional under the reward-shaping master switch.

TODO after NVIDIA-NeMo/Gym#6846 merges: replace temporary Gym pin a8913a1e7e75e1b9cbf82c9bf02c6c494259db52 with the landed squash commit. Dependency alignment and uv.lock belong to the prerequisite branch.

Signed-off-by: Renat Zayashnikov <[email protected]>
@u-brixton
u-brixton marked this pull request as ready for review November 30, 2026 21:15
@svcnvidia-nemo-ci svcnvidia-nemo-ci added the needs-review PR is ready for code review and waiting on a reviewer label Nov 30, 2026

@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

I reviewed all 17 changed files with separate detector, lifecycle and reporting reviews. No BLOCKER or RISK found. One non-blocking NOTE concerns unhandled late worker exceptions after assessment timeout or cancellation.

Validation used 766267172432.dkr.ecr.us-east-1.amazonaws.com/gym:d35258613354b88333a5bbd9894b49aa20345c50, the admitted default-branch tip's CI image, with Python 3.13.14. No successful head-image build was visible.

  • Targeted reporting, pooling, reverification and CLI tests: 370 passed after installing missing optional wandb outside the checkouts. The initial run had 3 failures and 6 skips; those resolved.
  • Focused lifecycle/collection/GDPVal tests: 9 passed. Detector tests: 5 passed, 4 deselected.
  • Purpose-built probes exercised repetition boundaries, resource limits, real process recovery, cancellation, saved labels and weighted diagnostic counts. A base-versus-head probe kept existing quality and token metrics unchanged. The late-exception probe reproduced the NOTE below for both timeout and cancellation.

I relied on the head's successful Lint check for lint. No core/server CI test jobs were visible on this head. I did not run the full suite, live model rollouts, GPU tests or the companion RL integration.

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.

Comment thread nemo_gym/rollouts/looping.py Outdated

future.add_done_callback(release)
submitted = True
return await asyncio.shield(asyncio.wrap_future(future))

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.

NOTE: Consume late exceptions after the assessment caller stops waiting.

At this shielded await, timeout or caller cancellation leaves the wrapped asyncio future running, but nothing retrieves its eventual exception. I exercised the real assessor with a delayed worker future using python /workspace/review-probes/leader/late_future_cases.py. Both paths invoked the loop's exception handler with Future exception was never retrieved and ValueError('late worker failure'). Capacity recovered and the next assessment returned False, so this is diagnostic noise rather than a scoring or backpressure failure.

Could you keep a named wrapped future and consume its terminal exception in a done callback, including when its waiter has gone away? Preserve shielding and the existing worker-completion capacity release; cancelling the caller must not cancel submitted work or free its slot early.

Acceptance: test timeout and explicit cancellation followed by a late worker exception, allow callback/reference cleanup, and assert that the event-loop exception handler is not invoked. Keep the capacity-reservation checks and verify that the next assessment succeeds.

@ffrujeri ffrujeri 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, one shared label for training and evaluation is a good direction, and the check is bounded and opt-in. Two questions inline before approval: how the check scales on the rollout completion path, and whether the new _ng_no_persist marker changes runs that do not enable it. CI is waiting on a maintainer's /ok to test.

Comment thread nemo_gym/rollouts/rollout_collection.py Outdated
if owned_token_source is not None:
output_files.push_async_callback(owned_token_source.close)
output_files.enter_context(store)
looping_assessor = LoopingAssessor() if config.assess_looping else None

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.

Gym runs thousands of rollouts at once, and each one awaits this check before it completes. With one worker, the checks run one at a time, and a check can use up to 4M steps of pure Python. At high concurrency, many checks wait past the 30 s timeout and return None, so looping/coverage drops and each rollout is held up to 30 s. Could the worker count follow the available CPUs (or a config field), and could a test or a smoke run show coverage at a realistic concurrency?

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.

I agree, good catch about the need to increase the num of cpu workers and make it truly parallell!
added looping_workers and moved the checks into the per-rollout tasks so the pool can actually run them in parallel

@u-brixton u-brixton Dec 2, 2026 •

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.

In terms of evidence I did have some production runs with looping zeroing on, although it was an older code w/o CPU pools and just with asyncio.to_thread spread across 16 Gym replicas
Coverage was close to 100% (99.98%), in terms of time was 12 ms per response

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.

But will try to run a newer smoke test to prove on the current code!

@u-brixton u-brixton Dec 2, 2026 •

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.

For large runs also important that uses sets num Gym replicas >> 1 (e.g. 16), as we saw in large runs other things could also be problematic in low num Gym replicas

Comment thread nemo_gym/rollouts/rollout_collection.py Outdated
# This metrics-only copy honors the explicit denominator policy. The original
# answer, failure diagnostics, and training mask remain untouched in the sidecar.
scored["mask_sample"] = False
scored[NG_NO_PERSIST_KEY] = True

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.

These metric-input copies now carry _ng_no_persist, also when assess_looping is off. Other readers skip rows with that key, for example nemo_gym/artifacts/exporters/mlflow.py (_is_exportable). Does any of them read these copies, so a run with count_failure_classes_as_zero reports differently? If the marker is only for looping_metrics, could it be a key that only that function reads?

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.

changed this to _ng_looping_excluded so only the looping counter reads it.

@ffrujeri

ffrujeri commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

/review 001df4f

@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

This is a follow-up to review 6121132798, not a fresh broad review. The admitted head is identical to that review's commit, so there are no post-review changes or eligible new findings. I verified the prior review and its inline NOTE with a delegated reviewer.

Prior NOTE, unchanged: late worker exceptions remain unconsumed. At the shielded await, a worker failure after caller timeout or cancellation still produces Future exception was never retrieved. This remains low-impact diagnostic noise in the exercised paths: cancellation propagated, capacity stayed reserved until worker completion, and the next assessment returned False.

The existing suggestion in comment 4745950906 still applies: keep a named wrapped future and retrieve its terminal exception through a done callback. Preserve shielding and worker-completion capacity release. Acceptance should cover timeout and explicit cancellation followed by a late exception, verify no unhandled-exception callback after reference cleanup, and confirm the next assessment succeeds. I found no basis to escalate this NOTE to RISK or BLOCKER.

Validation used 766267172432.dkr.ecr.us-east-1.amazonaws.com/gym:d35258613354b88333a5bbd9894b49aa20345c50, the admitted default-branch CI image, with Python 3.13.14. No successful head-image build was visible. Two CPU probe scripts exercised the real assessor with fake worker futures and reproduced both interruption paths. An initial probe assertion retained a mock reference too long; the corrected probe passed. I relied on the head's successful Lint check; no core/server CI test jobs were visible. I reused the unchanged baseline validation rather than rerunning its suites. No live model, GPU, or companion RL integration runs were performed.

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

@ffrujeri

ffrujeri commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

/ok to test 001df4f

@nemo-pr-automation
nemo-pr-automation Bot requested review from a team December 1, 2026 19:01
@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

@ffrujeri

ffrujeri commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

CI ran at 001df4f9. Core shard 0 has one failure that looks related to the run_labels change in nemo_gym/metrics/reward_profile.py: tests/unit_tests/tooling/test_reward_profile_summary.py::test_a_row_of_unknown_run_keeps_the_other_runs_coverage (assert {False, True} == {None}). Could you take a look? The Harness conformance failures are non-blocking. The two questions in the review above are still open.

@u-brixton

Copy link
Copy Markdown
Contributor Author

Core shard 0 has one failure that looks related to the run_labels change in nemo_gym/metrics/reward_profile.py: tests/unit_tests/tooling/test_reward_profile_summary.py::test_a_row_of_unknown_run_keeps_the_other_runs_coverage (assert {False, True} == {None}). Could you take a look?

Thanks for the warning, fixed the test!

Add a bounded shared text assessor with process execution, persist row labels before enrichment, and report pooled evaluation rates and coverage.

Signed-off-by: Renat Zayashnikov <[email protected]>
Name repeat-derived metrics explicitly, reserve looping metrics for pooled counts, and explain both aggregation rules in comparison notes. Extend the existing regression to prevent repeat ratios from overwriting the combined rate.

Signed-off-by: Renat Zayashnikov <[email protected]>
Discard a broken executor only when it is still the assessor current pool, allowing the next assessment to recreate it. Retain the existing unknown outcome and future-based capacity handling. Extend the spawned-worker regression with an actual child exit and verify that a replacement pool resumes assessment.

Signed-off-by: Renat Zayashnikov <[email protected]>
Overlay shared looping counts after custom aggregation, using the original completed rows. Extend existing regressions to protect saved annotations, unknown labels and worker capacity after deadline expiry.

Signed-off-by: Renat Zayashnikov <[email protected]>
Use the shared environment-server-aware identity resolver for coverage and retain the full-input label map while quality scores are filtered. Extend existing profile regressions for episode rows, shared agents and fully masked runs.

Signed-off-by: Renat Zayashnikov <[email protected]>
@u-brixton
u-brixton force-pushed the rzayashnikov/looping-runtime-eval branch from 95161b7 to d87c295 Compare December 2, 2026 23:32
@ffrujeri

ffrujeri commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

/review d87c295

@ffrujeri

ffrujeri commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

/ok to test d87c295

@nemo-pr-automation
nemo-pr-automation Bot requested a review from a team December 3, 2026 00:11

@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

The prior NOTE is fixed. I found no new findings above the prior low-impact ceiling in this follow-up to review 6137889672. The earlier reviewed revision is unavailable for comparison, so I could not verify an exact post-review diff.

The exception-consumption callback handles late worker failures after timeout and cancellation. Fake-future and real-process probes produced zero unhandled-exception callbacks, kept capacity reserved until worker completion, and allowed the next assessment to succeed.

I reviewed the changes with three delegated reviewers. CPU probes also confirmed overlapping assessment without holding the HTTP admission slot, saved-label preservation, reverification filtering, and count-weighted pooled metrics. A base-versus-head probe kept existing quality, token, group and repeat metrics unchanged. The real profiling CLI kept run labels distinct across masked and missing outputs.

Validation used gym:d35258613354b88333a5bbd9894b49aa20345c50, the default branch’s CI image, with Python 3.13.14. An initial GDPVal probe loaded the image’s source copy; the corrected probe exercised this PR’s source and passed. No production-scale load, live-model, GPU or companion RL integration run was performed.

I relied on CI for the existing suites. Lint check, Unit tests / Test, and Unit tests / Server suite passed for the merge of this head into the supplied base. The four core shards report 26,188 passed and 207 skipped. The optional harness-conformance check is red for OpenClaw, OpenCode and mini-SWE. OpenClaw and OpenCode show matching timeouts on base; mini-SWE reports missing or schema-invalid scenario evidence, which I have not attributed to this change.

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

@u-brixton

Copy link
Copy Markdown
Contributor Author

/ok to test cee4bcb

@nemo-pr-automation
nemo-pr-automation Bot requested a review from a team December 3, 2026 17:06

This branch has not been deployed

No deployments
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 risk:high Autobot PR risk: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants