Pull Request已成功合入, 合并人@ascend-robot
(感谢 AllenGuan 的贡献)变更摘要
本 PR 修复了 auto_blockify_size 传递通路缺失导致的编译崩溃:此前该 triton-ascend 编译选项(NPUOptions 字段,非 kernel constexpr)被写入 Config.kwargs,_precompile_config 会把 kwargs 灌入 ASTSource 的 constants,ast_to_ttir 按 kernel 签名解析键名失败,导致 grid>65535 的 kernel 编译必崩 ValueError: 'auto_blockify_size' is not in list。本 PR 将其改经上游第三方后端槽位 Config.extra_options 注入,并在 _precompile_config 中转发进 triton.compile 的 options dict 送达 NPUOptions.auto_blockify_size,同时扩展 autotune 去重/hash 身份键以保留 {2,4,8} 三个候选的独立性,并新增 7 个 UT 用例看护。
主要改动
- 注入槽位切换(
npu_triton_config):auto_blockify_size不再写入cfg.kwargs,改为设置config.extra_options = {"auto_blockify_size": ...},kwargs 恢复为纯 constexpr,constants 通道不再携带后端选项。 - 选项送达(
_precompile_config): 在triton.compile前新增options.update(getattr(cfg, "extra_options", None) or {}),将槽位内容转发进 options dict(NPUOptions.parse_options按需映射),转发不感知具体键名。 - 候选身份与去重(
cached_autotune): 新增_npu_config_key/_npu_unique_configs/_npu_hash_configs,将extra_options并入身份/hash 键,替换上游仅含 kwargs+num_warps+num_stages 的unique_configs/hash_configs,避免 {2,4,8} 三候选被折叠为一个。 - 兜底透传(
_compile_small_block_fallback): 小方块回退重建Config时,将 template 的extra_options显式拷贝到fallback_cfg.extra_options,保证缓存命中路径下槽位不丢失。 - 测试看护(
test/_inductor/test_triton_experimental_autotune.py): 新增TestAutoBlockify7 个用例,覆盖槽位放置/kwargs 零泄漏、gate 开关矩阵(65535 严格边界、all_blocks_parallel开关、小 kernel)、候选身份去重及序列化 round-trip。


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


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


| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | Build_X86 | 🕚 | >>> |
| Build_ARM | 🕚 | >>> | |
| Build_LibTorch_x86 | 🕚 | >>> | |
| Build_LibTorch_ARM | 🕚 | >>> | |
| Build_X86_torchair | 🕚 | >>> | |
| Build_ARM_torchair | 🕚 | >>> | |
| patch_test | 🕚 | >>> | |
| 恶意代码检查 | 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 | 🕚 | >>> | |
| 流水线 | PR-pipeline_pytorch | 🟨 | >>> |
- compile、compile_inductor、compile_torchair : 运行流水线
- retry : 重试流水线所有失败子任务
- retry <任务名> : 仅重试指定失败子任务
- stop : 停止流水线


ascend docs pipeline is running...


ascend docs pipeline is running...


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


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


| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | Build_X86 | ✅ | >>> |
| Build_ARM | ❌ | >>> | |
| Build_LibTorch_x86 | ✅ | >>> | |
| Build_LibTorch_ARM | ✅ | >>> | |
| Build_X86_torchair | 🛑 | >>> | |
| Build_ARM_torchair | 🛑 | >>> | |
| patch_test | 🛑 | >>> | |
| 恶意代码检查 | 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 | 🕚 | >>> | |
| 流水线 | PR-pipeline_pytorch | ❌ | >>> |
- compile、compile_inductor、compile_torchair : 运行流水线
- retry : 重试流水线所有失败子任务
- retry <任务名> : 仅重试指定失败子任务
- stop : 停止流水线


| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | Build_X86 | ✅ | >>> |
| Build_ARM | ✅ | >>> | |
| Build_LibTorch_x86 | ✅ | >>> | |
| Build_LibTorch_ARM | ✅ | >>> | |
| Build_X86_torchair | 🛑 | >>> | |
| Build_ARM_torchair | 🛑 | >>> | |
| patch_test | 🛑 | >>> | |
| 恶意代码检查 | 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 | ✅ | >>> | |
| 流水线 | PR-pipeline_pytorch | ✅ | >>> |
- compile、compile_inductor、compile_torchair : 运行流水线
- retry : 重试流水线所有失败子任务
- retry <任务名> : 仅重试指定失败子任务
- stop : 停止流水线


/approve




【合入来源】
社区 issue 链接待创建后补充。
【修改方案】
背景:
auto_blockify_size是 triton-ascend 的编译选项(NPUOptions字段,经 options 通道生效于 AutoBlockify pass),不是 kernel constexpr。此前前端把它注入Config.kwargs,_precompile_config将全部 cfg kwargs 灌进ASTSource的 constants,triton 核心ast_to_ttir以fn.arg_names.index(key)解析键名——kernel 签名无此参数,导致 grid>65535 的 kernel(默认 1D 路径_pw1d_formula_configs生成auto_blockify_size∈{2,4,8}候选时)编译必崩ValueError: 'auto_blockify_size' is not in list,且 options 通道从未被喂值,该选项此前不存在送达后端的通路。npu_triton_config):auto_blockify_size不再写入cfg.kwargs,改设上游第三方后端官方槽位Config.extra_options(AutotuneCache.save原生序列化、read_best原生恢复);kwargs 恢复纯 constexpr,constants 通道因构造正确而安全,无需过滤逻辑。_precompile_config):options.update(getattr(cfg, "extra_options", None) or {})将槽位转发进triton.compile的 options dict →NPUOptions.auto_blockify_size→ 编译 metadata →add_auto_blockifypass → bishengir。转发不感知具体键名,后续新增后端选项自动走通。cached_autotune):上游去重/hash 键只含 kwargs+num_warps+num_stages,看不到 extra_options,{2,4,8} 三候选会被折叠为一个;改用_npu_config_key/_npu_unique_configs/_npu_hash_configs(键扩展 extra_options),save/read 同经本文件,hash 前后自洽。_compile_small_block_fallback):小方块回退重建 Config 时显式携带 template 的 extra_options(缓存命中路径configs=[winner]时 template 即带槽位的 winner)。gate 语义零变更:
all_blocks_parallel=True 且 ceildiv(numel, cap_XBLOCK)>65535时在 cap tile 上追加 {2,4,8} 候选,与原行为一致。【资料变更】
不涉及
【接口变更】
不涉及(
Config.extra_options为上游既有第三方后端槽位,本 PR 仅使用,未新增对外接口)【功能验证】
test/_inductor/test_triton_experimental_autotune.py新增TestAutoBlockify7 用例——槽位正确性(extra_options 位置/kwargs 零泄漏/仅 cap tile 携带)、gate 开关矩阵(65535 严格边界、all_blocks_parallel开关、小 kernel)、候选身份与去重、序列化 round-trip 形态。TORCHINDUCTOR_CACHE_DIR等缓存目录清空)后全量test_triton_experimental_autotune.py66 passed(存量 59 + 新增 7)。torch.compile编译通过、输出数值正确。auto_blockify_size∈{2,4,8}三个独立 hash 的编译产物(options 参与缓存 key,三候选真实参与 autotune 竞速)。【CheckList】