fix(vlm): fail loudly in PP chunker when pixel_values cannot be aligned#2181
Open
khazic wants to merge 2 commits intoNVIDIA-NeMo:mainfrom
Open
fix(vlm): fail loudly in PP chunker when pixel_values cannot be aligned#2181khazic wants to merge 2 commits intoNVIDIA-NeMo:mainfrom
khazic wants to merge 2 commits intoNVIDIA-NeMo:mainfrom
Conversation
…ed to batch The legacy fallback in _chunk_vlm_media (when n_images != batch_size and no n_images_per_sample is provided) used to log a warning, dump every image into mb0, and emit empty pixel_values for mb1..N. Subsequent microbatches whose text still contained media tokens would then scatter into empty tensors — silent corruption rather than a crash. Replace the warn-and-continue with raise ValueError. Callers must either pass pixel_values shaped [batch_size, ...] (one media tensor per sample) or include n_images_per_sample so the chunker can map images to samples. Update the two existing tests that codified the warn-and-continue behavior to assert the new contract via pytest.raises. Signed-off-by: khazic <khazzz1c@gmail.com>
Contributor
|
/ok to test 0e2d985 |
Contributor
|
/claude review |
HuiyingLi
approved these changes
May 8, 2026
Contributor
|
/ok to test c7b7b13 |
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.
Summary
`_chunk_vlm_media`'s legacy fallback (`n_images != batch_size` AND `n_images_per_sample is None` AND pixel_values is not shaped `[batch_size, ...]`) used to dump every image into mb0, emit empty pixel_values for mb1..N, and log a warning. Subsequent microbatches whose text still carried media tokens would then scatter into empty tensors — silent corruption rather than a crash.
This patch replaces the warn-and-continue with `raise ValueError`, forcing the calling collate to align with the chunker's contract instead of training on broken data.
Changelog
Behavioral note
This is a breaking change for any caller relying on the previous warn-and-continue behavior. Such callers were already producing incorrect training data — empty pixel_values scattered into media tokens cannot yield meaningful gradients — so the breakage is intentional. All in-tree collates already set `n_images_per_sample`, so no in-tree recipe is affected.
Test plan