Merged
[fix] 修复 VLM 默认训练配置 #422
panchao-gitcodeAdd on Jul 10
[fix] 修复 VLM 默认训练配置 #422
Merged
Pull Request has been successfully merged by CANN-robot.
(Thank you for panchao-gitcode's contribution.)atomgit-bot
Jul 10 Comments:
Jul 10 Comments:
变更摘要
此 PR 修复了 vlm_debugmodel_npu 默认训练配置中因 seq_len=256 过短导致 cc12m-test 数据集样本(编码后长度 258~452)被跳过、无法进入有效训练的问题。通过将序列长度提升至 2048 并同步调整图片相关参数,使编码后长度为 767~1212 的样本可被正常容纳;同时更新了文档示例以使用 8 卡真实通信运行。
主要改动
- 训练配置参数调整: 将
vlm_debugmodel_npu()中的local_batch_size从1改为8、seq_len从256改为2048、steps从2改为10,确保序列长度足以容纳视觉 token 展开后的样本。 - 图片数据加载器配置增强: 在
HuggingFaceMultiModalDataLoader.Config中新增max_patches_per_image=1024和max_images_per_batch=64两个参数,匹配调整后的序列长度。 - VLM 文档示例更新: 将
docs/feature_guides/vlm.md示例改为 8 卡真实通信方式运行,移除fake_backend及会覆盖正确默认值的命令行参数。


Incorrect?
atomgit-bot
Jul 10 Comments:
Jul 10 Comments:
Jul 10 Added label: cann-cla/yes
CANN-robot
Jul 10 Comments:
Jul 10 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
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 | ✅ lrwei0709, xuyujun (2/2) | ✅ lrwei0709 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
panchao-gitcode, thanks for your pull request. All authors of the commits have signed the CLA. 👍


panchao-gitcode
Jul 10 Comments:
Jul 10 Comments:
compile


Jul 10 Added label: ci-pipeline-running
CANN-robot
Jul 10 Comments:
Jul 10 Comments:
流水线任务触发成功
任务链接 [40ec7c8411a14d4685e4f0bb7d82d85c][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| codecheck | ✅ SUCCESS | >>>>> | |
| SCA | ✅ SUCCESS | >>>>> | |
| antipoison | ✅ SUCCESS | >>>>> | |
| pre_comment | ✅ SUCCESS | >>>>> | |
| lint | ✅ SUCCESS | ||
| UT_Test | ✅ SUCCESS | >>>>> | |
| PreSmoke_A900_npupool | ✅ SUCCESS | >>>>> | |
| codecheck_codestyle | ✅ SUCCESS | >>>>> | |
| precommit | ⚠️ WARNING | >>>>> | >>>>> |
[2026-07-10 21:18:12] CI执行结束


Jul 10 Removed label: ci-pipeline-running
Jul 10 Added label: ci-pipeline-passed
CANN-robot
Jul 10 Comments:
Jul 10 Comments:
流水线 PR-pipeline_cann_torchtitan-npu#1645 [ commitID:a26f3dbb ] 已完成


xuyujun
Jul 11 Comments:
Jul 11 Comments:
【MR评价】评价分数:3,
评价意见:基本功能修复
编码规范遵守度:无编码规范问题;
代码设计:不涉及代码设计;
DT质量:基本逻辑DT测试覆盖充足;


xuyujun
Jul 11 Comments:
Jul 11 Comments:
/lgtm


weijinyi
Jul 11 Comments:
Jul 11 Comments:
/approve


Jul 11 Added label: lgtmapproved
Jul 11 Merged pull request
描述
VLM 的图片 patch 会展开为视觉 token,并与图片边界、caption 和 EOS 一起占用语言模型序列长度。原默认配置使用
training.seq_len=256,当前cc12m-test图片编码后长度为 258~452,导致样本因超长被跳过,无法进入有效训练。本次修改:
vlm_debugmodel_npu默认训练配置调整为local_batch_size=8、seq_len=2048、steps=10。max_patches_per_image=1024、max_images_per_batch=64;当前测试图片编码后长度为 767~1212,可被seq_len=2048容纳。docs/feature_guides/vlm.md示例改为 8 卡真实通信运行,删除fake_backend及会覆盖正确默认值的命令行参数。类型
Checklist:
如何测试
结果:全部通过。
PYTHONPATH=/data/p00465316/npu_moe_re_routing/torchtitan:$PWD \ python3 -m pytest tests/unit_tests/models/test_multimodal_helpers.py -q -k vlm_config结果:
5 passed。PYTHONPATH=/data/p00465316/npu_moe_re_routing/torchtitan:$PWD:${PYTHONPATH:-} \ NGPU=8 \ MODULE=torchtitan_npu.models.vlm \ CONFIG=vlm_debugmodel_npu \ bash scripts/run_train.sh结果:成功完成默认 10 step;训练初始化确认
local batch size=8、global batch size=64、sequence length=2048,loss 从8.18690降至0.47367,无 OOM、NaN 或 Inf。premerge-accuracy-check对改动前后进行数值验证:9d4ad2a92e5b1a328dbe4aa9e186790adf64d957a26f3dbb56e7963ee378ceecd61b506d27b4ebd5seed=42,确定性模式,各训练 100 step0;无 NaN 或 Inf,结论为 PASS其他信息
c49d9ac..a26f3db在torchtitan_npu/和docs/下无差异,训练运行时内容一致。