已关闭
[Bug-Report|缺陷反馈]: QuantMatmulActivationQuant golden 边界不一致及 SiLU 拼接对比缺失 #7359
ddssz创建于 6 天前关闭于 5 天前
6 天前 添加了label:bug-report
6 天前 关联了pull request:fix(quant_matmul_activation_quant): 对齐 golden 并支持 NPU 拼接对比
6 天前 修改了issue 的描述
6 天前 将 smdbha 设为负责人
5 天前 关闭了 issue
5 天前 添加了label:resolved
Describe the current behavior / 问题描述 (Mandatory / 必填)
QuantMatmulActivationQuant 的 CPU golden 对 OCP 极小值的处理与 sharedExp 为零时清零的规则不一致:FP8/FP4 的部分极小正规数仍会产生非零量化结果。GELU tanh 的常量和运算顺序也需要对齐现有实现。
此外,测试 spec 缺少 SiLU 的 NPU 小算子拼接标杆,无法直接通过 Kernel、ACLNN、E2E 比较融合实现与 QBMM + SiLU + DynamicMxQuant 的精度和性能。
Environment Information / 环境信息 (Mandatory / 必填)
Steps to reproduce the issue / 重现步骤 (Mandatory / 必填)
在修复前版本的 ops-nn 根目录运行:
import runpy import numpy as np spec = runpy.run_path("matmul/quant_matmul_activation_quant/tests/assets/spec.py") for dtype, exponent in ( ("float8_e4m3fn", -120), ("float8_e5m2", -120), ("float4_e2m1", -126), ): values = np.full((1, 32), 2.0 ** exponent, dtype=np.float32) y, scale = spec["quantize_mx"](values, dtype, scale_alg=0) print(dtype, np.unique(y), np.unique(scale))上述输入的 scale 编码均为零,旧 golden 仍输出非零量化数据。
Describe the expected behavior / 预期结果 (Mandatory / 必填)
OCP 在 sharedExp 为零时输出零量化数据,保留 E8M0 的零编码;FP8 BLAS 行为保持一致。补充 CSV 边界回归,并为 SiLU MXFP8 提供 NPU 拼接精度和性能标杆,默认 CPU golden 用法保持可用。
Related log / screenshot / 日志 / 截图 (Mandatory / 必填)
已完成修复前后的 CPU 定向对比:三种 dtype 的上述 OCP 用例均从非零输出修正为零;两种 FP8 的 BLAS 输出保持一致。Python 语法、差异格式及提交钩子检查通过,设备验证尚未执行。
Special notes for this issue/备注 (Optional / 选填)
SiLU 标杆保留激活后的 BF16 Cast,以匹配融合实现的舍入位置。WeightNZ NPU 标杆需要保留完整物理存储的 ops-test-kit 版本。
关联 PR:https://gitcode.com/cann/ops-nn/merge_requests/12747