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

9
.gitignore vendored
View File

@@ -12,6 +12,15 @@ venv/
*~ *~
*.swp *.swp
# BMM_Theory 调试/复现用临时 csv (issue#21, 防再次误提交; examples/ 下正式样例不受影响)
/BMM/BMM_Theory/bug*.csv
/BMM/BMM_Theory/bug*_out.csv
/BMM/BMM_Theory/bug*_p.csv
/BMM/BMM_Theory/t.csv
/BMM/BMM_Theory/t_*.csv
/BMM/BMM_Theory/t*.csv
/BMM/BMM_Theory/p2.csv
# IDE / OS # IDE / OS
.idea/ .idea/
.vscode/ .vscode/

View File

@@ -43,22 +43,33 @@ class IterBatchBranch(Branch):
return "b", k, f"双batch乒乓: 2*(MK+KN)*dtype={2*single/1024:.0f}KB <= L1" return "b", k, f"双batch乒乓: 2*(MK+KN)*dtype={2*single/1024:.0f}KB <= L1"
# c) 一侧驻留 + 对侧切 K, 预算按 b_core 分档 # c) 一侧驻留 + 对侧切 K, 预算按 b_core 分档
# dValue 守卫与条件 4 / constraints 同源 (issue#19): 转置感知连续维判据
# (dv_a=M*dt 当 A 转置, 否则 k_l1*dt; dv_b=N*dt 当 B 不转置, 否则 k_l1*dt).
from ..models import dvalue_contig_dims
l1_budget = s.l1_bytes / min(b_core, 2) l1_budget = s.l1_bytes / min(b_core, 2)
for resident, side in ((m * k * dt, "A"), (k * n * dt, "B")): for resident, side in ((m * k * dt, "A"), (k * n * dt, "B")):
other = n * dt if side == "A" else m * dt other = n * dt if side == "A" else m * dt
if resident <= l1_budget: if resident <= l1_budget:
k_l1 = min(int((l1_budget - resident) / other / 2), k) k_l1 = min(int((l1_budget - resident) / other / 2), k)
k_l1 = align_down(max(k_l1, s.fractal), s.fractal) k_l1 = align_down(max(k_l1, s.fractal), s.fractal)
if k_l1 >= s.fractal and k_l1 * dt >= s.dvalue_min: dv_a, dv_b = dvalue_contig_dims(case, k_l1)
# 双缓冲适配: 驻留侧 + 对侧 k_l1 段 x2 必须 <= 预算
# (resident 恰占满预算时 k_l1 被抬到 16 会造成超预算的假方案)
if (k_l1 >= s.fractal and
resident + 2 * k_l1 * other <= l1_budget and
dv_a >= s.dvalue_min and dv_b >= s.dvalue_min):
return "c", k_l1, ( return "c", k_l1, (
f"一侧驻留({side})+对侧切K: {side}驻留{resident/1024:.0f}KB, " f"一侧驻留({side})+对侧切K: {side}驻留{resident/1024:.0f}KB, "
f"预算L1/{min(b_core,2)}, k_L1={k_l1}") f"预算L1/{min(b_core,2)}, k_L1={k_l1}, "
f"dValueA={dv_a:.0f}B/dValueB={dv_b:.0f}B")
# b_core>=2 时另一半 L1 预取下一 batch 驻留侧, 边界无气泡 # b_core>=2 时另一半 L1 预取下一 batch 驻留侧, 边界无气泡
# d) 两侧都切 K (兜底) # d) 两侧都切 K (兜底)
k_l1 = align_down(int(s.l1_bytes / (2 * (m + n) * dt)), s.fractal) k_l1 = align_down(int(s.l1_bytes / (2 * (m + n) * dt)), s.fractal)
if k_l1 >= s.fractal and k_l1 * dt >= s.dvalue_min: dv_a, dv_b = dvalue_contig_dims(case, k_l1)
return "d", k_l1, f"两侧都切K: k_L1={k_l1}, K段成对流水, batch边界天然无缝" if (k_l1 >= s.fractal and dv_a >= s.dvalue_min and dv_b >= s.dvalue_min):
return "d", k_l1, (f"两侧都切K: k_L1={k_l1}, K段成对流水, batch边界天然无缝; "
f"dValueA={dv_a:.0f}B/dValueB={dv_b:.0f}B")
return None, 0, "L1 四形态均不满足 (M/N 相对 L1 过大)" return None, 0, "L1 四形态均不满足 (M/N 相对 L1 过大)"
@@ -90,24 +101,18 @@ class IterBatchBranch(Branch):
form is not None, form_desc)) form is not None, form_desc))
# 条件 4: 搬移效率下限 (c/d 切分后) # 条件 4: 搬移效率下限 (c/d 切分后)
# 转置影响 (参考 bmmv3): A 不转置时 K 向连续, dValue 判 K*dt; # dValue 判定按转置调整连续维 (与 l1_form 守卫/constraints 同源, issue#19):
# A 转置 M 向连续, dValue 判 M*dt; # A 不转置: K 向连续 -> k_l1*dt; A 转置: M 向连续 -> M*dt;
# B 转置时 N 向连续, dValue 判 N*dt; # B 不转置: N 向连续 -> N*dt; B 转置: K 向连续 -> k_l1*dt.
# B 转置时 K 向连续, dValue 判 K*dt. from ..models import dvalue_contig_dims
m, n, k = case.m, case.n, case.k m, n, k = case.m, case.n, case.k
dt = case.dtype_in_bytes dt = case.dtype_in_bytes
if form in ("c", "d"): if form in ("c", "d"):
tile_ok = (k_l1 * m * dt >= s.min_tile_size) or (k_l1 * n * dt >= s.min_tile_size) tile_ok = (k_l1 * m * dt >= s.min_tile_size) or (k_l1 * n * dt >= s.min_tile_size)
# dValue 判定按转置调整连续维 dv_a, dv_b = dvalue_contig_dims(case, k_l1)
if case.trans_a: # 切 K 时 A/B 两侧分段各自搬移, 两侧连续维 dValue 均须 >= 下限 (与生成守卫/约束同源,
dv_a = m * dt # A 转置: M 向连续 # issue#19; 非转置时两侧同为 k_l1*dt, 等价于历史口径)
else: dv_ok = dv_a >= s.dvalue_min and dv_b >= s.dvalue_min
dv_a = k_l1 * dt # A 不转置: K 向连续 (切分后)
if case.trans_b:
dv_b = k_l1 * dt # B 转置: K 向连续 (切分后)
else:
dv_b = n * dt # B 不转置: N 向连续
dv_ok = dv_a >= s.dvalue_min or dv_b >= s.dvalue_min # 至少一侧满足
c4 = tile_ok and dv_ok c4 = tile_ok and dv_ok
checks.append(ConditionCheck( checks.append(ConditionCheck(
"4_搬移效率: 搬移分块>=min_TileSize 且 dValue>=128B (转置调整连续维)", "4_搬移效率: 搬移分块>=min_TileSize 且 dValue>=128B (转置调整连续维)",

View File

@@ -24,11 +24,14 @@ class SpecialBranch(Branch):
c1 = case.k <= 1 c1 = case.k <= 1
checks = [ConditionCheck("1_K<=1 (Cube 无用)", c1, f"K={case.k}")] checks = [ConditionCheck("1_K<=1 (Cube 无用)", c1, f"K={case.k}")]
if case.k == 1: if case.k == 1:
# K=1 触发 AIV 通路需 B >= 2*AIV核数 且单 batch 输入输出能驻留 UB # K=1 AIV 通路恒可用 (issue#12/#17): B>=2*AIV 开 UB 乒乓; B<128 退化为
c2 = case.batch_c >= 2 * self.spec.aiv_num # AIV 单缓冲 (无乒乓, 逐 batch 串行搬入), 不再是无方案空洞.
b = case.batch_c
pingpong = b >= 2 * self.spec.aiv_num
mode = "UB乒乓" if pingpong else "AIV单缓冲(逐batch串行, B<2*AIV)"
checks.append(ConditionCheck( checks.append(ConditionCheck(
"2_K=1的AIV触发: B >= 2*AIV核数 (开UB乒乓)", "2_K=1的AIV通路: 恒可用 (B>=128 开UB乒乓, 否则单缓冲)",
c2, f"B={case.batch_c} vs {2*self.spec.aiv_num}")) True, f"B={b}, 模式={mode}"))
return checks return checks
# ------------------------------------------------------------------ # ------------------------------------------------------------------
@@ -36,11 +39,15 @@ class SpecialBranch(Branch):
s = self.spec s = self.spec
if case.k == 0: if case.k == 0:
sub = "K=0纯写值" sub = "K=0纯写值"
mode = ""
note = "无任何计算, C=bias 或 0, 纯 AIV 写值; 按行均分到 AIV 核" note = "无任何计算, C=bias 或 0, 纯 AIV 写值; 按行均分到 AIV 核"
else: else:
sub = "K=1逐元素乘" sub = "K=1逐元素乘"
note = ("退化为 C=A⊙B 无累加深度, Cube 16x16x16 粒度浪费 15/16; " pingpong = case.batch_c >= 2 * s.aiv_num
"AIV 通路 GM->UB->Mul->GM, UB 乒乓") mode = "UB乒乓" if pingpong else "AIV单缓冲"
note = (f"退化为 C=A⊙B 无累加深度, Cube 16x16x16 粒度浪费 15/16; "
f"走 AIV 通路 GM->UB->Mul->GM, {mode} "
f"({'B>=2*AIV 双batch乒乓流水' if pingpong else 'B<2*AIV 逐batch单缓冲串行'})")
return ImplPlan( return ImplPlan(
case_id=case.case_id, branch=self.name, case_id=case.case_id, branch=self.name,
used_core_num=s.aiv_num, # 用 AIV 核 used_core_num=s.aiv_num, # 用 AIV 核
@@ -48,7 +55,8 @@ class SpecialBranch(Branch):
core_map="AIV 核间按行均分 (无 Cube tile 概念)", core_map="AIV 核间按行均分 (无 Cube tile 概念)",
b_core=0, merge_b0=1, b_core=0, merge_b0=1,
single_core_m=0, single_core_n=0, single_core_k=case.k, single_core_m=0, single_core_n=0, single_core_k=case.k,
k_l1=0, b_l1=1, l1_form="UB驻留(AIV)", k_l1=0, b_l1=1,
l1_form="UB驻留(AIV)" if case.k == 0 else "UB驻留(AIV) " + mode,
base_m=0, base_n=0, base_k=0, base_m=0, base_n=0, base_k=0,
l2_policy_in="allocate", l2_policy_out="direct_gm", l2_policy_in="allocate", l2_policy_out="direct_gm",
swizzle_w=0, workspace_bytes=0, swizzle_w=0, workspace_bytes=0,

View File

@@ -145,13 +145,15 @@ class StreamKBranch(Branch):
t_mmad = t_mmad_tile / grid_k t_mmad = t_mmad_tile / grid_k
t_mte2 = t_mte2_tile / grid_k t_mte2 = t_mte2_tile / grid_k
# 归约: 部分和 4B 驻留 L2, AIV 归约 (含最终按 C dtype 写回) # 归约: 部分和 4B 驻留 L2, AIV 归约 (含部分和写/读回/求和/最终按 C dtype 写回)
# 口径 (issue#11/#17): 归约整体为串行追加 (t_drain=t_reduce, reduce_serial=True),
# 部分和写出已计入 eval_streamk_reduce 的 t_write_partial —— 稳态 Fixpipe 不再
# 重复计账. 若再按 grid_k*tile*4B/单核带宽份额另计一次, 既重复计账又把整组
# 部分和串行压到单核写口, 高估 grid_k 倍 (streamk_demo 曾虚高到 55us/FIXPIPE;
# 第三轮曾回退该修复, issue#17 恢复).
t_reduce = eval_streamk_reduce(tile_elems, grid_k, out_b, s) t_reduce = eval_streamk_reduce(tile_elems, grid_k, out_b, s)
fix_bytes = 0.0
# Fixpipe: 部分和写出按 4B (L0C dtype, 防精度丢失), 驻留 L2. t_fix = 0.0
# 最终归约结果的 C dtype 写回已在 t_reduce 内计, 此处不重复 (issue#9 口径对齐).
fix_bytes = grid_k * tile_elems * 4
t_fix = fix_bytes / s.bw_l2_pc
flops_pc = 2.0 * tile_elems * k / grid_k flops_pc = 2.0 * tile_elems * k / grid_k
gm_bytes = k * (2 * math.sqrt(tile_elems)) * dt / grid_k gm_bytes = k * (2 * math.sqrt(tile_elems)) * dt / grid_k

View File

@@ -36,6 +36,13 @@ def check_plan_constraints(case: BmmCase, plan: ImplPlan,
s = spec s = spec
v = [] v = []
# 占位/无效方案: used_core_num<1 说明没有真实方案 (如 router._no_plan 的占位),
# recommend 侧 advice 已标注"[无方案]", evaluate 侧必须判不可行 (issue#18),
# 不得当作可行方案给正常时延.
if plan.used_core_num < 1:
v.append("used_core_num=0: 占位/未生成方案, 不可评估")
return v
# AIV 通路: 只校验 AIV 核数 # AIV 通路: 只校验 AIV 核数
if plan.branch in AIV_BRANCHES: if plan.branch in AIV_BRANCHES:
if plan.used_core_num > s.aiv_num: if plan.used_core_num > s.aiv_num:
@@ -77,9 +84,19 @@ def check_plan_constraints(case: BmmCase, plan: ImplPlan,
# --- dValue --- (issue#6 口径裁定: 只对"以 K 段为连续维"的方案生效) # --- dValue --- (issue#6 口径裁定: 只对"以 K 段为连续维"的方案生效)
if _k_segment_is_contiguous(plan, case) and plan.k_l1 > 0: if _k_segment_is_contiguous(plan, case) and plan.k_l1 > 0:
dv = plan.k_l1 * case.dtype_in_bytes if plan.branch == "IterBatch" and plan.l1_form.startswith(("c_", "d_")):
if dv < s.dvalue_min: # 转置感知判据与生成守卫/条件 4 同源 (issue#19):
v.append(f"dValue={dv}B < 下限 {s.dvalue_min}B, K 段连续维搬移效率崩塌") # dv_a = M*dt (A 转置) 或 k_l1*dt; dv_b = N*dt (B 不转置) 或 k_l1*dt;
# 两侧连续维 dValue 均低于下限才算违规.
from .models import dvalue_contig_dims
dv_a, dv_b = dvalue_contig_dims(case, plan.k_l1)
if dv_a < s.dvalue_min and dv_b < s.dvalue_min:
v.append(f"dValueA={dv_a:.0f}B 与 dValueB={dv_b:.0f}B 均 < 下限 "
f"{s.dvalue_min}B, 搬移连续维效率崩塌")
else:
dv = plan.k_l1 * case.dtype_in_bytes
if dv < s.dvalue_min:
v.append(f"dValue={dv}B < 下限 {s.dvalue_min}B, K 段连续维搬移效率崩塌")
# --- 写出 dtype --- (StreamK 部分和 4B 是正确行为) # --- 写出 dtype --- (StreamK 部分和 4B 是正确行为)
if plan.branch not in PARTIAL_SUM_4B_BRANCHES: if plan.branch not in PARTIAL_SUM_4B_BRANCHES:

View File

@@ -75,8 +75,18 @@ class PlanEvaluator:
tips.append("瓶颈在 Cube 计算: 已接近理论算力上限, 检查是否有冗余计算 " tips.append("瓶颈在 Cube 计算: 已接近理论算力上限, 检查是否有冗余计算 "
"(MergeBatch 交叉项) 可消除") "(MergeBatch 交叉项) 可消除")
elif bn == "FIXPIPE": elif bn == "FIXPIPE":
tips.append("瓶颈在 Fixpipe 写出: 检查输出 dtype (fp16/fp8 可减半写出量), " if plan.branch == "StreamK":
"或评估输出驻留 L2 异步回写策略") # StreamK 部分和按 L0C dtype 4B 防精度丢失, 不随 C 的 fp16/fp8 转换,
# dtype 减半提示不适用 (issue#14); 写账已并入归约, 需查归约侧配置
tips.append("瓶颈标注在 Fixpipe: StreamK 的部分和写出已并入归约计账 "
"(4B 防精度丢失, 不可随 C dtype 减半), 请核查 L2 写口/"
"归约并行度(grid_K) 设置")
else:
tips.append("瓶颈在 Fixpipe 写出: 检查输出 dtype (fp16/fp8 可减半写出量), "
"或评估输出驻留 L2 异步回写策略")
elif bn == "REDUCE":
tips.append("瓶颈在 StreamK 归约 (串行追加): 可增大 grid_K 摊薄归约 "
"或核对确定性要求是否允许 StreamK")
if plan.branch == "MergeBatch" and plan.k_l1 < case.k: if plan.branch == "MergeBatch" and plan.k_l1 < case.k:
tips.append("警告: MergeBatch 处于 L1 绑定情形 (k_L1<K), 理论证明其恒劣于 " tips.append("警告: MergeBatch 处于 L1 绑定情形 (k_L1<K), 理论证明其恒劣于 "
"IterBatch (v1.1 §4.4), 建议改用 IterBatch") "IterBatch (v1.1 §4.4), 建议改用 IterBatch")

View File

@@ -55,6 +55,23 @@ def align_down(x: int, align: int) -> int:
return (x // align) * align return (x // align) * align
def dvalue_contig_dims(case: "BmmCase", k_l1: float) -> tuple:
"""A/B 两侧 GM->L1 搬移的连续维 dValue (Byte) —— 依转置定连续维 (ND 排布).
A 不转置存储 [M,K]: 行内 K 连续, 切 K 后每行连续段 k_l1 -> k_l1*dt;
A 转置存储 [K,M]: M 连续 -> m*dt;
B 不转置存储 [K,N]: N 连续 -> n*dt;
B 转置存储 [N,K]: 行内 K 连续, 切 K 后连续段 k_l1 -> k_l1*dt.
供三处共用 (issue#19): l1_form 生成守卫 / IterBatch 条件 4 / constraints 校验,
保证"生成说可行、条件说可行、校验说可行"口径一致.
"""
dt = case.dtype_in_bytes
dv_a = case.m * dt if case.trans_a else k_l1 * dt
dv_b = k_l1 * dt if case.trans_b else case.n * dt
return dv_a, dv_b
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Case 输入 # Case 输入
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------

View File

@@ -1,2 +0,0 @@
case_id,batch_a,batch_b,m,n,k,dtype_a,dtype_b,dtype_c
bug1,64,64,8192,32,1,int8,int8,int8
1 case_id batch_a batch_b m n k dtype_a dtype_b dtype_c
2 bug1 64 64 8192 32 1 int8 int8 int8

View File

@@ -1,2 +0,0 @@
case_id,batch_a,batch_b,m,n,k,dtype_a,dtype_b,dtype_c,trans_a,trans_b,has_bias,out_nd,deterministic_level,plan_case_id,plan_branch,plan_npu,plan_op,plan_used_core_num,plan_split_b,plan_m_cnt,plan_n_cnt,plan_grid_k,plan_core_map,plan_b_core,plan_merge_b0,plan_single_core_m,plan_single_core_n,plan_single_core_k,plan_k_l1,plan_b_l1,plan_l1_form,plan_base_m,plan_base_n,plan_base_k,plan_l2_policy_in,plan_l2_policy_out,plan_swizzle_w,plan_workspace_bytes,plan_tail_strategy,plan_tail_m_cnt,plan_tail_n_cnt,plan_tail_k_cnt,plan_tail_m_main,plan_tail_n_main,plan_tail_block_cnt,plan_tail_wave_num,plan_fixpipe_unitflag,plan_out_dtype_bytes,plan_note,gm_read_bytes,l2_read_bytes,t_mte2_gm,t_mte2_l2,t_mte2,dma_cmd_count,t_dma_cmd,cube_flops,t_mmad,fixpipe_bytes,t_fixpipe,t_reduce,t_steady,t_drain,t_total,bottleneck,feasible,violations,bound_type,advice
bug1,64,64,8192,32,1,int8,int8,int8,False,False,False,True,0,bug1,特殊分支,Ascend950PR,batch_mat_mul_v3,0,1,1,1,1,,0,1,0,0,0,0,1,,0,0,0,,,0,0,,1,1,1,0,0,0,0,True,2,该区域暂无理论方案(进入条件不满足),0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,,True,,,"[无方案] K=1逐元素乘, 走AIV向量通路; 但进入条件不满足 (2_K=1的AIV触发: B >= 2*AIV核数 (开UB乒乓)), 该区域暂无理论方案, 建议参考 Cube 兜底或 AIV 单缓冲"
1 case_id batch_a batch_b m n k dtype_a dtype_b dtype_c trans_a trans_b has_bias out_nd deterministic_level plan_case_id plan_branch plan_npu plan_op plan_used_core_num plan_split_b plan_m_cnt plan_n_cnt plan_grid_k plan_core_map plan_b_core plan_merge_b0 plan_single_core_m plan_single_core_n plan_single_core_k plan_k_l1 plan_b_l1 plan_l1_form plan_base_m plan_base_n plan_base_k plan_l2_policy_in plan_l2_policy_out plan_swizzle_w plan_workspace_bytes plan_tail_strategy plan_tail_m_cnt plan_tail_n_cnt plan_tail_k_cnt plan_tail_m_main plan_tail_n_main plan_tail_block_cnt plan_tail_wave_num plan_fixpipe_unitflag plan_out_dtype_bytes plan_note gm_read_bytes l2_read_bytes t_mte2_gm t_mte2_l2 t_mte2 dma_cmd_count t_dma_cmd cube_flops t_mmad fixpipe_bytes t_fixpipe t_reduce t_steady t_drain t_total bottleneck feasible violations bound_type advice
2 bug1 64 64 8192 32 1 int8 int8 int8 False False False True 0 bug1 特殊分支 Ascend950PR batch_mat_mul_v3 0 1 1 1 1 0 1 0 0 0 0 1 0 0 0 0 0 1 1 1 0 0 0 0 True 2 该区域暂无理论方案(进入条件不满足) 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 True [无方案] K=1逐元素乘, 走AIV向量通路; 但进入条件不满足 (2_K=1的AIV触发: B >= 2*AIV核数 (开UB乒乓)), 该区域暂无理论方案, 建议参考 Cube 兜底或 AIV 单缓冲

View File

@@ -1,2 +0,0 @@
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
bug1,特殊分支,Ascend950PR,batch_mat_mul_v3,0,1,1,1,1,,0,1,0,0,0,0,1,,0,0,0,,,0,0,,1,1,1,0,0,0,0,True,2,该区域暂无理论方案(进入条件不满足)
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 bug1 特殊分支 Ascend950PR batch_mat_mul_v3 0 1 1 1 1 0 1 0 0 0 0 1 0 0 0 0 0 1 1 1 0 0 0 0 True 2 该区域暂无理论方案(进入条件不满足)

View File

@@ -1,2 +0,0 @@
case_id,batch_a,batch_b,m,n,k,dtype_a,dtype_b,dtype_c
x,51,51,255,42,682,fp32,fp32,fp32
1 case_id batch_a batch_b m n k dtype_a dtype_b dtype_c
2 x 51 51 255 42 682 fp32 fp32 fp32

View File

@@ -1,2 +0,0 @@
case_id,batch_a,batch_b,m,n,k,dtype_a,dtype_b,dtype_c
bug1,64,64,8192,32,1,int8,int8,int8
1 case_id batch_a batch_b m n k dtype_a dtype_b dtype_c
2 bug1 64 64 8192 32 1 int8 int8 int8

View File

@@ -20,13 +20,14 @@ K 维度是 CubeMMAD存在的意义——`C = Σ_k A[..,k]·B[k,..]` 的
- 数据流GM→UB读 A、B→ Mul → GM写 C全程 AIV - 数据流GM→UB读 A、B→ Mul → GM写 C全程 AIV
- 时延:`T = max(搬入, 搬出)`AIV 算力远剩,瓶颈在搬移:`T ≈ B·(MK + KN + MN)·dt / W_GM` - 时延:`T = max(搬入, 搬出)`AIV 算力远剩,瓶颈在搬移:`T ≈ B·(MK + KN + MN)·dt / W_GM`
- **触发条件**`B ≥ 2×AIV核数 = 128`(开 UB 乒乓需要每核至少 2 个 batch 块)且单 batch 输入输出能驻留 UB - **触发条件**`B ≥ 2×AIV核数 = 128`(开 UB 乒乓需要每核至少 2 个 batch 块)且单 batch 输入输出能驻留 UB
- **B < 128 时并不无解**issue#12/#17退化为 **AIV 单缓冲**——无乒乓 batch 串行搬入计算仍远优于 Cube 通路K=1 Cube 16×16×16 浪费 15/16只是流水掩盖能力下降软件 `special.py` `B ≥ 128` 自动选择"UB乒乓 / AIV单缓冲"模式
## 4. 软件处理 ## 4. 软件处理
`router.py` 前置归约中`k ≤ 1` 直接路由到特殊分支 `router.py` 前置归约中`k ≤ 1` 直接路由到特殊分支
- `K=0` 标注" AIV 写值"评估时延 = 写出时延; - `K=0` 标注" AIV 写值"评估时延 = 写出时延;
- `K=1` → 标注"AIV 逐元素乘",评估时延 = 搬入/搬出较大者。 - `K=1` 标注"AIV 逐元素乘"评估时延 = 搬入/搬出较大者plan `B ≥ 128` 自动选择"UB乒乓 / AIV单缓冲"模式`l1_form` `note` 中可见)。
不进入 Cube 切分体系 ImplPlan tile 字段 used_core_num = AIV 核数外均不适用)。 不进入 Cube 切分体系 ImplPlan tile 字段 used_core_num = AIV 核数外均不适用)。

View File

@@ -134,6 +134,7 @@ bmmv3: b0 = min(L0C/(2·M·N·4), ceil(B/C), 607.5·(M+N)/(2·M·N))
|---|---|---| |---|---|---|
| fp40.5Bdtype 支持 | 高 | ✅ **已补(本期)**——`DTYPE_BYTES``"fp4": 0.5` / `"fp4_e2m1": 0.5``dtype_bytes()` 返回 float | | fp40.5Bdtype 支持 | 高 | ✅ **已补(本期)**——`DTYPE_BYTES``"fp4": 0.5` / `"fp4_e2m1": 0.5``dtype_bytes()` 返回 float |
| 转置对 dValue/base_k 的影响建模 | 高 | ✅ **已补(本期)**——MergeBatch 加条件 6A 转置对齐IterBatch dValue 判定按转置调整连续维 | | 转置对 dValue/base_k 的影响建模 | 高 | ✅ **已补(本期)**——MergeBatch 加条件 6A 转置对齐IterBatch dValue 判定按转置调整连续维 |
| 转置判据三处同源 | 中 | ✅ **已补issue#19**——`models.dvalue_contig_dims` 统一连续维 dValue`l1_form` c/d 生成守卫 / IterBatch 条件 4 / `constraints` 校验共用同一判据,非转置行为不变 |
| XLSX 原表追加输出 | 中 | 待做 | | XLSX 原表追加输出 | 中 | 待做 |
| c1/c2 的 step 幂次搜索 | 低 | 不做(理论极限不需要离散化) | | c1/c2 的 step 幂次搜索 | 低 | 不做(理论极限不需要离散化) |
@@ -172,4 +173,4 @@ bmmv3: b0 = min(L0C/(2·M·N·4), ceil(B/C), 607.5·(M+N)/(2·M·N))
--- ---
*版本v1.0 | 2026-09-03 | 基于 BMM_Theory 最新版(含 issue#11-#16 修复)与 bmmv3 最新版对照* *版本v1.1 | 2026-09-06 | 基于 BMM_Theory main(含 issue#11-#22 修复:含 #17 恢复 StreamK 单次计账/K=1 单缓冲/#14 advice#19 转置判据三处同源)与 bmmv3 最新版对照*

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 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" 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_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_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 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_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写最终" 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_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 跌破搬移效率下限反而更慢)" 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 跌破搬移效率下限反而更慢)

View File

@@ -1,11 +1,11 @@
case_id,batch_a,batch_b,m,n,k,dtype_a,dtype_b,dtype_c,trans_a,trans_b,has_bias,out_nd,deterministic_level,plan_case_id,plan_branch,plan_npu,plan_op,plan_used_core_num,plan_split_b,plan_m_cnt,plan_n_cnt,plan_grid_k,plan_core_map,plan_b_core,plan_merge_b0,plan_single_core_m,plan_single_core_n,plan_single_core_k,plan_k_l1,plan_b_l1,plan_l1_form,plan_base_m,plan_base_n,plan_base_k,plan_l2_policy_in,plan_l2_policy_out,plan_swizzle_w,plan_workspace_bytes,plan_tail_strategy,plan_tail_m_cnt,plan_tail_n_cnt,plan_tail_k_cnt,plan_tail_m_main,plan_tail_n_main,plan_tail_block_cnt,plan_tail_wave_num,plan_fixpipe_unitflag,plan_out_dtype_bytes,plan_note,gm_read_bytes,l2_read_bytes,t_mte2_gm,t_mte2_l2,t_mte2,dma_cmd_count,t_dma_cmd,cube_flops,t_mmad,fixpipe_bytes,t_fixpipe,t_reduce,t_steady,t_drain,t_total,bottleneck,feasible,violations,bound_type,advice case_id,batch_a,batch_b,m,n,k,dtype_a,dtype_b,dtype_c,trans_a,trans_b,has_bias,out_nd,deterministic_level,plan_case_id,plan_branch,plan_npu,plan_op,plan_used_core_num,plan_split_b,plan_m_cnt,plan_n_cnt,plan_grid_k,plan_core_map,plan_b_core,plan_merge_b0,plan_single_core_m,plan_single_core_n,plan_single_core_k,plan_k_l1,plan_b_l1,plan_l1_form,plan_base_m,plan_base_n,plan_base_k,plan_l2_policy_in,plan_l2_policy_out,plan_swizzle_w,plan_workspace_bytes,plan_tail_strategy,plan_tail_m_cnt,plan_tail_n_cnt,plan_tail_k_cnt,plan_tail_m_main,plan_tail_n_main,plan_tail_block_cnt,plan_tail_wave_num,plan_fixpipe_unitflag,plan_out_dtype_bytes,plan_note,gm_read_bytes,l2_read_bytes,t_mte2_gm,t_mte2_l2,t_mte2,dma_cmd_count,t_dma_cmd,cube_flops,t_mmad,fixpipe_bytes,t_fixpipe,t_reduce,t_steady,t_drain,t_total,bottleneck,feasible,violations,bound_type,advice
to_matmul_demo,1,1,2048,2048,2048,bf16,bf16,bf16,False,False,False,True,0,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",16777216,0.0,1.048576e-05,0.0,1.048576e-05,0.0,0.0,17179869184.0,3.534952506995885e-05,8388608,5.24288e-06,0.0,3.534952506995885e-05,0.0,3.534952506995885e-05,MMAD,True,,计算Bound,"瓶颈在 Cube 计算: 已接近理论算力上限, 检查是否有冗余计算 (MergeBatch 交叉项) 可消除" to_matmul_demo,1,1,2048,2048,2048,bf16,bf16,bf16,False,False,False,True,0,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",16777216,0.0,1.048576e-05,0.0,1.048576e-05,0.0,0.0,17179869184.0,3.534952506995885e-05,8388608,5.24288e-06,0.0,3.534952506995885e-05,0.0,3.534952506995885e-05,MMAD,True,,计算Bound,"瓶颈在 Cube 计算: 已接近理论算力上限, 检查是否有冗余计算 (MergeBatch 交叉项) 可消除"
special_k0_demo,128,128,256,256,0,bf16,bf16,bf16,False,False,False,True,0,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 核",0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,16777216,1.048576e-05,0.0,1.048576e-05,0.0,1.048576e-05,FIXPIPE,True,,写出Bound,"瓶颈在 Fixpipe 写出: 检查输出 dtype (fp16/fp8 可减半写出量), 或评估输出驻留 L2 异步回写策略" special_k0_demo,128,128,256,256,0,bf16,bf16,bf16,False,False,False,True,0,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 核",0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,16777216,1.048576e-05,0.0,1.048576e-05,0.0,1.048576e-05,FIXPIPE,True,,写出Bound,"瓶颈在 Fixpipe 写出: 检查输出 dtype (fp16/fp8 可减半写出量), 或评估输出驻留 L2 异步回写策略"
special_k1_demo,128,128,256,256,1,bf16,bf16,bf16,False,False,False,True,0,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 乒乓",131072,0.0,8.192e-08,0.0,8.192e-08,0.0,0.0,8388608.0,6.206060606060606e-07,16777216,1.048576e-05,0.0,1.048576e-05,0.0,1.048576e-05,FIXPIPE,True,,写出Bound,"瓶颈在 Fixpipe 写出: 检查输出 dtype (fp16/fp8 可减半写出量), 或评估输出驻留 L2 异步回写策略" special_k1_demo,128,128,256,256,1,bf16,bf16,bf16,False,False,False,True,0,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乒乓流水)",131072,0.0,8.192e-08,0.0,8.192e-08,0.0,0.0,8388608.0,6.206060606060606e-07,16777216,1.048576e-05,0.0,1.048576e-05,0.0,1.048576e-05,FIXPIPE,True,,写出Bound,"瓶颈在 Fixpipe 写出: 检查输出 dtype (fp16/fp8 可减半写出量), 或评估输出驻留 L2 异步回写策略"
merge_demo_k_trunc,2048,2048,32,32,256,bf16,bf16,bf16,False,False,False,True,0,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]",2097152,0.0,4.194304e-05,0.0,4.2743039999999997e-05,16.0,8.000000000000001e-07,134217728.0,8.837381267489712e-06,131072,2.62144e-06,0.0,4.2743039999999997e-05,3.0192408230452674e-07,4.3044964082304525e-05,MTE2_GM,True,,访存Bound(GM),"瓶颈在 GM 搬入: 可考虑增大 tile 提升 dValue/单核搬移量, 或利用 L2 驻留吸收重复读 (MergeBatch/ASW swizzle 方向)" merge_demo_k_trunc,2048,2048,32,32,256,bf16,bf16,bf16,False,False,False,True,0,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]",2097152,0.0,4.194304e-05,0.0,4.2743039999999997e-05,16.0,8.000000000000001e-07,134217728.0,8.837381267489712e-06,131072,2.62144e-06,0.0,4.2743039999999997e-05,3.0192408230452674e-07,4.3044964082304525e-05,MTE2_GM,True,,访存Bound(GM),"瓶颈在 GM 搬入: 可考虑增大 tile 提升 dValue/单核搬移量, 或利用 L2 驻留吸收重复读 (MergeBatch/ASW swizzle 方向)"
merge_iter_arbitrate,128,128,64,64,512,bf16,bf16,bf16,False,False,False,True,0,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,524288,0.0,1.048576e-05,0.0,1.0685759999999999e-05,4,2.0000000000000002e-07,16777216.0,1.104672658436214e-06,32768,6.5536e-07,0.0,1.0685759999999999e-05,4.400081646090535e-07,1.1125768164609053e-05,MTE2_GM,True,,访存Bound(GM),"瓶颈在 GM 搬入: 可考虑增大 tile 提升 dValue/单核搬移量, 或利用 L2 驻留吸收重复读 (MergeBatch/ASW swizzle 方向)" merge_iter_arbitrate,128,128,64,64,512,bf16,bf16,bf16,False,False,False,True,0,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,524288,0.0,1.048576e-05,0.0,1.0685759999999999e-05,4,2.0000000000000002e-07,16777216.0,1.104672658436214e-06,32768,6.5536e-07,0.0,1.0685759999999999e-05,4.400081646090535e-07,1.1125768164609053e-05,MTE2_GM,True,,访存Bound(GM),"瓶颈在 GM 搬入: 可考虑增大 tile 提升 dValue/单核搬移量, 或利用 L2 驻留吸收重复读 (MergeBatch/ASW swizzle 方向)"
iter_demo_form_b,128,128,64,64,256,bf16,bf16,bf16,False,False,False,True,0,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,262144,0.0,5.24288e-06,0.0,5.4428799999999995e-06,4,2.0000000000000002e-07,8388608.0,5.52336329218107e-07,32768,6.5536e-07,0.0,5.4428799999999995e-06,3.0192408230452674e-07,5.744804082304526e-06,MTE2_GM,True,,访存Bound(GM),"瓶颈在 GM 搬入: 可考虑增大 tile 提升 dValue/单核搬移量, 或利用 L2 驻留吸收重复读 (MergeBatch/ASW swizzle 方向)" iter_demo_form_b,128,128,64,64,256,bf16,bf16,bf16,False,False,False,True,0,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,262144,0.0,5.24288e-06,0.0,5.4428799999999995e-06,4,2.0000000000000002e-07,8388608.0,5.52336329218107e-07,32768,6.5536e-07,0.0,5.4428799999999995e-06,3.0192408230452674e-07,5.744804082304526e-06,MTE2_GM,True,,访存Bound(GM),"瓶颈在 GM 搬入: 可考虑增大 tile 提升 dValue/单核搬移量, 或利用 L2 驻留吸收重复读 (MergeBatch/ASW swizzle 方向)"
iter_demo_form_d,64,64,64,64,8192,bf16,bf16,bf16,False,False,False,True,0,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边界天然无缝",4194304,0.0,8.388608e-05,0.0,8.468608e-05,16,8.000000000000001e-07,134217728.0,8.837381267489712e-06,16384,3.2768e-07,0.0,8.468608e-05,7.16176329218107e-07,8.540225632921811e-05,MTE2_GM,True,,访存Bound(GM),"瓶颈在 GM 搬入: 可考虑增大 tile 提升 dValue/单核搬移量, 或利用 L2 驻留吸收重复读 (MergeBatch/ASW swizzle 方向)" iter_demo_form_d,64,64,64,64,8192,bf16,bf16,bf16,False,False,False,True,0,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",4194304,0.0,8.388608e-05,0.0,8.468608e-05,16,8.000000000000001e-07,134217728.0,8.837381267489712e-06,16384,3.2768e-07,0.0,8.468608e-05,7.16176329218107e-07,8.540225632921811e-05,MTE2_GM,True,,访存Bound(GM),"瓶颈在 GM 搬入: 可考虑增大 tile 提升 dValue/单核搬移量, 或利用 L2 驻留吸收重复读 (MergeBatch/ASW swizzle 方向)"
streamk_demo,4,4,128,128,10240,bf16,bf16,bf16,False,False,False,True,0,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写最终",327680.0,0.0,6.5536e-06,0.0,6.5536e-06,0.0,0.0,41943040.0,2.761681646090535e-06,8388608,5.162220307692308e-05,3.4067453613053613e-06,5.162220307692308e-05,3.4067453613053613e-06,5.5028948438228435e-05,FIXPIPE,True,,写出Bound,"瓶颈在 Fixpipe 写出: 检查输出 dtype (fp16/fp8 可减半写出量), 或评估输出驻留 L2 异步回写策略" streamk_demo,4,4,128,128,10240,bf16,bf16,bf16,False,False,False,True,0,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写最终",327680.0,0.0,6.5536e-06,0.0,6.5536e-06,0.0,0.0,41943040.0,2.761681646090535e-06,0.0,0.0,3.4067453613053613e-06,6.5536e-06,3.4067453613053613e-06,9.960345361305361e-06,MTE2_GM,True,,访存Bound(GM),"瓶颈在 GM 搬入: 可考虑增大 tile 提升 dValue/单核搬移量, 或利用 L2 驻留吸收重复读 (MergeBatch/ASW swizzle 方向)"
asw_demo_full,2,2,8192,8192,1024,bf16,bf16,bf16,False,False,False,True,0,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反超",67108864.0,0.0,4.194304e-05,0.0,4.194304e-05,0.0,0.0,274877906944.0,0.0005655924011193416,268435456,0.00016777216,0.0,0.0005655924011193416,0.0,0.0005655924011193416,MMAD,True,,计算Bound,"瓶颈在 Cube 计算: 已接近理论算力上限, 检查是否有冗余计算 (MergeBatch 交叉项) 可消除" asw_demo_full,2,2,8192,8192,1024,bf16,bf16,bf16,False,False,False,True,0,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反超",67108864.0,0.0,4.194304e-05,0.0,4.194304e-05,0.0,0.0,274877906944.0,0.0005655924011193416,268435456,0.00016777216,0.0,0.0005655924011193416,0.0,0.0005655924011193416,MMAD,True,,计算Bound,"瓶颈在 Cube 计算: 已接近理论算力上限, 检查是否有冗余计算 (MergeBatch 交叉项) 可消除"
asw_demo_reduce_core,16,16,256,256,128,bf16,bf16,bf16,False,False,False,True,0,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 跌破搬移效率下限反而更慢)",2097152.0,0.0,2.62144e-06,0.0,2.62144e-06,0.0,0.0,268435456.0,1.104672658436214e-06,2097152,2.62144e-06,0.0,2.62144e-06,0.0,2.62144e-06,MTE2_GM,True,,访存Bound(GM),"瓶颈在 GM 搬入: 可考虑增大 tile 提升 dValue/单核搬移量, 或利用 L2 驻留吸收重复读 (MergeBatch/ASW swizzle 方向)" asw_demo_reduce_core,16,16,256,256,128,bf16,bf16,bf16,False,False,False,True,0,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 跌破搬移效率下限反而更慢)",2097152.0,0.0,2.62144e-06,0.0,2.62144e-06,0.0,0.0,268435456.0,1.104672658436214e-06,2097152,2.62144e-06,0.0,2.62144e-06,0.0,2.62144e-06,MTE2_GM,True,,访存Bound(GM),"瓶颈在 GM 搬入: 可考虑增大 tile 提升 dValue/单核搬移量, 或利用 L2 驻留吸收重复读 (MergeBatch/ASW swizzle 方向)"
1 case_id batch_a batch_b m n k dtype_a dtype_b dtype_c trans_a trans_b has_bias out_nd deterministic_level plan_case_id plan_branch plan_npu plan_op plan_used_core_num plan_split_b plan_m_cnt plan_n_cnt plan_grid_k plan_core_map plan_b_core plan_merge_b0 plan_single_core_m plan_single_core_n plan_single_core_k plan_k_l1 plan_b_l1 plan_l1_form plan_base_m plan_base_n plan_base_k plan_l2_policy_in plan_l2_policy_out plan_swizzle_w plan_workspace_bytes plan_tail_strategy plan_tail_m_cnt plan_tail_n_cnt plan_tail_k_cnt plan_tail_m_main plan_tail_n_main plan_tail_block_cnt plan_tail_wave_num plan_fixpipe_unitflag plan_out_dtype_bytes plan_note gm_read_bytes l2_read_bytes t_mte2_gm t_mte2_l2 t_mte2 dma_cmd_count t_dma_cmd cube_flops t_mmad fixpipe_bytes t_fixpipe t_reduce t_steady t_drain t_total bottleneck feasible violations bound_type advice
2 to_matmul_demo 1 1 2048 2048 2048 bf16 bf16 bf16 False False False True 0 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 16777216 0.0 1.048576e-05 0.0 1.048576e-05 0.0 0.0 17179869184.0 3.534952506995885e-05 8388608 5.24288e-06 0.0 3.534952506995885e-05 0.0 3.534952506995885e-05 MMAD True 计算Bound 瓶颈在 Cube 计算: 已接近理论算力上限, 检查是否有冗余计算 (MergeBatch 交叉项) 可消除
3 special_k0_demo 128 128 256 256 0 bf16 bf16 bf16 False False False True 0 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 核 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 16777216 1.048576e-05 0.0 1.048576e-05 0.0 1.048576e-05 FIXPIPE True 写出Bound 瓶颈在 Fixpipe 写出: 检查输出 dtype (fp16/fp8 可减半写出量), 或评估输出驻留 L2 异步回写策略
4 special_k1_demo 128 128 256 256 1 bf16 bf16 bf16 False False False True 0 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乒乓流水) 131072 0.0 8.192e-08 0.0 8.192e-08 0.0 0.0 8388608.0 6.206060606060606e-07 16777216 1.048576e-05 0.0 1.048576e-05 0.0 1.048576e-05 FIXPIPE True 写出Bound 瓶颈在 Fixpipe 写出: 检查输出 dtype (fp16/fp8 可减半写出量), 或评估输出驻留 L2 异步回写策略
5 merge_demo_k_trunc 2048 2048 32 32 256 bf16 bf16 bf16 False False False True 0 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] 2097152 0.0 4.194304e-05 0.0 4.2743039999999997e-05 16.0 8.000000000000001e-07 134217728.0 8.837381267489712e-06 131072 2.62144e-06 0.0 4.2743039999999997e-05 3.0192408230452674e-07 4.3044964082304525e-05 MTE2_GM True 访存Bound(GM) 瓶颈在 GM 搬入: 可考虑增大 tile 提升 dValue/单核搬移量, 或利用 L2 驻留吸收重复读 (MergeBatch/ASW swizzle 方向)
6 merge_iter_arbitrate 128 128 64 64 512 bf16 bf16 bf16 False False False True 0 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 524288 0.0 1.048576e-05 0.0 1.0685759999999999e-05 4 2.0000000000000002e-07 16777216.0 1.104672658436214e-06 32768 6.5536e-07 0.0 1.0685759999999999e-05 4.400081646090535e-07 1.1125768164609053e-05 MTE2_GM True 访存Bound(GM) 瓶颈在 GM 搬入: 可考虑增大 tile 提升 dValue/单核搬移量, 或利用 L2 驻留吸收重复读 (MergeBatch/ASW swizzle 方向)
7 iter_demo_form_b 128 128 64 64 256 bf16 bf16 bf16 False False False True 0 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 262144 0.0 5.24288e-06 0.0 5.4428799999999995e-06 4 2.0000000000000002e-07 8388608.0 5.52336329218107e-07 32768 6.5536e-07 0.0 5.4428799999999995e-06 3.0192408230452674e-07 5.744804082304526e-06 MTE2_GM True 访存Bound(GM) 瓶颈在 GM 搬入: 可考虑增大 tile 提升 dValue/单核搬移量, 或利用 L2 驻留吸收重复读 (MergeBatch/ASW swizzle 方向)
8 iter_demo_form_d 64 64 64 64 8192 bf16 bf16 bf16 False False False True 0 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 4194304 0.0 8.388608e-05 0.0 8.468608e-05 16 8.000000000000001e-07 134217728.0 8.837381267489712e-06 16384 3.2768e-07 0.0 8.468608e-05 7.16176329218107e-07 8.540225632921811e-05 MTE2_GM True 访存Bound(GM) 瓶颈在 GM 搬入: 可考虑增大 tile 提升 dValue/单核搬移量, 或利用 L2 驻留吸收重复读 (MergeBatch/ASW swizzle 方向)
9 streamk_demo 4 4 128 128 10240 bf16 bf16 bf16 False False False True 0 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写最终 327680.0 0.0 6.5536e-06 0.0 6.5536e-06 0.0 0.0 41943040.0 2.761681646090535e-06 8388608 0.0 5.162220307692308e-05 0.0 3.4067453613053613e-06 5.162220307692308e-05 6.5536e-06 3.4067453613053613e-06 5.5028948438228435e-05 9.960345361305361e-06 FIXPIPE MTE2_GM True 写出Bound 访存Bound(GM) 瓶颈在 Fixpipe 写出: 检查输出 dtype (fp16/fp8 可减半写出量), 或评估输出驻留 L2 异步回写策略 瓶颈在 GM 搬入: 可考虑增大 tile 提升 dValue/单核搬移量, 或利用 L2 驻留吸收重复读 (MergeBatch/ASW swizzle 方向)
10 asw_demo_full 2 2 8192 8192 1024 bf16 bf16 bf16 False False False True 0 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反超 67108864.0 0.0 4.194304e-05 0.0 4.194304e-05 0.0 0.0 274877906944.0 0.0005655924011193416 268435456 0.00016777216 0.0 0.0005655924011193416 0.0 0.0005655924011193416 MMAD True 计算Bound 瓶颈在 Cube 计算: 已接近理论算力上限, 检查是否有冗余计算 (MergeBatch 交叉项) 可消除
11 asw_demo_reduce_core 16 16 256 256 128 bf16 bf16 bf16 False False False True 0 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 跌破搬移效率下限反而更慢) 2097152.0 0.0 2.62144e-06 0.0 2.62144e-06 0.0 0.0 268435456.0 1.104672658436214e-06 2097152 2.62144e-06 0.0 2.62144e-06 0.0 2.62144e-06 MTE2_GM True 访存Bound(GM) 瓶颈在 GM 搬入: 可考虑增大 tile 提升 dValue/单核搬移量, 或利用 L2 驻留吸收重复读 (MergeBatch/ASW swizzle 方向)

View File

@@ -1,11 +1,11 @@
case_id,batch_a,batch_b,m,n,k,dtype_a,dtype_b,dtype_c,trans_a,trans_b,has_bias,out_nd,deterministic_level,plan_case_id,plan_branch,plan_npu,plan_op,plan_used_core_num,plan_split_b,plan_m_cnt,plan_n_cnt,plan_grid_k,plan_core_map,plan_b_core,plan_merge_b0,plan_single_core_m,plan_single_core_n,plan_single_core_k,plan_k_l1,plan_b_l1,plan_l1_form,plan_base_m,plan_base_n,plan_base_k,plan_l2_policy_in,plan_l2_policy_out,plan_swizzle_w,plan_workspace_bytes,plan_tail_strategy,plan_tail_m_cnt,plan_tail_n_cnt,plan_tail_k_cnt,plan_tail_m_main,plan_tail_n_main,plan_tail_block_cnt,plan_tail_wave_num,plan_fixpipe_unitflag,plan_out_dtype_bytes,plan_note,gm_read_bytes,l2_read_bytes,t_mte2_gm,t_mte2_l2,t_mte2,dma_cmd_count,t_dma_cmd,cube_flops,t_mmad,fixpipe_bytes,t_fixpipe,t_reduce,t_steady,t_drain,t_total,bottleneck,feasible,violations,bound_type,advice case_id,batch_a,batch_b,m,n,k,dtype_a,dtype_b,dtype_c,trans_a,trans_b,has_bias,out_nd,deterministic_level,plan_case_id,plan_branch,plan_npu,plan_op,plan_used_core_num,plan_split_b,plan_m_cnt,plan_n_cnt,plan_grid_k,plan_core_map,plan_b_core,plan_merge_b0,plan_single_core_m,plan_single_core_n,plan_single_core_k,plan_k_l1,plan_b_l1,plan_l1_form,plan_base_m,plan_base_n,plan_base_k,plan_l2_policy_in,plan_l2_policy_out,plan_swizzle_w,plan_workspace_bytes,plan_tail_strategy,plan_tail_m_cnt,plan_tail_n_cnt,plan_tail_k_cnt,plan_tail_m_main,plan_tail_n_main,plan_tail_block_cnt,plan_tail_wave_num,plan_fixpipe_unitflag,plan_out_dtype_bytes,plan_note,gm_read_bytes,l2_read_bytes,t_mte2_gm,t_mte2_l2,t_mte2,dma_cmd_count,t_dma_cmd,cube_flops,t_mmad,fixpipe_bytes,t_fixpipe,t_reduce,t_steady,t_drain,t_total,bottleneck,feasible,violations,bound_type,advice
to_matmul_demo,1,1,2048,2048,2048,bf16,bf16,bf16,False,False,False,True,0,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",16777216,0.0,1.048576e-05,0.0,1.048576e-05,0.0,0.0,17179869184.0,3.534952506995885e-05,8388608,5.24288e-06,0.0,3.534952506995885e-05,0.0,3.534952506995885e-05,MMAD,True,,计算Bound,"BatchA=1或BatchB=1, 折叠转普通Matmul" to_matmul_demo,1,1,2048,2048,2048,bf16,bf16,bf16,False,False,False,True,0,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",16777216,0.0,1.048576e-05,0.0,1.048576e-05,0.0,0.0,17179869184.0,3.534952506995885e-05,8388608,5.24288e-06,0.0,3.534952506995885e-05,0.0,3.534952506995885e-05,MMAD,True,,计算Bound,"BatchA=1或BatchB=1, 折叠转普通Matmul"
special_k0_demo,128,128,256,256,0,bf16,bf16,bf16,False,False,False,True,0,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 核",0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,16777216,1.048576e-05,0.0,1.048576e-05,0.0,1.048576e-05,FIXPIPE,True,,写出Bound,K=0纯写值 special_k0_demo,128,128,256,256,0,bf16,bf16,bf16,False,False,False,True,0,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 核",0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,16777216,1.048576e-05,0.0,1.048576e-05,0.0,1.048576e-05,FIXPIPE,True,,写出Bound,K=0纯写值
special_k1_demo,128,128,256,256,1,bf16,bf16,bf16,False,False,False,True,0,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 乒乓",131072,0.0,8.192e-08,0.0,8.192e-08,0.0,0.0,8388608.0,6.206060606060606e-07,16777216,1.048576e-05,0.0,1.048576e-05,0.0,1.048576e-05,FIXPIPE,True,,写出Bound,"K=1逐元素乘, 走AIV向量通路" special_k1_demo,128,128,256,256,1,bf16,bf16,bf16,False,False,False,True,0,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乒乓流水)",131072,0.0,8.192e-08,0.0,8.192e-08,0.0,0.0,8388608.0,6.206060606060606e-07,16777216,1.048576e-05,0.0,1.048576e-05,0.0,1.048576e-05,FIXPIPE,True,,写出Bound,"K=1逐元素乘, 走AIV向量通路"
merge_demo_k_trunc,2048,2048,32,32,256,bf16,bf16,bf16,False,False,False,True,0,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]",2097152,0.0,4.194304e-05,0.0,4.2743039999999997e-05,16.0,8.000000000000001e-07,134217728.0,8.837381267489712e-06,131072,2.62144e-06,0.0,4.2743039999999997e-05,3.0192408230452674e-07,4.3044964082304525e-05,MTE2_GM,True,,访存Bound(GM),"两分支均合法, 仲裁: [分界条件] MergeBatch最优=True (k_L1=K(截断); b_core=64 vs 阈值 b0*(T_comp+T_write)/T_cmd=6.0; drain惩罚=(b0-1)*(T_comp+T_write)=0.23us, 搬移节省=b_core*(1-1/b0)*T_cmd=2.40us); [时延模型] T_MergeBatch=43.04us vs T_IterBatch=45.22us -> MergeBatch更优; [裁决] MergeBatch" merge_demo_k_trunc,2048,2048,32,32,256,bf16,bf16,bf16,False,False,False,True,0,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]",2097152,0.0,4.194304e-05,0.0,4.2743039999999997e-05,16.0,8.000000000000001e-07,134217728.0,8.837381267489712e-06,131072,2.62144e-06,0.0,4.2743039999999997e-05,3.0192408230452674e-07,4.3044964082304525e-05,MTE2_GM,True,,访存Bound(GM),"两分支均合法, 仲裁: [分界条件] MergeBatch最优=True (k_L1=K(截断); b_core=64 vs 阈值 b0*(T_comp+T_write)/T_cmd=6.0; drain惩罚=(b0-1)*(T_comp+T_write)=0.23us, 搬移节省=b_core*(1-1/b0)*T_cmd=2.40us); [时延模型] T_MergeBatch=43.04us vs T_IterBatch=45.22us -> MergeBatch更优; [裁决] MergeBatch"
merge_iter_arbitrate,128,128,64,64,512,bf16,bf16,bf16,False,False,False,True,0,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,524288,0.0,1.048576e-05,0.0,1.0685759999999999e-05,4,2.0000000000000002e-07,16777216.0,1.104672658436214e-06,32768,6.5536e-07,0.0,1.0685759999999999e-05,4.400081646090535e-07,1.1125768164609053e-05,MTE2_GM,True,,访存Bound(GM),"两分支均合法, 仲裁: [分界条件] MergeBatch最优=False (k_L1=K(截断); b_core=4 vs 阈值 b0*(T_comp+T_write)/T_cmd=17.6; drain惩罚=(b0-1)*(T_comp+T_write)=0.44us, 搬移节省=b_core*(1-1/b0)*T_cmd=0.10us); [时延模型] T_MergeBatch=11.49us vs T_IterBatch=11.13us -> IterBatch更优; [裁决] IterBatch" merge_iter_arbitrate,128,128,64,64,512,bf16,bf16,bf16,False,False,False,True,0,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,524288,0.0,1.048576e-05,0.0,1.0685759999999999e-05,4,2.0000000000000002e-07,16777216.0,1.104672658436214e-06,32768,6.5536e-07,0.0,1.0685759999999999e-05,4.400081646090535e-07,1.1125768164609053e-05,MTE2_GM,True,,访存Bound(GM),"两分支均合法, 仲裁: [分界条件] MergeBatch最优=False (k_L1=K(截断); b_core=4 vs 阈值 b0*(T_comp+T_write)/T_cmd=17.6; drain惩罚=(b0-1)*(T_comp+T_write)=0.44us, 搬移节省=b_core*(1-1/b0)*T_cmd=0.10us); [时延模型] T_MergeBatch=11.49us vs T_IterBatch=11.13us -> IterBatch更优; [裁决] IterBatch"
iter_demo_form_b,128,128,64,64,256,bf16,bf16,bf16,False,False,False,True,0,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,262144,0.0,5.24288e-06,0.0,5.4428799999999995e-06,4,2.0000000000000002e-07,8388608.0,5.52336329218107e-07,32768,6.5536e-07,0.0,5.4428799999999995e-06,3.0192408230452674e-07,5.744804082304526e-06,MTE2_GM,True,,访存Bound(GM),仅 IterBatch 条件满足 iter_demo_form_b,128,128,64,64,256,bf16,bf16,bf16,False,False,False,True,0,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,262144,0.0,5.24288e-06,0.0,5.4428799999999995e-06,4,2.0000000000000002e-07,8388608.0,5.52336329218107e-07,32768,6.5536e-07,0.0,5.4428799999999995e-06,3.0192408230452674e-07,5.744804082304526e-06,MTE2_GM,True,,访存Bound(GM),仅 IterBatch 条件满足
iter_demo_form_d,64,64,64,64,8192,bf16,bf16,bf16,False,False,False,True,0,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边界天然无缝",4194304,0.0,8.388608e-05,0.0,8.468608e-05,16,8.000000000000001e-07,134217728.0,8.837381267489712e-06,16384,3.2768e-07,0.0,8.468608e-05,7.16176329218107e-07,8.540225632921811e-05,MTE2_GM,True,,访存Bound(GM),仅 IterBatch 条件满足 iter_demo_form_d,64,64,64,64,8192,bf16,bf16,bf16,False,False,False,True,0,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",4194304,0.0,8.388608e-05,0.0,8.468608e-05,16,8.000000000000001e-07,134217728.0,8.837381267489712e-06,16384,3.2768e-07,0.0,8.468608e-05,7.16176329218107e-07,8.540225632921811e-05,MTE2_GM,True,,访存Bound(GM),仅 IterBatch 条件满足
streamk_demo,4,4,128,128,10240,bf16,bf16,bf16,False,False,False,True,0,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写最终",327680.0,0.0,6.5536e-06,0.0,6.5536e-06,0.0,0.0,41943040.0,2.761681646090535e-06,8388608,5.162220307692308e-05,3.4067453613053613e-06,5.162220307692308e-05,3.4067453613053613e-06,5.5028948438228435e-05,FIXPIPE,True,,写出Bound,"P<=C/2, B/M/N并行度买不满, 切K (grid_K=32)" streamk_demo,4,4,128,128,10240,bf16,bf16,bf16,False,False,False,True,0,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写最终",327680.0,0.0,6.5536e-06,0.0,6.5536e-06,0.0,0.0,41943040.0,2.761681646090535e-06,0.0,0.0,3.4067453613053613e-06,6.5536e-06,3.4067453613053613e-06,9.960345361305361e-06,MTE2_GM,True,,访存Bound(GM),"P<=C/2, B/M/N并行度买不满, 切K (grid_K=32)"
asw_demo_full,2,2,8192,8192,1024,bf16,bf16,bf16,False,False,False,True,0,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反超",67108864.0,0.0,4.194304e-05,0.0,4.194304e-05,0.0,0.0,274877906944.0,0.0005655924011193416,268435456,0.00016777216,0.0,0.0005655924011193416,0.0,0.0005655924011193416,MMAD,True,,计算Bound,ASW_Basic兜底 (StreamK未过: 1_并行缺口: P=B*MN*4B/L0C <= C/2; 2_单核K段下限: K/grid_K >= 256B/dtype 且 grid_K>=2; 3_归约代价可接受) asw_demo_full,2,2,8192,8192,1024,bf16,bf16,bf16,False,False,False,True,0,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反超",67108864.0,0.0,4.194304e-05,0.0,4.194304e-05,0.0,0.0,274877906944.0,0.0005655924011193416,268435456,0.00016777216,0.0,0.0005655924011193416,0.0,0.0005655924011193416,MMAD,True,,计算Bound,ASW_Basic兜底 (StreamK未过: 1_并行缺口: P=B*MN*4B/L0C <= C/2; 2_单核K段下限: K/grid_K >= 256B/dtype 且 grid_K>=2; 3_归约代价可接受)
asw_demo_reduce_core,16,16,256,256,128,bf16,bf16,bf16,False,False,False,True,0,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 跌破搬移效率下限反而更慢)",2097152.0,0.0,2.62144e-06,0.0,2.62144e-06,0.0,0.0,268435456.0,1.104672658436214e-06,2097152,2.62144e-06,0.0,2.62144e-06,0.0,2.62144e-06,MTE2_GM,True,,访存Bound(GM),ASW_Basic兜底 (StreamK未过: 2_单核K段下限: K/grid_K >= 256B/dtype 且 grid_K>=2) asw_demo_reduce_core,16,16,256,256,128,bf16,bf16,bf16,False,False,False,True,0,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 跌破搬移效率下限反而更慢)",2097152.0,0.0,2.62144e-06,0.0,2.62144e-06,0.0,0.0,268435456.0,1.104672658436214e-06,2097152,2.62144e-06,0.0,2.62144e-06,0.0,2.62144e-06,MTE2_GM,True,,访存Bound(GM),ASW_Basic兜底 (StreamK未过: 2_单核K段下限: K/grid_K >= 256B/dtype 且 grid_K>=2)
1 case_id batch_a batch_b m n k dtype_a dtype_b dtype_c trans_a trans_b has_bias out_nd deterministic_level plan_case_id plan_branch plan_npu plan_op plan_used_core_num plan_split_b plan_m_cnt plan_n_cnt plan_grid_k plan_core_map plan_b_core plan_merge_b0 plan_single_core_m plan_single_core_n plan_single_core_k plan_k_l1 plan_b_l1 plan_l1_form plan_base_m plan_base_n plan_base_k plan_l2_policy_in plan_l2_policy_out plan_swizzle_w plan_workspace_bytes plan_tail_strategy plan_tail_m_cnt plan_tail_n_cnt plan_tail_k_cnt plan_tail_m_main plan_tail_n_main plan_tail_block_cnt plan_tail_wave_num plan_fixpipe_unitflag plan_out_dtype_bytes plan_note gm_read_bytes l2_read_bytes t_mte2_gm t_mte2_l2 t_mte2 dma_cmd_count t_dma_cmd cube_flops t_mmad fixpipe_bytes t_fixpipe t_reduce t_steady t_drain t_total bottleneck feasible violations bound_type advice
2 to_matmul_demo 1 1 2048 2048 2048 bf16 bf16 bf16 False False False True 0 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 16777216 0.0 1.048576e-05 0.0 1.048576e-05 0.0 0.0 17179869184.0 3.534952506995885e-05 8388608 5.24288e-06 0.0 3.534952506995885e-05 0.0 3.534952506995885e-05 MMAD True 计算Bound BatchA=1或BatchB=1, 折叠转普通Matmul
3 special_k0_demo 128 128 256 256 0 bf16 bf16 bf16 False False False True 0 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 核 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 16777216 1.048576e-05 0.0 1.048576e-05 0.0 1.048576e-05 FIXPIPE True 写出Bound K=0纯写值
4 special_k1_demo 128 128 256 256 1 bf16 bf16 bf16 False False False True 0 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乒乓流水) 131072 0.0 8.192e-08 0.0 8.192e-08 0.0 0.0 8388608.0 6.206060606060606e-07 16777216 1.048576e-05 0.0 1.048576e-05 0.0 1.048576e-05 FIXPIPE True 写出Bound K=1逐元素乘, 走AIV向量通路
5 merge_demo_k_trunc 2048 2048 32 32 256 bf16 bf16 bf16 False False False True 0 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] 2097152 0.0 4.194304e-05 0.0 4.2743039999999997e-05 16.0 8.000000000000001e-07 134217728.0 8.837381267489712e-06 131072 2.62144e-06 0.0 4.2743039999999997e-05 3.0192408230452674e-07 4.3044964082304525e-05 MTE2_GM True 访存Bound(GM) 两分支均合法, 仲裁: [分界条件] MergeBatch最优=True (k_L1=K(截断); b_core=64 vs 阈值 b0*(T_comp+T_write)/T_cmd=6.0; drain惩罚=(b0-1)*(T_comp+T_write)=0.23us, 搬移节省=b_core*(1-1/b0)*T_cmd=2.40us); [时延模型] T_MergeBatch=43.04us vs T_IterBatch=45.22us -> MergeBatch更优; [裁决] MergeBatch
6 merge_iter_arbitrate 128 128 64 64 512 bf16 bf16 bf16 False False False True 0 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 524288 0.0 1.048576e-05 0.0 1.0685759999999999e-05 4 2.0000000000000002e-07 16777216.0 1.104672658436214e-06 32768 6.5536e-07 0.0 1.0685759999999999e-05 4.400081646090535e-07 1.1125768164609053e-05 MTE2_GM True 访存Bound(GM) 两分支均合法, 仲裁: [分界条件] MergeBatch最优=False (k_L1=K(截断); b_core=4 vs 阈值 b0*(T_comp+T_write)/T_cmd=17.6; drain惩罚=(b0-1)*(T_comp+T_write)=0.44us, 搬移节省=b_core*(1-1/b0)*T_cmd=0.10us); [时延模型] T_MergeBatch=11.49us vs T_IterBatch=11.13us -> IterBatch更优; [裁决] IterBatch
7 iter_demo_form_b 128 128 64 64 256 bf16 bf16 bf16 False False False True 0 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 262144 0.0 5.24288e-06 0.0 5.4428799999999995e-06 4 2.0000000000000002e-07 8388608.0 5.52336329218107e-07 32768 6.5536e-07 0.0 5.4428799999999995e-06 3.0192408230452674e-07 5.744804082304526e-06 MTE2_GM True 访存Bound(GM) 仅 IterBatch 条件满足
8 iter_demo_form_d 64 64 64 64 8192 bf16 bf16 bf16 False False False True 0 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 4194304 0.0 8.388608e-05 0.0 8.468608e-05 16 8.000000000000001e-07 134217728.0 8.837381267489712e-06 16384 3.2768e-07 0.0 8.468608e-05 7.16176329218107e-07 8.540225632921811e-05 MTE2_GM True 访存Bound(GM) 仅 IterBatch 条件满足
9 streamk_demo 4 4 128 128 10240 bf16 bf16 bf16 False False False True 0 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写最终 327680.0 0.0 6.5536e-06 0.0 6.5536e-06 0.0 0.0 41943040.0 2.761681646090535e-06 8388608 0.0 5.162220307692308e-05 0.0 3.4067453613053613e-06 5.162220307692308e-05 6.5536e-06 3.4067453613053613e-06 5.5028948438228435e-05 9.960345361305361e-06 FIXPIPE MTE2_GM True 写出Bound 访存Bound(GM) P<=C/2, B/M/N并行度买不满, 切K (grid_K=32)
10 asw_demo_full 2 2 8192 8192 1024 bf16 bf16 bf16 False False False True 0 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反超 67108864.0 0.0 4.194304e-05 0.0 4.194304e-05 0.0 0.0 274877906944.0 0.0005655924011193416 268435456 0.00016777216 0.0 0.0005655924011193416 0.0 0.0005655924011193416 MMAD True 计算Bound ASW_Basic兜底 (StreamK未过: 1_并行缺口: P=B*MN*4B/L0C <= C/2; 2_单核K段下限: K/grid_K >= 256B/dtype 且 grid_K>=2; 3_归约代价可接受)
11 asw_demo_reduce_core 16 16 256 256 128 bf16 bf16 bf16 False False False True 0 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 跌破搬移效率下限反而更慢) 2097152.0 0.0 2.62144e-06 0.0 2.62144e-06 0.0 0.0 268435456.0 1.104672658436214e-06 2097152 2.62144e-06 0.0 2.62144e-06 0.0 2.62144e-06 MTE2_GM True 访存Bound(GM) ASW_Basic兜底 (StreamK未过: 2_单核K段下限: K/grid_K >= 256B/dtype 且 grid_K>=2)

