Fix review issues #17-#22: 恢复 #11/#12/#14 (StreamK fixpipe 单次计账/K=1 AIV单缓冲/advice) + 占位方案不可评估 + 转置 dValue 判据三处同源(form c 双缓冲适配修复) + 恢复 #13/#15 回归测试 + 清理临时 csv/.gitignore + 文档同步

This commit is contained in:
2026-09-03 21:10:05 +08:00
parent f5a0b6fe81
commit 9afe6eec02
22 changed files with 219 additions and 76 deletions

View File

@@ -1,11 +1,11 @@
case_id,branch,npu,op,used_core_num,split_b,m_cnt,n_cnt,grid_k,core_map,b_core,merge_b0,single_core_m,single_core_n,single_core_k,k_l1,b_l1,l1_form,base_m,base_n,base_k,l2_policy_in,l2_policy_out,swizzle_w,workspace_bytes,tail_strategy,tail_m_cnt,tail_n_cnt,tail_k_cnt,tail_m_main,tail_n_main,tail_block_cnt,tail_wave_num,fixpipe_unitflag,out_dtype_bytes,note
to_matmul_demo,转Matmul,Ascend950PR,batch_mat_mul_v3,32,1,0,0,1,"折叠为 Matmul [2048,2048]x[2048,2048], 复用 Matmul 切分体系",0,1,0,0,2048,0,1,,0,0,0,,,0,0,转Matmul后由 Matmul 体系决定,1,1,1,0,0,0,0,True,2,"BatchB=1免费折叠: 左矩阵 [1,2048,2048] 视图折叠为 [2048,2048], 零重排零 split"
special_k0_demo,特殊分支,Ascend950PR,batch_mat_mul_v3,64,1,1,1,1,AIV 核间按行均分 (无 Cube tile 概念),0,1,0,0,0,0,1,UB驻留(AIV),0,0,0,allocate,direct_gm,0,0,不涉及(AIV逐元素),1,1,1,0,0,0,0,False,2,"K=0纯写值: 无任何计算, C=bias 或 0, 纯 AIV 写值; 按行均分到 AIV 核"
special_k1_demo,特殊分支,Ascend950PR,batch_mat_mul_v3,64,1,1,1,1,AIV 核间按行均分 (无 Cube tile 概念),0,1,0,0,1,0,1,UB驻留(AIV),0,0,0,allocate,direct_gm,0,0,不涉及(AIV逐元素),1,1,1,0,0,0,0,False,2,"K=1逐元素乘: 退化为 C=A⊙B 无累加深度, Cube 16x16x16 粒度浪费 15/16; 走 AIV 通路 GM->UB->Mul->GM, UB 乒乓"
special_k1_demo,特殊分支,Ascend950PR,batch_mat_mul_v3,64,1,1,1,1,AIV 核间按行均分 (无 Cube tile 概念),0,1,0,0,1,0,1,UB驻留(AIV) UB乒乓,0,0,0,allocate,direct_gm,0,0,不涉及(AIV逐元素),1,1,1,0,0,0,0,False,2,"K=1逐元素乘: 退化为 C=A⊙B 无累加深度, Cube 16x16x16 粒度浪费 15/16; 走 AIV 通路 GM->UB->Mul->GM, UB乒乓 (B>=2*AIV 双batch乒乓流水)"
merge_demo_k_trunc,MergeBatch,Ascend950PR,batch_mat_mul_v3,32,32,1,1,1,切B均分(核间零重复读零依赖),64,4,128,128,256,256,8,合并驻留,128,128,128,allocate(GM->L1随路驻留L2),direct_gm,0,0,不涉及(核内不切M/N),1,1,1,0,0,0,0,True,2,"b0=4 (L0C上限5.7/算存比上限19.0/b_core=64); K截断; 合并后单次DMA搬入 A'[128,256]+B'[256,128]"
merge_iter_arbitrate,IterBatch,Ascend950PR,batch_mat_mul_v3,32,32,1,1,1,切B轮转分配(核间零重复读零依赖),4,1,64,64,512,512,2,b_双batch乒乓,64,64,256,allocate(GM->L1随路驻留L2),"direct_gm(输出仅写一次,直写GM不占L2)",0,0,不涉及(核内不切M/N),1,1,1,0,0,0,0,True,2,双batch乒乓: 2*(MK+KN)*dtype=256KB <= L1
iter_demo_form_b,IterBatch,Ascend950PR,batch_mat_mul_v3,32,32,1,1,1,切B轮转分配(核间零重复读零依赖),4,1,64,64,256,256,2,b_双batch乒乓,64,64,256,allocate(GM->L1随路驻留L2),"direct_gm(输出仅写一次,直写GM不占L2)",0,0,不涉及(核内不切M/N),1,1,1,0,0,0,0,True,2,双batch乒乓: 2*(MK+KN)*dtype=128KB <= L1
iter_demo_form_d,IterBatch,Ascend950PR,batch_mat_mul_v3,32,32,1,1,1,切B轮转分配(核间零重复读零依赖),2,1,64,64,8192,1024,1,d_两侧都切K,64,64,256,allocate(GM->L1随路驻留L2),"direct_gm(输出仅写一次,直写GM不占L2)",0,0,不涉及(核内不切M/N),1,1,1,0,0,0,0,True,2,"两侧都切K: k_L1=1024, K段成对流水, batch边界天然无缝"
iter_demo_form_d,IterBatch,Ascend950PR,batch_mat_mul_v3,32,32,1,1,1,切B轮转分配(核间零重复读零依赖),2,1,64,64,8192,1024,1,d_两侧都切K,64,64,256,allocate(GM->L1随路驻留L2),"direct_gm(输出仅写一次,直写GM不占L2)",0,0,不涉及(核内不切M/N),1,1,1,0,0,0,0,True,2,"两侧都切K: k_L1=1024, K段成对流水, batch边界天然无缝; dValueA=2048B/dValueB=128B"
streamk_demo,StreamK,Ascend950PR,batch_mat_mul_v3,32,1,1,1,32,"B/M/N切出4块, 每块32核切K归约 (归约组内核c负责K段[c*K/32,(c+1)*K/32))",1,1,128,128,320,256,1,K段标准分块流水,128,128,64,allocate(部分和驻留L2),"resident(部分和4B驻留L2, 防精度丢失不随C的fp16/fp8转换)",0,8388608,grid_K=32路切K+归约,1,1,32,0,0,0,0,True,4,"P=1.00, grid_K=32, 部分和驻留L2按4B写出, AIV归约后按C dtype=2B写最终"
asw_demo_full,ASW_Basic,Ascend950PR,batch_mat_mul_v3,32,1,47,47,1,B->M->N线性映射+ASW滑窗蛇形(W=4),0,1,176,176,1024,256,1,双缓冲驻留当前tile输入,176,176,80,allocate(输入驻留L2吸收重复读),direct_gm(输出直写GM不占L2),4,0,方案B,52,52,1,52,52,2,139,True,2,"L2场景B_输入驻留输出直写GM, r_in=1.00; 尾轮: 周长型主导, rho=0.06<rho_dv=0.53, A1b被dValue卡死, 方案B反超"
asw_demo_reduce_core,ASW_Basic_降核,Ascend950PR,batch_mat_mul_v3,16,1,1,1,1,"降核: 只用16核, 每核一个L0C满载输出块, 其余核闲置",0,1,256,256,128,128,1,标准核内流水,256,256,64,allocate,direct_gm,0,0,不涉及(每核一块无尾轮),1,1,1,0,0,0,0,True,2,"P=16.00<C, 降核是理性选择 (强切则 tile 跌破搬移效率下限反而更慢)"
1 case_id branch npu op used_core_num split_b m_cnt n_cnt grid_k core_map b_core merge_b0 single_core_m single_core_n single_core_k k_l1 b_l1 l1_form base_m base_n base_k l2_policy_in l2_policy_out swizzle_w workspace_bytes tail_strategy tail_m_cnt tail_n_cnt tail_k_cnt tail_m_main tail_n_main tail_block_cnt tail_wave_num fixpipe_unitflag out_dtype_bytes note
2 to_matmul_demo 转Matmul Ascend950PR batch_mat_mul_v3 32 1 0 0 1 折叠为 Matmul [2048,2048]x[2048,2048], 复用 Matmul 切分体系 0 1 0 0 2048 0 1 0 0 0 0 0 转Matmul后由 Matmul 体系决定 1 1 1 0 0 0 0 True 2 BatchB=1免费折叠: 左矩阵 [1,2048,2048] 视图折叠为 [2048,2048], 零重排零 split
3 special_k0_demo 特殊分支 Ascend950PR batch_mat_mul_v3 64 1 1 1 1 AIV 核间按行均分 (无 Cube tile 概念) 0 1 0 0 0 0 1 UB驻留(AIV) 0 0 0 allocate direct_gm 0 0 不涉及(AIV逐元素) 1 1 1 0 0 0 0 False 2 K=0纯写值: 无任何计算, C=bias 或 0, 纯 AIV 写值; 按行均分到 AIV 核
4 special_k1_demo 特殊分支 Ascend950PR batch_mat_mul_v3 64 1 1 1 1 AIV 核间按行均分 (无 Cube tile 概念) 0 1 0 0 1 0 1 UB驻留(AIV) UB驻留(AIV) UB乒乓 0 0 0 allocate direct_gm 0 0 不涉及(AIV逐元素) 1 1 1 0 0 0 0 False 2 K=1逐元素乘: 退化为 C=A⊙B 无累加深度, Cube 16x16x16 粒度浪费 15/16; 走 AIV 通路 GM->UB->Mul->GM, UB 乒乓 K=1逐元素乘: 退化为 C=A⊙B 无累加深度, Cube 16x16x16 粒度浪费 15/16; 走 AIV 通路 GM->UB->Mul->GM, UB乒乓 (B>=2*AIV 双batch乒乓流水)
5 merge_demo_k_trunc MergeBatch Ascend950PR batch_mat_mul_v3 32 32 1 1 1 切B均分(核间零重复读零依赖) 64 4 128 128 256 256 8 合并驻留 128 128 128 allocate(GM->L1随路驻留L2) direct_gm 0 0 不涉及(核内不切M/N) 1 1 1 0 0 0 0 True 2 b0=4 (L0C上限5.7/算存比上限19.0/b_core=64); K截断; 合并后单次DMA搬入 A'[128,256]+B'[256,128]
6 merge_iter_arbitrate IterBatch Ascend950PR batch_mat_mul_v3 32 32 1 1 1 切B轮转分配(核间零重复读零依赖) 4 1 64 64 512 512 2 b_双batch乒乓 64 64 256 allocate(GM->L1随路驻留L2) direct_gm(输出仅写一次,直写GM不占L2) 0 0 不涉及(核内不切M/N) 1 1 1 0 0 0 0 True 2 双batch乒乓: 2*(MK+KN)*dtype=256KB <= L1
7 iter_demo_form_b IterBatch Ascend950PR batch_mat_mul_v3 32 32 1 1 1 切B轮转分配(核间零重复读零依赖) 4 1 64 64 256 256 2 b_双batch乒乓 64 64 256 allocate(GM->L1随路驻留L2) direct_gm(输出仅写一次,直写GM不占L2) 0 0 不涉及(核内不切M/N) 1 1 1 0 0 0 0 True 2 双batch乒乓: 2*(MK+KN)*dtype=128KB <= L1
8 iter_demo_form_d IterBatch Ascend950PR batch_mat_mul_v3 32 32 1 1 1 切B轮转分配(核间零重复读零依赖) 2 1 64 64 8192 1024 1 d_两侧都切K 64 64 256 allocate(GM->L1随路驻留L2) direct_gm(输出仅写一次,直写GM不占L2) 0 0 不涉及(核内不切M/N) 1 1 1 0 0 0 0 True 2 两侧都切K: k_L1=1024, K段成对流水, batch边界天然无缝 两侧都切K: k_L1=1024, K段成对流水, batch边界天然无缝; dValueA=2048B/dValueB=128B
9 streamk_demo StreamK Ascend950PR batch_mat_mul_v3 32 1 1 1 32 B/M/N切出4块, 每块32核切K归约 (归约组内核c负责K段[c*K/32,(c+1)*K/32)) 1 1 128 128 320 256 1 K段标准分块流水 128 128 64 allocate(部分和驻留L2) resident(部分和4B驻留L2, 防精度丢失不随C的fp16/fp8转换) 0 8388608 grid_K=32路切K+归约 1 1 32 0 0 0 0 True 4 P=1.00, grid_K=32, 部分和驻留L2按4B写出, AIV归约后按C dtype=2B写最终
10 asw_demo_full ASW_Basic Ascend950PR batch_mat_mul_v3 32 1 47 47 1 B->M->N线性映射+ASW滑窗蛇形(W=4) 0 1 176 176 1024 256 1 双缓冲驻留当前tile输入 176 176 80 allocate(输入驻留L2吸收重复读) direct_gm(输出直写GM不占L2) 4 0 方案B 52 52 1 52 52 2 139 True 2 L2场景B_输入驻留输出直写GM, r_in=1.00; 尾轮: 周长型主导, rho=0.06<rho_dv=0.53, A1b被dValue卡死, 方案B反超
11 asw_demo_reduce_core ASW_Basic_降核 Ascend950PR batch_mat_mul_v3 16 1 1 1 1 降核: 只用16核, 每核一个L0C满载输出块, 其余核闲置 0 1 256 256 128 128 1 标准核内流水 256 256 64 allocate direct_gm 0 0 不涉及(每核一块无尾轮) 1 1 1 0 0 0 0 True 2 P=16.00<C, 降核是理性选择 (强切则 tile 跌破搬移效率下限反而更慢)