Skip to content

[BUG] VLM prepare_dataset overrides still calibrate on a Mapping's key names ("input_ids", "attention_mask"): incomplete fix of #4193 #4308

Closed

Description

@Qubitium

Severity: medium (silently wrong calibration on popular VLMs). Status: confirmed end-to-end on gemma-3-4b-it and by a unit test of split_calibration_dataset. Kind: incomplete fix of #4193 (842d666).

Where

  • gptqmodel/models/definitions/_vlm_calibration.py:55: split_calibration_dataset does iter(calibration_dataset).
  • gptqmodel/models/definitions/gemma3.py:310.

Description

  • The [BUG] Passing a Mapping as the calibration dataset (BatchEncoding, dict of columns, DatasetDict) calibrates on the key names #4193 handling for Mapping and columnar input exists only in utils/calibration.prepare_calibration_dataset.
  • Every VLM override built on the shared helper iterates the mapping and wraps each key as a one-message chat. Affected: llava, internvl, internvl_chat, base_qwen2_vl (Qwen2/2.5-VL, Qwen2.5-Omni), smolvlm, lfm2_vl, ovis2, minicpmv / minicpm_o / minicpmv_4_6, and Gemma3.
  • Only Qwen3-VL rejects mappings.
  • The resulting rows are about 12 tokens, so they pass the default min_length=10 and quantization proceeds silently.

Repro

from gptqmodel import GPTQModel, QuantizeConfig
m = GPTQModel.load("google/gemma-3-4b-it", QuantizeConfig(bits=4, group_size=128))
enc = m.tokenizer(["The quick brown fox jumps over the lazy dog.", "Another calibration sentence for testing."], padding=True)
out = m.prepare_dataset(enc, batch_size=1, calibration_data_min_length=10)   # quantize(enc) uses the same path
  • Actual: 2 batches, which decode as '<bos><start_of_turn>user\ninput_ids<end_of_turn>…' and '…user\nattention_mask<end_of_turn>…'.
  • Expected: unpack the columns (or route token-id columns to the base text path), and reject DatasetDicts, as the base helper does.
  • Also: the helper's is_pretokenized_sample sends rows with extra keys (e.g. token_type_ids) or numpy / 0-D-tensor token ids down the processor path instead of the pre-tokenized path.

Found during an AI-assisted review (Claude Code, round 11) of 842d666; repros were run at that commit on RTX 4090/5090 (CUDA 13) and/or Radeon AI PRO R9700 (ROCm) unless marked static/suspected.

Activity

  1. added
    bug
    on Nov 16, 2026
  2. self-assigned this
    on Nov 16, 2026
  3. Qubitium commented on Nov 16, 2026

    @Qubitium
    CollaboratorAuthor

    Taking this. I'll investigate against current main, add a targeted regression test, and open a PR. Will report back here if the claim turns out to be invalid or already fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions