Open
[fix] Adapt SDC smoke tests and docs to TorchTitan 0.4.0 compile.model #1482
[fix] Adapt SDC smoke tests and docs to TorchTitan 0.4.0 compile.model #1482
Open
jiangna1111Add on 2 days ago
jiangna1111
jiangna1111Collaborators
2 days ago

描述

修复 #238 中 SDC smoke 测试在 TorchTitan 0.4.0 迁移后的配置与断言不兼容问题,并同步清理 SDC 文档中遗留的 0.3.0 编译配置写法。

  • 问题原因:dev_0.4.0 升级 PR !1171 将 torchtitan_npu/extensions/components/sdc/sdc.py 的编译配置校验从旧版 compile.enable / compile.components 切换为原生 compile.model,同步更新了 CPU 单测 tests/unit_tests/test_sdc.py,但未同步更新 tests/smoke_tests/sdc/test_sdc_smoke.py 及两篇 sdc.md 文档,导致 8 个 SDC smoke 实例全部因配置校验或错误断言失败并被临时跳过。
  • 修改内容:
    • tests/smoke_tests/sdc/test_sdc_smoke.py:_config() 改用 0.4.0 原生 CompileConfig(model=ModelCompileConfig(backend="inductor") if compiled else None);_check_invalid_config() 错误断言更新为 "compile.model";加固 FP32 checksum 分支输出的换行与解析逻辑(兼容 [rank0]: 等分布式/运行时前缀,失败时输出完整 stdout/stderr)。
    • tests/smoke_tests/conftest.py:移除 _DEFERRED_SMOKE_TESTS 中全部 6 个 SDC smoke 函数(8 个实例),恢复默认 smoke 执行。
    • docs/feature_guides/sdc.md、docs/user-guides/sdc.md:将遗留的 compile.enable / compile.components / compile.backend 示例更新为 compile.model 写法。
  • 未修改生产实现。

类型

Checklist:

如何测试

  1. 静态检查:ruff check、ruff format --check、codespell、架构边界检查、OAT 合规检查、git diff --check 均通过。
  2. CPU 单测(Python 3.12.16、torch==2.15.0+cpu、torchtitan==0.4.0):
    TORCH_DEVICE_BACKEND_AUTOLOAD=0 python -m pytest -v --tb=short \
      tests/unit_tests/test_sdc.py \
      tests/unit_tests/models/deepseek_v4_1/test_engram_sdc_replayer.py
    
    结果:35 passed, 0 skipped(0.48s)。
  3. NPU 默认 smoke(不加 --run-deferred-smoke,Ascend 910B4 单卡、CANN 9.2.2、torch==2.15.0+cpu、torch_npu==2.15.0.dev20261116、torchtitan==0.4.0):
    ASCEND_RT_VISIBLE_DEVICES=0 TORCH_DEVICE_BACKEND_AUTOLOAD=0 \
      python -m pytest -v -s --tb=short -rs tests/smoke_tests/sdc/test_sdc_smoke.py
    
    结果:12 passed, 0 skipped(332.74s),原 8 个延迟跳过的实例全部通过,test_fp32_checksum_preserves_compiled_results_and_detects_output_faults 输出 FP32 native checksum branch: V-ABFT。

精度和性能验证结果

不涉及

likedislike
Merge blocked
jiangna1111jiangna1111Collaborators
2 days ago Created pull request, commit 709355e7
jiangna1111jiangna1111Collaborators
2 days ago Associated issue: [test] 跟踪 0.4.0 迁移后独立处理的 smoke fixture/API 修复
CANN-robotCANN-robotCollaborators
2 days ago Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
2 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: 盛楠, xuyujun, zzyyjj012, zhaowei1936, lrwei0709) ❌ (0/1)(You can also ask: 盛楠, xuyujun, hwcaifubi, 徐道鸿, zzyyjj012)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies 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. 👍

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

compile

