Closed
[Bug-Report|缺陷反馈]: aclnnRmsNormQuant scale 维度与长度校验缺失(scale=[1,1]、[3] 均被放行,且长度>1 时只取 scale[0]) #7401
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 scale 维度与长度校验缺失(scale= 、 均被放行,且长度>1 时只取 scale )。
当前判断:从描述看,这是缺陷反馈「aclnnRmsNormQuant scale 维度与长度校验缺失(scale= 、 均被放行,且长度>1 时只取 scale )」(正文涉及返回码 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
现象
资料要求
scale维度为 1、A2 产品下 shape 为 [1]。实测scale=[1,1]与scale=[3]两种非法形态第一段、第二段都返回 0;scale=[3]且元素取 0.01/0.02/0.05 时,输出与scale=[0.01]的对照逐元素完全相同,说明只用第一个元素,其余被静默忽略。期望
资料
norm/rms_norm_quant/docs/aclnnRmsNormQuant.md:scale 使用说明「维度为 1,长度要求见下方产品说明」;A2 段写明「scale的 shape 为[1]」。两种形态都应在第一段返回 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 scale2d 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; }实测输出:
影响
把 per-channel scale(长度=H)误传给 per-tensor 接口时不会报错,只会拿第一个通道的 scale 得到全表错误结果,且两段都返回 0 —— 静默错值比报错更难定位。规避方式:调用方自行断言 scale.numel()==1。
建议
aclnn_rms_norm_quant.cpp的CheckShapeDim:if (scaleDimNum != 1)只打OP_LOGE,随后if (IsRegbase()) return false;使非 regbase 路径只记日志不报错;另外全文没有scale.numel() == 1的检查,唯一的长度约束来自OP_CHECK_SHAPE_NOT_EQUAL(scale, offset)。建议去掉 regbase 条件、并显式校验scale/offset元素数为 1,命中返回 161002。