Skip to content

Fix multimodal processor get duplicate arguments when receive kwargs for initialization #39125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 2, 2025

Conversation

Isotr0py
Copy link
Collaborator

@Isotr0py Isotr0py commented Jun 30, 2025

What does this PR do?

Also reported in vllm-project/vllm#19833

The current processor arguments revolving logic can hit TypeError: Qwen2VLProcessor.__init__() got multiple values for argument 'tokenizer' if we passed tokenizer as a kwargs. Because it will remove unused args, which caused an incorrect args order and raise TypeError: Qwen2VLProcessor.__init__() got multiple values for argument 'tokenizer'.

For example, Qwen2-VL receive (image_processor, tokenizer, video_processor) as args, if we passed tokenizer as kwargs, it will be removed from args, which will become (image_processor, video_processor) and pass video_processor as tokenizer:

def __init__(self, image_processor=None, tokenizer=None, video_processor=None, chat_template=None, **kwargs):

Code to reproduce

from transformers import Qwen2VLProcessor, Qwen2Tokenizer

processor = Qwen2VLProcessor.from_pretrained("/data/LLM-model/Qwen2-VL-2B-Instruct")
print(type(processor.tokenizer))

tokenizer = Qwen2Tokenizer.from_pretrained("/data/LLM-model/Qwen2.5-3B-Instruct")
processor = Qwen2VLProcessor.from_pretrained("/data/LLM-model/Qwen2-VL-2B-Instruct", tokenizer=tokenizer)
print(type(processor.tokenizer))

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@Isotr0py Isotr0py changed the title Fix processor getting duplicate arguments when rec Fix processor get duplicate arguments when receive kwargs for initialization Jun 30, 2025
@Isotr0py Isotr0py requested a review from zucchini-nlp June 30, 2025 12:12
@HuggingFaceDocBuilderDev

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.

Signed-off-by: Isotr0py <[email protected]>
@Isotr0py Isotr0py changed the title Fix processor get duplicate arguments when receive kwargs for initialization Fix multimodal processor get duplicate arguments when receive kwargs for initialization Jun 30, 2025
Copy link
Member

@zucchini-nlp zucchini-nlp left a comment

Choose a reason for hiding this comment

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

Thanks, looks good. I think this has a lot of assumptions about the order of args in the __init__, but I guess the codebase currently follows consistent ordering (🤞🏻 )

Can you add a small test in test_processing_common where one of the attributes can be arbitrarily overriden by a user?

Signed-off-by: Isotr0py <[email protected]>
@zucchini-nlp
Copy link
Member

Seems like it broke a whole lot of tests...

@zucchini-nlp zucchini-nlp added the for patch Tag issues / labels that should be included in the next patch label Jul 1, 2025
Copy link
Member

@zucchini-nlp zucchini-nlp left a comment

Choose a reason for hiding this comment

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

Thanks, we'll patch it today

@Isotr0py Isotr0py merged commit 28df7f8 into huggingface:main Jul 2, 2025
25 checks passed
@Isotr0py Isotr0py deleted the fix-processor-override branch July 2, 2025 11:57
Cyrilvallez pushed a commit that referenced this pull request Jul 4, 2025
…for initialization (#39125)

* fix processor tokenizer override

Signed-off-by: Isotr0py <[email protected]>

* code format

Signed-off-by: Isotr0py <[email protected]>

* add regression test

Signed-off-by: Isotr0py <[email protected]>

* fix

Signed-off-by: Isotr0py <[email protected]>

* check image processor same

Signed-off-by: Isotr0py <[email protected]>

---------

Signed-off-by: Isotr0py <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for patch Tag issues / labels that should be included in the next patch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Qwen2_5OmniProcessor.__init__() got multiple values for argument 'image_processor'
3 participants