Add regression tests for basic_collation_fn and get_assistant_mask#90
Open
lonexreb wants to merge 1 commit intoNVlabs:mainfrom
Open
Add regression tests for basic_collation_fn and get_assistant_mask#90lonexreb wants to merge 1 commit intoNVlabs:mainfrom
lonexreb wants to merge 1 commit intoNVlabs:mainfrom
Conversation
Pins down the public-API contracts of two helpers that recently had small fix/docs PRs land against them, so future edits don't quietly regress the same surface. src/alpamayo_r1/processor/test_qwen_processor.py covers basic_collation_fn: - Default arg behaves as "no extra unstackable keys" (no hidden mutable state across calls). - unstackable_keys=None is accepted and equivalent to omitting it. - Keys named in unstackable_keys are returned as a plain list. - Repeated calls don't accumulate state through the default. - Non-tensor values are always returned as lists (never stacked). src/alpamayo_r1/utils/test_get_label_mask.py covers get_assistant_mask: - torch.Tensor input -> torch.Tensor (bool) output. - list[int] input -> list[bool] output (the dual return shape that the annotation now reflects). - The mask covers exactly the assistant content + trailing EOS, with the user turn untouched (matches the body's start+3 / end+1 logic). - Tensor and list input paths produce the same booleans. Tests use a tiny stub tokenizer to avoid downloading real model weights, so they run on CI without HF auth. Signed-off-by: lonexreb <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Two small helpers in the package have public-API contracts that recently had docs/fix PRs land against them:
basic_collation_fninsrc/alpamayo_r1/processor/qwen_processor.py(the mutable-default-arg fix proposed in Replace mutable default list with None sentinel in basic_collation_fn #84).get_assistant_maskinsrc/alpamayo_r1/utils/get_label_mask.py(the return-type/docstring fix proposed in Fix get_label_mask docstrings and get_assistant_mask return type #85).Without tests, a future edit can quietly regress either contract. This PR follows the same pattern as the to_device tests in #80 — add focused, dependency-light pytest cases that lock in the documented behavior.
What
src/alpamayo_r1/processor/test_qwen_processor.py— 5 tests coveringbasic_collation_fn:unstackable_keys=Noneis accepted and equivalent to omitting it.unstackable_keyscome back as a plain list.src/alpamayo_r1/utils/test_get_label_mask.py— 4 tests coveringget_assistant_mask:torch.Tensorinput →torch.Tensor(bool) output.list[int]input →list[bool]output (the dual return shape the annotation now reflects).start+3/end+1logic).Tests use a tiny stub tokenizer that only implements
convert_tokens_to_ids, so they run on CI without HF auth or model downloads.Run
Notes
mainfor the get_assistant_mask file (the fix in Fix get_label_mask docstrings and get_assistant_mask return type #85 was docstring/annotation only; the runtime behavior these tests pin down already exists).maintoo — they will also pass after Replace mutable default list with None sentinel in basic_collation_fn #84 lands, which is the point of a regression test.