fix(mcore_adapter): support fused MTP expert weights in qwen3_5 template - #480
Open
returnL wants to merge 1 commit into
Open
fix(mcore_adapter): support fused MTP expert weights in qwen3_5 template#480returnL wants to merge 1 commit into
returnL wants to merge 1 commit into
Conversation
Qwen3.6 checkpoints store MTP expert weights fused (e.g. mtp.layers.0.mlp.experts.down_proj, without an expert index), while Qwen3.5 stores them per expert (mtp.layers.0.mlp.experts.0.down_proj.weight). hf_name_to_mca_names only handled the per-expert format and raised 'Cannot get layer prefix from weight_name' during shard filtering. Unify the MTP name splitting of add_hf_weight and hf_name_to_mca_names into a shared helper so file filtering always matches the converter's actual output for both checkpoint formats, and use MCA_MTP_MOE_PREFIX for the forward/reverse prefix mapping so the two directions are exact inverse substitutions of the same constant.
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.
Problem
Loading Qwen3.6 checkpoints (e.g.
Qwen/Qwen3.6-35B-A3B,model_type: qwen3_5_moe) fails during HF→MCA weight conversion:Root cause: Qwen3.5 checkpoints store MTP expert weights per expert (
mtp.layers.0.mlp.experts.{i}.down_proj.weight, 785 MTP keys), while Qwen3.6 stores them fused (mtp.layers.0.mlp.experts.down_proj/gate_up_proj, 19 MTP keys).hf_name_to_mca_namesonly handled the per-expert format when stripping the expert prefix for shard filtering.Fix
add_hf_weight(conversion) andhf_name_to_mca_names(shard filtering) into a shared helper, so filtered names always match the converter's actual output keys for both checkpoint formats.MCA_MTP_MOE_PREFIX, making them exact inverse substitutions of the same constant.Testing
Verified with
Qwen3.5-35B-A3B(per-expert MTP) andQwen3.6-35B-A3B(fused MTP): bothhf_name_to_mca_namesandadd_hf_weightproduce correct per-expert MCA names, and filter names match conversion keys exactly.