Closed
[Bug-Report|缺陷反馈]: aclnnDynamicQuantV2 专家数为 0 时返回错误码 561103,与真实参数错误不符且第一段接口未拦截 #6271
liuhanwen8Add on  Sep 28Closed at  Oct 8
liuhanwen8
liuhanwen8
Sep 28 Create

Describe the current behavior / 问题描述 (Mandatory / 必填)

aclnnDynamicQuantV2 传入 smoothScalesOptional 形状 (0, 8)、groupIndexOptional 形状 (0,)(专家数 E=0,x 非空为 (4, 8))时:

  1. 返回码可疑:接口返回 561103(ACLNN_ERR_INNER_NULLPTR,内部空指针错误),而设备侧真实原因是形状非法(EZ0012 Invalid_Argument_Tensor_Shape_Dim)。文档"第一段接口入参校验"表写明 shape 不满足限制应返回 161002(ACLNN_ERR_PARAM_INVALID),与实际返回码不符。
  2. 第一段接口未拦截:aclnnDynamicQuantV2GetWorkspaceSize 未校验该 shape,错误延迟到 tiling/kernel 阶段才抛出(日志中 Kernel GetWorkspace failed),对外表现为 PTA ERR00100 PTA call acl api failed。
  3. 设备侧报错文案也自相矛盾:The shape dim of smooth_scales must be 1,但此处传入的正是 2 维,且文档在有 groupIndexOptional 时要求 smoothScalesOptional 为 2 维 (专家数, x 最后一维)。

Environment Information / 环境信息 (Mandatory / 必填)

  • 昇腾硬件型号:Ascend 910_93(npu-smi 显示 Ascend910,hostname ascend910c-03),单卡
  • CANN 版本:9.2.0
  • Python 版本:3.10;torch 2.7.1+cpu / torch_npu 2.7.1.post5.dev20260613
  • 调用入口:torch_npu.npu_dynamic_quant(内部下发 aclnnDynamicQuantV2),ASCEND_LAUNCH_BLOCKING=1

Steps to reproduce the issue / 重现步骤 (Mandatory / 必填)

import os
os.environ.setdefault("ASCEND_LAUNCH_BLOCKING", "1")
import torch, torch_npu

torch.npu.set_device(0)
x = torch.randn(4, 8, dtype=torch.float16, device="npu")          # 非空,避免空 Tensor 提前返回
smooth = torch.empty(0, 8, dtype=torch.float16, device="npu")     # E = 0
group = torch.empty(0, dtype=torch.int32, device="npu")           # 与 smooth 第 0 维一致
torch_npu.npu_dynamic_quant(x, smooth_scales=smooth, group_index=group)

对照:smooth (1, 8) + group (4,) 可正常返回 y (4, 8) INT8、scale (4,)。

Describe the expected behavior / 预期结果 (Mandatory / 必填)

  • 第一段接口按文档完成入参校验,shape 不满足限制时返回 161002(ACLNN_ERR_PARAM_INVALID);
  • 不应返回 561103(内部空指针)这类与真实原因不符的错误码,错误也不应拖到 tiling 阶段才暴露。
RuntimeError: ... call aclnnDynamicQuantV2 failed, error code is 561103
[ERROR] ERR00100 PTA call acl api failed.
Invalid_Argument_Tensor_Shape_Dim(EZ0012): Parameter smooth_scales of DynamicQuant has incorrect shape dim 2. \
Reason: The shape dim of smooth_scales must be 1.
        smooth shape check failed![FUNC:CheckOpInputShape][FILE:dynamic_quant_tiling.cpp][LINE:223]
        input shape check failed![FUNC:CheckOpShape][FILE:dynamic_quant_tiling.cpp][LINE:306]
        input or output shape is invalid![FUNC:CheckOpParams][FILE:dynamic_quant_tiling.cpp][LINE:417]
        Failed to execute operator aclnnDynamicQuantV2_7_DynamicQuant. Reason: Failed to execute tiling.
        Kernel GetWorkspace failed. opType: 7
        DynamicQuant launch kernel failed.
likedislike
liuhanwen8liuhanwen8
Sep 28 Added label: bug-report
yuning_chen
yuning_chenCollaborators
Sep 29 Comments:

初步分析

感谢反馈,我们已开始核对这个问题。

现象理解:aclnnDynamicQuantV2 在专家数为 0 时返回 561103,文档约定 shape 不合法应返回 161002,且第一段接口没有拦住。
当前判断:初步判断,待复现确认。错误被推迟到 tiling、并报成内部空指针的可能性存在,需按给出的空专家输入复核返回码。
涉及范围:aclnnDynamicQuantV2 对 smoothScalesOptional 与 groupIndexOptional 的 shape 校验。
下一步:我们会按该输入复核第一段返回码,评估是否应在入口返回参数非法。

likedislike
yuning_chen
yuning_chenCollaborators
Sep 29 Comments:

/assign @menhaoTang

likedislike
CANN-robot
CANN-robotCollaborators
Sep 29 Comments:

Notice

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

likedislike
yuning_chenyuning_chenCollaborators
Sep 30 Assign liujie12345678 as responsible person
CANN-robotCANN-robotCollaborators
Oct 8 Close issue
CANN-robotCANN-robotCollaborators
Oct 8 Added label: resolved
CcuijieCollaborators
9 days ago Associated pull request
CcuijieCollaborators
9 days ago Associated pull request