Skip to content

Fix tie_word_embedding issues with Qwen2VL#44976

Merged
hmellor merged 2 commits intohuggingface:mainfrom
hmellor:fix-qwen2vl
Mar 24, 2026
Merged

Fix tie_word_embedding issues with Qwen2VL#44976
hmellor merged 2 commits intohuggingface:mainfrom
hmellor:fix-qwen2vl

Conversation

@hmellor
Copy link
Copy Markdown
Member

@hmellor hmellor commented Mar 24, 2026

  • Adds a type hint to ModernVBertForMaskedLM.__init__
  • Removes tie_word_embeddings from Qwen2VLTextConfig (and therefore also Qwen2_5_VLTextConfig) because it's not valid for these models
  • Remove hack from ColQwen2Config (and therefore also ColModernVBertConfig) and fix the config upstream instead

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
@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.

Copy link
Copy Markdown
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

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

I am probably missing some context (and previous code already looks super weird).

Might be worse adding a small test as well!

bos_token_id: int | None = 151643
eos_token_id: int | list[int] | None = 151645
pad_token_id: int | None = None
tie_word_embeddings: bool = False
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.

its false by default so that does not change much

Comment on lines +61 to +62
if tie_word_embeddings:
self.vlm_config["tie_word_embeddings"] = tie_word_embeddings.pop()
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.

we are checking tie word embedding from both text and vision config to know if we should tie for the vlm?

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.

I guess the vision config is a VLM as well?

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

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

run-slow: colmodernvbert, colqwen2, modernvbert, qwen2_5_vl, qwen2_vl

Copy link
Copy Markdown
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

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

Test can come later, TLDR: vllm reads the attribute. Having it here as false is an error!

@hmellor hmellor enabled auto-merge March 24, 2026 20:43
@hmellor hmellor added this pull request to the merge queue Mar 24, 2026
Merged via the queue into huggingface:main with commit 28af818 Mar 24, 2026
22 checks passed
@hmellor hmellor deleted the fix-qwen2vl branch March 24, 2026 20:55
zucchini-nlp pushed a commit to zucchini-nlp/transformers that referenced this pull request Mar 27, 2026
* Fix tie_word_embedding issues with `Qwen2VL`

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>

* remove colqwen hack

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>

---------

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
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