已关闭
[Documentation|文档反馈]: aclnnQuantMatmulV5 参数表 out 支持 FLOAT32,与 A2/A3 约束段矛盾且漏标角标 #6946
liuhanwen8创建于  11 天前关闭于  4 天前
liuhanwen8
liuhanwen8
11 天前 创建

Document Link(文档链接)

https://gitcode.com/cann/ops-nn/blob/master/matmul/quant_batch_matmul_v4/docs/aclnnQuantMatmulV5.md

Issues Section(问题文档片段)

1) 参数表 out 行(L471,数据类型列)

FLOAT16、INT8、BFLOAT16、INT32、FLOAT32

2) A2/A3 段的标注规则(L509–511)

- Atlas A2系列产品、Atlas A3系列产品:
  - 上表数据类型列中的角标“2”代表该系列不支持的数据类型。

3) A2/A3 公共约束(L656)

- out的shape支持2~6维,(batch, m, n),batch可不存在。数据类型支持FLOAT16、INT8、BFLOAT16、INT32。

Existing Issues(存在的问题)

参数表把 FLOAT32 列为 out 的支持类型,且未打"不支持"角标 2;同一文档 A2/A3 公共约束段却明确排除了 FLOAT32。按文档自身体例(该文档其他行会逐 dtype 打角标,如 L344 FLOAT32、FLOAT8_E8M0<sup>2</sup>、L358 ...FLOAT16<sup>2</sup>),读者只能理解为 A2/A3 支持 FP32 输出。

实机验证(Atlas A2 / Ascend910B2,CANN 9.2.0,torch 2.12.0+cpu / torch_npu 2.12.0.post3,算子 aclnnQuantMatmulV5)

x1/x2 = INT8,x2Scale = FLOAT32(per-tensor),M=64/K=128/N=64:

output_dtype 结果
FLOAT16 成功
BFLOAT16 成功
INT32 成功
FLOAT32 161002(ACLNN_ERR_PARAM_INVALID)
npu_quant_matmul:...QuantMatmulKernelNpuOpApi.cpp:318 NPU function error:
call aclnnQuantMatmulV5 failed, error code is 161002  (子码 EZ0020)
import torch, torch_npu
x1 = torch.randint(-128, 127, (64, 128), dtype=torch.int8).npu()
x2 = torch.randint(-128, 127, (128, 64), dtype=torch.int8).npu()
scale = torch.rand(1, dtype=torch.float32).npu()
torch_npu.npu_quant_matmul(x1, x2, scale, output_dtype=torch.float16)  # OK
torch_npu.npu_quant_matmul(x1, x2, scale, output_dtype=torch.float32)  # 161002

影响:调用方按参数表选择 FP32 输出,会被 161002 拒绝,且报错只提示"数据类型不在支持范围",无法从文档判断是设备限制。

建议:若 FP32 输出仅 Ascend 950 系列支持,请在参数表 out 行的 FLOAT32 上补角标 2;若全系列均不支持,则从参数表移除该 dtype。A3 与 A2 表现一致(A3 上同样为 161002)。

likedislike
liuhanwen8liuhanwen8
11 天前 添加了label:documentation
yuning_chenyuning_chen成员
10 天前 将 yolic 设为负责人
yuning_chen
yuning_chen成员
10 天前 评论:

初步分析

感谢反馈。

现象理解:aclnnQuantMatmulV5 参数表把 FLOAT32 列为 out 的支持类型,且没有标成 A2、A3 不支持。同一文档的 A2、A3 约束只写了 FLOAT16、INT8、BFLOAT16、INT32。A2 上 INT8 输入、FLOAT32 输出返回 161002,其余几种输出可以成功。

当前判断:初步判断,待复现确认。需要对照当前文档和 A2、A3 的 dtype 检查。

涉及范围:matmul/quant_batch_matmul_v4 的 aclnnQuantMatmulV5 文档。

下一步:确认 FLOAT32 输出只在 950 支持后,在参数表给它补上 A2、A3 不支持的角标。若全系列都不支持,则从参数表去掉。

likedislike
yuning_chenyuning_chen成员
8 天前 移除了负责人 yolic
yuning_chenyuning_chen成员
8 天前 将 zhengyuhao3 设为负责人
Zzhengyuhao3成员
5 天前 关联了pull request:修复matmul算子Issue问题
CANN-robotCANN-robot成员
4 天前 关闭了 issue
CANN-robotCANN-robot成员
4 天前 添加了label:resolved