Closed
[Bug-Report|缺陷反馈]: aclnnRmsNormQuant x/y 前置维不一致时报 561103 而非 161002(仅比对末维) #7400
liuhanwen8Add on 26 days agoClosed at 17 days ago
26 days ago Added label: bug-report
yuning_chen
26 days ago Comments:
26 days ago Comments:
初步分析
感谢反馈,我们已开始核对这个问题。
现象理解:缺陷反馈;aclnnRmsNormQuant x/y 前置维不一致时报 561103 而非 161002(仅比对末维)。
当前判断:从描述看,这是缺陷反馈「aclnnRmsNormQuant x/y 前置维不一致时报 561103 而非 161002(仅比对末维)」(正文涉及返回码 561103 / 161002)。正文已给出对照用例与期望/实际差异,更像参数校验、错误码语义或静默错值类问题。以上为初步判断,待复现确认,不能当成已确认根因。
涉及范围:aclnnRmsNormQuant、aclnnop、aclnn_rms_norm_quant
下一步:我们会对照资料契约与实现路径继续定位,并按需补充回归用例。


25 days ago Assign liujie12345678 as responsible person
yuning_chen
25 days ago Comments:
25 days ago Comments:
您好,问题已收到,当前 @liujie12345678 正在处理中。


25 days ago Assign liuyun_nj as responsible person
25 days ago Removed responsible person liujie12345678
17 days ago changed custom state from 进行中 to 已完成
17 days ago Close issue
chenjiayi_
11 days ago Comments:
11 days ago Comments:
补充说明本问题的修复结果:
结论:x / y 前置维一致性校验已覆盖 regbase 与 A2/A3 路径,前置维存在差异时第一段返回 161002,错误码语义与资料一致。
修复内容(文件/函数):
norm/rms_norm_quant/op_host/op_api/aclnn_rms_norm_quant.cpp的CheckShapeDim():- DT_INT32 输出分支:
CheckShapeDimWithFrontN(x, y, xDimNum - 1)外层增加所有平台的统一校验,前 n-1 维在 regbase 与 A2/A3 上均参与比对。 - 其余输出分支:新增
CheckShapeDimWithFrontN(x, y, xDimNum),按全部维度比对,存在差异时报x shape should be the same as y shape。 - 两个分支的
OP_LOGE改为OP_LOGE_FOR_INVALID_SHAPES_WITH_REASON等结构化错误宏,返回码为ACLNN_ERR_PARAM_INVALID(161002)。
- DT_INT32 输出分支:
- A2/A3 路径在
CheckParams通过后遇空 Tensor 直接返回workspaceSize=0与ACLNN_SUCCESS。
验证:
- 修复后
x=[1,3,5]、y=[3,5]在第一段被拒绝并返回 161002; - 合法基线
x=[3,5]、y=[3,5]两段均返回 0; - MR 中 UT 已更新,覆盖 x/y 前置维存在差异的新场景。
该 issue 已随修复合入关闭。MR 链接:PR#13356
如果还有后续需要,请重新提 issue。


