From 933b428c069a021f914249f51f6837148d5193f4 Mon Sep 17 00:00:00 2001 From: admin Date: Thu, 3 Sep 2026 11:34:20 +0000 Subject: [PATCH] Update BMM_Theory: bmm_theory/timing.py (fix review issues #4-#10) --- BMM/BMM_Theory/bmm_theory/timing.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/BMM/BMM_Theory/bmm_theory/timing.py b/BMM/BMM_Theory/bmm_theory/timing.py index 7779b9d..2c44f94 100644 --- a/BMM/BMM_Theory/bmm_theory/timing.py +++ b/BMM/BMM_Theory/bmm_theory/timing.py @@ -98,18 +98,28 @@ def assemble_timing(t_mte2_gm: float, t_mte2_l2: float, t_dma_cmd: float, t_drain: float, gm_read_bytes: float, l2_read_bytes: float, dma_cmd_count: float, cube_flops: float, - fixpipe_bytes: float) -> HardwareTiming: - """汇总各级时延, 判定瓶颈.""" + fixpipe_bytes: float, + reduce_serial: bool = True) -> HardwareTiming: + """汇总各级时延, 判定瓶颈. + + 归约计账约定 (issue#9): REDUCE 默认**串行追加** (reduce_serial=True, 归约不可 + 掩盖, 体现在 t_drain 中), 不进稳态 max(); 仅当调用方显式声明归约可流水掩盖 + (reduce_serial=False) 时才进稳态 max(). 避免"既取最大又串行追加"的双倍计账. + """ t_mte2 = t_mte2_gm + t_mte2_l2 + t_dma_cmd stages = { "MTE2_GM": t_mte2_gm + t_dma_cmd, "MTE2_L2": t_mte2_l2, "MMAD": t_mmad, "FIXPIPE": t_fixpipe, - "REDUCE": t_reduce, } + if not reduce_serial: + stages["REDUCE"] = t_reduce bottleneck = max(stages, key=stages.get) t_steady = max(stages.values()) + # 归约串行追加时, 若它是全链路最大项则瓶颈标注为 REDUCE (但时延只计一次) + if reduce_serial and t_reduce > t_steady: + bottleneck = "REDUCE" return HardwareTiming( gm_read_bytes=gm_read_bytes, l2_read_bytes=l2_read_bytes, t_mte2_gm=t_mte2_gm, t_mte2_l2=t_mte2_l2, t_mte2=t_mte2,