Closed
[Bug-Report|缺陷反馈] DynamicQuant large-shape copy length overflow #8907
chuboningAdd on 5 days agoClosed at 4 days ago
5 days ago Change title to "[Ascend960] DynamicQuant large-shape copy length overflow", originally titled "[Ascend960] DynamicQuant large-shape 输入拷贝长度溢出导致结果错误".
5 days ago Change title to "[Ascend960] DynamicQuant large-shape copy length overflow", originally titled "[Ascend960] DynamicQuant large-shape 输入拷贝长度溢出导致结果错误".
5 days ago Modify description of issue
5 days ago Associated pull request
5 days ago Modify description of issue
5 days ago Change title to "[Bug-Report|缺陷反馈] DynamicQuant large-shape copy length overflow", originally titled "[Ascend960] DynamicQuant large-shape copy length overflow".
5 days ago Change title to "[Bug-Report|缺陷反馈] DynamicQuant large-shape copy length overflow", originally titled "[Ascend960] DynamicQuant large-shape copy length overflow".
5 days ago Modify description of issue
5 days ago Assign chuboning as responsible person
5 days ago Modify description of issue
yuning_chen
5 days ago Comments:
5 days ago Comments:
收到。DynamicQuant 大 shape 下 copy length 溢出,典型是 uint32/int32 长度字段在高元素数时溢出(numel 超过 2^31 或 4G 边界)。建议:①长度计算统一用 int64,并在 tiling 阶段校验 numel 上限;②补大 shape UT(临界 2^31 元素);③同族 *Quant 算子一并核对长度字段类型。


4 days ago Close issue
4 days ago changed custom state from 待办的 to 已完成
4 days ago Added label: resolved
Describe the current behavior / 问题描述 (Mandatory / 必填)
在 Ascend960DT 环境下,
aclnnDynamicQuant处理 FP16/BF16 输入时,最后一维大于 34816 后会进入 large-shape 路径,输入数据搬入长度发生 16 位截断,导致 per-token scale 计算错误,量化输出也存在错误风险。Ascend950 相同形状下未出现该问题。Environment Information / 环境信息 (Mandatory / 必填)
__NPU_ARCH__ == 9201);对照平台为 Ascend950。Steps to reproduce the issue / 重现步骤 (Mandatory / 必填)
aclnnDynamicQuant,使用 FP16/BF16 输入,将最后一维设置为大于 34816,例如 34817。innerLoopEle可达到 47744。CopyInByEle将elementNum * sizeof(T)写入uint16_t类型的DataCopyParams::blockLen。以 34817 个 FP16/BF16 元素为例,期望拷贝 69634 字节,截断后仅为 4098 字节。Describe the expected behavior / 预期结果 (Mandatory / 必填)
各平台的 large-shape 路径均应完整搬入输入及 smooth 数据,正确计算 scale 和量化输出,避免后续芯片因 UB 或分块增大再次触发同类问题。
Related log / screenshot / 日志 / 截图 (Mandatory / 必填)
NA
Special notes for this issue/备注 (Optional / 选填)
修复方案见 PR #14544:全部五条 large-shape 实现路径不再按芯片类型区分,统一使用
DataCopyExtParams和DataCopyPadExtParams<T>,以 32 位blockLen完成输入及 smooth 拷贝,避免后续芯片继续出现同类问题。关联 PR:https://gitcode.com/cann/ops-nn/merge_requests/14544