Repository navigation
fix(calibration): declare IMAGE_TO_TEXT modality for 4 multimodal wrappers - #3558
Merged
Merged
Conversation
…ppers GlmOCRGPTQ, MiniMaxM3VLGPTQ, Qwen3OmniMoeGPTQ, and NemotronOmniQModel inherited BaseQModel.modality = [MODALITY.TEXT], so model_test.py and the quantize path calibrated their language towers on text-only activations while inference feeds image-conditioned activations. - GlmOCRGPTQ now inherits BaseQwen3VLGPTQ and requires mm_token_type_ids - MiniMaxM3VLGPTQ/Qwen3OmniMoeGPTQ/NemotronOmniQModel build image+text calibration batches through their native processors - Nemotron input capture uses generate() because the top-level forward requires image_flags and calls torch.distributed.get_rank() - get_calib_dataset routes the new models to image calibration sets - add regression tests for modality, processor output, and dispatch GLM-OCR text-vs-image calibration on ROCm (2 samples, final logits vs dense): text cosine 0.9835 / KL 0.1423; image cosine 0.9950 / KL 0.0470.
ZX-ModelCloud
marked this pull request as ready for review
November 6, 2026 10:13
The dynamic-resolution image processor returns pixel_values as a list when image sizes differ, but the remote generate() only accepts a stacked tensor. Disable batch quantization for Nemotron Omni so heterogeneous images cannot be mixed into one calibration batch.
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.
Summary
BaseQModel.modalitydefaults to[MODALITY.TEXT](gptqmodel/models/base.py:423). Four multimodal wrappers never overrode it, sotests/models/model_test.pytook the text-only calibration branch (is_image_to_text_model = False) even though their language towers consume image embeddings at inference time:GlmOCRGPTQBaseQModelIMAGE_TO_TEXTMiniMaxM3VLGPTQBaseQModelIMAGE_TO_TEXTQwen3OmniMoeGPTQBaseQModelIMAGE_TO_TEXTNemotronOmniQModelNemotronHQModelIMAGE_TO_TEXTAdding
modalityalone is not enough: none of the four implemented a multimodalprepare_dataset, soget_calib_dataset()would have hit itsNotImplementedError.Related:
The only open PR mentioning this area is #3457, a docs-only draft that explicitly does not resolve #2928.
Changes
GlmOCRGPTQ: now inheritsBaseQwen3VLGPTQ(itsmodel.visual+model.language_modellayout matches), reuses the shared multimodal calibration path, and setsrequire_mm_token_type_ids = Truebecause GLM-OCR's forward requires it. Keeps its originalmodule_tree,pre_lm_head_norm_module, androtary_embedding.MiniMaxM3VLGPTQ: declaresIMAGE_TO_TEXT; builds the nativeMiniMaxM3VLProcessorfromAutoImageProcessor+AutoTokenizer+AutoVideoProcessor(loading the remote processor withtrust_remote_code=Truealso swaps in a config that cannot rebuild the model); addsprocess_vision_info()/prepare_dataset().Qwen3OmniMoeGPTQ: declaresIMAGE_TO_TEXT;require_load_processor = True; image+text calibration through the native processor.NemotronOmniQModel: declaresIMAGE_TO_TEXT;AutoProcessor(trust_remote_code=True); calibration keepspixel_values,imgs_sizes,num_patches,num_tokens;run_input_capture()usesmodel.generate()for multimodal batches because the top-levelforward()requiresimage_flagsand callstorch.distributed.get_rank()unconditionally.tests/models/ovis/image_to_test_dataset.py: routesMiniMaxM3VLGPTQ/NemotronOmniQModeltoformat_qwen2_vl_datasetandQwen3OmniMoeGPTQtoformat_qwen2_5_omni_dataset.GlmOCRGPTQis covered by the existingBaseQwen3VLGPTQbranch.tests/models/test_minimax_m3.py:LOAD_PROCESSOR = FalsebecauseAutoProcessor.from_pretrained(..., trust_remote_code=False)fails for MiniMax-M3.tests/test_multimodal_modality_calibration.py: 9 regression tests covering modality declarations, GLM-OCR's shared-base contract andmm_token_type_idsrequirement, real fake-processorprepare_datasetoutputs for all families, Nemotron's generate-based capture, andget_calib_dataset()dispatch.Validation
CPU-only unit tests (ROCm env):
Real processors (
prepare_dataset, batch=1 and batch=2) all emitpixel_values:input_ids, attention_mask, mm_token_type_ids, pixel_values, image_grid_thwinput_ids, attention_mask, pixel_values, image_grid_thwinput_ids, attention_mask, pixel_values, image_grid_thwinput_ids, attention_mask, pixel_values, num_patches, num_tokens, imgs_sizesReal GLM-OCR text-vs-image calibration on AMD ROCm GPUs 2/3 (2 samples, final-token logits vs dense bf16):
gptq-text(old behavior)gptq-multimodal(this PR)Image-conditioned calibration is materially closer to dense on multimodal inference. This is a smoke-level comparison (2 samples), not a statistical result.
Scope / limitations
Notes for reviewers
NemotronOmniQModel.forward(). It still delegates to the model's top-level forward for multimodal calls; only the calibration input-capture path avoids theimage_flags/torch.distributed.get_rank()requirements.tests/models/test_glm_ocr.py) is run end-to-end.