Closed
[Bug-Report|缺陷反馈]: aclnnClippedSwiglu out 形状/rank/dim 越界返回 561002,资料声明 161002(实测 561002) #7555
liuhanwen8Add on 24 days agoClosed at 4 days ago
24 days ago Added label: bug-report
yuning_chen
24 days ago Comments:
24 days ago Comments:
24 days ago Assign clwsy1 as responsible person
yuning_chen
24 days ago Comments:
24 days ago Comments:
您好,该问题已收到,当前问题 @clwsy1 正在处理中


15 days ago Removed responsible person clwsy1
10 days ago Assign east_yang as responsible person
10 days ago Assign shilulu as responsible person
10 days ago Removed responsible person east_yang
7 days ago Assign east_yang as responsible person
7 days ago Removed responsible person shilulu
east_yang
7 days ago Comments:
7 days ago Comments:
/unassign @east_yang


7 days ago Removed responsible person east_yang
7 days ago Assign shilulu as responsible person
4 days ago Associated pull request
shilulu
4 days ago Comments:
4 days ago Comments:
感谢反馈,问题确认有效,资料已修正,见修复 PR:https://gitcode.com/cann/ops-nn/pull/14619。说明如下:
一、复现确认(910B3 + CANN 9.3.0)
- out=[2,32](dim 轴未减半)、out=[2](rank 与 x 不一致)、dim=2(越界):三个用例均在第一段返回 561002,第二段不执行——与报告一致;
- dtype 不匹配(x=fp32、out=fp16):第一段返回 161002;x=fp64:第一段返回 161002——dtype 类校验在 host 首段拦截,资料 161002 声明对该子项成立。
二、确认结论
维度与 dim 两类非法入参的校验位于 tiling 层(CheckY 的 rank 相等与 dim 轴减半校验、CheckAndGetXAndAttrs 的 dim 取值域校验),tiling 拒绝按框架约定包装为 561002(ACLNN_ERR_INNER_TILING_ERROR);资料将其声明在 161002
下与实际行为不符,属资料-实现不一致。dtype 子项由 host 首段校验返回 161002,声明正确。
报告补充指出的 CheckY 取 dtype 用 GetInputDesc(Y_INDEX)(导致 out 与 x dtype 一致性校验恒假)的问题:该问题已在 f134ef309(2026-10-28 内部错误码整改)中修正为 GetOutputDesc,报告基线(10-28 快照)早于该修复;且 dtype
一致性另有 host 首段校验(实测 161002),tiling 侧校验为二道防线。
三、修复内容
错误码表拆分(见修复 PR:https://gitcode.com/cann/ops-nn/pull/14619):
- "数据类型不在支持的范围内"维持 161002;
- "输入或输出的参数维度不在支持的范围内""dim 不在指定的取值范围内"拆分至 561002(ACLNN_ERR_INNER_TILING_ERROR),与 tiling 层校验的实际拦截行为一致,也与 V2 资料(aclnnClippedSwigluV2.md)已有口径对齐。
关于报告期望的"参数非法应统一 161002":参数维度/dim 取值类校验实施在 tiling 层,按框架约定归 561002 内部错误类,资料如实按此描述。
感谢支持。


4 days ago Close issue
4 days ago changed custom state from 进行中 to 已完成
4 days ago Added label: resolved
[Bug-Report|缺陷反馈]: aclnnClippedSwiglu out 形状/rank/dim 越界返回 561002,资料声明 161002(实测 561002)
现象
aclnnClippedSwigluGetWorkspaceSize对维度类非法入参返回561002(内部 tiling 异常),与资料错误码表声明的
ACLNN_ERR_PARAM_INVALID(161002)不符。第一段即返回,第二段不执行。x=fp32[2,32],dim=-1,alpha=1.702,limit=7.0,bias=1.0,interleaved=true)out=fp32[2,16](在dim上减半,合法)0 / 0out=fp32[2,32](out在dim上未减半)561002/ 未执行out=fp32[2](outrank 与x不一致)561002/ 未执行out=fp32[2,16]、dim=2(dim等于 rank,越界)561002/ 未执行activation/clipped_swiglu/docs/aclnnClippedSwiglu.md错误码表161002的第 2 子项「输入或输出的参数维度不在支持的范围内」、第 3 子项「dim 不在指定的取值范围内」。
out的 rank 与out[dim]减半关系、dim的取值范围,三类非法入参未被拦截,落到
clipped_swiglu_tiling.cpp的CheckY()(yDims != xDims_、y[cutDim] != xCutDimNum_/2)与CheckAndGetXAndAttrs()(cutDim_越界)返回GRAPH_FAILED,再由 aclnn 层统一包成
561002。CheckY()第 237 行取 dtype 用context_->GetInputDesc(Y_INDEX)(Y_INDEX=0即x),yDtype != xDtype_恒为假,out与xdtype 一致性校验实际不生效。#7297(aclnnDeepNorm)、#7531(aclnnDynamicBlockQuantV2)。本 issue 是前向aclnnClippedSwiglu,校验点在clipped_swiglu_tiling.cpp的CheckY()/CheckAndGetXAndAttrs(),与上述两条不是同一处代码。
期望
这两类非法入参应返回 161002,实测返回 561002。应得值有两个独立来源:① 上引本接口资料错误码表
把「参数维度」与「dim 取值」两类挂在
161002下;② 仓内docs/zh/context/aclnn_return_code.md表 1/表 2 定义ACLNN_ERR_PARAM_INVALID = 161002(参数校验错误)、ACLNN_ERR_INNER_TILING_ERROR = 561002(API 内部做 tiling 时发生异常)。用户传入的 out 形状错误属参数问题,不属于 API 内部异常。
环境
ASCEND_HOME_PATH=/usr/local/Ascend/ascend-toolkit/latest)cann/ops-nnmasterf769b5ed(2026-10-28git fetch后)。该提交下clipped_swiglu_tiling.cpp的校验点与上文一致,文件内161002/ACLNN_ERR_PARAM_INVALID出现 0 次aclnnClippedSwiglu(aclnnClippedSwigluGetWorkspaceSize+aclnnClippedSwiglu)复现步骤
repro.cpp。source $ASCEND_HOME_PATH/set_env.shg++ -std=c++17 -O2 repro.cpp -o repro -I$ASCEND_HOME_PATH/include -L$ASCEND_HOME_PATH/lib64 -lascendcl -lopapi -lnnopbase./repro0,第 2-4 行为561002且第二段不执行。复现脚本
#include <acl/acl.h> #include <aclnnop/aclnn_clipped_swiglu.h> #include <cstdio> #include <vector> static aclTensor* mkT(void* d, std::vector<int64_t> sh, aclDataType dt) { std::vector<int64_t> st(sh.size()); int64_t acc = 1; for (int i = (int)sh.size() - 1; i >= 0; --i) { st[i] = acc; acc *= sh[i] ? sh[i] : 1; } return aclCreateTensor(sh.data(), (uint64_t)sh.size(), dt, st.data(), 0, ACL_FORMAT_ND, sh.data(), (uint64_t)sh.size(), d); } // x 固定 fp32[2,32];out 形状与 dim 按用例变;groupIndex 传 nullptr static void run_case(const char* tag, void* dIn, void* dOut, std::vector<int64_t> outShape, int64_t dim, aclrtStream s) { aclTensor* x = mkT(dIn, {2, 32}, ACL_FLOAT); aclTensor* out = mkT(dOut, outShape, ACL_FLOAT); uint64_t ws = 0; aclOpExecutor* ex = nullptr; int r1 = (int)aclnnClippedSwigluGetWorkspaceSize(x, nullptr, dim, 1.702, 7.0, 1.0, true, out, &ws, &ex); int r2 = -1; if (r1 == 0) { void* w = nullptr; if (ws > 0) { aclrtMalloc(&w, ws, ACL_MEM_MALLOC_HUGE_FIRST); } r2 = (int)aclnnClippedSwiglu(w, ws, ex, s); aclrtSynchronizeStream(s); if (w) { aclrtFree(w); } } printf("[%s] GetWorkspaceSize = %d, Execute = %d\n", tag, r1, r2); aclDestroyTensor(x); aclDestroyTensor(out); } int main() { if (aclInit(nullptr) != ACL_SUCCESS) { printf("aclInit failed\n"); return 2; } aclrtSetDevice(0); aclrtStream s; aclrtCreateStream(&s); void *dIn = nullptr, *dOut = nullptr; aclrtMalloc(&dIn, 2 * 32 * 4, ACL_MEM_MALLOC_HUGE_FIRST); aclrtMalloc(&dOut, 2 * 32 * 4, ACL_MEM_MALLOC_HUGE_FIRST); run_case("对照组 ok out 2x16", dIn, dOut, {2, 16}, -1, s); run_case("缺陷组 out未减半 2x32", dIn, dOut, {2, 32}, -1, s); run_case("缺陷组 out rank=1", dIn, dOut, {2}, -1, s); run_case("缺陷组 dim=2", dIn, dOut, {2, 16}, 2, s); aclrtDestroyStream(s); aclrtResetDevice(0); aclFinalize(); return 0; }实测输出(910B2 / CANN 26.1.1):
影响
调用方按资料写
if (ret == 161002)的参数错误分支收不到该错误,非法入参被报成ACLNN_ERR_INNER_TILING_ERROR,与「算子包缺失 / tiling 内部故障」同类,无法区分调用方参数问题与环境故障;训练脚本里表现为难以定位的算子初始化失败。建议
host 侧(op_api 适配层)补
outrank、out[dim]减半关系、dim取值范围的显式校验并返回ACLNN_ERR_PARAM_INVALID;同时把CheckY()第 237 行的context_->GetInputDesc(Y_INDEX)改为输出描述符接口,使out与x的 dtype 一致性校验真正生效。