Repository navigation
Add Qwen 3.8 support for text, VLM, and MTP speculative decoding - #545
Conversation
|
Ha, I was just about to look into this myself. Not surprised you beat me to it! |
davidkoski
left a comment
There was a problem hiding this comment.
Change looks good, but see questions -- those may or may not be real issues. Thanks!
davidkoski
left a comment
There was a problem hiding this comment.
See question about Gemma4AssistantDraftModel. Aside from that I think this looks ready to go. Thanks!
davidkoski
left a comment
There was a problem hiding this comment.
I think this is ready to go -- just needs conflicts resolved on the ssmIdx / faIdx. Thanks!
|
@davidkoski this should be really ready to go now, I see other forks integrating it already, so I guess it is good... |
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.
davidkoski
left a comment
There was a problem hiding this comment.
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
|
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. |
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.
… 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.
Proposed changes
Adds support for Qwen 3.8 (e.g.
mlx-community/Qwen3.8-27B-4bitandmlx-community/Qwen3.8-27B-8bit) across text LLM, multimodal VLM, and Multi-Token Prediction (MTP) speculative decoding pipelines.Checklist
Put an
xin the boxes that apply.pre-commit run --all-filesto format my code / installed pre-commit prior to committing changes