Repository navigation
test(token-capture): pin the mask_incomplete_when_attributed pass-through - #4364
linj-glitch merged 1 commit into
Conversation
…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]>
linj-glitch
left a comment
There was a problem hiding this comment.
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.
|
/ok to test dbdbaa0 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/38306102819 |
What does this PR do?
Pull request #3974 added the setting
token_id_capture.mask_incomplete_when_attributed(defaulttrue). The collection loop reads it once withmask_incomplete_when_attributed_from_config(...)(nemo_gym/rollout_collection.py:2636) and passes the value tofinalize_rollout_token_capture(...)as a keyword argument (nemo_gym/rollout_collection.py:2832-2834), which forwards it totrajectories_from_source(...)(nemo_gym/token_id_capture/delivery.py:171). The finalizer defaults that argument toTrue(nemo_gym/token_id_capture/delivery.py:88). Nothing intests/unit_tests/test_rollout_collection.pypinned that the configured value reaches the finalizer: with the keyword argument dropped at the call site, every existing test stays green while a configuredfalsenever 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.get_global_config_dictat atoken_id_captureblock withenabled,all_agents,rebuild_response, and adirundertmp_path, plus the parametrized setting (mask_incomplete_when_attributed: falsein one case, absent in the other). It patchesinstalled_token_sourceto returnNone, so the collection loop builds its ownTokenCaptureStorefromdir.nemo_gym.rollout_collection.finalize_rollout_token_capturewithAsyncMock(wraps=finalize_rollout_token_capture), so the call arguments are recorded while the real finalizer still runs.run_from_configover one rollout through aRolloutCollectionHelpersubclass whose_run_examples_with_metadatareturns a completed rollout, as the neighbouring tests do. The store holds no records for the rollout, so the real finalizer masks it and emits thecapture contains no token recordswarning the test expects.mask_incomplete_when_attributed=Falsefor the configured case andTruefor 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 onPYTHONPATH: 431 passed, 0 failed (12 warnings; the new test on its own reports only pytest'sUnknown config option: cache_dirnotice for this pytest version).nemo_gym/rollout_collection.py:2832-2834(finalize_rollout_token_capture(result, token_source)), both parameterizations fail withKeyError: '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.pyandruff format --check tests/unit_tests/test_rollout_collection.pyare both clean.🤖 Generated with Claude Code