Skip to content

test(token-capture): pin the mask_incomplete_when_attributed pass-through - #4364

Merged
linj-glitch merged 1 commit into
mainfrom
alexandery/test-mask-incomplete-when-attributed-pass-through
Oct 12, 2026
Merged

linj-glitch merged 1 commit into
mainfrom
alexandery/test-mask-incomplete-when-attributed-pass-through

Conversation

@alexandery-nvidia

Copy link
Copy Markdown
Contributor

What does this PR do?

Pull request #3974 added the setting token_id_capture.mask_incomplete_when_attributed (default true). The collection loop reads it once with mask_incomplete_when_attributed_from_config(...) (nemo_gym/rollout_collection.py:2636) and passes the value to finalize_rollout_token_capture(...) as a keyword argument (nemo_gym/rollout_collection.py:2832-2834), which forwards it to trajectories_from_source(...) (nemo_gym/token_id_capture/delivery.py:171). The finalizer defaults that argument to True (nemo_gym/token_id_capture/delivery.py:88). Nothing in tests/unit_tests/test_rollout_collection.py pinned that the configured value reaches the finalizer: with the keyword argument dropped at the call site, every existing test stays green while a configured false never takes effect.

This PR adds one parametrized test, TestRolloutCollection::test_run_from_config_forwards_mask_incomplete_when_attributed_to_the_finalizer, next to the other collection-path token-capture tests. The test does the following.

  1. It points get_global_config_dict at a token_id_capture block with enabled, all_agents, rebuild_response, and a dir under tmp_path, plus the parametrized setting (mask_incomplete_when_attributed: false in one case, absent in the other). It patches installed_token_source to return None, so the collection loop builds its own TokenCaptureStore from dir.
  2. It replaces nemo_gym.rollout_collection.finalize_rollout_token_capture with AsyncMock(wraps=finalize_rollout_token_capture), so the call arguments are recorded while the real finalizer still runs.
  3. It runs run_from_config over one rollout through a RolloutCollectionHelper subclass whose _run_examples_with_metadata returns a completed rollout, as the neighbouring tests do. The store holds no records for the rollout, so the real finalizer masks it and emits the capture contains no token records warning the test expects.
  4. It asserts that the finalizer was awaited once, with mask_incomplete_when_attributed=False for the configured case and True for the absent case.

This PR changes no production code.

Issue

No issue filed; the gap was found while reviewing #3974's merge.

Validation

  • pytest -q -p no:cacheprovider -o addopts= tests/unit_tests/test_rollout_collection.py, run from the checkout with the checkout on PYTHONPATH: 431 passed, 0 failed (12 warnings; the new test on its own reports only pytest's Unknown config option: cache_dir notice for this pytest version).
  • Mutation check: with the keyword argument temporarily removed from the call at nemo_gym/rollout_collection.py:2832-2834 (finalize_rollout_token_capture(result, token_source)), both parameterizations fail with KeyError: 'mask_incomplete_when_attributed' on the recorded call arguments. The call site was restored before committing, and the diff touches only the test file.
  • ruff check tests/unit_tests/test_rollout_collection.py and ruff format --check tests/unit_tests/test_rollout_collection.py are both clean.

🤖 Generated with Claude Code

…ough

The collection loop in nemo_gym/rollout_collection.py reads
token_id_capture.mask_incomplete_when_attributed once through
mask_incomplete_when_attributed_from_config and passes the value to
finalize_rollout_token_capture as a keyword argument. The finalizer defaults
that argument to True, so dropping the pass-through would leave every existing
test in tests/unit_tests/test_rollout_collection.py green while a configured
false value never reached the finalizer.

The new parametrized test runs run_from_config over one rollout with the
setting configured as false and with the setting absent. It wraps the real
finalizer in an AsyncMock installed where the collection module looks it up,
so the rollout still takes the real finalization path, and asserts that the
recorded call carries mask_incomplete_when_attributed=False in the first case
and True in the second. Removing the keyword argument at the call site makes
both cases fail with a KeyError on the recorded call arguments.

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

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

@alexandery-nvidia
alexandery-nvidia marked this pull request as ready for review October 10, 2026 08:12
@yaoyu-33 yaoyu-33 added area:evaluation Evaluation, rollout collection, reward profiling, comparison, and exporters ci CI, automation, test queue, or workflow infrastructure work complexity:low Localized change in one scope with a small, straightforward review surface needs-review PR is ready for code review and waiting on a reviewer labels Oct 10, 2026
@github-actions github-actions Bot added the sla:triage-overdue Review assignment is over the one-business-day SLA label Oct 12, 2026

@linj-glitch linj-glitch left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The test protects the configured mask_incomplete_when_attributed value at the collection/finalizer boundary while wrapping the real finalizer. Existing trajectory-builder tests cover the resulting masking behavior. The prerequisite #3974 is merged. No blocking findings.

Validation: 637 rollout/capture/trajectory tests passed. Removing the forwarded keyword failed both new cases; hardcoding True failed the configured-False case. Restored source passed, and full pre-commit passed. Model rollout is N/A for this test-only change. Trusted runtime CI is still a separate handoff check.

Reviewed with Codex, including an independent source/history pass.

@linj-glitch

Copy link
Copy Markdown
Collaborator

/ok to test dbdbaa0

@nemo-automation-bot
nemo-automation-bot Bot requested review from a team October 12, 2026 20:19
@github-actions github-actions Bot removed the sla:triage-overdue Review assignment is over the one-business-day SLA label Oct 12, 2026
@linj-glitch
linj-glitch added this pull request to the merge queue Oct 12, 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/38306102819

Merged via the queue into main with commit 3f56780 Oct 12, 2026
56 of 58 checks passed
@linj-glitch
linj-glitch deleted the alexandery/test-mask-incomplete-when-attributed-pass-through branch October 12, 2026 20:58

This branch was previously deployed

1 inactive deployment
public — dbdbaa01 Deployed Oct 12, 2026 by copy-pr-bot[bot] via release / finalize / notify #5087
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 ci CI, automation, test queue, or workflow infrastructure work complexity:low Localized change in one scope with a small, straightforward review surface 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