Repository navigation
Fuse Qwen GDN input projections - #572
Merged
Merged
Conversation
davidkoski
reviewed
Aug 24, 2026
davidkoski
reviewed
Aug 24, 2026
davidkoski
requested changes
Aug 24, 2026
davidkoski
left a comment
Member
There was a problem hiding this comment.
See questions about mutation.
davidkoski
approved these changes
Aug 28, 2026
davidkoski
left a comment
Member
There was a problem hiding this comment.
Changes look good -- new prepare lifecycle looks good! Thank you!
djandrewgibbons
pushed a commit
to djandrewgibbons/mlx-swift-lm
that referenced
this pull request
Sep 1, 2026
* Fuse Qwen GDN input projections * Move inference preparation to LanguageModel lifecycle * Use prepare overload for inference lifecycle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
Qwen 3.5’s Gated Delta Network currently runs four separate quantized projections over the same input. Each projection starts another GPU operation, adding overhead during text generation.
This PR combines those four projections into one operation and then splits the result into the expected outputs. It applies to both text-only and vision-language Qwen 3.5 models.
The optimization is enabled only when the projections use compatible standard quantization. Models using adapters, custom quantizers, or mixed quantization settings automatically keep the existing path. Checkpoint parameter names remain unchanged.
On my Apple M2 16GB RAM running
Qwen3.5-9B-4bit, using alternating same-process comparisons:The optimization can be disabled with
MLX_QWEN_FOUR_GDN=0if needed.Checklist
pre-commit run --all-filesto format my code / installed pre-commit prior to committing changes