Skip to content

Fix 'Block pattern could not be match. Pass block_name_to_quantize argument in quantize_model' while loading Qwen VL GPTQ model#2295

Merged
IlyasMoutawwakil merged 1 commit into
huggingface:mainfrom
arunmadhusud:main
Jun 19, 2025
Merged

Conversation

@arunmadhusud

@arunmadhusud arunmadhusud commented Jun 18, 2025

Copy link
Copy Markdown
Contributor

What does this PR do?

This PR fixes the issue encountered when using Qwen2VLForConditionalGeneration to load the GPTQ model:

ValueError                                Traceback (most recent call last)

[<ipython-input-1-1109427887>](https://localhost:8080/#) in <cell line: 0>()
      4 
      5 gptq_config = GPTQConfig(bits=4, use_exllama=False)
----> 6 model = Qwen2VLForConditionalGeneration.from_pretrained(
      7     "Qwen/Qwen2-VL-2B-Instruct-GPTQ-Int4",
      8     torch_dtype=torch.float16,

5 frames

[/usr/local/lib/python3.11/dist-packages/optimum/gptq/utils.py](https://localhost:8080/#) in get_block_name_with_pattern(model)
     75         if any(name.startswith(pattern_candidate) for name in modules_names):
     76             return pattern_candidate
---> 77     raise ValueError("Block pattern could not be match. Pass `block_name_to_quantize` argument in `quantize_model`")
     78 
     79 

ValueError: Block pattern could not be match. Pass `block_name_to_quantize` argument in `quantize_model`

The reason for the error is

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?

Test Plan:

Run the following:

from transformers import Qwen2VLForConditionalGeneration, AutoTokenizer, AutoProcessor, GPTQConfig
from qwen_vl_utils import process_vision_info
import torch

gptq_config = GPTQConfig(bits=4, use_exllama=False)
model = Qwen2VLForConditionalGeneration.from_pretrained(
    "Qwen/Qwen2-VL-2B-Instruct-GPTQ-Int4",
    torch_dtype=torch.float16,
    device_map="auto",
    quantization_config=gptq_config
)

Who can review?

@fxmarty, @SunMarc, @Qubitium

@IlyasMoutawwakil IlyasMoutawwakil left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks !

@IlyasMoutawwakil
IlyasMoutawwakil merged commit ed70d27 into huggingface:main Jun 19, 2025
28 of 31 checks passed
@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

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.

3 participants