Closed
[Bug-Report|缺陷反馈]: aclnnRotateQuant 的 N/K 越界返回 561103 而非资料声明的 161002 #7415
liuhanwen8Add on 26 days agoClosed at 18 days ago
26 days ago Added label: bug-report
yuning_chen
26 days ago Comments:
26 days ago Comments:
25 days ago Assign yushan-kite as responsible person
yuning_chen
25 days ago Comments:
25 days ago Comments:
您好,问题已收到,当前 @yushan-kite 正在处理中。


zhangzhuoran3
24 days ago Comments:
24 days ago Comments:
/assign @zhangzhuoran3


24 days ago Assign zhangzhuoran3 as responsible person
24 days ago Removed responsible person yushan-kite
18 days ago Associated pull request
18 days ago Close issue
18 days ago Added label: resolved
环境
aclnnRotateQuant,资料docs/aclnnRotateQuant.md(A2 分支),仓 ops-nn711a4f5d现象
资料「约束说明」写明 A2 上
N范围[128, 16000]、K范围[16, 1024],错误码表只列161001(空指针)与161002(数据类型/维度/shape/参数取值不符)。实测越界的N、K返回 561103(内部错误码):
源码锚点:
op_api/aclnn_rotate_quant.cpp的CheckIntRotationShape()只校验N % 8 == 0、K != 0、N % K == 0与方阵,没有 N/K 范围校验;范围校验在op_host/arch22/rotate_quant_tiling.cpp的N_MIN/N_MAX/K_MIN/K_MAX,tiling 失败经 aclnn转成 561103。同族约束
N % 8 != 0(N=132)、N % K != 0都能正确返回 161002,说明校验被拆成两段、报错码随之分裂。
期望
四条越界用例都返回 161002;或资料补充声明「N/K 越界由 tiling 拒绝并返回 561103」。
复现步骤
repro.cpp。g++ -std=c++17 -O2 repro.cpp -I$ASCEND_HOME_PATH/include -L$ASCEND_HOME_PATH/lib64 -lascendcl -lnnopbase -lopapi -o reproexport ASCEND_RT_VISIBLE_DEVICES=<空闲卡号>./repro,对比五行返回码。复现脚本
#include <cstdio> #include <cstdint> #include <cstring> #include <vector> #include "acl/acl.h" #include "aclnnop/aclnn_rotate_quant.h" static aclTensor* mkT(const std::vector<int64_t>& v, aclDataType dt, void* d) { std::vector<int64_t> s(v.size(), 1); for (int i = (int)v.size() - 2; i >= 0; i--) s[i] = v[i + 1] * s[i + 1]; return aclCreateTensor(v.data(), v.size(), dt, s.data(), 0, ACL_FORMAT_ND, v.data(), v.size(), d); } static int call(int64_t M, int64_t N, int64_t K) { std::vector<int64_t> xv{M, N}, rv{K, K}, yv{M, N}, sv{M}; size_t xb = (size_t)M * N * 2, rb = (size_t)K * K * 2, yb = (size_t)M * N; if (!xb) xb = 2; if (!rb) rb = 2; if (!yb) yb = 1; void *xd = nullptr, *rd = nullptr, *yd = nullptr, *sd = nullptr; aclrtMalloc(&xd, xb, ACL_MEM_MALLOC_HUGE_FIRST); aclrtMalloc(&rd, rb, ACL_MEM_MALLOC_HUGE_FIRST); aclrtMalloc(&yd, yb, ACL_MEM_MALLOC_HUGE_FIRST); aclrtMalloc(&sd, (size_t)M * 4, ACL_MEM_MALLOC_HUGE_FIRST); aclrtMemset(xd, xb, 0, xb); aclrtMemset(rd, rb, 0, rb); aclrtMemset(yd, yb, 0, yb); aclrtMemset(sd, (size_t)M * 4, 0, (size_t)M * 4); aclTensor* xT = mkT(xv, ACL_BF16, xd); aclTensor* rT = mkT(rv, ACL_BF16, rd); aclTensor* yT = mkT(yv, ACL_INT8, yd); aclTensor* sT = mkT(sv, ACL_FLOAT, sd); uint64_t ws = 0; aclOpExecutor* ex = nullptr; char rm[] = "rint"; aclnnStatus p1 = aclnnRotateQuantGetWorkspaceSize(xT, rT, nullptr, -1, rm, 0, 0.0, false, yT, sT, &ws, &ex); aclDestroyTensor(xT); aclDestroyTensor(rT); aclDestroyTensor(yT); aclDestroyTensor(sT); aclrtFree(xd); aclrtFree(rd); aclrtFree(yd); aclrtFree(sd); return (int)p1; } int main() { aclInit(nullptr); aclrtSetDevice(0); printf("baseline M=4 N=256 K=64 -> p1=%d\n", call(4, 256, 64)); printf("N<128 M=4 N=64 K=64 -> p1=%d (doc:161002)\n", call(4, 64, 64)); printf("N>16000 M=4 N=16384 K=64 -> p1=%d (doc:161002)\n", call(4, 16384, 64)); printf("K<16 M=4 N=128 K=8 -> p1=%d (doc:161002)\n", call(4, 128, 8)); printf("K>1024 M=2 N=2048 K=2048 -> p1=%d (doc:161002)\n", call(2, 2048, 2048)); int bad = (call(4, 64, 64) == 561103) || (call(4, 16384, 64) == 561103); printf("对照组 CTRL return code = 0\n"); printf("缺陷组 DEFECT return code = %d\n", bad ? 1 : 0); aclrtResetDevice(0); aclFinalize(); return 0; }实测输出:
影响
561103 是内部错误码,调用方无法据此判断是传参越界还是算子内部异常,通常按「算子故障」上报;
同类越界(
N%8、N%K)已返回 161002,口径不一致会让上层参数校验用例产生误判。建议
把
N_MIN/N_MAX/K_MIN/K_MAX上移到CheckIntRotationShape()(与N % 8、K != 0放在一起)返回 161002,tiling 侧保留同样兜底。
同族参考:#7400(前置维不一致报 561103)、#7298(aclnnEinsum 形状不符 561103)、
#7293(同族 matmul 两种错误码并存)。