View File

@@ -1,2 +0,0 @@
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
x,StreamK,Ascend950PR,batch_mat_mul_v3,32,1,1,1,3,"B/M/N切出51块, 每块3核切K归约 (归约组内核c负责K段[c*K/3,(c+1)*K/3))",1,1,255,42,228,128,1,K段标准分块流水,128,42,64,allocate(部分和驻留L2),"resident(部分和4B驻留L2, 防精度丢失不随C的fp16/fp8转换)",0,6554520,grid_K=3路切K+归约,1,1,3,0,0,0,0,True,4,"P=8.33, grid_K=3, 部分和驻留L2按4B写出, AIV归约后按C dtype=4B写最终"
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 x StreamK Ascend950PR batch_mat_mul_v3 32 1 1 1 3 B/M/N切出51块, 每块3核切K归约 (归约组内核c负责K段[c*K/3,(c+1)*K/3)) 1 1 255 42 228 128 1 K段标准分块流水 128 42 64 allocate(部分和驻留L2) resident(部分和4B驻留L2, 防精度丢失不随C的fp16/fp8转换) 0 6554520 grid_K=3路切K+归约 1 1 3 0 0 0 0 True 4 P=8.33, grid_K=3, 部分和驻留L2按4B写出, AIV归约后按C dtype=4B写最终