9 days ago Assign chenjiayi_ as responsible person
1 day ago Removed responsible person chenjiayi_
现象
x 与 y 的前置维不一致(x=[1,3,5]、y=[3,5])时第一段返回 561103,资料要求该形态返回 161002。对照:末维不一致(x=[3,5]、y=[3,4])能被正确拦下并返回 161002。
期望
资料
norm/rms_norm_quant/docs/aclnnRmsNormQuant.md「返回值」表:「输入/输出的 shape 关系不符合预期」→ 161002。环境
711a4f5dda0d(norm/rms_norm_quant),2026-10-26复现步骤
repro.cpp;g++ -O2 -std=c++17 repro.cpp -o repro -I$ASCEND_HOME_PATH/include \ -L$ASCEND_HOME_PATH/lib64 -lascendcl -lnnopbase -lopapi./repro ctrl 0、./repro xyrank3 0;GetWorkspaceSize与第二段RmsNormQuant)。复现脚本
#include <cstdio> #include <cstdlib> #include <string> #include <vector> #include "acl/acl.h" #include "aclnnop/aclnn_rms_norm_quant.h" static void* MkDev(size_t bytes) { void* p = nullptr; aclrtMalloc(&p, bytes, ACL_MEM_MALLOC_HUGE_FIRST); return p; } static aclTensor* MkTen(const std::vector<int64_t>& sh, aclDataType dt, void* dev, size_t esz) { int64_t n = 1; for (auto v : sh) n *= v; std::vector<int64_t> st(sh.size(), 1); for (int i = (int)sh.size() - 2; i >= 0; --i) st[i] = sh[i + 1] * st[i + 1]; return aclCreateTensor(sh.data(), sh.size(), dt, st.data(), 0, ACL_FORMAT_ND, sh.data(), sh.size(), dev); } int main(int argc, char** argv) { std::string sc = argc > 1 ? argv[1] : "ctrl"; std::vector<int64_t> xs{3,5}, gs{1,5}, bs{1,5}, ss{1}, os{1}, ys{3,5}; aclDataType ydt = ACL_INT8; if (sc == "gamma2d") gs = {3,5}; else if (sc == "scale2d") { ss = {1,1}; os = {1,1}; } else if (sc == "scalelen3") { ss = {3}; os = {3}; } else if (sc == "empty") { xs = {0,5}; ys = {0,5}; } else if (sc == "yint4") { xs = {3,16}; gs = {1,16}; bs = {1,16}; ys = {3,16}; ydt = ACL_INT4; } else if (sc == "yint32") { xs = {3,40}; gs = {1,40}; bs = {1,40}; ys = {3,5}; ydt = ACL_INT32; } else if (sc == "xyrank3") { xs = {1,3,5}; ys = {3,5}; } if (aclInit(nullptr) != ACL_SUCCESS) return 1; if (aclrtSetDevice(atoi(argc > 2 ? argv[2] : "0")) != ACL_SUCCESS) return 1; aclrtStream stm = nullptr; aclrtCreateStream(&stm); auto num = [](const std::vector<int64_t>& s) { int64_t n = 1; for (auto v : s) n *= v; return (int)(n > 0 ? n : 1); }; int nx = num(xs), ng = num(gs), nb = num(bs), ns = num(ss), no = num(os), ny = num(ys); std::vector<uint16_t> xh(nx), gh(ng), bh(nb), sh(ns); for (auto& v : xh) v = aclFloatToFloat16(-1.5f); for (auto& v : gh) v = aclFloatToFloat16(1.0f); for (auto& v : bh) v = aclFloatToFloat16(0.25f); for (int i = 0; i < ns; ++i) sh[i] = aclFloatToFloat16(sc == "scalelen3" ? std::vector<float>{0.01f,0.02f,0.05f}[i] : 0.01f); std::vector<int8_t> oh(no, 2), yh(ny * (ydt == ACL_INT4 ? 1 : 4), 0); void *dx = MkDev(nx*2), *dg = MkDev(ng*2), *db = MkDev(nb*2), *ds = MkDev(ns*2), *dof = MkDev(no), *dy = MkDev(yh.size()); aclrtMemcpy(dx, nx*2, xh.data(), nx*2, ACL_MEMCPY_HOST_TO_DEVICE); aclrtMemcpy(dg, ng*2, gh.data(), ng*2, ACL_MEMCPY_HOST_TO_DEVICE); aclrtMemcpy(db, nb*2, bh.data(), nb*2, ACL_MEMCPY_HOST_TO_DEVICE); aclrtMemcpy(ds, ns*2, sh.data(), ns*2, ACL_MEMCPY_HOST_TO_DEVICE); aclrtMemcpy(dof, no, oh.data(), no, ACL_MEMCPY_HOST_TO_DEVICE); aclTensor* x = MkTen(xs, ACL_FLOAT16, dx, 2); aclTensor* g = MkTen(gs, ACL_FLOAT16, dg, 2); aclTensor* b = MkTen(bs, ACL_FLOAT16, db, 2); aclTensor* s = MkTen(ss, ACL_FLOAT16, ds, 2); aclTensor* o = MkTen(os, ACL_INT8, dof, 1); aclTensor* y = MkTen(ys, ydt, dy, 1); uint64_t ws = 0; aclOpExecutor* ex = nullptr; auto r1 = aclnnRmsNormQuantGetWorkspaceSize(x, g, b, s, o, 1e-6, y, &ws, &ex); printf("[%s] GetWorkspaceSize = %d\n", sc.c_str(), (int)r1); if (r1 == 0) { void* p = ws > 0 ? MkDev((size_t)ws) : nullptr; auto r2 = aclnnRmsNormQuant(p, ws, ex, stm); printf("[%s] RmsNormQuant = %d\n", sc.c_str(), (int)r2); if (r2 == 0) { aclrtSynchronizeStream(stm); std::vector<int8_t> out(ny, 0); aclrtMemcpy(out.data(), ny, dy, ny, ACL_MEMCPY_DEVICE_TO_HOST); printf(" y[0..7]="); for (int i = 0; i < ny && i < 8; ++i) printf("%d ", out[i]); printf("\n"); } if (p) aclrtFree(p); } aclFinalize(); return 0; }实测输出:
影响
同 B1:非法 shape 未在契约面被拦下,错误码语义类别与资料不符;调用方无法据返回码定位是自己传错。规避方式:调用方自行保证 y.shape == x.shape。
建议
CheckShapeDim的非 regbase 分支只做xLastDim == outLastDim,前置维比对(CheckShapeDimWithFrontN)只在IsRegbase()分支执行。建议在非 regbase 分支同样比对前 n-1 维,命中时返回 161002。