Repository navigation
fix(vlm): reject multimodal calibration rows instead of dropping tensors (#4371) - #4402
Merged
Merged
Conversation
is_pretokenized_sample() treated any mapping with input_ids as text, so processor(text=..., images=...) rows lost pixel_values/image_grid_thw on the base text path. Only text-only extra columns now count as pre-tokenized; rows with other columns raise an actionable error instead of silently dropping them. Columnar processor output (BatchEncoding) is validated before unpacking, which previously dropped those columns too.
This was referenced Nov 16, 2026
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.
Fixes #4371.
Problem
is_pretokenized_sample()ingptqmodel/models/definitions/_vlm_calibration.pyclassified any mapping containinginput_idsas pre-tokenized text.split_calibration_dataset()then routed processor-produced rows to the base text path, which keeps onlyinput_ids/attention_mask. A row fromprocessor(text=..., images=...)therefore kept its image placeholder tokens but silently lostpixel_values/image_grid_thw.Fix
A token-id row is pre-tokenized only when its extra columns are text-only (
token_type_ids,labels,special_tokens_mask,position_ids, tokenizer metadata,text/messages). Rows carrying any other column are rejected with an actionableValueErrornaming the offending columns.Rejecting is the correct contract here:
split_calibration_dataset()returns only(pretokenized_rows, conversations), and all VLMprepare_datasetoverrides dispatch on that binary result. Neither path can forward arbitrary processor tensors without changing every caller plus model-specific batching/truncation/pixel alignment. This restores the pre-2b51d4dloud failure, but with a clear message instead of an accidental processor crash. Columnar processor output (BatchEncoding) is validated before_columnar_mapping_examples()unpacking, which previously dropped the same tensors silently.Tests
tests/test_vlm_multimodal_calibration_4371.py: 4 passed.tests/test_vlm_pretokenized_calibration.py tests/test_vlm_mapping_calibration_4308.py tests/test_calibration_mapping_input.py: 146 passed (150 together with the new file).ruff checkon both changed files: clean.Residual risk
{"text": ..., "pixel_values": ...}rows (noinput_ids) remain on the pre-existing conversation path.