View File

@@ -1,3 +0,0 @@
case_id,batch_a,batch_b,m,n,k,dtype_a,dtype_b,dtype_c,out_nd
mix,4,4,128,128,10240,fp8,bf16,bf16,1
nond,4,4,128,128,10240,bf16,bf16,bf16,0
1 case_id batch_a batch_b m n k dtype_a dtype_b dtype_c out_nd
2 mix 4 4 128 128 10240 fp8 bf16 bf16 1
3 nond 4 4 128 128 10240 bf16 bf16 bf16 0

View File

@@ -1,4 +0,0 @@
case_id,batch_a,batch_b,m,n,k,dtype_a,dtype_b,dtype_c,trans_a,trans_b,has_bias,out_nd,deterministic_level,plan_case_id,plan_branch,plan_npu,plan_op,plan_used_core_num,plan_split_b,plan_m_cnt,plan_n_cnt,plan_grid_k,plan_core_map,plan_b_core,plan_merge_b0,plan_single_core_m,plan_single_core_n,plan_single_core_k,plan_k_l1,plan_b_l1,plan_l1_form,plan_base_m,plan_base_n,plan_base_k,plan_l2_policy_in,plan_l2_policy_out,plan_swizzle_w,plan_workspace_bytes,plan_tail_strategy,plan_tail_m_cnt,plan_tail_n_cnt,plan_tail_k_cnt,plan_tail_m_main,plan_tail_n_main,plan_tail_block_cnt,plan_tail_wave_num,plan_fixpipe_unitflag,plan_out_dtype_bytes,plan_note,gm_read_bytes,l2_read_bytes,t_mte2_gm,t_mte2_l2,t_mte2,dma_cmd_count,t_dma_cmd,cube_flops,t_mmad,fixpipe_bytes,t_fixpipe,t_reduce,t_steady,t_drain,t_total,bottleneck,feasible,violations,bound_type,advice
x,51,51,255,42,682,fp32,fp32,fp32,False,False,False,True,0,x,StreamK,Ascend950PR,batch_mat_mul_v3,32,1,1,1,3,"B/M/N切出51块, 每块3核切K归约 (归约组内核c负责K段[c*K/3,(c+1)*K/3))",1,1,255,42,228,128,1,K段标准分块流水,128,42,64,allocate(部分和驻留L2),"resident(部分和4B驻留L2, 防精度丢失不随C的fp16/fp8转换)",0,6554520,grid_K=3路切K+归约,1,1,3,0,0,0,0,True,4,"P=8.33, grid_K=3, 部分和驻留L2按4B写出, AIV归约后按C dtype=4B写最终",465578.6666666667,0.0,9.311573333333333e-06,0.0,9.311573333333333e-06,0.0,0.0,29797034.666666668,1.9619446694101507e-06,262144,1.6131938461538462e-06,3.674316083916084e-07,9.311573333333333e-06,3.674316083916084e-07,9.679004941724942e-06,MTE2_GM,True,,访存Bound(GM),"切B分支条件不满足, 落 StreamK"
y,2,2,64,16,32,fp16,fp16,fp16,False,False,False,True,0,y,ASW_Basic_降核,Ascend950PR,batch_mat_mul_v3,1,1,1,1,1,"降核: 只用1核, 每核一个L0C满载输出块, 其余核闲置",0,1,64,16,32,32,1,标准核内流水,64,16,32,allocate,direct_gm,0,0,不涉及(每核一块无尾轮),1,1,1,0,0,0,0,True,2,"P=0.03<C, 降核是理性选择 (强切则 tile 跌破搬移效率下限反而更慢)",10240.0,0.0,2.048e-07,0.0,2.048e-07,0.0,0.0,131072.0,8.630255144032922e-09,4096,8.192e-08,0.0,2.048e-07,0.0,2.048e-07,MTE2_GM,True,,访存Bound(GM),"ASW_Basic兜底 (StreamK未过: 2_单核K段下限: K/grid_K >= 256B/dtype 且 grid_K>=2; 3_归约代价可接受: K > grid_K^2/(grid_K-1)*theta_c) [自检违规: dValue=64B < 下限 128B, K 段连续维搬移效率崩塌] —— 方案生成存在缺陷, 需人工复核"
z,256,256,128,1024,8,bf16,bf16,bf16,False,False,False,True,0,z,IterBatch,Ascend950PR,batch_mat_mul_v3,32,32,1,1,1,切B轮转分配(核间零重复读零依赖),8,1,128,1024,8,8,2,b_双batch乒乓,128,256,16,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=36KB <= L1,147456,0.0,2.94912e-06,0.0,3.34912e-06,8,4.0000000000000003e-07,16777216.0,1.104672658436214e-06,2097152,4.194304e-05,0.0,4.194304e-05,5.380964082304527e-06,4.7324004082304525e-05,FIXPIPE,True,,写出Bound,仅 IterBatch 条件满足
1 case_id batch_a batch_b m n k dtype_a dtype_b dtype_c trans_a trans_b has_bias out_nd deterministic_level plan_case_id plan_branch plan_npu plan_op plan_used_core_num plan_split_b plan_m_cnt plan_n_cnt plan_grid_k plan_core_map plan_b_core plan_merge_b0 plan_single_core_m plan_single_core_n plan_single_core_k plan_k_l1 plan_b_l1 plan_l1_form plan_base_m plan_base_n plan_base_k plan_l2_policy_in plan_l2_policy_out plan_swizzle_w plan_workspace_bytes plan_tail_strategy plan_tail_m_cnt plan_tail_n_cnt plan_tail_k_cnt plan_tail_m_main plan_tail_n_main plan_tail_block_cnt plan_tail_wave_num plan_fixpipe_unitflag plan_out_dtype_bytes plan_note gm_read_bytes l2_read_bytes t_mte2_gm t_mte2_l2 t_mte2 dma_cmd_count t_dma_cmd cube_flops t_mmad fixpipe_bytes t_fixpipe t_reduce t_steady t_drain t_total bottleneck feasible violations bound_type advice
2 x 51 51 255 42 682 fp32 fp32 fp32 False False False True 0 x StreamK Ascend950PR batch_mat_mul_v3 32 1 1 1 3 B/M/N切出51块, 每块3核切K归约 (归约组内核c负责K段[c*K/3,(c+1)*K/3)) 1 1 255 42 228 128 1 K段标准分块流水 128 42 64 allocate(部分和驻留L2) resident(部分和4B驻留L2, 防精度丢失不随C的fp16/fp8转换) 0 6554520 grid_K=3路切K+归约 1 1 3 0 0 0 0 True 4 P=8.33, grid_K=3, 部分和驻留L2按4B写出, AIV归约后按C dtype=4B写最终 465578.6666666667 0.0 9.311573333333333e-06 0.0 9.311573333333333e-06 0.0 0.0 29797034.666666668 1.9619446694101507e-06 262144 1.6131938461538462e-06 3.674316083916084e-07 9.311573333333333e-06 3.674316083916084e-07 9.679004941724942e-06 MTE2_GM True 访存Bound(GM) 切B分支条件不满足, 落 StreamK
3 y 2 2 64 16 32 fp16 fp16 fp16 False False False True 0 y ASW_Basic_降核 Ascend950PR batch_mat_mul_v3 1 1 1 1 1 降核: 只用1核, 每核一个L0C满载输出块, 其余核闲置 0 1 64 16 32 32 1 标准核内流水 64 16 32 allocate direct_gm 0 0 不涉及(每核一块无尾轮) 1 1 1 0 0 0 0 True 2 P=0.03<C, 降核是理性选择 (强切则 tile 跌破搬移效率下限反而更慢) 10240.0 0.0 2.048e-07 0.0 2.048e-07 0.0 0.0 131072.0 8.630255144032922e-09 4096 8.192e-08 0.0 2.048e-07 0.0 2.048e-07 MTE2_GM True 访存Bound(GM) ASW_Basic兜底 (StreamK未过: 2_单核K段下限: K/grid_K >= 256B/dtype 且 grid_K>=2; 3_归约代价可接受: K > grid_K^2/(grid_K-1)*theta_c) [自检违规: dValue=64B < 下限 128B, K 段连续维搬移效率崩塌] —— 方案生成存在缺陷, 需人工复核
4 z 256 256 128 1024 8 bf16 bf16 bf16 False False False True 0 z IterBatch Ascend950PR batch_mat_mul_v3 32 32 1 1 1 切B轮转分配(核间零重复读零依赖) 8 1 128 1024 8 8 2 b_双batch乒乓 128 256 16 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=36KB <= L1 147456 0.0 2.94912e-06 0.0 3.34912e-06 8 4.0000000000000003e-07 16777216.0 1.104672658436214e-06 2097152 4.194304e-05 0.0 4.194304e-05 5.380964082304527e-06 4.7324004082304525e-05 FIXPIPE True 写出Bound 仅 IterBatch 条件满足

View File

@@ -1,4 +0,0 @@
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
x,StreamK,Ascend950PR,batch_mat_mul_v3,32,1,1,1,3,"B/M/N切出51块, 每块3核切K归约 (归约组内核c负责K段[c*K/3,(c+1)*K/3))",1,1,255,42,228,128,1,K段标准分块流水,128,42,64,allocate(部分和驻留L2),"resident(部分和4B驻留L2, 防精度丢失不随C的fp16/fp8转换)",0,6554520,grid_K=3路切K+归约,1,1,3,0,0,0,0,True,4,"P=8.33, grid_K=3, 部分和驻留L2按4B写出, AIV归约后按C dtype=4B写最终"
y,ASW_Basic_降核,Ascend950PR,batch_mat_mul_v3,1,1,1,1,1,"降核: 只用1核, 每核一个L0C满载输出块, 其余核闲置",0,1,64,16,32,32,1,标准核内流水,64,16,32,allocate,direct_gm,0,0,不涉及(每核一块无尾轮),1,1,1,0,0,0,0,True,2,"P=0.03<C, 降核是理性选择 (强切则 tile 跌破搬移效率下限反而更慢)"
z,IterBatch,Ascend950PR,batch_mat_mul_v3,32,32,1,1,1,切B轮转分配(核间零重复读零依赖),8,1,128,1024,8,8,2,b_双batch乒乓,128,256,16,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=36KB <= L1
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 x StreamK Ascend950PR batch_mat_mul_v3 32 1 1 1 3 B/M/N切出51块, 每块3核切K归约 (归约组内核c负责K段[c*K/3,(c+1)*K/3)) 1 1 255 42 228 128 1 K段标准分块流水 128 42 64 allocate(部分和驻留L2) resident(部分和4B驻留L2, 防精度丢失不随C的fp16/fp8转换) 0 6554520 grid_K=3路切K+归约 1 1 3 0 0 0 0 True 4 P=8.33, grid_K=3, 部分和驻留L2按4B写出, AIV归约后按C dtype=4B写最终
3 y ASW_Basic_降核 Ascend950PR batch_mat_mul_v3 1 1 1 1 1 降核: 只用1核, 每核一个L0C满载输出块, 其余核闲置 0 1 64 16 32 32 1 标准核内流水 64 16 32 allocate direct_gm 0 0 不涉及(每核一块无尾轮) 1 1 1 0 0 0 0 True 2 P=0.03<C, 降核是理性选择 (强切则 tile 跌破搬移效率下限反而更慢)
4 z IterBatch Ascend950PR batch_mat_mul_v3 32 32 1 1 1 切B轮转分配(核间零重复读零依赖) 8 1 128 1024 8 8 2 b_双batch乒乓 128 256 16 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=36KB <= L1

