Pull Request已成功合入, 合并人@ascend-robot
(感谢 stonexxx 的贡献)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
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| test | ✅ crazyDannyBoy, TonyYA (2/2) | ✅ crazyDannyBoy (1/1) |
| torch_npu/_inductor | ✅ crazyDannyBoy, TonyYA (2/2) | ✅ crazyDannyBoy (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
stonexxx, thanks for your pull request. All authors of the commits have signed the CLA. 👍


Linking Issue Notice
@stonexxx , the pull request must be linked to at least one issue.
If an issue has already been linked, but the needs-issue label remains, you can remove the label by commenting /check-issue .


当前仓库存在以下 保护分支 :
| Protected Branch | Version | Release |
|---|---|---|
| master | ||
| v2.9.0 | ||
| v2.10.0 | ||
| v2.7.1 | ||
| v2.11.0 | ||
| v2.12.0 | ||
| v2.7.1-26.1.0 | ||
| v2.9.0-26.1.0 | ||
| v2.11.0-26.1.0 | ||
| v2.10.0-26.1.0 | ||
| v2.12.0-26.1.0 | ||
| ci-test | ||
| sync-pr28113--to-v2.9.0 |
评论 /sync <branch1> <branch2> ... 可将当前 PR 修改同步到其它分支(创建同步 PR):
a) 如果当前 PR 是 Open 状态,同步操作将延迟到 PR 被合并时执行
b) 如果当前 PR 已经 Merged,将立即执行同步操作
注意:
- /sync 命令可以指定同步到多个分支,仅最后一个 /sync 命令生效
- 如果创建的同步 PR 不正确,可通过向同步 PR 的源分支提交轻量级 PR 完善,或使用 /close 命令关闭


ascend docs pipeline is running...


✅ 跳过 docs ci 检查,没有需要检查的文档文件


变更摘要
此 PR 修复了 Ascend 线性代码生成(linear codegen)中 no_linear 模式相关的多个问题,主要纠正了 inductor_ascend_linear_mode 配置值与内核类型、调度策略之间的映射关系,改进了 TTIR 测试配置的选择逻辑,并调整了编译选项和日志行为。
主要改动
-
NPUNoLinearTritonScheduling默认内核类型与条件反转:将默认kernel_type从NPUTritonKernelWithLoop改为NPUTritonKernel,同时将触发NPUTritonKernelWithLoop的条件由'no_linear'改为'no_linear_loop',使no_linear模式使用无循环内核、no_linear_loop模式使用带循环内核。 -
NPUTritonKernel中 linear 回退目标修正:当inductor_ascend_linear_mode == "linear"时,回退写入的inductor_meta值从"no_linear_loop"改为"no_linear";同时npu_kernel_type由硬编码字符串"simt_only"改为NPUKernelType.SIMD_SIMT_MIX的字符串形式。 -
新增
_select_ttir_test_config方法:在NPUCachingAutotuner中新增该方法,从所有配置中选择 SUB tiling 乘积最小的配置作为 TTIR 测试配置(替代原来直接取self.configs[0]),以降低编译开销。 -
no_linear模式启用enable_auto_blockify:在NPUCachingAutotuner的编译选项设置中,当inductor_ascend_linear_mode == "no_linear"时,自动设置options['enable_auto_blockify'] = True。 -
移除 SIMD 内核类型的 tile 配置生成:在
triton_config_npu_index中删除了NPUKernelType.SIMD对应的descend_split_tiling()调用;同时在no_linear模式下处理 tiling 参数时,改为从kwargs中弹出原始_SUB后缀键(pop)而非仅添加新键,避免重复键残留。


代码审查
I've completed my thorough review. Let me provide the closing summary.
审查总结
已审查全部 5 个变更文件:
| 文件 | 状态 |
|---|---|
test/_inductor/test_exceptions.py |
无问题(仅测试 meta 新增 inductor_ascend_linear_mode: 'linear',匹配内核的 SUB tiling 模式) |
torch_npu/_inductor/codegen/npu_combined_scheduling.py |
发现问题 P2:日志级别从 ERROR 降为 DEBUG |
torch_npu/_inductor/codegen/scheduling.py |
无问题(NPUNoLinearTritonScheduling 的 kernel_type 默认值/条件交换与整体 bugfix 方向一致) |
torch_npu/_inductor/codegen/triton.py |
发现问题 P3:注释与代码不一致 |
torch_npu/_inductor/runtime/triton_heuristics.py |
无问题(新增 _select_ttir_test_config、enable_auto_blockify、移除 SIMD 配置生成、pop SUB key 均为功能性改动,逻辑自洽) |
问题统计:P2 × 1,P3 × 1
整体风险评估:此变更是一个有意的行为修正(bugfix),核心逻辑变更(mode 字符串从 no_linear_loop→no_linear,kernel_type 默认值交换,npu_kernel_type 从 simt_only→simd_simt_mix)在多处保持一致性。主要风险在于 linear codegen 失败时的 fallback 路径现在完全静默(日志降级为 DEBUG),可能导致生产环境中问题难以排查。建议将日志级别至少恢复为 log.warning。
| 类型 | 数量 |
|---|---|
| 🔴 阻塞 | 0 |
| 🟡 建议 | 1 |
💬 仅评论


