Skip to content

[QUALITY] Regression from #4930 (fix of #4861): capture now passes 2-D position_ids to mRoPE VL models (Qwen3-VL/Qwen3.5/GLM-4V...), so image tokens are calibrated at 1-D positions (Qwen3-VL-2B: decoder input up to 45% off) #4933

Closed

Description

@Qubitium

Found on main @ 3867c82, RTX 4090.

What is wrong

#4930 (fix of #4861) makes BaseQModel.run_input_capture (gptqmodel/models/base.py:3266) pass position_ids = mask.cumsum(-1) - 1 to every model whose forward accepts position_ids (_with_capture_position_ids, base.py:794). The derived ids are 2-D text positions.

Multimodal-RoPE models compute their 3-D/4-D position ids (the image/video grid layout, from get_rope_index/compute_3d_position_ids) only when position_ids is None (for example Qwen3VLModel.forward: if position_ids is None: position_ids = self.compute_3d_position_ids(...)). Once a 2-D tensor is passed, the text model expands it to all of t/h/w, so every image token gets a sequential 1-D position instead of its grid position. Calibration then runs on hidden states the model never produces at inference (generate() still uses the mRoPE ids). The result is silent and nothing raises.

Before #4930 the capture forward passed no position_ids, so this path was correct.

Affected: every definition that keeps the base run_input_capture and whose HF model builds mRoPE ids only when none are given. That includes qwen3_vl, qwen3_vl_moe (and glm_ocr, which uses BaseQwen3VLGPTQ), qwen3_5/qwen3_5_moe, glm4v/glm4v_moe, hunyuan_vl, qwen3_omni_moe, cohere_compass and qwen4_exp. Qwen2-VL, Qwen2.5-VL, Qwen2.5-Omni and ERNIE-VL are not affected because they override run_input_capture for image rows.

Repro (real quantize path, Qwen3-VL-2B-Instruct, one image conversation)

m = GPTQModel.load("Qwen3-VL-2B-Instruct", GPTQConfig(bits=4, group_size=128))
rec = {}
class Stop(Exception): pass
def hook(mod, args, kwargs):
    rec["pos"] = kwargs.get("position_ids"); raise Stop
m._core_multimodal_model().language_model.register_forward_pre_hook(hook, with_kwargs=True)
conv = [{"role": "user", "content": [{"type": "image", "image": img}, {"type": "text", "text": "generate a caption for this image"}]},
        {"role": "assistant", "content": "A street scene with a sign."}]
try: m.quantize(CalibrationConfig(dataset=[conv], batch_size=1))
except Stop: pass
print(rec["pos"].shape, rec["pos"].max())
5fb25294f^ : position_ids passed to language_model: (3, 1, 358)  max 49   (mRoPE, t/h/w differ)
main       : position_ids passed to language_model: (1, 358)     max 357  (plain 1-D positions)

Here is the impact on the unquantized HF model with the same image, comparing the default call against the call through gptqmodel.models.base._with_capture_position_ids. The score is the NLL of the model's own greedy 40-token answer:

mrope (what inference uses)   answer-token NLL 0.2005
derived 2-D (what capture now feeds) answer-token NLL 0.2555
decoder input rel. diff: layer 1 0.119, layer 7 0.023, layer 14 0.045, layer 21 0.149, layer 28 0.452

So every Hessian and AWQ activation statistic for image calibration rows on these families is now collected on hidden states that are up to 45% off.

Suggested fix

Derive position_ids only for models that need it: ones with learned absolute position embeddings, or at least only when the model has no multimodal rope index. For example, skip the derivation when the example carries multimodal inputs (pixel_values*, image_grid_thw, video_grid_thw, mm_token_type_ids) or when the core model defines get_rope_index/compute_3d_position_ids. Another option is to make it an opt-in class attribute on the GPT-2/GPT-Neo-style definitions. The capture path for RoPE/ALiBi models needs no position_ids at all, which the #4930 commit message itself says.

Test that should have caught it

tests/test_calibration_padding_mask.py (added by #4930) only uses a GPT-2 model. It needs a case with an mRoPE model (Qwen3-VL-2B, image row) asserting that capture leaves position_ids unset, or that the decoder sees the same ids generate() would use.

Severity: silent calibration-quality regression for image calibration on all Qwen3-VL/Qwen3.5/GLM-4V-class models.

🤖 Generated with Claude Code

Activity

  1. Qubitium commented on Nov 17, 2026

    @Qubitium
    CollaboratorAuthor

    Agent claim released: agent-53ba17eb4d83 finished this issue.

    Pull request: #4961

    Fix the #4930 regression: run_input_capture must not pass derived 2-D position_ids to mRoPE VL models that compute their own 3-D/4-D grid ids; gate on the model's own capability and add a Qwen3-VL-style test.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions