modelscope / modelscope/ms-swift

ms-swift 3.12.5 无法加载一个由 ms-swift 4.0.3 训练/导出的 Qwen3-VL MoE HF checkpoint

Open
#9,663 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
Python
Stars
15.7k
Forks
1.7k
Avg merge
1d 16h
Merged PRs (30d)
136

Description

Checklist / 检查清单
  • I have searched existing issues, and this is a new question or discussion topic. / 我已经搜索过现有的 issues,确认这是一个新的问题与讨论。
Question Description / 问题描述

问题描述

我在尝试用 ms-swift 3.12.5 + vLLM 0.13.0 环境运行 Megatron-SWIFT GRPO colocate 训练时,加载一个由 ms-swift 4.0.3 训练/导出的 Qwen3-VL MoE HF checkpoint 失败。

初步判断原因是:ms-swift 4.0.3 导出的模型 metadata 中 model_typeqwen3_vl_moe,但 ms-swift 3.12.5 中注册的 Qwen3-VL MoE 类型似乎是 qwen3_moe_vl,因此 3.12.5 无法识别 4.0.3导出的 checkpoint。

我想请教:是否有官方推荐的兼容迁移方式,让 ms-swift 4.0.3 训练/导出的 Qwen3-VL MoE 模型可以被 ms-swift 3.12.5 读取?例如是否可以通过 ms-swift 3.12.5 重新执行 mcore2hf 转换,或修改某些 metadata 文件来实现兼容?

运行环境

使用的镜像:

modelscope-registry.cn-hangzhou.cr.aliyuncs.com/modelscope-repo/modelscope:ubuntu22.04-cuda12.8.1-py311-torch2.9.0-vllm0.13.0-modelscope1.33.0-swift3.12.5

额外安装:
Megatron-LM core_r0.15.0
megatron.core.version: 0.15.4

模型来源:

基座模型:Qwen3-VL-30B-A3B-Instruct
训练/导出环境:ms-swift 4.0.3
导出格式:HF/safetensors
导出的 checkpoint 中 args.json 里记录的 model_type 为 qwen3_vl_moe

报错信息

关键报错如下:
[INFO:swift] Successfully loaded /path/to/checkpoint/args.json.
ValueError: model_type: 'qwen3_vl_moe' not in [...]

完整报错中可以看到 ms-swift 3.12.5 当前注册的模型类型列表里包含:
qwen3_vl
qwen3_moe_vl

但不包含:
qwen3_vl_moe

因此在这里失败:
File "/usr/local/lib/python3.11/site-packages/swift/llm/model/register.py", line 622, in _get_model_info
raise ValueError(f"model_type: '{model_type}' not in {list(MODEL_MAPPING.keys())}")
ValueError: model_type: 'qwen3_vl_moe' not in [...]

我的理解

我理解 ms-swift 3.12.5 中 Qwen3-VL MoE 的 model type 名称可能是:
qwen3_moe_vl
而 ms-swift 4.0.3 中对应名称变成了:
qwen3_vl_moe
所以 4.0.3 导出的 HF checkpoint,在 3.12.5 环境中读取时会因为 args.json / metadata 中的 model_type 不兼容而失败。

想请教的问题

ms-swift 是否支持跨版本读取 Qwen3-VL MoE checkpoint?特别是 4.x 导出的 qwen3_vl_moe checkpoint 是否可以在 3.12.5 中加载?
如果只是 model type 命名变化,是否可以安全地把导出 checkpoint 中的 args.json 里的 model_type 从 qwen3_vl_moe 改为 qwen3_moe_vl?
除了 args.json,是否还需要同步修改 config.json 或其他 metadata?
是否有官方推荐的转换流程?例如:用 ms-swift 4.x 先转换回某种 mcore 格式,再用 ms-swift 3.12.5 执行 mcore2hf?
或者直接用 ms-swift 3.12.5 对原始 Megatron checkpoint 执行 mcore2hf,使导出的 HF metadata 与 3.12.5 兼容?

感谢。

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with swift/llm/model/register.py around _get_model_info at line 622, then compare the model_type entries in args.json and config.json for the exported checkpoint. Check the ms-swift 3.12.5 model registrations and the mcore2hf conversion path to determine whether the metadata rename is sufficient or whether a documented conversion is required. Done means a confirmed compatible migration procedure or a reproducible explanation of why the checkpoint cannot be loaded.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.