Pull Request has been successfully merged by CANN-robot.
(Thank you for zx1029's contribution.)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 | ✅ wanghui0, xuyujun (2/2) | ✅ wanghui0 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
zhaoxi1029, thanks for your pull request. All authors of the commits have signed the CLA. 👍


compile


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


流水线分析报告 — torchtitan-npu run#3523
流水线: https://gitcode.com/CANN/torchtitan-npu/actions/runs/0d33dfe6ac3c4f42839b18551bb44a73 | PR#1465 | 2026-12-03 16:12:48 ~ 2026-12-03 16:27:10 | 失败 Job 2 个
定界结论: 代码问题x2(共 2 个根因)
根因 #1(代码问题 / 代码检查错误)
- 根因: Codecheck_dt 的 openlibing codecheck 返回
no pass - 处置: 通知 PR 提交者打开 codecheck 看板确认命中规则并修复后重触发
根因 #2(代码问题 / 代码检查错误)
-
根因: pre-commit 的 Pyrefly 类型检查失败,命中 3 处类型错误(
recipes.py2 处、token_dispatcher.py1 处) -
处置: 通知 PR 提交者修复下列类型错误后重触发
- 参考链接: 本地执行 pre-commit 指导
-
排除项: 本次两个失败 Job 均为代码静态检查类失败,日志中未出现平台内部错误(如
DEV-CODECI-35002、查询 step status 失败)、依赖下载失败、镜像拉取失败或网络异常,故不属于环境问题/工程问题。
失败根因分析
根因 #1: 代码问题 / 代码检查错误 — Codecheck_dt: openlibing codecheck result: no pass
- 判据:
codecheck result: no pass - 定位步骤:
3_Codecheck_dt.log - 影响 Job: Codecheck_dt
- 根因说明: 日志显示 codecheck 任务创建成功、轮询约 13 分钟后返回
state=no pass,任务退出码 255。该Codecheck_dtJob 的日志只给出 codecheck 平台的汇总结果与看板地址,规则级命中明细(具体文件/行)需打开看板查看。 - codecheck 看板地址(日志原文返回):
https://www.openlibing.com/apps/entryCheckDashCode/MR_272971723f744384bb837a59464b8b64/9c492b499c24e1b2ac9ef8d861dad8ac?projectId=300033&codeHostingPlatformFlag=gitcode - 根因证据(日志原文):
[2026-12-03 16:26:47.253+08:00] 响应: {"code":"200","msg":"success","data":"https://www.openlibing.com/apps/entryCheckDashCode/MR_272971723f744384bb837a59464b8b64/9c492b499c24e1b2ac9ef8d861dad8ac?projectId=300033&codeHostingPlatformFlag=gitcode","uuid":null,"state":"no pass","failData":null,"taskCount":0,"task_id":null}
[2026-12-03 16:26:47.272+08:00] 2026-12-03 16:26:47,253 - INFO [codecheck 2026-12-03 16:26:47] Task failed
[2026-12-03 16:26:47.272+08:00] 2026-12-03 16:26:47,256 - INFO [codecheck 2026-12-03 16:26:47] codecheck result: no pass.
[2026-12-03 16:26:47.277+08:00] ::error::Process exited with code 255
根因 #2: 代码问题 / 代码检查错误 — Pyrefly 类型检查失败(3 errors) — recipes.py / token_dispatcher.py
- 判据:
Pyrefly (type checking)...Failed+ERROR ... [missing-attribute]/[bad-argument-type] - 定位步骤:
5_precommit.log - 影响 Job: CodeCheck_precommit
- 定位到的文件/行(日志原文注解):
torchtitan_npu/extensions/adaptor/torchao/recipes.py:393:44—Object of class 'type' has no attribute 'Config' [missing-attribute]torchtitan_npu/extensions/adaptor/torchao/recipes.py:398:36—Object of class 'type' has no attribute 'Config' [missing-attribute]torchtitan_npu/extensions/adaptor/torchao/token_dispatcher.py:47:61—Argument 'None' is not assignable to parameter 'class_or_tuple' with type 'type' in function 'issubclass' [bad-argument-type]
- 与 PR 变更的关联: 上述两个文件均在 PR#1465 的变更文件列表中(
recipes.py +107/-1、token_dispatcher.py +213/-0),属于本次 PR 引入/修改代码。 - 根因证据(日志原文):
[2026-12-03 16:14:16.021+08:00] Pyrefly (type checking)..................................................Failed
[2026-12-03 16:14:16.021+08:00] - hook id: pyrefly
[2026-12-03 16:14:16.021+08:00] - exit code: 1
[2026-12-03 16:14:16.021+08:00] INFO Checking project configured at `/runner/workers/***.version/worker_dir/cann/torchtitan-npu/pyproject.toml`
[2026-12-03 16:14:16.021+08:00] ERROR Object of class `type` has no attribute `Config` [missing-attribute]
[2026-12-03 16:14:16.021+08:00] --> torchtitan_npu/extensions/adaptor/torchao/recipes.py:393:44
[2026-12-03 16:14:16.021+08:00] 393 | type(dispatcher_config) is quantized_dispatcher.Config
[2026-12-03 16:14:16.021+08:00] ERROR Object of class `type` has no attribute `Config` [missing-attribute]
[2026-12-03 16:14:16.021+08:00] --> torchtitan_npu/extensions/adaptor/torchao/recipes.py:398:36
[2026-12-03 16:14:16.021+08:00] 398 | dispatcher_config, quantized_dispatcher.Config, _activation_quant_config=activation_config
[2026-12-03 16:14:16.021+08:00] ERROR Argument `None` is not assignable to parameter `class_or_tuple` with type `type` in function `issubclass` [bad-argument-type]
[2026-12-03 16:14:16.021+08:00] --> torchtitan_npu/extensions/adaptor/torchao/token_dispatcher.py:47:61
[2026-12-03 16:14:16.021+08:00] 47 | if parent_cls is None or not issubclass(parent_cls, cann_cls):
[2026-12-03 16:14:16.021+08:00] INFO 3 errors (176 suppressed)
[2026-12-03 16:14:16.021+08:00] ::error::precommit.py 异常退出: exit code=1, signal=null
- 说明: 同一次 pre-commit 中 trailing-whitespace / ruff / codespell / OAT 等其余检查均 Passed,仅 Pyrefly 检查 Failed,故本次失败点是类型检查而非格式化。
结构化定界摘要
[
{
"repo": "torchtitan-npu",
"run_number": 3523,
"Failed_Type": "代码问题",
"Failed_Sub_Type": "代码检查错误",
"Failed_Reason": "Codecheck_dt: openlibing codecheck 返回 no pass",
"evidence": "[2026-12-03 16:26:47.256+08:00] [codecheck 2026-12-03 16:26:47] codecheck result: no pass.",
"suggestion": "通知 PR 提交者按 codecheck 看板命中规则修复后重触发",
"jobs": "Codecheck_dt"
},
{
"repo": "torchtitan-npu",
"run_number": 3523,
"Failed_Type": "代码问题",
"Failed_Sub_Type": "代码检查错误",
"Failed_Reason": "CodeCheck_precommit: Pyrefly 类型检查失败 3 处(recipes.py:393/398, token_dispatcher.py:47)",
"evidence": "[2026-12-03 16:14:16.021+08:00] ERROR Argument `None` is not assignable to parameter `class_or_tuple` with type `type` in function `issubclass` [bad-argument-type] --> torchtitan_npu/extensions/adaptor/torchao/token_dispatcher.py:47:61",
"suggestion": "通知 PR 提交者修复 Pyrefly 类型错误(recipes.py:393/398 missing-attribute, token_dispatcher.py:47 bad-argument-type)后重触发",
"jobs": "CodeCheck_precommit"
}
]
由门禁失败定界分析自动生成 | repo: torchtitan-npu | run: 0d33dfe6ac3c4f42839b18551bb44a73 | PR#1465


