Repository navigation
fix(models): load Qwen3.5's float32 GDN tensors in the model dtype - #1
Merged
Merged
Conversation
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.
Qwen3.5 stores
linear_attn.A_login float32 (the original release also storeslinear_attn.norm.weightthat way).load_staterequires an exact dtype match, so every Qwen3.5 checkpoint except NVIDIA's NVFP4 exports fails to load:Fix
WeightRules.castsnames the parameters that load in the model's dtype.load_weightscasts float tensors under those names, then runs the strictload_stateas before. Onlyqwen3_5_moeuses it, forA_logandlinear_attn.norm.weight.A_log: the cast is lossless. All 16,512 float32 values across 7 Qwen3.5 checkpoints are bf16-exact.linear_attn.norm.weight: rounded to bf16, which is what mlx-lm's own conversions already store.Now loads
Checked with a header-only dry run (configs plus safetensors headers, zero tensors in place of weights). These 7 repos go from FAIL to PASS, and nothing else changes across 67 candidate repos:
Qwen/Qwen3.5-122B-A10Bmlx-community/Qwen3.5-{35B-A3B-4bit, 122B-A10B-4bit, 122B-A10B-bf16, 397B-A17B-nvfp4}lmstudio-community/Qwen3.5-397B-A17B-MLX-{4bit, 8bit}Tested
Apple M4, 24 GB, macOS 15.3.
dt_bias, and an int32 tensor under a cast name, are still refused.uv run pytest tests/ -q(1845 passed, 66 skipped) anduv run pre-commit run --all-filespass.mlx-community/Qwen3.5-35B-A3B-4bitwithftm serve --model <dir> --max-seq-len 4096:main, loading fails with theA_logerror above.