View File

@@ -150,12 +150,17 @@ class TestIssueRegression(unittest.TestCase):
def setUp(self): def setUp(self):
self.router = BranchRouter() self.router = BranchRouter()
def test_issue4_k1_small_batch_no_crash(self): def test_issue4_k1_small_batch_real_plan(self):
# issue#4 P0: K=1 且 B<128 不崩溃, 应标注"暂无理论方案" # issue#4/#12/#17: K=1 且 B<128 不崩溃, 且给出 AIV 单缓冲真实方案 (不再是无方案占位)
r = self.router.route(mkcase(64, 8192, 32, 1, dtype_a="int8", dtype_b="int8")) case = mkcase(64, 8192, 32, 1, dtype_a="int8", dtype_b="int8")
self.assertIsNotNone(r["plan"]) # 占位方案, 不为 None r = self.router.route(case)
self.assertEqual(r["plan"].used_core_num, 0) # 标注无方案 self.assertIsNotNone(r["plan"])
self.assertIn("暂无理论方案", r["arbitration"]) self.assertEqual(r["branch"], "特殊分支")
self.assertEqual(r["plan"].used_core_num, 64) # AIV 核
self.assertNotIn("暂无理论方案", r["arbitration"])
self.assertIn("单缓冲", r["plan"].note)
from bmm_theory.constraints import check_plan_constraints
self.assertEqual(check_plan_constraints(case, r["plan"]), [])
def test_issue5_asw_reduced_core_base_k_dtype_aware(self): def test_issue5_asw_reduced_core_base_k_dtype_aware(self):
# issue#5: ASW 降核 base_k 按 dtype 反推, fp32 不再 L0A 溢出 # issue#5: ASW 降核 base_k 按 dtype 反推, fp32 不再 L0A 溢出
@@ -204,6 +209,97 @@ class TestIssueRegression(unittest.TestCase):
self.assertNotEqual(r["branch"], "StreamK") self.assertNotEqual(r["branch"], "StreamK")
class TestIssueRegression2(unittest.TestCase):
"""第三轮复评问题 (#17-#20) + 恢复 #11-#15 回归."""
def setUp(self):
self.router = BranchRouter()
def test_issue11_streamk_fixpipe_no_double_count(self):
# issue#11/#17: 部分和写出只经 t_reduce 计账一次; 稳态 fixpipe 不得再计
from bmm_theory.branches.stream_k import StreamKBranch
case = mkcase(4, 128, 128, 10240)
sk = StreamKBranch().analyze(case)
self.assertTrue(sk.capable)
t = sk.timing
self.assertAlmostEqual(t.t_fixpipe, 0.0) # 归约串行口径下无稳态 fixpipe 账
self.assertAlmostEqual(t.fixpipe_bytes, 0.0)
# 端到端 = max(MTE2, MMAD) + 归约, 不再虚高到 55us/FIXPIPE
expect = max(t.t_mte2, t.t_mmad) + t.t_reduce
self.assertAlmostEqual(t.t_total, expect)
self.assertEqual(t.bottleneck, "MTE2_GM")
def test_issue12_k1_pingpong_still_ok(self):
# issue#12/#17: K=1 且 B>=128 仍走 UB 乒乓 (原行为不变)
r = self.router.route(mkcase(128, 256, 256, 1))
self.assertEqual(r["branch"], "特殊分支")
self.assertIn("乒乓", r["plan"].l1_form)
self.assertIsNotNone(r["timing"])
def test_issue13_merge_b0_l0ab_capped(self):
# issue#13: MergeBatch 瘦长 case 的 b0 受 L0A/L0B 容量约束 (B=811 M=33 N=1 fp32)
from bmm_theory.constraints import check_plan_constraints
case = mkcase(811, 33, 1, 2459, dtype_a="fp32", dtype_b="fp32", dtype_c="fp32")
r = self.router.route(case)
self.assertEqual(r["branch"], "MergeBatch")
p = r["plan"]
self.assertLessEqual(p.base_m * p.base_k * 4 * 2, 64 * 1024) # L0A 容量内
self.assertLessEqual(p.base_n * p.base_k * 4 * 2, 64 * 1024) # L0B 容量内
self.assertEqual(check_plan_constraints(case, p), [])
def test_issue13_router_fallback_when_winner_infeasible(self):
# issue#13: 仲裁胜出的 MergeBatch 自检违规时, 回退到可行候选 IterBatch
from bmm_theory.constraints import check_plan_constraints
case = mkcase(256, 1, 256, 4096, dtype_a="int8", dtype_b="int8") # 原 0.2% 违规样例
r = self.router.route(case)
self.assertEqual(r["branch"], "IterBatch") # 回退
self.assertIn("自检违规", r["arbitration"])
self.assertIn("回退", r["arbitration"])
self.assertEqual(check_plan_constraints(case, r["plan"]), [])
def test_issue15_input_validation(self):
# issue#15: 非法维度/负值必须抛错, 不再静默产出伪方案
for kw in (dict(m=0), dict(m=-5), dict(n=0), dict(k=-1),
dict(batch_a=0), dict(batch_b=-3)):
with self.assertRaises(ValueError, msg=str(kw)):
BmmCase(case_id="bad", **kw)
with self.assertRaises(ValueError):
BmmCase(case_id="bad", m=64, n=64, k=1, dtype_a="xxx")
def test_issue18_placeholder_plan_infeasible_in_evaluate(self):
# issue#18: 占位方案(used_core_num=0)在 evaluate 中必须不可行,
# 不得被当作可行方案给出正常时延
from bmm_theory.evaluator import PlanEvaluator
from bmm_theory.models import ImplPlan
# K=1 且 B<128 已恢复真实单缓冲方案 (#17), 故直接构造占位 plan 验证约束层
case = mkcase(64, 8192, 32, 1, dtype_a="int8", dtype_b="int8")
r = self.router.route(case)
self.assertGreater(r["plan"].used_core_num, 0) # 真实方案
ph = ImplPlan(case_id="ph", branch="特殊分支", used_core_num=0,
note="该区域暂无理论方案(进入条件不满足)")
er = PlanEvaluator().evaluate(case, ph)
self.assertFalse(er.feasible, "占位方案应判不可行")
self.assertIn("used_core_num", er.violations)
def test_issue19_transpose_dvalue_guard_effective(self):
# issue#19: 转置感知 dValue 判据在生成守卫/条件4/约束三处同源后真正生效.
# 判别形状: B=64 M=4096 N=64 K=4096 bf16 —— d 形态 k_l1=16,
# 均不转置时 dv_a=k_l1*2=32B <128 挡下 (B 侧 dv_b=N*2=128B 恰好达标也不放行,
# 因为两侧切 K 两侧都要高效);
# A 转置后 dv_a=M*2=8192B, 应能走 IterBatch 形态 d.
from bmm_theory.constraints import check_plan_constraints
c_not = BmmCase(case_id="x", batch_a=64, batch_b=64, m=4096, n=64, k=4096,
trans_a=False, trans_b=False)
r_not = self.router.route(c_not)
self.assertNotEqual(r_not["branch"], "IterBatch") # 非转置被 dValue 守卫挡下
c_tr = BmmCase(case_id="x", batch_a=64, batch_b=64, m=4096, n=64, k=4096,
trans_a=True, trans_b=False)
r_tr = self.router.route(c_tr)
self.assertEqual(r_tr["branch"], "IterBatch") # A 转置 M 向连续, 守卫放行
self.assertIn("d_", r_tr["plan"].l1_form)
self.assertEqual(check_plan_constraints(c_tr, r_tr["plan"]), [])
class TestFp4Support(unittest.TestCase): class TestFp4Support(unittest.TestCase):
"""fp4 (0.5B) dtype 支持 (对齐 bmmv3, 2026-09-03).""" """fp4 (0.5B) dtype 支持 (对齐 bmmv3, 2026-09-03)."""