Thanks for sending an requirement! Please fill in the following template to help quickly solve your problem.
Ascend 950 上的 Sort 算子在非末轴小轴场景中可通过 no-transpose 路径避免前后转置,但现有 two-stage 路径主要按相邻 inner 位置分批。当 innerSize 较小、outerSize 较大或 batch 分布不均时,单批规模和活跃核数不足,无法充分利用多核;非连续 GM 数据的逐段搬运及 int64 索引 UB 占用也会限制 batch 大小。部分极端 shape 下,no-transpose 路径的 gather/scatter 固定开销还可能高于成熟的 transpose 路径。
本需求面向有收益的非末轴小轴 shape,新增与末轴 Sort、KthValue 隔离的专项 two-stage 调度,并完善 host 侧批处理、UB 规划和 aclnn 路由收益判断。
[outer, axis, inner]
本次优化不改变 Sort 的接口与既有 dtype 范围。Ascend 950 kernel 路径沿用现有支持类型:int8、int16、int32、int64、uint8、uint16、uint32、uint64、float16、float32、bfloat16;输出索引沿用 int32/int64 配置。aclnnSort 的 bool 输入继续使用既有 uint8 转换路径。
innerSize == 1
batchSize = outerSlicesPerBatch * innerSize
keyParams4
innerLoopNum
SortGroupedOuterSmallAxisTwoStage
[segment, axis]
[axis, inner]
Ascend 950PR / Ascend 950DT。
[2, 2048]
💡 备注(选填)
补充 Sort host tiling UT 覆盖 strided two-stage、innerSize == 1 连续布局、完整 outer slice 分组、紧凑索引和 FP32 wide-inner-tile,并补充 KthValue 回归用例验证其原有 two-stage 路由不受影响。
Thanks for sending an requirement! Please fill in the following template to help quickly solve your problem.
一、背景信息 (必填)
Ascend 950 上的 Sort 算子在非末轴小轴场景中可通过 no-transpose 路径避免前后转置,但现有 two-stage 路径主要按相邻 inner 位置分批。当 innerSize 较小、outerSize 较大或 batch 分布不均时,单批规模和活跃核数不足,无法充分利用多核;非连续 GM 数据的逐段搬运及 int64 索引 UB 占用也会限制 batch 大小。部分极端 shape 下,no-transpose 路径的 gather/scatter 固定开销还可能高于成熟的 transpose 路径。
本需求面向有收益的非末轴小轴 shape,新增与末轴 Sort、KthValue 隔离的专项 two-stage 调度,并完善 host 侧批处理、UB 规划和 aclnn 路由收益判断。
二、价值/作用 (必填)
[outer, axis, inner]布局,减少前后转置带来的额外 GM 搬运。三、设计方案 (必填)
3.1 使能方式(涉及哪些框架:如Aclnn直调、Pytorch训练等)
3.2 总体设计
3.2.1 算子支持的数据类型
本次优化不改变 Sort 的接口与既有 dtype 范围。Ascend 950 kernel 路径沿用现有支持类型:int8、int16、int32、int64、uint8、uint16、uint32、uint64、float16、float32、bfloat16;输出索引沿用 int32/int64 配置。aclnnSort 的 bool 输入继续使用既有 uint8 转换路径。
3.2.2 host侧设计
innerSize == 1场景继续使用 schId 6;KthValue 继续使用原有批处理策略,避免新策略改变既有二进制行为。batchSize = outerSlicesPerBatch * innerSize,通过keyParams4下发每批 outer slice 数,并将innerLoopNum设为 1。3.2.3 kernel侧设计
SortGroupedOuterSmallAxisTwoStage,复用既有 two-stage 排序基类,只隔离非末轴 GM 映射和批处理。[outer, axis, inner]聚集为 UB[segment, axis]:inner 行满足 block 对齐时使用三维 NDDMA,否则使用 SIMT gather。[axis, inner]到密集 UB 的搬运。3.3 支持硬件
Ascend 950PR / Ascend 950DT。
3.4 算子约束限制
[2, 2048];收益判断不满足时回退前后 transpose。💡 备注(选填)
补充 Sort host tiling UT 覆盖 strided two-stage、
innerSize == 1连续布局、完整 outer slice 分组、紧凑索引和 FP32 wide-inner-tile,并补充 KthValue 回归用例验证其原有 two-stage 路由不受影响。