Closed
[refactor] 简化 DeepSeek-V4 并行化包装 #1291
hanboyouAdd on 20 days agoClosed at 17 days ago
[refactor] 简化 DeepSeek-V4 并行化包装 #1291
Closed
hanboyouAdd on 20 days agoClosed at 17 days ago
hanboyou
hanboyouCollaborators
20 days ago

描述

删除未使用的 eager 转发函数,将仅调用一次的图注解 helper 内联到图并行入口,保留注解、SPMD、SimpleFSDP 与 compile 的执行顺序。按上游原地 compile 语义保留并返回当前模型对象。

功能归属:models/deepseek_v4/parallelize.py 的包装与图流程;本 PR 仍保留原 _dsv4_param_dtypes,精度机制由独立 precision PR 处理。

类型

Checklist:

如何测试

基线:6e3c9320453c0e36875a1fb7f9af59abb57ed3b8;本分支:372d79de8a1b6d57e45969b2f7423ec99e327eb1,目标为 dev_0.4.0。

TORCH_DEVICE_BACKEND_AUTOLOAD=0 OMP_NUM_THREADS=1 python -m pytest -q --tb=short tests/unit_tests/models/deepseek_v4/test_graph_trainer_parallelize.py tests/unit_tests/models/deepseek_v4/test_parallelize_policy.py

CPU 结果:9 项通过。现有图并行 CPU 检查使用替代的分片/编译操作验证可观察的控制流程;它不执行真实 NPU 图捕获或整步训练。

完整本地 pre-commit --all-files 已在 CI 对应的 Torch 2.14 类型环境通过;仅在独立配置中将 Pyrefly 查找路径指向固定 TorchTitan 0.4.0,保留全部 15 个 hooks,并使用实际 checkpoint/grain 依赖别名。训练 CPU 测试使用 Torch 2.15;其全项目类型检查与目标分支有相同 8 条既有诊断、无新增。OAT 另对本 PR 的实际变更文件完成实扫。

完整 CPU 套件使用 TORCH_DEVICE_BACKEND_AUTOLOAD=0 python -m pytest -v --tb=short tests/unit_tests(去掉 -x,执行全部收集用例):1248 passed / 75 skipped / 1 xfailed / 1 failed,原始 exit 1。剩余可复现失败均为 test_virtual_optimizer_dcp_roundtrip_preserves_two_rank_dtensor_shards:原生 DCP 在 fork 子进程中初始化 NPU,未修改的目标分支同样失败;未发现新增可复现失败,完整套件仍未全绿。

本地原始日志、JUnit、复现环境与基线比较;保留全量运行与失败项重跑的独立结果,未修改测试或增加跳过。

远端 CI #2699 已通过,UT 为 1241 passed / 82 skipped / 1 xfailed。已核对实际检出的合并提交父节点,分别为上述目标基线与本分支;CI 的 workflow head 与被测代码 head 分开核对。该结果补充 compile 入口的验证,NPU ST 和训练对齐状态见下文。

精度和性能验证结果

当前分支的 NPU smoke/ST、100 步训练对齐、整步 GraphTrainer 与性能测试均未执行,保留草稿;不以 CPU 控制流程检查声明 NPU 数值或性能通过。

历史整组记录见 #1257,其基线为 c84d8b76、整组版本为 7c4f16f0;该记录不是本拆分分支的独立验证,也不用于声明本分支精度或性能通过。

其他信息

维护中的 eager/graph 并行支持限制保持;本 PR 没有增加新的并行组合。 本 PR 是 #1257 的独立功能拆分,以草稿提交,等待对应分支的后续验证。

likedislike
The current Pull Request has been closed by hanboyou.
hanboyouhanboyouCollaborators
20 days ago Created pull request, commit 0ddf4529
CANN-robotCANN-robotCollaborators
20 days ago Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
20 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

⚠️ This PR does not yet meet the following requirements:lgtm (requires ≥ 2 person(s) per module)、approve (requires ≥ 1 person(s) per module)

Module Approval Details

module lgtm status approve status
repo-cann/torchtitan-npu ❌ (0/2)(You can also ask: zhanghz1, xuyujun, wanghui0, zhaowei1936, 盛楠) ❌ (0/1)(You can also ask: 张德鹏, hwcaifubi, zhaowei1936, 徐道鸿, panchao-gitcode)

💡 Tip:

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

CLA Signature Pass

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

likedislike
CANN-robotCANN-robotCollaborators
20 days ago Set hwcaifubi,lrwei0709,zhaowei1936,zhong_lin,zhanghz1,depeng1994,shengnan666,XDaoHong,xuyujun,zhuofanshen,wanghui0,panchao-gitcode,zzyyjj012 as approver
CANN-robotCANN-robotCollaborators
20 days ago Set hwcaifubi,lrwei0709,zhaowei1936,zhong_lin,zhanghz1,depeng1994,shengnan666,XDaoHong,xuyujun,zhuofanshen,wanghui0,panchao-gitcode,zzyyjj012 as approver
hanboyouhanboyouCollaborators
20 days ago Modify description of pull request
hanboyou
hanboyouCollaborators
20 days ago Comments:

compile

likedislike
hanboyouhanboyouCollaborators
20 days ago Pre merge succeeded (commit_id: e15f7e1b7fab4bfc114253caf1e41c1dc78c531e)
CANN-robot
CANN-robotCollaborators
20 days ago Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
20 days ago Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
20 days ago Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
20 days ago Added label: ci-pipeline-passed
hanboyouhanboyouCollaborators
20 days ago Modify description of pull request
hanboyouhanboyouCollaborators
19 days ago Draft state has been cancelled
hanboyouhanboyouCollaborators
17 days ago Close pull request