Closed
kernel_utils_constants.h:733 `using hif4_scale = hif4_scale;` 在 `using namespace pto;` 下报 ambiguous(CANN 1107+,pypto 用例编译失败) #2010
范泽清Add on  18 days agoClosed at  15 days ago
范泽清
范泽清
18 days ago Create

现象

CANN 1107 / 1108 下,pypto JIT 生成的 kernel 编译失败:

asc/impl/basic_api/utils/kernel_utils_constants.h:757:20: error: reference to 'hif4_scale' is ambiguous
using hif4_scale = hif4_scale;
                    ^
note: candidate found by name lookup is 'hif4_scale'
      asc/impl/utils/common_types.h:47: using hif4_scale = struct hif4_scale {
note: candidate found by name lookup is 'pto::hif4_scale'
      include/pto/common/type.hpp:119: struct hif4_scale {

CANN 1106 及以前正常;1107 起复现(1107、1108 均失败)。

触发条件

编译单元里有 using namespace pto;,且该指令位于 include asc 头之前。pypto JIT 生成的 kernel.cpp 正是这个顺序:

#include <pto/pto-inst.hpp>

using namespace pto;                              // 第 10 行

#include <basic_api/kernel_operator_cache_intf.h> // 第 12 行
    -> kernel_reg.h -> kernel_utils.h -> kernel_utils_constants.h:757

CANN 1107 打包的 include/pto/common/type.hpp 新增了 pto::hif4_scale(来自 pto-isa 5aa53307),于是 757 行右侧的 hif4_scale 同时命中全局 ::hif4_scale 和 pto::hif4_scale。

建议修法

  1. 757(master 733)行改为:
using hif4_scale = ::hif4_scale;

或直接删掉——common_types.h:47 已有全局定义,这行本来是冗余别名。

  1. 想请教一个设计问题:为什么 hif4_scale 定义在 namespace AscendC 之外?common_types.h 第 45 行已经 } // namespace AscendC,第 47 行的 hif4_scale 落在全局作用域。如果收进 namespace AscendC:

    • 这类"下游 namespace 同名类型 + using-directive"造成的冲突天然隔离;
    • 757 行这个别名也不需要了,AscendC::hif4_scale 依然可用。

    common_types.h 第 45 行之后还有一批全局声明:fp4x2_e2m1_t / fp8_e5m2_t / fp8_e4m3fn_t / fp8_e8m0_t / hif4x2_t / fp8_e6m2_t、INT4_BIT_NUM、conditional、integer_sub_type 等,建议一并评估同类风险。

影响面

目前只影响 pypto 的 2 个用例(test_icache_preload_aic_execution / test_icache_preload_aiv_execution)编译。改这一行不影响任何 API 和调用方。

环境

  • CANN: Ascend-cann-toolkit 9.3.0 / V100R001C25B046 / build 20261107_152116398
  • 平台: Ascend950 (A5)
  • 失败日志: pypto A5 daily 第二轮日志 pypto.pro.wl.log 第 3646 行(11-08 轮为第 3205 行)

建议 @

impl/basic_api 路径 committer:@chenyiyuan @wuyang_hw @hujiawen_kaven @chentianyu19

likedislike
ApeiriaNode_Booker
ApeiriaNode_BookerCollaborators
18 days ago Comments:

您好,感谢您的反馈,我们目前正在核实您反馈的情况。确认后会在第一时间回复您~

该pr确认有效,我们已复现hif4_scale定义编译问题,待pr合入修复。

likedislike
ApeiriaNode_BookerApeiriaNode_BookerCollaborators
17 days ago Assign maohaodi as responsible person
毛浩地毛浩地Collaborators
17 days ago Associated pull request
ApeiriaNode_Booker
ApeiriaNode_BookerCollaborators
15 days ago Comments:

您好,当前修复pr已经合入,本issue即将关闭,感谢您的反馈~

likedislike
ApeiriaNode_BookerApeiriaNode_BookerCollaborators
15 days ago Added label: Accepted
ApeiriaNode_BookerApeiriaNode_BookerCollaborators
15 days ago changed custom category from 任务 to 缺陷
ApeiriaNode_BookerApeiriaNode_BookerCollaborators
15 days ago changed custom state from 待办的 to 已完成
ApeiriaNode_BookerApeiriaNode_BookerCollaborators
15 days ago Close issue
CANN-robotCANN-robotCollaborators
15 days ago Added label: resolved
ApeiriaNode_BookerApeiriaNode_BookerCollaborators
10 days ago Assign ApeiriaNode_Booker as responsible person