Merged
040 的 Qwen 和 SFT #1205
Merged
Can Learn BotAdd on 28 days ago
Can Learn Bot
Can Learn BotCollaborators
28 days ago

描述

Qwen3.5 系列 SFT 适配 TorchTitan 0.4.0

本 PR 在 dev_0.4.0 接入 Qwen3.5 系列文本 SFT。统一所有标识符为 Qwen 3.5, 实际涵盖 Qwen3.5, Qwen3.6, Qwen3.8, 对于 Qwen 3.8 等存在较大差异的模型已做重点验证

类型

Checklist:

如何测试

训练验证

使用 Qwen3.6-27B,序列长度为 32K。固定初始权重、训练输入和运行环境,对比 master d2eb7d2c 与验收提交 bca9b327。两边均使用 lr=1e-5、weight_decay=0.1,完成 16 个优化步。

精度和性能验证结果

指标 一致记录数 最大绝对差
Loss 256 / 256 0
Grad norm 256 / 256 0

Qwen3.6-27B 32K 的 loss 和 grad norm 对拍

Qwen 模型适配

三个 27B 模型均通过官方权重索引和参数名映射检查。监督校验使用同一组 31 条对话,覆盖普通答复、带推理答复、多轮工具调用和仅监督推理正文的自定义模板。

模型 已验证的官方模板行为 逐 token 校验 验证范围
Qwen3.5-27B 保留最后一条 user 消息之后的推理。历史推理可通过定制模板保留 31 条,70,767 个位置 CPU 监督与权重映射
Qwen3.6-27B preserve_thinking 保留历史推理 31 条,71,047 个位置 CPU 监督与权重映射
Qwen3.8-27B preserve_thinking 保留历史推理,按该版本的 tokenizer 和模板生成标签 31 条,72,297 个位置 CPU 监督与权重映射

其他信息

与 Qwen 原厂框架 ms-swift 的监督策略对照

策略 ms-swift --loss_scale 本 PR --loss-mask
多轮监督 default 选中各轮 assistant 回复 default 选择相同的轮次范围,标签按 Qwen 模板的输出生成
末轮监督 last_round 从最后一条 user 消息之后选取 assistant 回复 last_round 同样包含末轮内经工具往返后的 assistant 回复
屏蔽空推理 ignore_empty_think,混合推理模型默认追加 ignore_empty_think,省略参数时等价于 default+ignore_empty_think
屏蔽推理开头 ignore_think_prefix 屏蔽起始标记,保留正文和结束标记 同名策略保留正文和结束标记,已验证的 Qwen 基础策略也屏蔽该起始标记

表格依据 ms-swift 的策略定义和数据说明。上面的逐 token 结果使用各模型模板及独立参考标签进行核对。

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for Can Learn Bot's contribution.)
Can Learn BotCan Learn BotCollaborators
28 days ago Created pull request, commit baf63d16
CANN-robotCANN-robotCollaborators
28 days ago Added label: cann-cla/no
CANN-robot
CANN-robotCollaborators
28 days ago Comments:

Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.


PR Approval Progress

✅ Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
repo-cann/torchtitan-npu ✅ zhaowei1936, xuyujun (2/2) ✅ zhaowei1936 (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

botcanlearn, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
CANN-robotCANN-robotCollaborators
28 days ago Set hwcaifubi,lrwei0709,zhaowei1936,zhong_lin,zhanghz1,depeng1994,shengnan666,XDaoHong,xuyujun,zhuofanshen,wanghui0,panchao-gitcode,zzyyjj012 as approver
CANN-robotCANN-robotCollaborators
28 days ago Set hwcaifubi,lrwei0709,zhaowei1936,zhong_lin,zhanghz1,depeng1994,shengnan666,XDaoHong,xuyujun,zhuofanshen,wanghui0,panchao-gitcode,zzyyjj012 as approver
350 messages are collapsed here。 See more
CANN-robotCANN-robotCollaborators
16 days ago Merged pull request
CANN-robot
CANN-robotCollaborators
16 days ago Comments:

Pull Request 已合并或已关闭。

If you want to solve this problem, you can click here to do it in the FAQs.

likedislike
Can Learn BotCan Learn BotCollaborators
15 days ago Modify description of pull request
CANN-robot
CANN-robotCollaborators
15 days ago Comments:

Pull Request 已合并或已关闭。

If you want to solve this problem, you can click here to do it in the FAQs.

likedislike
CANN-robot
CANN-robotCollaborators
15 days ago Comments:

Pull Request 已合并或已关闭。

If you want to solve this problem, you can click here to do it in the FAQs.

likedislike