Skip to content

Modularize qwen-format vision processors - #47573

Merged
zucchini-nlp merged 19 commits into
huggingface:mainfrom
zucchini-nlp:qwen-image-processors
Aug 4, 2026
Merged

Modularize qwen-format vision processors#47573
zucchini-nlp merged 19 commits into
huggingface:mainfrom
zucchini-nlp:qwen-image-processors

Conversation

@zucchini-nlp

@zucchini-nlp zucchini-nlp commented Jul 27, 2026

Copy link
Copy Markdown
Member

CI

What does this PR do?

For easier modular inheritance when we only want to change the resize-fn or the patch layout + easier to read the code


do_resize = True
resample = PILImageResampling.BICUBIC
class Cosmos3EdgeImageProcessor(Glm4vImageProcessor):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

basically, it is same just with different default values, why not copy in that case?

Comment on lines -86 to -96
def _standardize_kwargs(self, **kwargs) -> dict:
"""
Update kwargs that need further processing before being validated
Can be overridden by subclasses to customize the processing of kwargs.
"""
kwargs = super()._standardize_kwargs(**kwargs)
size = kwargs.get("size", self.size)
if not size.shortest_edge or not size.longest_edge:
raise ValueError("size must contain 'shortest_edge' and 'longest_edge' keys.")
return kwargs

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

i don't think we need to check it in here, it belong to self.validate but I decided to move inside self.resize, that makes it easier to re-use in modular

Comment on lines -833 to 836
# Add/overwrite all needed function nodes and dependencies
# Add/overwrite all needed function nodes and dependencies, but save fn names from modular file before
self.modular_defined_global_objects.update(functions.keys())
self.functions.update(functions)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Cases when we want to copy video processing from e.g. Qwen2VL but the model has no image processing. Video processor has an import line from .image_processing_model import smart_resize and currently it's impossible to override it with custom smart_resize

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Tbh, we should never have cross imports in the first place so I'd rather we copy the smart resize functions to vid processor for example

This looks like a workaround we actually don't want to have as it hides the issue with cross imports

@zucchini-nlp
zucchini-nlp requested a review from vasqu July 28, 2026 10:59
@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.

@zucchini-nlp zucchini-nlp mentioned this pull request Jul 28, 2026
6 tasks

@vasqu vasqu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Super nice to get more modular usage out of these 馃 I have a few comments, mostly the modular change is making me hesitate to approve for now

Also we are breaking! We do change kwargs orders etc for the price of uniform implementation so we do need a 馃毃

Comment thread src/transformers/models/cosmos3_edge/image_processing_cosmos3_edge.py Outdated
Comment thread src/transformers/models/cosmos3_edge/image_processing_cosmos3_edge.py Outdated
patch_size: int,
temporal_patch_size: int,
merge_size: int,
disable_grouping: bool | None,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

breaking

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

haha, kinda though can we say it's breaking for a private method? 馃槃 They will have defaults propagated iirc when we get to this point

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

fair point :D yea its not too breaking

Comment thread src/transformers/models/cosmos3_edge/modular_cosmos3_edge.py Outdated
Comment thread src/transformers/models/glmga/modular_glmga.py
Comment thread src/transformers/models/qwen3_vl/modular_qwen3_vl.py Outdated
Comment thread src/transformers/models/qwen3_vl/modular_qwen3_vl.py Outdated
Comment on lines -833 to 836
# Add/overwrite all needed function nodes and dependencies
# Add/overwrite all needed function nodes and dependencies, but save fn names from modular file before
self.modular_defined_global_objects.update(functions.keys())
self.functions.update(functions)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Tbh, we should never have cross imports in the first place so I'd rather we copy the smart resize functions to vid processor for example

This looks like a workaround we actually don't want to have as it hides the issue with cross imports

@zucchini-nlp

Copy link
Copy Markdown
Member Author

not ready yet, will fix and run slow CI

@zucchini-nlp

Copy link
Copy Markdown
Member Author

run-slow: cosmos3_edge, ernie4_5_vl_moe, glm46v, glm4v, glm_image, glmga, hunyuan_vl, kimi_k25, minimax_m3_vl, paddleocr_vl, qwen2_vl, qwen3_vl, video_llama_3

@github-actions

Copy link
Copy Markdown
Contributor

Workflow Run 鈿欙笍

This comment contains run-slow, running the specified jobs:

models: ["models/cosmos3_edge", "models/ernie4_5_vl_moe", "models/glm46v", "models/glm4v", "models/glm_image", "models/glmga", "models/hunyuan_vl", "models/kimi_k25", "models/minimax_m3_vl", "models/paddleocr_vl", "models/qwen2_vl", "models/qwen3_vl", "models/video_llama_3"]
quantizations: []

@github-actions

Copy link
Copy Markdown
Contributor

CI Results

Workflow Run 鈿欙笍

Commit Info

Context Commit Description
RUN e4bc4f09 workflow commit (merge commit)
PR bfef0374 branch commit (from PR)
main 5f3e9a41 base commit (on main)

鈿狅笍 Model CI failed to report results

The test failure analysis could not be completed. Please check the workflow run for details.

@zucchini-nlp

Copy link
Copy Markdown
Member Author

looks fine, same tests failing as main

@zucchini-nlp
zucchini-nlp requested a review from vasqu July 30, 2026 10:34
@zucchini-nlp

Copy link
Copy Markdown
Member Author

@bot /repo

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Repo. Consistency bot fixed some files and pushed the changes.

@vasqu vasqu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM now thanks 馃 just a few nits but nothing major, one idea for potential mlinter

Comment thread utils/modular_model_converter.py Outdated
Comment thread src/transformers/models/voxtral_realtime/processing_voxtral_realtime.py Outdated
Comment thread src/transformers/models/cosmos3_edge/modular_cosmos3_edge.py Outdated
Comment thread src/transformers/models/cosmos3_edge/modular_cosmos3_edge.py
Comment thread src/transformers/models/hunyuan_vl/modular_hunyuan_vl.py
Comment thread src/transformers/models/janus/modular_janus.py
Comment thread src/transformers/models/qwen2_vl/video_processing_qwen2_vl.py
Comment thread src/transformers/models/qwen3_vl/modular_qwen3_vl.py
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: cosmos3_edge, ernie4_5_vl_moe, glm46v, glm4v, glm_image, glmga, hunyuan_vl, janus, kimi_k25, minimax_m3_vl, paddleocr_vl, qwen2_vl, qwen3_vl, tvp, video_llama_3, vitmatte

@zucchini-nlp
zucchini-nlp enabled auto-merge August 4, 2026 08:21
@zucchini-nlp
zucchini-nlp added this pull request to the merge queue Aug 4, 2026
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

CI recap

Dashboard: View test results in Grafana
Latest run: 30815025986:1
Result: success | Jobs: 16 | Tests: 178,174 | Failures: 0 | Duration: 12h 54m

Merged via the queue into huggingface:main with commit bed02e1 Aug 4, 2026
112 checks passed
@zucchini-nlp
zucchini-nlp deleted the qwen-image-processors branch August 4, 2026 08:44
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