| compat(v2.14): register v2.14, follow upstream #185272 and #187115 Co-authored-by: chz34<chenhaozhe1@huawei.com> # message auto-generated for no-merge-commit merge: !5388 merge compat/2.14 into master compat(v2.14): register v2.14, follow upstream #185272 and #187115 Created-by: c_34 Commit-by: chz34 Merged-by: ascend-robot Description: <!-- PR描述模板更新日期:20260203 --> # 【合入来源】 > <font color="red">**如有社区issue,请关联issue链接**</font>\ > <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font> - [ ] 需求 - [ ] 问题单 - [x] issue/工单 https://gitcode.com/Ascend/pytorch/issues/2578 , https://gitcode.com/Ascend/pytorch/issues/2594 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 > 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\ > 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容) 1. 针对https://gitcode.com/Ascend/pytorch/issues/2578,临时采用python白名单控制转换,依赖隐式转换实现多版本的兼容。正式方案依赖算子补充.out类型,并参照上游进行meta处理与device处理的解耦,特殊算子依赖950硬件验证,后续单独处理 2. 针对https://gitcode.com/Ascend/pytorch/issues/2594,直接补齐缺省参数,天然兼容历史版本,补齐的参数与原默认参数保持一致。 compat(v2.14): register v2.14, follow upstream #185272 and #187115 Register PyTorch 2.14 as a supported minor across op-plugin's version housekeeping so gencode.sh can produce the v2r14 dispatch tables and VERSION_BETWEEN(...) macros compile in a torch 2.14 build: * op_plugin/utils/Version.h -- add #define V2R14 13 and move VERSION_NEWEST from V2R13 to V2R14. Without this, torch 2.14 builds cause CMakeLists.txt to inject -DCURRENT_VERSION=V2R14, which then fails at preprocessing. * op_plugin/config/op_plugin_functions.yaml + derivatives.yaml -- append v2.14 to the all_version list so gencode.sh generates registration entries for v2.14. * gencode.sh -- bump newest_minor_version=13 to 14 so the test/test_v2r{n}_ops loop covers v2r14. * test/test_v2r14_ops/unsupported_ops_info.yaml -- new stub matching the v2r13 template (the header-only comment file; gencode.sh will prepend test/unsupported_ops_info_base.yaml at build time). Also, follow upstream pytorch#185272 which converted _scaled_mm_v2 into a structured operator (landed 2026-06-15, releasing in 2.14). As a side effect, torchgen switched the C++ binding of the Tensor[] scale_a / scale_b params from at::TensorList to const at::ITensorListRef&, so the wrapper generated in torch_npu's RegisterNPU.cpp on 2.14 no longer matches op_plugin::_scaled_mm_v2, which still expects at::TensorList: * torchnpugen/context.py -- add a small op whitelist that force-enables param_use_ilistref_for_tensor_lists for _scaled_mm_v2 regardless of what op_plugin_functions.yaml says. Codegen output for the four interface files now declares scale_a / scale_b as const at::ITensorListRef&; the other 73 ops that use Tensor[] params are untouched. * op_plugin/ops/opapi/ScaledMmV2KernelNpuOpApi.cpp -- change the handwritten impl signature to match, then materialize the ilist inputs into a local at::TensorList at function entry so the existing body -- ten scale_a[i] indexings, .empty() / .size() checks, matcher_fn pass-through -- needs no further edit. Both directions of the boundary are safe without version gating: * On 2.11-2.13, torch_npu's wrapper still passes at::TensorList; IListRef has an implicit constructor from ArrayRef so it converts transparently to const ITensorListRef&. * On 2.14, torch_npu's wrapper passes const at::ITensorListRef& directly and the types match. Follow upstream pytorch#187115, which dropped the includeBool=false default on at::isIntegralType(t): all such callsites in MatmulAllReduceBaseKernelNpuOpApi.cpp, RangeKernelNpuOpApi.cpp, OpUtils.cpp and ScalarOpApi.cpp now pass the second argument explicitly to compile on both 2.13 and 2.14. Users must rerun gencode.sh <version> python3 to regenerate the four untracked interface files after this change; the source-tracked change alone is not enough for a working build. Independent follow-up (not in this commit): upstream 2.14 deprecates c10::value_or_else in favor of std::optional::value_or; op_plugin emits many warnings but no errors. See docs/issue_scaled_mm_v2_structured.md. # 【资料变更】 > 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及” 不涉及 # 【接口变更】 > 请确认是否涉及跨代码仓或者客户面可见的接口变更。如涉及,需要详细说明接口以及对应的变更内容,同时需要在资料中体现。如不涉及,需填写“不涉及” 不涉及 # 【功能验证】 > 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\ > 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图 兼容性修改,依赖历史测试用例 # 【CheckList】 > PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x] - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等 - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/op-plugin!5388 | 1 个月前 |