Merged
GMM支持a8w4支持新的数据类型: support float4 e1m2 for mx a8w4 #8748
zhangzhizhuoAdd on Jul 15
GMM支持a8w4支持新的数据类型: support float4 e1m2 for mx a8w4 #8748
Merged
Merged fromzhangzhizhuo/ops-transformera8w4intocann/ops-transformermaster
Pull Request has been successfully merged by CANN-robot.
(Thank you for zhangzhizhuo's contribution.)Jul 15 Created pull request, commit 4f59ec9a
atomgit-bot
Jul 15 Comments:
Jul 15 Comments:
变更摘要
本PR主要扩展了GMM(Grouped MatMul)在MX A8W4场景下的权重数据类型支持,新增 float4_e1m2(FP4 E1M2)格式。改动覆盖了API校验、infershape检查、tiling策略和内核计算等环节,使 FP4_E1M2 与已有的 FP4_E2M1 遵循相同的NZ格式对齐约束、tiling配置和代码路径,仅在kernel层面通过编译期常量分派不同的移位量和掩码进行比特级解码。
主要改动
- API层权重对齐与校验扩展:在
aclnn_grouped_matmul.cpp的TransWeightToNzCheckAlign和CheckWeightQuantGMMWeightNz中,将DT_FLOAT4_E2M1的所有判断条件同步扩展为也支持DT_FLOAT4_E1M2,使新类型复用相同的4-bit对齐逻辑和Fp8_e4m3fn-Fp4_e1m2-BF16/Fp16组合校验。 - Checker与Infershape中的类型识别:在
IsMxA8W4NZ()及相关形状/参数校验函数中,新增对DT_FLOAT4_E1M2的判断分支,确保该类型在权重量化场景下同样满足32B对齐、antiquantScale和perTokenScale约束。 - Tiling策略复用:在
GroupedWeightQuantBatchMatmulTiling的SetMatMulTiling、SetTilingKey、IsMxA8W4和CheckUnsupportedRemainingCases中,将weightDtype_ == DT_FLOAT4_E1M2纳入MxA8W4分支,使其复用E2M1的mxTypePara配置、MTE模板和NZ格式约束。 - Kernel层比特解码适配:在
basic_block_vf_mx.h中新增E1M2_SHIFT_RIGHT_SIZE = 0x3和E1M2_AND_MASK = 0x8E常量,并在AntiQuantMxA8W4NzNkVf函数中通过IsSameType编译期判断选择对应的移位量与掩码,实现E1M2格式的比特级解包。 - 宏与编译条件更新:在
grouped_matmul_utils.h的V310_GMM_ANTI_QUANT宏中增加ORIG_DTYPE_WEIGHT == DT_FLOAT4_E1M2条件,确保新类型正确启用反量化宏。


Incorrect?
Jul 15 Added label: cann-cla/yes
CANN-robot
Jul 15 Comments:
Jul 15 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 |
|---|---|---|
| */*/docs/acl*.md | ✅ 陈娇, 吴瑶, 蒋礼锐 (3/2) | ✅ 陈娇 (1/1) |
| */*/op_host/*_def.cpp | ✅ 汤磊, 蒋礼锐 (2/2) | ✅ 汤磊 (1/1) |
| gmm | ✅ kknan, 陈康, 蒋礼锐 (3/2) | ✅ kknan (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
zhangzhizhuo, thanks for your pull request. All authors of the commits have signed the CLA. 👍


Jul 15 Set chenkang30,juyangokok,monologue815,chaotang233,wuyi_huawei,chen-linxin4,jiang-lirui,Allan_Yu,gitee-duhuiping,claire8090,liudan12,shi-rui,gitcode-chenjiao,cc-z,kknan,Ww7012,zhouwenfang,wenxin_fight,mabing1118,wuyao51511,caiwenwen as approver
Jul 15 Set chenkang30,juyangokok,monologue815,chaotang233,wuyi_huawei,chen-linxin4,jiang-lirui,Allan_Yu,gitee-duhuiping,claire8090,liudan12,shi-rui,gitcode-chenjiao,cc-z,kknan,Ww7012,zhouwenfang,wenxin_fight,mabing1118,wuyao51511,caiwenwen as approver
95 messages are collapsed here。 See more
chen-kang30
Jul 31 Comments:
Jul 31 Comments:
/lgtm


jiang-lirui
Jul 31 Comments:
Jul 31 Comments:
/lgtm


Jul 31 Added label: lgtm
Jul 31 Closed associated issue
Jul 31 Merged pull request
描述
GroupedMatmul WeightNz MX量化A8W4场景原支持
FLOAT4_E2M1权重,本PR新增对FLOAT4_E1M2权重类型的支持。主要修改如下:
FLOAT8_E4M3FN × FLOAT4_E1M2。关联的Issue
关联Issue:https://gitcode.com/cann/ops-transformer/issues/3948
https://gitcode.com/cann/ops-transformer/issues/3176
测试
已补充以下测试:二级冒烟
测试结果:新增用例及存量回归用例通过。
文档更新
更新
aclnnGroupedMatmulWeightNz.md:FLOAT4_E1M2支持类型。类型标签