Closed
[Documentation|文档反馈]: aclnnDequantSwigluQuantV2 quantScale/quantOffset 未声明 static+groupIndex 下的形状([1] 被拒 561002) #7559
liuhanwen8Add on  24 days agoClosed at  16 days ago
liuhanwen8
liuhanwen8
24 days ago Create

现象

《aclnnDequantSwigluQuantV2》的接口说明里 quantScaleOptional 只写了 static 模式下 quantScale 的形状为 [1],没有声明「static + groupIndexOptional 非空」这一组合的形状要求;quantOffsetOptional 行同样只说「数据类型与shape同quantScale」。按资料字面构造的 [1] 在该组合下被接口拒绝(561002),调用方从资料里找不到正确形状。

quantScaleOptional 的形状说明原文(逐字):

当quantModeOptional为static时,shape为1维,值为1,shape表示为shape[1]。

同一格里紧随其后的三句分别给出:dynamic 时可为 [H]、[2H] 或 [groupNum, H];groupIndexOptional 为空指针且 activateDim 为尾轴时 [H];groupIndexOptional 不为空指针且 activateDim 为尾轴时 [groupNum, H]。后两句没有限定只对 dynamic 生效,但都排在 dynamic 之后。

即:唯一提到 static 的句子给的是 [1];提到 groupIndexOptional 非空的两句都跟在 dynamic 的语境之后,读者无法判断它们对 static 是否生效。

实测(910B2 / CANN 9.2.0,quantMode="static"、activateDim=-1、x=INT32、groupIndex=[4,4],H=64、groupNum=2):

quantScale quantOffset 期望(按资料 [1]) 实测 GetWorkspaceSize
[1] [1] 0 561002
[2,64] [2,64] — 0
[2,64] [1] — 561002
[1] [2,64] — 561002

无 groupIndex 时 [1] 正常返回 0,说明 [1] 本身不是非法形状,缺的是「分组场景要 [groupNum, H]」这条声明。

期望

资料应显式写出「static + groupIndexOptional 非空」时 quantScale/quantOffset 的形状为 [groupNum, H],因为实现要求如此(上表 4 组 A/B:只有 [2,64]+[2,64] 返回 0),而现有文字在这一组合下给的是 [1]。

判定依据是仓内资料本身:quantScaleOptional 的形状说明里所有含 static 的句子,没有任何一句同时给出 groupNum 维度。下文复现脚本对这一条做文本断言,找不到即判缺陷。

环境

  • 硬件:Ascend 910B2(单 die)
  • CANN:9.2.0(Ascend-cann-toolkit 9.2.0)
  • 目标仓:cann/ops-nn,master 0e188786
  • 资料:quant/dequant_swiglu_quant/docs/aclnnDequantSwigluQuantV2.md

复现步骤

  1. 取仓 cann/ops-nn 的 master(0e188786)。
  2. 保存下方断言脚本为 check_doc.py。
  3. 运行 python3 check_doc.py --repo-root <ops-nn 仓根>。
  4. 观察输出:[DEFECT] static 分支的形状句未覆盖 groupIndex 场景,退出码 1。
  5. 若需复核实测侧(可选):按 §复现脚本 末尾的 5 组参数调用 aclnnDequantSwigluQuantV2GetWorkspaceSize,只有 [2,64]+[2,64] 返回 0。

复现脚本

import os
import re
import sys


def main():
    repo = sys.argv[sys.argv.index("--repo-root") + 1] if "--repo-root" in sys.argv else "."
    path = os.path.join(repo, "quant/dequant_swiglu_quant/docs/aclnnDequantSwigluQuantV2.md")
    if not os.path.isfile(path):
        print("[SKIP] 找不到资料:%s" % path)
        return 2
    txt = open(path, encoding="utf-8").read()
    head = "quantScaleOptional(aclTensor*)"
    tail = "quantOffsetOptional(aclTensor*)"
    if head not in txt or tail not in txt:
        print("[SKIP] 资料结构已变,找不到 quantScaleOptional 表格行")
        return 2
    cell = txt.split(head, 1)[1].split(tail, 1)[0]
    cell = re.sub(r"<[^>]+>", "", cell)
    sents = [s.strip() for s in re.split(r"[。;\n]", cell) if "static" in s]
    if not sents:
        print("[SKIP] 该单元格没有 static 分支说明")
        return 2
    bad = [s for s in sents if "groupNum" not in s]
    if bad:
        print("[DEFECT] static 分支的形状句未覆盖 groupIndex 场景:%s" % bad[0][:160])
        return 1
    print("[OK] static 分支已覆盖 groupNum")
    return 0


sys.exit(main())

实测运行输出:

[DEFECT] static 分支的形状句未覆盖 groupIndex 场景:当quantModeOptional为static时,shape为1维,值为1,shape表示为shape[1]

上表 5 组实测对应的 C 直调参数(x=INT32[8,128]、weightScale=[2,128]、activationScale=[8]、groupIndex=[4,4]、y=INT8[8,64]、scaleOut=[8]、quantMode="static"、dstType=2、roundMode="rint"、activateDim=-1、swigluMode=0、clampLimit=7.0、gluAlpha=1.702、gluBias=1.0),逐组只改 quantScale/quantOffset 形状。

影响

静态量化 + MoE 分组(groupIndexOptional 非空)是按资料写代码的必然路径,这一组合的形状没有声明,调用方只能靠试错;失败码 561002 只说「参数非法」,不指向具体张量。本轮 1000 条用例的构造阶段因此失败 173 条(17%),按 [groupNum,H] 修正后降到 46 条(剩余为另一条 dtype 组合问题)。

建议

在 quantScaleOptional 的形状说明补一行,按「quantMode × groupIndex」给形状:

quantMode groupIndexOptional quantScale / quantOffset 形状
static 空 [1]
static 非空 [groupNum, H]
dynamic 空 [H]
dynamic 非空 [groupNum, H]

并在 quantOffsetOptional 行保留「形状同 quantScale」。

likedislike
liuhanwen8liuhanwen8
24 days ago Added label: documentation
yuning_chen
yuning_chenCollaborators
24 days ago Comments:

初步分析

感谢反馈。

现象理解:
资料未声明 static+groupIndex 非空时 quantScale/Offset 形状;按字面 [1] 被拒 561002。

当前判断:初步判断,待复现确认。
偏文档缺口。实现有形状要求但资料未写清该组合。

涉及范围:
docs/aclnnDequantSwigluQuantV2 quantScale/Offset 使用说明。

下一步:
补 static+group 下正确 shape(如 [groupNum,H])说明。

likedislike
yuning_chenyuning_chenCollaborators
24 days ago Assign east_yang as responsible person
yuning_chen
yuning_chenCollaborators
24 days ago Comments:

您好,该问题已收到,当前问题 @east_yang 正在处理中

likedislike
east_yang
east_yangCollaborators
19 days ago Comments:

/unassign @east_yang

likedislike
CANN-robotCANN-robotCollaborators
19 days ago Removed responsible person east_yang
east_yang
east_yangCollaborators
19 days ago Comments:
likedislike
CANN-robotCANN-robotCollaborators
19 days ago Assign fengying555682 as responsible person
east_yang
east_yangCollaborators
19 days ago Comments:

/assign @guijianwei

likedislike
CANN-robot
CANN-robotCollaborators
19 days ago Comments:

Notice

This issue can not be assigned to guijianwei. Please try to assign to the repository members.

likedislike
fengying555682fengying555682Collaborators
18 days ago Assign guijianwei as responsible person
fengying555682fengying555682Collaborators
18 days ago Removed responsible person fengying555682
guijianwei
guijianweiCollaborators
18 days ago Comments:

/assign @jzj007

likedislike
CANN-robot
CANN-robotCollaborators
18 days ago Comments:

Notice

This issue can not be assigned to jzj007. Please try to assign to the repository members.

likedislike
guijianweiguijianweiCollaborators
18 days ago Assign jzj007 as responsible person
guijianweiguijianweiCollaborators
18 days ago Removed responsible person guijianwei
jzj007jzj007Collaborators
17 days ago Associated pull request
CANN-robotCANN-robotCollaborators
16 days ago Close issue
CANN-robotCANN-robotCollaborators
16 days ago Added label: resolved