Closed
[Inductor] NPU AlgorithmSelectorCache 缺少 best_config_future 参数导致上游调用不兼容 #5312
stonexxxAdd on Oct 9Closed at 8 days ago
Oct 9 Added label: triage-reviewmodule: graph-mode
TorchNPU-Bot
Oct 9 Comments:
Oct 9 Comments:
问题涉及 torch_npu 对上游 PyTorch Inductor 的 AlgorithmSelectorCache 补丁兼容性,属 Inductor/图编译路径,归图模式类
添加分类标签:module: graph-mode。
当前分类由社区bot提供,如分类有误请在评论中回复。


Oct 9 Associated pull request
Oct 9 Added label: bot-triaged; Removed label: triage-review
TorchNPU-Bot
Oct 9 Comments:
Oct 9 Comments:
检测到当前 issue 已关联 PR,自动添加标签:bot-triaged


chenrayray
8 days ago Comments:
8 days ago Comments:
这条开发自提 issue 提出已超过一个月,先关闭。如仍需跟进,请重新打开。


8 days ago Close issue
8 days ago changed custom state from TODO to DONE
8 days ago Added label: resolved
问题描述
上游 PyTorch Inductor 的 AlgorithmSelectorCache.call 支持 best_config_future,GEMM lowering 会通过 autotune_select_algorithm 传入该关键字(包括默认值 None)。torch_npu/_inductor/select_algorithm.py 中 patch_algorithm_selector 替换的方法未声明该参数,使这类调用发生关键字参数不兼容。
影响使用该上游接口的 NPU Inductor 编译路径;当前 torch_npu master 的补丁方法也缺少该参数。
触发方式
在 NPU 后端安装 selector 补丁后,调用形态如下:
autotune_select_algorithm( name, choices, input_nodes, layout, best_config_future=None, )旧补丁签名不接受 best_config_future,会触发 unexpected keyword argument 错误。传入非空 future 时,还需要等待配置并只 benchmark 匹配的候选。
原因与期望行为
NPU 补丁签名及筛选流程未同步该上游可选参数。应对齐签名和默认值,等待并复用 best_config_future 的结果,让 lookup 和反馈使用筛选后的 choices;筛掉第一个 choice 后,应从有效 timings 中选择最快候选。
已有 precompilation_timeout_seconds、return_multi_template 和 defer_epilogue_compile_only 行为保持不变。其他新增参数在本次修复中仅兼容签名,标注 Not supported on NPU。
验证情况
select_fix 分支已准备 best_config_future 修复。通过历史测试脚本隔离加载当前 selector,签名、future 筛选及部分 timings 选择共 3 项回归测试通过;语法检查、lintrunner 和目标 master 的合并检查通过。
验证范围为 Python 逻辑,本机缺少 torch_npu._C,尚未进行 NPU 真机验证和远端 CI。