Skip to content

fix(gym rollouts): mark rollouts cut by max_output_tokens as truncated - #4711

Open
arendu wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
arendu:fix/overlong-filter-use-response-status
Open

arendu wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
arendu:fix/overlong-filter-use-response-status

Conversation

@arendu

@arendu arendu commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

hit_max_tokens in _postprocess_single_nemo_gym_group only tested whether the whole sequence reached vllm_cfg.max_model_len. In the common configuration where policy.generation.max_new_tokens is below the context length, a rollout cut by the per-call generation cap was never marked truncated, so:

  • grpo.overlong_filtering: true silently kept training on incomplete rollouts, and
  • the truncation_rate / natural_termination_rate metrics reported 0 / 1 for them.

The Responses API already reports this case: NeMo Gym returns the response with status: incomplete and incomplete_details.reason: max_output_tokens. This PR also treats that status as truncated, keeping the existing context-length check. One file, three lines.

How was it tested?

  • Unit-style check on synthetic Gym results (CPU): a 10K-token natural stop is not flagged; a rollout whose response has status: incomplete is flagged; a context-filling rollout is still flagged.
  • Observed in practice on an OPD run (32K cap, 64K context): 37% of rollouts hit the cap by the end of training while truncation_rate logged 0; with this change they are flagged and overlong_filtering masks them.

🤖 Generated with Claude Code

`hit_max_tokens` (and therefore the `truncated` field consumed by
`grpo.overlong_filtering`, plus the `truncation_rate` metric) only tested
whether the full sequence reached `vllm_cfg.max_model_len`. With the usual
configuration where `max_new_tokens` is below the context length, a rollout
cut by the per-call generation cap was never flagged, so overlong filtering
silently trained on incomplete rollouts and `truncation_rate` reported 0.

The Responses API already reports this case: NeMo Gym returns the response
with `status: incomplete` (`incomplete_details.reason: max_output_tokens`).
Treat that as truncated as well, keeping the context-length check.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: adithyare <[email protected]>
@copy-pr-bot

copy-pr-bot Bot commented Oct 13, 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.

@arendu
arendu requested review from yfw and a balanced review from Copilot October 13, 2026 19:10

Copilot AI 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.

🟡 Changes recommended

Detection must check the incomplete reason specifically and needs regression coverage.

1 open finding
What changed in this PR

Updates NeMo Gym rollout postprocessing to recognize output-cap truncation.

Changes:

  • Treats incomplete Responses API results as truncated.
  • Preserves context-length truncation detection.
File Description
nemo_rl/​experience/​rollouts.py Extends Gym rollout truncation detection.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

"hit_max_tokens": sum(len(m["token_ids"]) for m in r["message_log"])
== max_total_tokens_per_sample,
== max_total_tokens_per_sample
# also truncated when a model call hit max_output_tokens (Responses API status)
@terrykong terrykong added the CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) label Nov 5, 2026

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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants