Closed
[Documentation|文档反馈]: aclnnDequantSwigluQuant 未声明 groupIndex 非空时 quantScale/quantOffset 的形状约束(按资料构造必 561002) #7582
liuhanwen8Add on 24 days agoClosed at 16 days ago
24 days ago Added label: documentation
yuning_chen
24 days ago Comments:
24 days ago Comments:
24 days ago Assign east_yang as responsible person
yuning_chen
24 days ago Comments:
24 days ago Comments:
您好,该问题已收到,当前问题 @east_yang 正在处理中


east_yang
19 days ago Comments:
19 days ago Comments:
/unassign @east_yang


19 days ago Removed responsible person east_yang
east_yang
19 days ago Comments:
19 days ago Comments:
/assign @fengying555682


19 days ago Assign fengying555682 as responsible person
east_yang
19 days ago Comments:
19 days ago Comments:
/assign @guijianwei


CANN-robot
19 days ago Comments:
19 days ago Comments:
18 days ago Assign guijianwei as responsible person
18 days ago Removed responsible person fengying555682
18 days ago Assign jzj007 as responsible person
18 days ago Removed responsible person guijianwei
17 days ago Associated pull request
16 days ago Close issue
16 days ago Added label: resolved
现象
docs/aclnnDequantSwigluQuant.md未声明groupIndexOptional非空时对quantScaleOptional/quantOffsetOptional形状的附加约束,按资料字面构造的合法输入被拒绝(561002)。资料现状(
docs/aclnnDequantSwigluQuant.md):groupIndexOptional只写「MoE 分组需要的 group_index」、维度写1,没有写它与x首维 /groupNum的关系;weightScale/activationScale/quantScale/quantOffset/quantMode五个参数,唯独没有groupIndexOptional;static时quantScale/quantOffset为 1 维、值为 1」。按第 3 条构造(无
groupIndexOptional)可以正常执行;一旦groupIndexOptional非空,同一份quantScale=[1]直接被拒561002。实测 5 种quantScale/quantOffset形状全部被拒,资料里没有任何一句能解释该给什么:[1][2][1][2][2,128][2][2,64][2][128][2][2,64]期望
资料补充
groupIndexOptional非空时的约束:① 形状与取值语义(groupNum与x首维关系、cumsum 还是 per-group count);② 对quantScale/quantOffset/bias形状的连带要求(static / dynamic 分别给出);③ 若存在,dtype 组合限制。环境
ascend-toolkit/latest),npu-smi 26.1.1,Linux aarch64 / glibc 2.35ops-nn/quant/dequant_swiglu_quant/docs/aclnnDequantSwigluQuant.md,源码提交711a4f5d复现步骤
repro_grp.cpp,编译:g++ -std=c++17 -O1 repro_grp.cpp -I$ASCEND/include -L$ASCEND/lib64 -L$ASCEND/aarch64-linux/lib64 -lascendcl -lnnopbase -lopapi -Wl,--allow-shlib-undefined -o repro_grp。./repro_grp nogroup→ret1=0:资料字面的 static 形态可用。./repro_grp group→ret1=561002:只增加groupIndex=[2],其余完全不变;对照资料参数表与 A2/A3 约束段,找不到任何一句说明groupIndexOptional会改变quantScale的形状。复现脚本
#include <cstdio> #include <string> #include <unistd.h> #include <vector> #include "acl/acl.h" #include "aclnnop/aclnn_dequant_swiglu_quant.h" static aclTensor *mk(const std::vector<int64_t> &s, void *a, aclDataType dt) { std::vector<int64_t> st(s.size(), 1); for (int i = (int)s.size() - 2; i >= 0; i--) st[i] = s[i + 1] * st[i + 1]; return aclCreateTensor(s.data(), s.size(), dt, st.data(), 0, aclFormat::ACL_FORMAT_ND, s.data(), s.size(), a); } static int64_t numel(const std::vector<int64_t> &s) { int64_t n = 1; for (auto v : s) n *= v; return n; } int main(int argc, char **argv) { bool grp = argc > 1 && std::string(argv[1]) == "group"; const int64_t G = 2, H = 128; std::vector<int64_t> xs{4, H}, ys{4, H / 2}, ss{4}, qs{1}; // static: quantScale=[1] aclInit(nullptr); aclrtSetDevice(0); aclrtStream stream = nullptr; aclrtCreateStream(&stream); void *xd, *wsd, *asd, *bd, *qd, *od, *gd, *yd, *sd; aclrtMalloc(&xd, numel(xs) * 4, ACL_MEM_MALLOC_HUGE_FIRST); aclrtMalloc(&wsd, H * 4, ACL_MEM_MALLOC_HUGE_FIRST); aclrtMalloc(&asd, 16, ACL_MEM_MALLOC_HUGE_FIRST); aclrtMalloc(&bd, (grp ? G : 1) * H * 4, ACL_MEM_MALLOC_HUGE_FIRST); aclrtMalloc(&qd, 4, ACL_MEM_MALLOC_HUGE_FIRST); aclrtMalloc(&od, 4, ACL_MEM_MALLOC_HUGE_FIRST); aclrtMalloc(&gd, G * 4, ACL_MEM_MALLOC_HUGE_FIRST); aclrtMalloc(&yd, numel(ys), ACL_MEM_MALLOC_HUGE_FIRST); aclrtMalloc(&sd, numel(ss) * 4, ACL_MEM_MALLOC_HUGE_FIRST); std::vector<int32_t> xh(numel(xs), 3); std::vector<float> wsh(H, 1), ash(4, 1), ov(1, 0.0f), qv(1, 1.0f); std::vector<float> bh((grp ? G : 1) * H, 0); std::vector<int64_t> gv{2, 4}; aclrtMemcpy(xd, numel(xs) * 4, xh.data(), numel(xs) * 4, ACL_MEMCPY_HOST_TO_DEVICE); aclrtMemcpy(wsd, H * 4, wsh.data(), H * 4, ACL_MEMCPY_HOST_TO_DEVICE); aclrtMemcpy(asd, 16, ash.data(), 16, ACL_MEMCPY_HOST_TO_DEVICE); aclrtMemcpy(bd, bh.size() * 4, bh.data(), bh.size() * 4, ACL_MEMCPY_HOST_TO_DEVICE); aclrtMemcpy(qd, 4, qv.data(), 4, ACL_MEMCPY_HOST_TO_DEVICE); aclrtMemcpy(od, 4, ov.data(), 4, ACL_MEMCPY_HOST_TO_DEVICE); if (grp) aclrtMemcpy(gd, G * 4, gv.data(), G * 4, ACL_MEMCPY_HOST_TO_DEVICE); aclTensor *x = mk(xs, xd, ACL_INT32), *ws = mk({H}, wsd, ACL_FLOAT); aclTensor *as = mk({4, 1}, asd, ACL_FLOAT); aclTensor *b = grp ? mk({G, H}, bd, ACL_FLOAT) : mk({H}, bd, ACL_FLOAT); aclTensor *q = mk(qs, qd, ACL_FLOAT), *o = mk(qs, od, ACL_FLOAT); aclTensor *g = grp ? mk({G}, gd, ACL_INT64) : nullptr; aclTensor *y = mk(ys, yd, ACL_INT8), *s = mk(ss, sd, ACL_FLOAT); uint64_t wsp = 0; aclOpExecutor *e = nullptr; char qm[] = "static"; int r1 = (int)aclnnDequantSwigluQuantGetWorkspaceSize(x, ws, as, b, q, o, g, true, qm, y, s, &wsp, &e); printf("%s : groupIndex=%s quantScale=[1] ret1=%d\n", grp ? "group " : "nogroup", grp ? "[2]" : "nullptr", r1); fflush(stdout); _exit(0); }实测输出:
影响
561002(内部 tiling 错误),看起来像算子缺陷而非「我传错了」;MoE 场景groupIndex是主用入口,缺这一条会让该分支基本不可用;建议
在
docs/aclnnDequantSwigluQuant.md的 A2/A3 约束段补一条groupIndexOptional专项说明:分组语义(cumsum / count)、groupNum与x首维的关系、非空时quantScale/quantOffset/bias的形状要求(static / dynamic 分别给出),并给一个可运行样例。