Open
[fix] 补齐 ebdfc8c 升级后的 TorchFT 初始化与故障 step 生命周期 #1210
zhangyifan999Add on 26 days ago
[fix] 补齐 ebdfc8c 升级后的 TorchFT 初始化与故障 step 生命周期 #1210
Open
Merge blocked
26 days ago Created pull request, commit ac998eab
26 days ago Added label: cann-cla/yes
CANN-robot
26 days ago Comments:
26 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 | ❌ hwcaifubi (1/2)(You can also ask: 张德鹏, wanghui0, 钟林, zzyyjj012, 盛楠) | ❌ (0/1)(You can also ask: 徐道鸿, xuyujun, zhuofanshen, zhanghz1, lrwei0709) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
zhangyifan999, thanks for your pull request. All authors of the commits have signed the CLA. 👍


26 days ago Set hwcaifubi,lrwei0709,zhaowei1936,zhong_lin,zhanghz1,depeng1994,shengnan666,XDaoHong,xuyujun,zhuofanshen,wanghui0,panchao-gitcode,zzyyjj012 as approver
26 days ago Set hwcaifubi,lrwei0709,zhaowei1936,zhong_lin,zhanghz1,depeng1994,shengnan666,XDaoHong,xuyujun,zhuofanshen,wanghui0,panchao-gitcode,zzyyjj012 as approver
26 days ago Set hwcaifubi,lrwei0709,zhaowei1936,zhong_lin,zhanghz1,depeng1994,shengnan666,XDaoHong,xuyujun,zhuofanshen,wanghui0,panchao-gitcode,zzyyjj012 as approver
26 days ago Set hwcaifubi,lrwei0709,zhaowei1936,zhong_lin,zhanghz1,depeng1994,shengnan666,XDaoHong,xuyujun,zhuofanshen,wanghui0,panchao-gitcode,zzyyjj012 as approver
44 messages are collapsed here。 See more
24 days ago Modify description of pull request
23 days ago Resolved final issue
torchtitan_npu/extensions/torchtitan/trainer.py
@@ -255,24 +254,27 @@
254+ self._initialize_trainer(config)
255255 self._carve_grad_slots(pool)
256256 else:
257- super().__init__(config)
257+ self._initialize_trainer(config)
258258 engine = cast("NPUTrainingEngine", self.engine)
259259 engine._sdc = config.sdc.build(
260260 trainer_config=config,
261261 model_parts=self.engine.model_parts,
262262 gradient_accumulation_steps=self.gradient_accumulation_steps,
263263 )
264264 if getattr(config.training, "enable_cpu_offload", False):
265265 from torchtitan_npu.override.common.optimizer import CpuOffloadOptimizersContainer
266266
267267 if not isinstance(self.engine.optim.optimizers, CpuOffloadOptimizersContainer):
268268 raise ValueError(
269269 "--training.enable-cpu-offload requires a CPU-offload optimizer "
270270 "container, and this optimizer schema does not carry the NPU "
271271 "offload carrier field, so no CPU-offload container can be "
272272 "derived for it automatically"
273273 )
274274
275275 self.anticipatory_schedule = AnticipatorySchedule(self) if config.anticipatory.enable else None
276276 engine.anticipatory_schedule = self.anticipatory_schedule
277277
278+ def _initialize_trainer(self, config: Config) -> None:
279+ """Build the trainer while allowing experiments to own data partitioning."""
280+ super().__init__(config)
这个修改是为什么?


hwcaifubi
23 days ago Comments:
23 days ago Comments:
/lgtm


23 days ago Associated issue: [RFC] TorchTitan v0.4.0 分阶段升级规划与进度跟踪
描述
WIP:补齐 TorchTitan
ebdfc8c2a24d89d89c99c0ef96ed8ac149864175升级后的 NPU TorchFT 生命周期适配。目标分支
dev_0.4.0已完成基础版本升级。本 PR 已 rebase 到最新目标提交22206257,只保留尚缺的 FT 修复,不重复提交基础网络迁移。TrainerEx增加受保护的初始化入口,FT 子类复用上游FaultTolerantTrainer.__init__(),确保 dataloader 的 DP world size/rank 与 GAS 包含全部 replica。engine_cls,并在任何 mock 前测试实际绑定。optim_step()并推进步号,之后日志处理等阶段再出现可恢复 HCCL 异常,明确退出并要求重启 replica,不重复投票、不再次推进 step/LR。use_async_quorum=False;显式请求异步 quorum 时立即报错。Step 语义
沿用固定上游 TorchFT 的 consumed-attempt 语义,而不是 successful-optimizer-update 计数。
should_commit=False时上游跳过参数更新,但上层仍推进 scheduler 和 engine 步号。因此发生拒绝/丢弃时,实际参数更新次数可能少于training.steps;本 PR 不补跑这些 attempt,也不承诺与无故障训练相同的数据消费或参数更新次数。类型
Checklist
如何测试
2026-11-10 框架提交
a0ad43b6(最新51112005已 rebase 到22206257,FT 修复内容保持不变):Python 3.12.9 / aarch64、torch 2.14.0+cpu、torch_npu 2.14.0.dev20260918、TorchFT 0.2.0、CANN 9.2.0、attn-gym 0.0.16;TorchTitan 固定为上述提交。2026-11-10 两组 NPU 记录的框架 Python 文件哈希与a0ad43b6一致;本次 rebase 仅重跑下述 CPU/mock 定向测试和标准门禁,没有重新执行 NPU 故障注入。/tmp/torchtitan搜索路径后仍有 5 项未修改的 TorchAO 相关错误,不能宣称全仓通过两组 NPU 用例均未设置
HCCL_BUFFSIZE,不依赖此前的HCCL_BUFFSIZE=64workaround。此前缓冲区申请失败的历史根因仍未确认,本轮只说明默认配置复测通过。测试精简
不新增独立测试函数,也不增加参数化场景。将初始化分片/GAS 检查并入现有生命周期测试;丢弃 attempt 的计步与无 optimizer/EMA 更新并入设备恢复测试;晚到日志异常并入现有 rejected-step 测试;SDC discard 检查并入累积边界测试。删除重复构造和 4 个独立入口。Rebase 后同时修正目标分支新合入的 SDC 配置拒绝用例:Tyro 将实例化错误转换成 SystemExit(2) 时检查退出码和诊断文本,不放宽生产校验。未新增测试函数;其他已有用例覆盖不同失败边界,未直接删除。
历史验证与边界
以下结果来自本轮修复之前的
34d11d06,不混作最终提交重新验收:100-step eager 显存稳定;旧/新 FT-off 30 步数值一致;等有效 batch 的 FT-off / FT-on 30 步比较,loss 最大相对差异 0.0241348%,grad norm 最大相对差异 0.480633%,并非位级一致。本轮模型为 DeepSeek-V4 debug 尺寸,256-token context/microbatch、2048 tokens/global step、AdamW、Full AC、无 MTP、seed 42,共用初始权重,保留 A3 RoPE workaround。故障注入及诊断记录会影响耗时,不作为性能验收。
其他信息
aot_eager通过不等于 Inductor 通过。Inductor 的make_reduction(strict_sum)兼容问题仍独立保留。51112005的 流水线 #2541 已通过,触发评论为compile。仍待维护者 lgtm/approve。