likedislike
jiangna1111jiangna1111Collaborators
2 days ago Pre merge succeeded (commit_id: ad0f4e827112868b5f2edb0410885ed7b0d32667)
CANN-robot
CANN-robotCollaborators
2 days ago Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
2 days ago Added label: ci-pipeline-running
jiangna1111jiangna1111Collaborators
2 days ago Pre merge succeeded (commit_id: 1aa310c71cf1ff2b6ba0a5508d7db5521d3061c6)
jiangna1111jiangna1111Collaborators
2 days ago Force-pushed 1 commits:a034361c-[fix] Adapt SDC smoke tests and docs to TorchTitan 0.4.0 compile.model
jiangna1111jiangna1111Collaborators
2 days ago Pre merge succeeded (commit_id: c1064487305f5637ff8bbc250e9883dacb7dba18)
CANN-robotCANN-robotCollaborators
2 days ago Removed label: cann-cla/yes
CANN-robotCANN-robotCollaborators
2 days ago Added label: cann-cla/yes
jiangna1111
jiangna1111Collaborators
2 days ago Comments:

compile

likedislike
jiangna1111jiangna1111Collaborators
2 days ago Pre merge succeeded (commit_id: 38601b10ee442993c28e8a1940e1b6153b90f89d)
CANN-robot
CANN-robotCollaborators
2 days ago Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
2 days ago Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
2 days ago Added label: ci-pipeline-passed
CANN-robot
CANN-robotCollaborators
2 days ago Comments:

流水线分析报告 — torchtitan-npu run#3590

流水线: https://gitcode.com/CANN/torchtitan-npu/actions/runs/ddef48e959644df59be52818c77484ff | PR#1482 | 2026-12-04 18:13:17 ~ 2026-12-04 18:15:53 | 失败 Job 2 个

定界结论: 代码问题、工程问题(共 2 个根因)

根因 #1(代码问题 / 代码检查错误)

  • 根因: codecheck 检查不通过
  • 处置: 通知 PR 提交者修复(见各根因的具体建议)
  • 影响 Job: Codecheck_dt

根因 #2(工程问题 / GitCode平台限流)

  • 根因: API 限流
  • 处置: 转 CI 维护者处理
  • 影响 Job: PostBuild

失败根因分析

根因 #1: 代码问题 / 代码检查错误 — 2026-12-04 18:15:32,598 - INFO [codechec
  • 判据: codecheck 检查不通过
  • 定位步骤: 3_Codecheck_dt.log
  • 影响 Job: Codecheck_dt
  • 根因证据(日志原文):
[2026-12-04 18:15:32.618+08:00] 2026-12-04 18:15:32,598 - INFO [codecheck 2026-12-04 18:15:32] codecheck result: no pass.
根因 #2: 工程问题 / GitCode平台限流 — API 请求失败: HTTP 429
  • 判据: API 限流
  • 定位步骤: 1_query_pipeline.log
  • 影响 Job: PostBuild
  • 根因证据(日志原文):
[2026-12-04 18:15:50.507+08:00] API 请求失败: HTTP 429
结构化定界摘要
[
  {
    "repo": "torchtitan-npu",
    "run_number": 3590,
    "Failed_Type": "代码问题",
    "Failed_Sub_Type": "代码检查错误",
    "Failed_Reason": "codecheck 检查不通过",
    "evidence": "[2026-12-04 18:15:32.618+08:00] 2026-12-04 18:15:32,598 - INFO [codecheck 2026-12-04 18:15:32] codecheck result: no pass.",
    "suggestion": "通知 PR 提交者修复(见各根因的具体建议)",
    "jobs": "Codecheck_dt"
  },
  {
    "repo": "torchtitan-npu",
    "run_number": 3590,
    "Failed_Type": "工程问题",
    "Failed_Sub_Type": "GitCode平台限流",
    "Failed_Reason": "API 限流",
    "evidence": "[2026-12-04 18:15:50.507+08:00] API 请求失败: HTTP 429",
    "suggestion": "转 CI 维护者处理",
    "jobs": "PostBuild"
  }
]

由门禁失败定界分析自动生成 | repo: torchtitan-npu | run: ddef48e959644df59be52818c77484ff | PR#1482

likedislike
xuyujun
xuyujunCollaborators2 days agoStart code review1
docs/user-guides/sdc.md
@@ -17,14 +17,13 @@ import torch
1717import torch.nn as nn
1818from torchtitan.trainer import Trainer
xuyujun
xuyujun2 days agoComments:

用户指南里的接入示例在 0.4.0 上跑不起来。这里用 Trainer.Config() 再给 compile 赋值,实际会先报少了必填的 model;就算绕过构造,上游配置也没有 compile 字段,赋值还是会报错。这是改之前就有的问题,不过这个 PR 正好改了这几行(含 L25–26)。建议像 smoke 和 CPU 单测那样,用 SimpleNamespace 构造这份配置。

likedislike