Repository navigation
[BUG] VLM prepare_dataset overrides added after #4228/#4308 bypass the shared calibration helper: pre-tokenized rows silently become an empty chat prompt or the text "input_ids" (Cohere Compass, HunyuanOCR, Muse-Glimmer); Inkling/Cohere crash at batch_size>1 #4633
Description
Found on main @ 597b39b, RTX 4090 host (repro runs on CPU with the real processors).
What is wrong
#4256 (#4228), #4308 and #4402 (#4371) gave the VLM prepare_dataset overrides one shared contract in models/definitions/_vlm_calibration.py:
split_calibration_dataset()sends pre-tokenized rows and columnar mappings to the base text path, and rejects rows that carry multimodal tensors;pop_conversation_calibration_options()/finalize_conversation_batches()rejectcalibration_concat_sizeand applycalibration_sort/calibration_data_min_length;- the batched processor call passes
padding=True.
The fix was applied to the definitions that existed at the time (qwen2_vl, gemma3, internvl, ovis2, lfm2_vl, smolvlm, llava, minicpm*). It was never applied to definitions added since, and they reintroduce every symptom of #4228 and #4308:
| definition | pre-tokenized rows | columnar {"input_ids": [...]} |
concat_size / sort / min_length |
batch_size > 1 |
|---|---|---|---|---|
inkling.py:132 (InklingMMQModel) |
list[int]: AttributeError; dict: TemplateError | n/a | del kwargs: silently ignored |
ValueError (no padding=True, support_batch_quantize=True) |
cohere_compass.py:374 |
list[int]: AttributeError; dict: silently calibrates on an empty prompt | calibrates on the text "input_ids" |
del kwargs: ignored |
ValueError (no padding, support_batch_quantize=True) |
hunyuan_vl.py:110 |
list[int]: AttributeError; dict: silently calibrates on BOS only | calibrates on "input_ids" |
del kwargs: ignored |
OK |
muse_glimmer.py:83 |
list[int]: AttributeError; dict: silently calibrates on the system prompt only | calibrates on "input_ids" |
del kwargs: ignored |
forced to 1 |
ernie4_5_vl_moe.py:399 |
AttributeError / KeyError 'content' | ignored | OK | |
minimax_m3_vl.py:114 |
ValueError ('int' object is not subscriptable) | ignored | forced to 1 | |
interns1.py:127, lfm3_vl.py:143, lfm3_omni.py:139, intern_s2_preview.py:187 |
same code shape: no split helper, options ignored; interns1/lfm3_* also call apply_chat_template(tokenize=True, return_tensors="pt") without padding and keep support_batch_quantize=True (static, no local checkpoint) |
The silent cases are the bad ones. A user who passes the documented pre-tokenized form, [{"input_ids": ids, "attention_mask": mask}, ...] or tokenizer(texts), gets no error. Every calibration sample is replaced by the template rendered around a dict that has no content / text, or around the literal key names. GPTQ then calibrates every layer on 1 to 9 tokens of boilerplate, which is the exact #4308 failure.
Repro
Uses the real processors from the local checkpoints. Only prepare_dataset is called, the same way quantize() calls it through partial(self.prepare_dataset, ...).
import torch
from transformers import AutoTokenizer
from gptqmodel.models.definitions.cohere_compass import CohereCompassQModel
from gptqmodel.models.definitions.hunyuan_vl import HunYuanVLQModel
from gptqmodel.models.definitions.inkling import InklingMMQModel
def make(cls, path):
m = object.__new__(cls); m.model_local_path = path; m.trust_remote_code = True
m.processor = None; m.tokenizer = AutoTokenizer.from_pretrained(path)
return m
ids = list(range(100, 140))
for cls, path in [(CohereCompassQModel, "North-Micro-Vision-Instruct"), (HunYuanVLQModel, "HunyuanOCR")]:
m = make(cls, path); tok = m.load_processor().tokenizer
for data in ([{"input_ids": ids, "attention_mask": [1] * 40}], # pre-tokenized rows
{"input_ids": [ids], "attention_mask": [[1] * 40]}): # columnar / tokenizer(texts)
out = m.prepare_dataset(data, batch_size=1)
print(cls.__name__, type(data).__name__, len(out), repr(tok.decode(out[0]["input_ids"][0])))
convs = [[{"role": "user", "content": [{"type": "text", "text": "Hello world, this is a longer calibration sample."}]}],
[{"role": "user", "content": [{"type": "text", "text": "Short."}]}]]
make(InklingMMQModel, "Inkling-0.6B-A0.6B").prepare_dataset(convs, batch_size=2)Output:
CohereCompassQModel list 1 '<BOS_TOKEN><|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>'
CohereCompassQModel dict 2 '<BOS_TOKEN><|START_OF_TURN_TOKEN|><|USER_TOKEN|>input_ids<|END_OF_TURN_TOKEN|><|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>'
HunYuanVLQModel list 1 '<|hy_begin▁of▁sentence|>'
HunYuanVLQModel dict 2 '<|hy_begin▁of▁sentence|>input_ids<|hy_User|>'
MuseGlimmerQModel (same probe) dict -> '...<|start|>user<|message|>input_ids<|eot|><|start|>assistant'
InklingMMQModel bs=2: ValueError: Unable to create tensor, you should probably activate truncation and/or padding with 'padding=True' ... (inkling.py:123)
CohereCompassQModel bs=2: same ValueError (cohere_compass.py:366); plain text rows ["...", "..."] at bs=2 fail the same way
For comparison, Qwen2VLQModel / LlavaQModel / Gemma3ForConditionalGenerationGPTQ route the same inputs to the base text path and keep all 40 tokens. They reject calibration_concat_size on conversations, where these overrides drop it with del kwargs.
Suggested fix
Route every override through the shared helpers instead of copying the loop. For example, add one BaseQModel helper (or mixin) that does split_calibration_dataset -> base path, pop_conversation_calibration_options, the per-model processor call, then finalize_conversation_batches. Each definition then supplies only its prepare_inputs_for_conversations. Pass padding=True (or processor_kwargs={"padding": True}) in every prepare_inputs_for_conversations whose class keeps support_batch_quantize=True.
Test that should have caught it
tests/test_vlm_pretokenized_calibration.py and tests/test_vlm_mapping_calibration_4308.py cover a hand-picked class list. Parametrize them over every definition that overrides prepare_dataset (discover by "prepare_dataset" in cls.__dict__), with a stub processor. Assert the token ids survive, calibration_concat_size is rejected, and batch_size=2 with unequal lengths works or support_batch_quantize is False. New VLM definitions then cannot skip the contract.
Severity
Medium. Silent calibration on boilerplate (Cohere Compass / North-Vision, HunyuanOCR, Muse-Glimmer) for documented input forms, plus crashes on batch_size > 1 for Inkling / Cohere Compass. This is an incomplete fix of #4228 / #4308.
🤖 Generated with Claude Code
Activity
Qubitium commentedon Nov 17, 2026
Claimed. This issue is now owned by a dedicated worker; a fix PR referencing it will follow. Please avoid duplicating work on it in the meantime.
fix(models): route every VLM prepare_dataset through the shared calib…
Port every supported model onto the Transformers 5.23 ABI; never patc…