合并受阻
变更摘要
该 PR 修复 torch_npu Inductor 的 triton_experimental 后端中 DALLE2 注意力索引的性能问题:NPUTritonScheduling._fold_dual_decomp 在处理输入视图 [260, 8, 2] 与输出视图 [260, 16] 这类共享轴(如 x0)的双分解时,会错误地只将互不相交的 x5 视为第二条链,导致其被当作独立轴启动,产生 16 倍 Cartesian 网格。本次改动让第二条链可以借助 basis 轴补齐共享的前缀/后缀,并在映射副节点时跳过已属于 basis 的节点,同时调整 _npu_apply_promoted_rtree_lines 提前重建被 CSE 删除的扁平归约别名,并新增对应回归测试。
主要改动
-
共享链查找逻辑:在
_fold_dual_decomp中新增_find_shared_chain,当 alternate 视图与 basis 共享一个或多个轴(如[260, 8, 2]与[260, 16]共享x0)时,查找一条包含所有真正 alternate 节点、且允许 basis 节点补齐共享前缀/后缀的完整链,避免x5被当作独立轴生成 16x Cartesian 网格。 -
跳过 basis 节点的映射:将副节点映射为 basis 扁平索引的 div/mod 表达式时,新增
if o.name in basis_names: continue跳过已属于 basis 的节点,只对真正 alternate 的节点生成映射。 -
提前重建扁平归约别名:在
_npu_apply_promoted_rtree_lines中,将flat_recon别名赋值改为伴随 promoted aranges 无条件提前发出(rloop 内外均覆盖),因为 CSE 可能删除原始扁平归约别名赋值,而生成的 load 仍引用该别名;后续遇到该别名的旧赋值直接跳过。 -
新增 DALLE2 回归测试:新增
test/_inductor/test_triton_experimental_dalle2_regressions.py,其中TestDalle2CodegenRegressions.test_attention_softmax_accuracy对比torch.compile(npu_backend="triton_experimental")与 eager 的注意力 softmax 数值精度,test_fold_dual_decomposition_with_shared_axis直接验证共享轴场景下_fold_dual_decomp将x5推导为x1/x2的折叠结果(代入x0=17, x1=3, x2=1应得11)。


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.
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 |
|---|---|---|
| test | ❌ (0/2)(You can also ask: 王朝, wasd1111222, xuyun15, 陈豪, wjlflyer) | ❌ (0/1)(You can also ask: 陈豪, kisnwang, chujinjin, zhenyu10, li_jing_hw) |
| torch_npu/_inductor | ❌ (0/2)(You can also ask: hbhu_bin, renyujin, 楚浩田, huangyunlong2022, zqwenn) | ❌ (0/1)(You can also ask: medivh-x, wjlflyer, 楚浩田, liangsongwei, anyrenwei) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
caoyilun, thanks for your pull request. All authors of the commits have signed the CLA. 👍


Linking Issue Notice
@caoyilun , 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.7.1 | ||
| v2.12.0-26.1.0 | ||
| v2.11.0-26.1.0 | ||
| v2.10.0-26.1.0 | ||
| v2.9.0-26.1.0 | ||
| v2.7.1-26.1.0 | ||
| v2.12.0 | ||
| v2.10.0 | ||
| v2.11.0 | ||
| ci-test |
评论 /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 检查,没有需要检查的文档文件


| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | Build_X86 | ✅ | >>> |
| Build_ARM | ✅ | >>> | |
| Build_X86_torchair | 🛑 | >>> | |
| Build_ARM_torchair | 🛑 | >>> | |
| patch_test | 🛑 | >>> | |
| Build_X86_213 | ✅ | >>> | |
| Build_ARM_213 | ✅ | >>> | |
| 恶意代码检查 | Antipoison | ✅ | >>> |
| 编码安全与规范检查 | codecheck_pre-commit | ✅ | >>> |
| check_error | ✅ | >>> | |
| 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 | ✅ | >>> | |
| UT_ARM_A2_Part_01_213 | ✅ | >>> | |
| UT_ARM_A2_Part_02_213 | ✅ | >>> | |
| UT_ARM_A2_Part_03_213 | ✅ | >>> | |
| UT_inductor_Part_01_213 | ✅ | >>> | |
| UT_inductor_Part_02_213 | ✅ | >>> | |
| UT_inductor_Part_03_213 | ✅ | >>> | |
| UT_inductor_Part_04_213 | ✅ | >>> | |
| UT_DIST_ARM_Part_01_213 | 🛑 | >>> | |
| UT_DIST_ARM_Part_02_213 | 🛑 | >>> | |
| UT_DIST_ARM_Part_03_213 | 🛑 | >>> | |
| UT_DIST_ARM_Part_04_213 | 🛑 | >>> | |
| UT_ARM_A2_Select_Part_01_213 | ✅ | >>> | |
| UT_ARM_A2_Select_Part_02_213 | ✅ | >>> | |
| 流水线 | PR-pipeline_pytorch | ✅ | >>> |
- compile、compile_inductor、compile_torchair : 运行流水线
- retry : 重试流水线所有失败子任务
- retry <任务名> : 仅重试指定失败子任务
- stop : 停止流水线


ascend docs pipeline is running...


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


【合入来源】
【修改方案】
【资料变更】
【接口变更】
【功能验证】
【CheckList】