Skip to content

re-port sanitize, fix #431#432

Merged
davidkoski merged 2 commits into
mainfrom
fix-qwen3vl-sanitize
Nov 4, 2025
Merged

re-port sanitize, fix #431#432
davidkoski merged 2 commits into
mainfrom
fix-qwen3vl-sanitize

Conversation

@davidkoski
Copy link
Copy Markdown
Collaborator

No description provided.

newKey = newKey.replacingOccurrences(of: "lm_head", with: "language_model.lm_head")
guard !config.textConfiguration.tieWordEmbeddings else { continue }
adjusted[newKey] = value
continue
Copy link
Copy Markdown
Collaborator Author

@davidkoski davidkoski Oct 28, 2025

Choose a reason for hiding this comment

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

Make the sanitize match the python version, see #431. It was converting

(lldb) po weights.keys.sorted()
▿ 1258 elements
  - 0 : "language_model.lm_head.biases"
  - 1 : "language_model.lm_head.scales"
  - 2 : "language_model.lm_head.weight"

to

(lldb) po weights.keys.sorted()
▿ 1258 elements
  - 0 : "language_language_model.lm_head.biases"
  - 1 : "language_language_model.lm_head.scales"
  - 2 : "language_language_model.lm_head.weight"

This omits the logic of guard !config.textConfiguration.tieWordEmbeddings else { continue } (these keys are unused if tieWordEmbeddings is present). If we need that I think it should be re-inserted right before line 1725 (adjusted[newKey] = value)

@DePasqualeOrg @rudrankriyam

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I think the mlx_vlm code doesn't end up caring if the lm_head keys are consumed so we do need that logic.

@davidkoski davidkoski requested a review from awni October 28, 2025 16:07
@rudrankriyam
Copy link
Copy Markdown
Contributor

Just went through this; LGTM! Apologies for the error in the first place

Copy link
Copy Markdown
Member

@awni awni left a comment

Choose a reason for hiding this comment

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

👍

@davidkoski davidkoski merged commit b071763 into main Nov 4, 2025
2 checks passed
@davidkoski davidkoski deleted the fix-qwen3vl-sanitize branch November 4, 2025 18:26
atdrendel pushed a commit to shareup/mlx-swift-examples that referenced this pull request Dec 6, 2025
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