🟡 Medium Priority
变更行:npu_combined_scheduling.py 第92-97行。原代码在 linear codegen 失败时使用 log.exception(...) 记录异常(ERROR 级别,自动附带 traceback),新代码改为 log.debug(..., exc_info=True)(DEBUG 级别)。
影响:当用户配置 inductor_ascend_linear_mode = "linear"(也是默认值)且 linear codegen 因任何原因失败时,原代码会在默认日志级别(WARNING)下输出完整的异常信息,开发者可以感知到 fallback 的发生。新代码将日志降级为 DEBUG,在生产环境的默认日志级别下,这些 fallback 完全不可见。如果 linear codegen 存在持续性问题(如某个算子始终无法走 linear 路径),故障排查将变得更加困难——异常被静默吞掉,只留下 fallback 行为生效,开发者可能完全不知道 linear codegen 已经失败了。
虽然 fallback 本身是预期行为(注释写 "fallback to origin codegen"),但用 DEBUG 级别记录异常会丢失可观测性。建议至少使用 log.warning 或 log.info,或者在降级的同时增加一个 counter/metrics 来统计 fallback 次数,便于运维监控。
建议:将 log.debug 至少提升为 log.warning 或 log.info,确保 linear codegen 的静默 fallback 在默认日志级别下可被观测。或者保持 debug 但额外增加一个 metric/counter 来记录 fallback 次数。


| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | Build_X86 | ✅ | >>> |
| Build_ARM | ✅ | >>> | |
| Build_LibTorch_x86 | ✅ | >>> | |
| Build_LibTorch_ARM | ✅ | >>> | |
| Build_X86_torchair | 🛑 | >>> | |
| Build_ARM_torchair | 🛑 | >>> | |
| patch_test | 🛑 | >>> | |
| 恶意代码检查 | Antipoison | ✅ | >>> |
| 编码安全与规范检查 | CodeCheck | ✅ | >>> |
| check_error | ✅ | >>> | |
| CodeCheck_lintrunner | ✅ | >>> | |
| 开源片段检查 | SCA | ✅ | >>> |
| 开发者测试 | UT_X86_Part_01 | 🛑 | >>> |
| UT_X86_Part_02 | 🛑 | >>> | |
| UT_ARM_A3_Part_01 | 🛑 | >>> | |
| UT_ARM_A3_Part_02 | 🛑 | >>> | |
| UT_ARM_A2_Part_01 | ✅ | >>> | |
| UT_ARM_A2_Part_02 | ✅ | >>> | |
| UT_ARM_A2_Part_03 | ✅ | >>> | |
| UT_inductor_Part_01 | ✅ | >>> | |
| UT_inductor_Part_02 | ✅ | >>> | |
| UT_inductor_Part_03 | ✅ | >>> | |
| UT_inductor_Part_04 | ✅ | >>> | |
| UT_DIST_ARM_Part_01 | 🛑 | >>> | |
| UT_DIST_ARM_Part_02 | 🛑 | >>> | |
| UT_DIST_ARM_Part_03 | 🛑 | >>> | |
| UT_DIST_ARM_Part_04 | 🛑 | >>> | |
| UT_ARM_A2_Select_Part_01 | ✅ | >>> | |
| UT_ARM_A2_Select_Part_02 | ✅ | >>> | |
| 流水线 | PR-pipeline_pytorch | ✅ | >>> |
- compile、compile_inductor、compile_torchair : 运行流水线
- retry : 重试流水线所有失败子任务
- retry <任务名> : 仅重试指定失败子任务
- stop : 停止流水线


/lgtm


The following users do not have permission to comment /lgtm or /approve on any module in this PR:
zhucehw


/lgtm
/approve


The following users do not have permission to comment /lgtm or /approve on any module in this PR:
zhucehw


The MR is merging by another one
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.


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




【合入来源】
【修改方案】
https://gitcode.com/Ascend/pytorch/issues/2571
【资料变更】
【接口变更】
【功能验证】
【CheckList】