Closed
[Bug-Report|缺陷反馈]: 仿真模式执行含ERF算子的kernel报F16766 INVALID_PIPE_TYPE #3392
zhiweiyuanAdd on  Sep 20Closed at  Sep 22
zhiweiyuan
zhiweiyuanCollaborators
Sep 20 Create

Describe the current behavior / 问题描述 (Mandatory / 必填)

任务级仿真(--run_mode sim)执行 examples/02_intermediate/operators/activation/activation.py 时,GELU/GeGLU kernel 触发 cost model 仿真断言失败:

ASSERT FAILED: ErrCode: F16766! Enum: static_cast<unsigned>(CostModel::ForwardSimErrorScene::INVALID_PIPE_TYPE)
,[SIMULATION]: No pipe type corresponding to opcode is found. opcode=ERF
pypto.error.PyptoGeneralError: Failed to call JIT function 'gelu_activation_kernel'.

注:F16766 为十六进制显示,即 F92006 INVALID_PIPE_TYPE(error_code.h 中 INVALID_PIPE_TYPE = 92006U = 0x16766)。

环境信息 (Mandatory / 必填)

  • NPU/服务器:Ascend 910C (A3, d803)
  • CANN:9.2.0-beta.2
  • PyPTO Commit:a49c37568
  • Python:3.12.9 / OS:Ubuntu 24.04.3 LTS
  • torch 2.7.1+cpu / torch_npu 2.7.1.post4

Reproduce steps / 重现步骤 (Mandatory / 必填)

cd pypto
source env_setup.sh   # TILE_FWK_DEVICE_ID 与 PTO_TILE_LIB_CODE_PATH 就绪
python3 examples/02_intermediate/operators/activation/activation.py --run_mode sim

SiLU/SwiGLU(sigmoid)通过,首个使用 pypto.erf 的 GELU 用例失败。

Expected behavior / 预期结果 (Mandatory / 必填)

4 个用例(SiLU/GELU/SwiGLU/GeGLU)仿真全部通过。

Logs / 截图 (Mandatory / 必填)

关键错误栈:TileOp::GetPipeType()(framework/src/cost_model/simulation/common/ISA.cpp)中 SCHED_CORE_PIPE_TYPE 映射表缺少 ERF 的 pipe 类型映射,触发 ForwardSimErrorScene::INVALID_PIPE_TYPE 断言。同表已有 ERFC 但漏了 ERF。

备注 / 根因与修复方案 (Optional / 选填)

根因:cost model 仿真按 opcode 查 SCHED_CORE_PIPE_TYPE 决定流水分派;新增指令未同步注册时直接断言中断,无兜底路径(原 LOOP 豁免分支还存在解引用 end() 的 UB 隐患)。

修复方案(已实现,随后提交 PR):

  1. ISA.h 补注册 {"ERF", CorePipeType::PIPE_VECTOR_ALU}(与同类数学指令一致)
  2. ISA.cpp TileOp::GetPipeType() 重构:未注册 opcode 降级 fallback 到 PIPE_VECTOR_ALU 并输出 SIMULATION_LOGW,不再中断仿真(精度验证不受影响;性能仿真准确性依赖正确注册,WARN 提示注册遗漏)
likedislike
zhiweiyuan
zhiweiyuanCollaborators
Sep 20 Comments:

收到

likedislike
zhiweiyuanzhiweiyuanCollaborators
Sep 20 Assign zhiweiyuan as responsible person
zhiweiyuanzhiweiyuanCollaborators
Sep 20 Added label: Simulation
zhiweiyuanzhiweiyuanCollaborators
Sep 20 Associated pull request
zhiweiyuanzhiweiyuanCollaborators
Sep 21 Associated pull request
zhiweiyuanzhiweiyuanCollaborators
Sep 22 changed custom state from 进行中 to 已完成
zhiweiyuanzhiweiyuanCollaborators
Sep 22 Close issue
CANN-robotCANN-robotCollaborators
Sep 22 Added label: resolved