Merged
Restore ND MXFP4 error message rectification #8787
Restore ND MXFP4 error message rectification #8787
Merged
jayshuAdd on Jul 16
jayshu
jayshuCollaborators
Jul 16

描述

调整 grouped_matmul_swiglu_quant_v2 中 MXFP4 场景的 dtype 校验逻辑,使其按 weight format 区分 ND 和 NZ 的支持范围。

主要改动:

  • 拆分 MXFP4 的 x / weight / output dtype 支持列表:
    • ND:仅支持 FLOAT4_E2M1
    • NZ:支持 FLOAT4_E2M1、FLOAT4_E1M2
  • CheckFp4DtypeValid 按 weight storage format 选择对应 dtype 支持列表。
  • CheckDtypeValid 前置校验同步按 ND/NZ 区分 MXFP4 dtype 支持范围。
  • 保留并整改 ND + DT_FLOAT4_E1M2 场景的 error message,使用 OP_LOGE_FOR_INVALID_DTYPES_WITH_REASON 标准错误日志宏。
  • 补充 op_api CSV 用例覆盖 NZ E1M2 有效场景和 ND output E1M2 非法场景。

关联的Issue

https://gitcode.com/cann/ops-transformer/issues/3790

测试

二级冒烟+异常用例验证

文档更新

无

类型标签

  • [] 🧪 测试
likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for jayshu's contribution.)
jayshujayshuCollaborators
Jul 16 Created pull request, commit f27d4180
atomgit-bot
atomgit-bot
Jul 16 Comments:

变更摘要

此 PR 主要修复了 ND 格式下 MXFP4 数据类型校验的错误消息问题。通过将原先统一的 MXFP4 支持列表按 weight 的存储格式(ND 与 NZ)拆分为两组常量,并新增辅助函数在运行时根据格式动态选择正确的支持列表,使得 ND 格式下不再接受 DT_FLOAT4_E1M2 类型,同时改进了相关错误消息的准确性和可读性。

主要改动

  • 拆分 MXFP4 数据类型支持列表:将 X_DTYPE_SUPPORT_LIST_MXFP4、WEIGHT_DTYPE_SUPPORT_LIST_MXFP4 和 QUANTOUT_DTYPE_SUPPORT_LIST_MXFP4 分别拆分为 _ND(仅含 DT_FLOAT4_E2M1)和 _NZ(含 DT_FLOAT4_E2M1 和 DT_FLOAT4_E1M2)两个常量,以区分不同存储格式下的类型支持范围。
  • 新增运行时格式判断辅助函数:添加 GetXSupportListMxfp4、GetWeightSupportListMxfp4、GetOutputSupportListMxfp4,根据 weight 的 StorageFormat 是否为私有格式(NZ)来返回对应的支持列表;同时新增 IsMxfp4Dtype 用于判断数据类型是否为 MXFP4 类型。
  • 更新 MXFP4 场景识别逻辑:在 GetGroupedMatmulSwigluQuantV2ScenarioName 中使用 IsMxfp4Dtype 替代原来仅检查 DT_FLOAT4_E2M1 的硬编码判断,使场景识别覆盖所有 MXFP4 类型。
  • 改进 ND 格式不支持 DT_FLOAT4_E1M2 的错误消息:将原来的 OP_LOGE 简单日志替换为 OP_LOGE_FOR_INVALID_DTYPES_WITH_REASON,明确列出 weight、x 和 output 的实际类型,并给出 "ND 格式下三者均不能为 DT_FLOAT4_E1M2" 的详细原因。
  • 根据格式动态生成错误消息中的支持类型列表:引入 dtypeSupportList 变量,在 NZ 格式下提示包含 FLOAT4_E1M2 的完整列表,在 ND 格式下则只提示到 FLOAT4_E2M1,使 x/weight 类型不匹配时的错误提示与实际约束一致。
likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Jul 16 Added label: stat/needs-squash
CANN-robotCANN-robotCollaborators
Jul 16 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Jul 16 Comments:

Thanks for your pull-request.
The full list of commands accepted by me can be found at here。
You can get sig-info at here


PR Approval Progress

✅ Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
gmm ✅ 马兵, kknan (2/2) ✅ 马兵 (1/1)
tests ✅ 马兵, gaoxiang618 (2/2) ✅ 马兵, gaoxiang618 (2/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

jayshu, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
51 messages are collapsed here。 See more
CANN-robotCANN-robotCollaborators
Jul 16 Added label: approved
gaoxiang618
gaoxiang618Collaborators
Jul 17 Comments:

/lgtm
/approve

likedislike
kknan
kknanCollaborators
Jul 17 Comments:

/lgtm

likedislike
CANN-robotCANN-robotCollaborators
Jul 17 Added label: lgtm
CANN-robotCANN-robotCollaborators
Jul 17 Merged pull request