Pull Request已成功合入, 合并人@ascend-robot
(感谢 qinhanmin 的贡献)变更摘要
本 PR 将 inductor 动态 shape reduction 分组自动调优(dynamic-reduction-group-autotune)特性合入 v2.10.0_dev 分支,主要聚焦三类改动:调整 SplitTiling 对含动态分裂轴的 reduction 核函数的分桶与停止分裂策略;为 NPUSymbolicGroupedAutotuner 引入候选筛选与更贴近真实数据的 benchmark 输入;新增 allow_embedding_dense_backward_lowering 配置开关以控制 aten.embedding_dense_backward 的 lowering 路径。
主要改动
- 分裂轴停止条件优化(
split_tiling.py):在meet_stop_condition中新增has_dynamic_split_axis与is_reduction_kernel判断,当启用npu_config.enable_symbolic_shape_group_autotune且 reduction 核函数已含动态分裂轴时直接返回True,避免再拉入静态分裂轴导致整轴驻留(residency)丢失和BLOCK_SUB碎片化。 - 分桶边界按静态轴因子缩放(
split_tiling.py):新增_OUTER_BUCKETS_WITH_STATIC_AXES(按核心数倍数定义边界)以及_static_group_factor、_scale_buckets_by_static_factor方法,对外层/reduction 组的GroupFeatureSpec桶边界乘以静态轴因子,避免静态轴把动态轴压成单元素导致组无法填满 grid。 - 分组 benchmark 候选筛选(
triton_heuristics.py):新增_screen_grouped_entries,当 reduction 分组候选数超过_GROUPED_SCREEN_MIN_CANDIDATES(200)时先对各候选执行单次 launch 预跑并按组保留头部候选,被筛掉的候选保留其单次耗时,避免对明显劣势配置做全量重复测量。 - 整型 benchmark 输入按真实取值范围采样(
triton_heuristics.py):新增integer_benchmark_range,在materialize_spec中对于 reduction 核函数的整型runtime_arg,依据运行时参数快照_grouped_runtime_args_snapshot的真实 min/max 区间随机填充 tensor,恢复 gather/embedding 类核函数在真实数据上的性能差异。 - reduction 分组运行时规则扩展(
triton_heuristics.py):在build_grouped_launch_policy中将"outer"、"reduction"纳入会附加representative_numel运行时规则的 primary feature 列表,避免低于 representative 的 shape 继承其 grid 而循环多余行数。 embedding_dense_backwardlowering 开关(config.py、decomposition.py、lowering_fallback_list.py):新增配置allow_embedding_dense_backward_lowering(由环境变量TORCHINDUCTOR_ENABLE_EMBEDDING_DENSE_BACKWARD_LOWERING控制),为真时将aten.embedding_dense_backward从TORCH_NATIVE_FALLBACK_LIST移除并注册到 triton decomposition,否则保持原有 fallback 行为。


Linking Issue Notice
@qindong0 , 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.12.0 | ||
| v2.11.0 | ||
| v2.10.0 | ||
| v2.9.0 | ||
| v2.7.1 | ||
| 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 命令关闭


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
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| torch_npu/_inductor | ✅ HinPeng, rain-666 (2/2) | ✅ HinPeng (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)


ascend docs pipeline is running...


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


compile


ascend docs pipeline is running...


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


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


/lgtm




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