Closed
[Requirement|需求建议]: Transpose 算子支持 ascend960dt/ascend960pr 平台(含 HIF4/FP4 4bit 数据类型) #3627
zhanw_codingAdd on 25 days agoClosed at 24 days ago
25 days ago Added label: requirement
zhanw_coding
25 days ago Comments:
25 days ago Comments:
/assign


25 days ago Assign zhanw_coding as responsible person
24 days ago Close issue
24 days ago Added label: resolved
一、背景信息 (必填)
Transpose(permute)算子当前仅注册 ascend310p / ascend910_93 / ascend910b / ascend950 / mc62 / ascend350
等芯片,且 x 的数据类型支持列表不包含 4bit(HIF4/FP4)类型。新平台 ascend960dt、ascend960pr 需要接入
Transpose 算子,并在其架构(arch92)下新增对 4bit 数据类型的支持。
二、价值/作用 (必填)
量化场景下转置的数据搬运需求。
三、设计方案 (必填)
3.1 使能方式(涉及哪些框架:如Aclnn直调、Pytorch训练等)
并在 scripts/kernel/binary_config/ascendc_config.json 中登记 compute_units 与编译选项。
3.2 总体设计
3.2.1 算子支持的数据类型
DT_HIFLOAT4 = 42、DT_HIFLOAT4_SCALE = 43;原有基础类型(int8/uint8/int16/uint16/int32/uint32/
int64/uint64/float/float16/bf16/bool/hifloat8/float8_e5m2/float8_e4m3fn 等)保持一致。
(aclnn_permute)/ ARCH92_AICORE_DTYPE_SUPPORT_LIST(transpose),其余架构沿用原列表。
3.2.2 host侧设计
AddConfig("ascend960dt", config92)、AddConfig("ascend960pr", config92)。ascend960pr,compile_options 增加
-mllvm -cce-aicore-dcci-before-kernel-end=false。SplitMode::B4_DOUBLE_SPLIT = 10009;触发条件为 4bit 且尾轴转置。
4bit 非尾轴转置按 int8 view 处理(尾轴折算);4bit 尾轴转置走 B4 模板;校验 4bit 输入/输出尾轴必须为偶数。
BIG_DIM 场景支持超大函数拆分后的缓冲回退(双缓冲不适用时回退单缓冲)。
3.2.3 kernel侧设计
CopyIn(Compact,HIF4 原始字节)→ Cast fp4→bf16 → 在 bf16 域转置 → Cast bf16→fp4 → CopyOut;
UB buffer 采用双缓冲。
4bit 场景下 TENSOR_MOVE/SMALL_SHAPE/CUT_ONE_AXIS/CUT_TWO_AXIS/BIG_DIM/N_LAST/GATHER 等模板按 int8_t 实例化处理。
transdata_5hd_021 / with_gather)在
__DAV_920R1__下使用带额外参数的 DataCopy/DataCopyPad 接口,base.h 新增 NDDMA_BUFFER_NUM(920R1 为 2,其余为 1),并将 UB buffer 按缓冲数切分。
3.3 支持硬件
3.4 算子约束限制
💡 备注(选填)