Pull Request已成功合入, 合并人@ascend-robot
(感谢 luqichao 的贡献)变更摘要
此 PR 为 NPU Inductor 的 group-autotune 机制引入了对 pointwise 模板内核的逐元素工作量分类能力。通过在 split_tiling.py 中新增 _classify_group_workload 等方法,对融合后的 pointwise 内核中每个调度节点的读写访问模式进行分析,判断其是否真正满足"无广播、无跨步访问、无副作用、无排序/扫描/随机等不支持操作"的逐元素语义,并将分类结果 "elementwise" 写入 GroupedKernelMeta.workload 字段,进而影响分组特征(feature specs)的计算,使 symbolic-shape 场景下的 autotune 能够为真正的逐元素内核生成更优的分组策略。
主要改动
- 工作量分类核心逻辑:在
split_tiling.py中新增_classify_group_workload方法,遍历 pointwise 模板的所有调度节点,逐一通过_classify_elementwise_node检查读写访问签名是否一致、是否存在广播/跨步/副作用/不支持语义等,综合判定是否属于"elementwise"工作量。 GroupedKernelMeta新增workload字段:在symbolic_grouping.py的GroupedKernelMeta数据类中新增workload: str | None字段,并增加_require_group_workload校验函数,限制合法值为None或"elementwise",同时更新了序列化/反序列化逻辑。- 分组特征计算适配:修改
_build_group_features方法,新增workload参数;当 workload 为"elementwise"时,使用基于outer_product和所有轴名的elementwise_numel特征规格,替代原有的 pointwise 默认特征计算方式。 - Triton 元数据输出扩展:在
triton.py的NPUIndexTritonKernel中,将group_workload字段添加到 inductor 元数据字典的启用/禁用/默认三个分支,确保编译产物中携带工作量分类信息。 - 单元测试覆盖:在
test_inductor_dynamic_shapes.py中新增TestSymbolicGroupElementwise测试类,覆盖基础逐元素(relu(x+y)*0.5)、广播排除(x+bias)、被消费的full_like视为逐元素、独立full_like排除、跨步索引(x[:, ::2])排除等场景,验证 workload 分类结果的正确性。


代码审查
审查总结
我逐一审查了所有 4 个变更文件:
| 文件 | 审查结果 |
|---|---|
test/_inductor/test_inductor_dynamic_shapes.py |
发现 1 个 P3 问题(setUp/tearDown 脆弱性) |
torch_npu/_inductor/codegen/split_tiling.py |
无问题——elementwise 分类逻辑正确,alpha-renaming 方法合理(sympy 符号按名称和假设比较相等),所有调用点已同步更新 |
torch_npu/_inductor/codegen/triton.py |
无问题——group_workload 在所有三个位置(启用、禁用、默认)均已正确添加到 inductor_meta |
torch_npu/_inductor/runtime/symbolic_grouping.py |
无问题——GroupedKernelMeta 的 workload 字段已正确添加到 dataclass、to_payload() 和 from_payload();_require_group_workload 验证器可安全防止反序列化时出现未知值 |
问题统计: P0: 0, P1: 0, P2: 0, P3: 1
整体风险评估:低。 此变更引入了定义明确、范围受限的逐元素工作负载分类功能,后端逻辑、序列化及测试用例均保持一致。唯一识别出的问题是测试夹具中的一个次要健壮性问题,在生产代码中既不影响正确性,也不影响安全性。
⚠️ 已识别出整体风险,但无法提取行内评论,请参考整体评估。


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


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


Linking Issue Notice
@luqichao , 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 .


ascend docs pipeline is running...


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


compile


| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | 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_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 : 停止流水线


ascend docs pipeline is running...


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


| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | 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_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


/lgtm


/lgtm
/approve




为 symbolic grouped autotune 增加 pointwise workload 分类能力,识别严格的逐元素访问模式并在 kernel metadata 中透传分类结果。
GroupedKernelMeta和inductor_meta增加group_workloadelementwiseworkloadelementwise_numel