Skip to content

fix(mcore_adapter): support fused MTP expert weights in qwen3_5 template - #480

Open
returnL wants to merge 1 commit into
alibaba:mainfrom
returnL:fix-qwen3p6-mtp-fused-experts
Open

fix(mcore_adapter): support fused MTP expert weights in qwen3_5 template#480
returnL wants to merge 1 commit into
alibaba:mainfrom
returnL:fix-qwen3p6-mtp-fused-experts

Conversation

@returnL

@returnL returnL commented Aug 12, 2026

Copy link
Copy Markdown

Problem

Loading Qwen3.6 checkpoints (e.g. Qwen/Qwen3.6-35B-A3B, model_type: qwen3_5_moe) fails during HF→MCA weight conversion:

ValueError: Cannot get layer prefix from weight_name='.mlp.experts.down_proj' with prefix='.mlp.experts.'

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_names only handled the per-expert format when stripping the expert prefix for shard filtering.

Fix

  • Unified the MTP name splitting of add_hf_weight (conversion) and hf_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.
  • The forward (hf→mca) and reverse (mca→hf) prefix mappings now both use MCA_MTP_MOE_PREFIX, making them exact inverse substitutions of the same constant.

Testing

Verified with Qwen3.5-35B-A3B (per-expert MTP) and Qwen3.6-35B-A3B (fused MTP): both hf_name_to_mca_names and add_hf_weight produce correct per-expert MCA names, and filter names match conversion keys exactly.

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

CLAassistant commented Aug 12, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants