Skip to content

Add Qwen 3.8 support for text, VLM, and MTP speculative decoding - #545

Merged
davidkoski merged 4 commits into
ml-explore:mainfrom
aleroot:qwen_3_8
Oct 12, 2026
Merged

davidkoski merged 4 commits into
ml-explore:mainfrom
aleroot:qwen_3_8

Conversation

@aleroot

@aleroot aleroot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Proposed changes

Adds support for Qwen 3.8 (e.g. mlx-community/Qwen3.8-27B-4bit and mlx-community/Qwen3.8-27B-8bit) across text LLM, multimodal VLM, and Multi-Token Prediction (MTP) speculative decoding pipelines.

Checklist

Put an x in the boxes that apply.

  • I have read the CONTRIBUTING document
  • I have run pre-commit run --all-files to format my code / installed pre-commit prior to committing changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the necessary documentation (if needed)

@thechriswebb

Copy link
Copy Markdown
Collaborator

Ha, I was just about to look into this myself. Not surprised you beat me to it!

Comment thread Libraries/MLXVLM/Models/Qwen35.swift Resolved
Comment thread Libraries/MLXVLM/Models/Qwen35.swift Resolved

@davidkoski davidkoski 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.

Change looks good, but see questions -- those may or may not be real issues. Thanks!

@davidkoski davidkoski 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.

See question about Gemma4AssistantDraftModel. Aside from that I think this looks ready to go. Thanks!

@davidkoski davidkoski 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.

I think this is ready to go -- just needs conflicts resolved on the ssmIdx / faIdx. Thanks!

@aleroot

aleroot commented Sep 16, 2026

Copy link
Copy Markdown
Contributor Author

@davidkoski this should be really ready to go now, I see other forks integrating it already, so I guess it is good...

ibrahimcetin added a commit to ibrahimcetin/mlx-swift-lm that referenced this pull request Sep 24, 2026
Adds Qwen3.8/Qwen3.8-MoE model types and MTP drafter registration for
both LLM and VLM factories, with a hybrid attention schedule helper
and matching tests.
@ngutech21 ngutech21 mentioned this pull request Oct 1, 2026
5 tasks done

@davidkoski davidkoski 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.

Changes look good. Needs a rebase -- conflict in Qwen35.

- Register qwen3_8, qwen3_8_text, and qwen3_8_moe architectures in LLMTypeRegistry and VLMTypeRegistry
- Add qwen3_8_27b_4bit and qwen3_8_27b_8bit model configuration presets to LLMRegistry and VLMRegistry
- Add Qwen3_5VLProcessor and Qwen3_8VLProcessor aliases to VLMProcessorTypeRegistry
- Add dynamic layer_types decoding and faIdx full-attention layer index resolution
- Harden weight sanitization across MLXLLM and MLXVLM for multimodal and text-only checkpoint loading
- Register Qwen 3.8 MTP draft model types in MTPDrafterTypeRegistry
- Add comprehensive Qwen38Tests unit test suite
@aleroot

aleroot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor Author

Rebased on latest main and adopted #580 design: Qwen 3.8 now loads its vision tower on first image/video use. Text-only loads skip vision tensors entirely, while multimodal use follows the shared validated on-demand loading path.

@davidkoski
davidkoski merged commit 4cc5504 into ml-explore:main Oct 12, 2026
4 of 5 checks passed
@aleroot aleroot mentioned this pull request Oct 13, 2026
5 tasks done
@spokvulcan spokvulcan mentioned this pull request Oct 13, 2026
4 of 5 tasks
davidkoski pushed a commit that referenced this pull request Oct 14, 2026
targetLoaderExcludesConvertedMTPComponent(vision: true) has failed on main
since #545 made the Qwen 3.5 VLM load its vision tower on first use: the
test counted parameters before the vision tower loads. It now loads with
componentLoading: .immediate and compares key sets, as #692 does.

testActiveSpeculativeDecodingReusesAlignedStorageAcrossTurns fails about one
run in a hundred. When the last speculative round accepts every draft, the
iterator leaves the last draft for the next round to feed, so the draft cache
ends one token behind the main cache and the next ChatSession turn rebuilds
both caches. finalizeGeneration now feeds that draft when it was returned,
unless the task is cancelled. Two tests that recorded the lag now expect both
caches at the same offset, and the Harmony tool-call restart now resumes on
both caches.
jeethu added a commit to numen-tech/mlx-swift-lm that referenced this pull request Nov 15, 2026
… faCacheOffset)

Upstream ml-explore#545/ml-explore#737 made faIdx optional and renamed the helper prepare uses to
anchorCacheOffset (a full-attention layer's offset, else a linear layer's).
For every model with a full-attention layer, which is every Qwen3.5 and
Ternary Bonsai 2 pack, it returns what faCacheOffset did.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants