Pull Request has been successfully merged by CANN-robot.
(Thank you for jiangna1111's contribution.)变更摘要
本 PR 将上游 TorchTitan 的 SDC replay(静默数据损坏重放)能力适配到本仓 NPU Trainer:新增实例级 adapter install_npu_sdc_adapter,复用上游 SDCReplayer 的 replay 状态机,仅替换实例的 _signature 方法,把官方 uint64 摘要按位 view 为 int64 后再搬到目标设备,以规避 NPU 对无符号整型 collective 的限制并保留完整 64 位内容。同时在 TrainerEx 中增加默认关闭、显式开启的配置校验与接线,禁止不支持的组合;并补充一条单元测试与一条短 NPU 集成回归用例,用于验证开启/关闭 replay 时训练结果一致。
主要改动
- 新增 NPU 签名 adapter:
torchtitan_npu/extensions/torchtitan/observability/sdc_replayer.py新增_npu_signature与install_npu_sdc_adapter,对 loss、CPU/加速器 RNG 状态、buffer 与梯度逐项生成 schema 与 digest,空张量和None统一记为 0,复杂张量转torch.view_as_real,并对哈希结果先.view(torch.int64)再跨设备搬运。 - Trainer 接线与配置校验:
TrainerEx.Config._validate_npu_sdc_replay在启用sdc_replayer时校验并拒绝compile、流水并行、CUDA Graph 关闭之外的情形、CPU offload、anticipatory、EMA、sdc.gradient_enabled/with_checksum/hccl_mode、非AdamW优化器、非DCPCheckpointManager.Config检查点以及三类 optimizer override,并校验NPU_ASD_CONFIG/NPU_ASD_ENABLE必须处于关闭状态。 - Trainer 初始化流程接入:
TrainerEx.__init__在量化与模型初始化前调用config._validate_npu_sdc_replay(),并在super().__init__之后对已构造的self.sdc_replayer安装 NPU adapter。 - Graph Trainer 显式拒绝:
GraphTrainerEx.__init__在config.sdc_replayer is not None时抛出ValueError,避免在图捕获路径下启用 replay。 - 新增测试与集成套件:新增单测
test_signature_preserves_all_64_bits_as_signed_digests验证摘要为int64且不经过数值化 uint64 转换;新增tests/integration_tests/sdc_replay.py与sdc_replay_config.py(ReplayValidationTrainer校验 batch/token/optimizer 调用与状态哈希一致性),并在run_tests.py注册sdc_replay套件、为dsv4_sdc_replay_ga2放开 checkpoint/EMA 迁移拦截。


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 | ✅ hwcaifubi, lrwei0709 (2/2) | ✅ hwcaifubi (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
jiangna1111, thanks for your pull request. All authors of the commits have signed the CLA. 👍


Pull Request 已合并或已关闭。
If you want to solve this problem, you can click here to do it in the FAQs.


Pull Request 已合并或已关闭。
If you want to solve this problem, you can click here to do it in the FAQs.


描述
uint64摘要按位视为int64,解决 Ascend NPU 报错,复用上游重放流程。类型
Checklist:
如何测试
远端兼容环境复用已有 UT,3 passed:
CPU replay 与上游 GraphTrainer replay recipe 的 NPU 配置校验已通过,保留上游 graphs 重放次数约束。
int64摘要,含 empty/None/CPU RNG 检查。aot_fx_trace训练 2 步;构图 1 次、图内前后向 4 次、优化器更新 2 次,两步 replay 均匹配(每次 54 个int64摘要)。使用已有rope.asc_complexNPU override,禁用cudagraph_pass,输入为合成 token。其他信息