Skip to content

fix: keep the base text path for pre-tokenized VLM calibration rows (#4228) - #4256

Merged
Qubitium merged 1 commit into
mainfrom
pr/4228
Nov 16, 2026
Merged

Qubitium merged 1 commit into
mainfrom
pr/4228

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Summary

Most VLM prepare_dataset overrides sent token-id rows to processor.apply_chat_template, crashing on inputs the public API accepts ([ids, ids], [{"input_ids", "attention_mask"}]). They also ignored calibration_concat_size, calibration_sort and calibration_data_min_length.

What Changed

  • New gptqmodel/models/definitions/_vlm_calibration.py helper: fully pre-tokenized datasets fall back to BaseQModel.prepare_dataset (so all base options work); mixed token-id/conversation datasets raise a clear ValueError; conversation path rejects calibration_concat_size explicitly and applies calibration_sort / calibration_data_min_length.
  • Wired into base_qwen2_vl (Qwen2/2.5-VL), base_qwen2_5_omni, internvl, internvl_chat, ovis2, lfm2_vl, smolvlm, llava, minicpmv, minicpmv_4_6, minicpm_o, plus option handling in gemma3 and base_qwen3_vl.
  • Added tests/test_vlm_pretokenized_calibration.py (91 parametrized cases over 17 classes).

Tests

pytest tests/test_vlm_pretokenized_calibration.py tests/test_gemma3_vl_support.py   tests/test_smolvlm_support.py tests/test_multimodal_calibration_replay.py   tests/test_multimodal_modality_calibration.py tests/test_qwen3_5_moe_multimodal_support.py   tests/test_internvl_optional_vision.py tests/test_pre_lm_head_norm_resolution.py   tests/test_qwen2_family_compat.py tests/test_awq_vl_rotary_resolution.py -q
# 205 passed, 6 skipped
ruff check <changed files>   # clean

Note: ~20 further VLM definitions have their own overrides and can adopt the same helper in a follow-up; the issue's named set is covered.

Fixes #4228

Model Support / Module Plan

N/A — no new model types or registry entries.

Verification environment

No compiled GPTQModel extensions are built in this environment (Machete/Marlin/QQQ-CUDA unavailable), so hardware-specific paths are called out explicitly above. The 19 fix branches from this sprint merge cleanly into one integration branch; the combined run was 195 passed, 2 skipped, ruff check clean.

…4228)

Vision-language `prepare_dataset` overrides sent every calibration row to
`processor.apply_chat_template`, so the token-id rows the public `quantize()`
API accepts crashed with `AttributeError: 'int' object has no attribute 'get'`
or `KeyError: 'content'`.

Fully pre-tokenized datasets now go to `BaseQModel.prepare_dataset`, a dataset
that mixes token ids with conversations is rejected with a clear error, and
`calibration_concat_size` on the conversation path is rejected instead of
silently ignored. `calibration_sort` and `calibration_data_min_length` are
applied to the processor-prepared batches.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG][model] Most VLM prepare_dataset overrides crash on pre-tokenized calibration rows the public API accepts, and ignore calibration options

1 participant