已合并
fix: wqbmmv2 uint8承载antiquantScale修正适配float4_e2m1 weight场景 #10133
fix: wqbmmv2 uint8承载antiquantScale修正适配float4_e2m1 weight场景 #10133
已合并
马琦钧创建于 26 天前
马琦钧
马琦钧成员
26 天前

描述

microscaling 场景采用 uint8 承载 float8_e8m0 数据时,aclnn 侧需在 TensorPreProcess 中将 antiquantScale 的 dtype 由 uint8 修正为 float8_e8m0。原修正条件仅覆盖 weight 为 float32 承载 float4_e2m1 的场景(weight 先经 DT_FLOAT -> DT_FLOAT4_E2M1 修正后不再满足 weight == DT_FLOAT);当 weight 直接为 float4_e2m1(如 weight_quant_preprocess MX 转置 ND 直拷后的输出)时修正不生效,antiquantScale 保持 uint8,后续 CheckDtypeValid 白名单(float16/bfloat16/float8_e8m0)校验失败,GetWorkspaceSize 返回 161002。

修改内容:

  • aclnn_weight_quant_batch_matmul_v2.cpp TensorPreProcess:uint8 -> float8_e8m0 修正条件由 weight == DT_FLOAT 扩展为 weight == DT_FLOAT || weight == DT_FLOAT4_E2M1(uint8 与 float8_e8m0 均为 1 字节,仅修正 dtype 不涉及 shape)。
  • 新增 2 个 Ascend950 UT 用例:a16mxf4_nd_weight_fp4_uint8_scale(weight 直接 FP4 + uint8 scale)、a16mxf4_nd_weight_fp32_uint8_scale(float32 承载 FP4 + uint8 scale,回归覆盖原路径)。

关联的Issue

https://gitcode.com/cann/ops-nn/issues/5709

测试

  • UT:Ascend950_WeightQuantBatchMatmulV2 套件 19 个用例全部通过(含新增 2 个)
  • Ascend 950 实机 aclnn 验证(K=256/N=128/gs=32,直调 aclnnWeightQuantBatchMatmulV2):
    • 修改前:FP4 weight + uint8 scale(ND 连续 / 转置视图)均返回 161002
    • 修改后:两场景跑通且与 golden 比对 0 mismatch,e8m0 scale 对照组无回归
  • 端到端联调(配套 https://gitcode.com/cann/ops-math/pull/5241 、https://gitcode.com/Ascend/op-plugin/pull/5803 ):weight_quant_preprocess MX 转置 ND 直拷输出直接衔接 wqbmmv2,torch/aclnn 全链路 golden 比对通过

文档更新

无

类型标签

AI/Agent生成声明

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 马琦钧 的贡献)
马琦钧马琦钧成员
26 天前 创建了 pull request,commit db5d5f93
马琦钧马琦钧成员
26 天前 关联了issue:[Bug-Report|缺陷反馈]: wqbmmv2 uint8承载antiquantScale修正仅覆盖float32承载weight,float4_e2m1 weight场景报161002
atomgit-bot
atomgit-bot
26 天前 评论:

变更摘要

本 PR 修复 aclnnWeightQuantBatchMatmulV2 在 microscaling 场景下 antiquantScale dtype 修正不生效的问题:当 weight 直接为 float4_e2m1(如 weight_quant_preprocess MX 转置 ND 直拷后的输出)时,原 TensorPreProcess 中 uint8 -> float8_e8m0 的修正条件(仅 weight == DT_FLOAT)不再满足,导致 antiquantScale 保持 uint8,CheckDtypeValid 白名单校验失败、GetWorkspaceSize 返回 161002。修改将修正条件扩展为同时覆盖 weight == DT_FLOAT || weight == DT_FLOAT4_E2M1,并新增 2 个 Ascend950 UT 用例覆盖直接 FP4 weight 与 float32 承载 FP4 weight 两种路径。

主要改动

  • 修正条件扩展:在 aclnn_weight_quant_batch_matmul_v2.cpp 的 TensorPreProcess 中,将 uint8 -> DT_FLOAT8_E8M0 的 dtype 修正条件由 weight->GetDataType() == DataType::DT_FLOAT 扩展为 weight->GetDataType() == DataType::DT_FLOAT || weight->GetDataType() == DataType::DT_FLOAT4_E2M1,使 weight 直接为 float4_e2m1 时 antiquantScale 修正也能生效(uint8 与 float8_e8m0 均为 1 字节,仅改 dtype 不影响 shape)。
  • 新增 UT 用例 a16mxf4_nd_weight_fp4_uint8_scale:在 test_aclnn_weight_quant_batch_matmul_v2_api.cpp 的 casesParamsAscend950 中新增用例,weight 直接为 ACL_FLOAT4_E2M1、scale 为 ACL_UINT8,期望结果 ACCLNN_SUCCESS,覆盖修复后的直接 FP4 weight 路径。
  • 新增 UT 用例 a16mxf4_nd_weight_fp32_uint8_scale:新增 float32 承载 FP4(weight N=16 打包、host 侧解包为逻辑 N=128)加 uint8 scale 的用例,回归覆盖原 DT_FLOAT 路径,确保原逻辑无回归。
likedislike
不准确?
atomgit-bot
atomgit-bot
26 天前 评论:

代码审查

✅ 未发现问题

likedislike
不准确?
CANN-robotCANN-robot成员
26 天前 添加了label:cann-cla/yes
此处折叠了49条消息 查看更多
CANN-robotCANN-robot成员
18 天前 添加了label:approved
xubinglin成员
18 天前 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
18 天前 添加了label:lgtm
CANN-robotCANN-robot成员
18 天前 关闭了关联的issue
CANN-robotCANN-robot成员
18 天前 合入了pull request