compile


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


流水线分析报告 — torchtitan-npu run#3528
流水线: https://gitcode.com/CANN/torchtitan-npu/actions/runs/f82b74c5c4b24ce18f0a17aa70e5cdaf | PR#1465 | 2026-12-03 17:28:35 ~ 2026-12-03 17:41:14 | 失败 Job 1 个
定界结论: 代码问题 / LLT测试失败 — FAILED tests/unit_tests/test_sdc.py::tes
- 失败类型: 代码问题
- 根因: pytest 用例失败: tests/unit_tests/test_sdc.py::test_trainer_initializes_sdc_once_after_model_setup
- 处置建议: 通知 PR 提交者修复(见各根因的具体建议)
- 检查失败用例(FAILED tests/unit_tests/test_sdc.py::tes)的断言与实现: 若 PR 行为变更符合预期则同步更新用例断言, 否则修正实现逻辑(断言详情见根因折叠块)
失败根因分析
根因 #1: 代码问题 / LLT测试失败 — FAILED tests/unit_tests/test_sdc.py::tes
- 判据: pytest 用例失败: tests/unit_tests/test_sdc.py::test_trainer_initializes_sdc_once_after_model_setup
- 定位步骤:
5_UT_Test.log - 影响文件:
tests/unit_tests/test_sdc.py - 影响 Job: UT_Test
- 根因证据(日志原文):
[2026-12-03 17:40:39.917+08:00] FAILED tests/unit_tests/test_sdc.py::test_trainer_initializes_sdc_once_after_model_setup - AttributeError: 'types.SimpleNamespace' object has no attribute 'all_to_all_quant_format'
结构化定界摘要
[
{
"repo": "torchtitan-npu",
"run_number": 3528,
"Failed_Type": "代码问题",
"Failed_Sub_Type": "LLT测试失败",
"Failed_Reason": "pytest 用例失败: tests/unit_tests/test_sdc.py::test_trainer_initializes_sdc_once_after_model_setup",
"evidence": "[2026-12-03 17:40:39.917+08:00] FAILED tests/unit_tests/test_sdc.py::test_trainer_initializes_sdc_once_after_model_setup - AttributeError: 'types.SimpleNamespace' object has no attribute 'all_to_all_q",
"suggestion": "通知 PR 提交者修复(见各根因的具体建议)",
"jobs": "UT_Test"
}
]
由门禁失败定界分析自动生成 | repo: torchtitan-npu | run: f82b74c5c4b24ce18f0a17aa70e5cdaf | PR#1465


compile


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


compile


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


/lgtm


/approve


描述
将已有的 MoE 专家激活 MXFP8 通信迁移到 TorchTitan 0.4.0 的类型化配置和 override 流程,使采用 CANN DeepEP 的 eager 训练可以按需降低 EP token 通信的传输字节数。
extension.quantization.all_to_all_quant_format。在启用低精训练的 DeepEP recipe 中设置为"mxfp8"即可开启,默认值为None。支持all_block_fp8和mix,要求 routed experts 的w13、w2使用相同的 E4M3 激活量化配置,block size 为 32。asc_deepepoverride。MXTensor。Dispatch 反向通过 CANN combine 归并高精度激活梯度和 router score 梯度。view形状推导,使零元素输入可以变形为(0, H),并对包含 0 且无法唯一推断-1的形状报错。类型
Checklist:
如何测试
ruff check、ruff format --check、Python 3.12 语法检查、python scripts/check_architecture_boundaries.py和git diff --check 1b32d27d ddaf0cda均通过。完整 pre-commit 待在配套 Linux 环境执行。resolve_view_shape的 16,824 组输入与 CPU PyTorch 2.14 的Tensor.view对照,结果一致。新增 UT 覆盖 dispatcher 选择、override 兼容、scale 布局及空 shape,待在具备torch_npu和 TorchAO-NPU 的环境执行。deepseek_v4_flash_cpt_4k_a5()recipe 打开通信量化,先确认日志中的 MXFP8 dispatcher 数量,再验证普通和 cached dispatch 的前后向及梯度。精度和性能验证结果
开启 mxfp8 通信有大约有 10 tps 提升
deepep 高精结果

deepep mxfp8 结果

其他信息
expert_parallel_degree > 1,并使用同时支持普通与 cached(qdata, scale)dispatch 的配套 CANN 算子和 wheel。启用示例见低精度训练指南。