From afa3b357826105e3716a83b8b28d3191d5492edf Mon Sep 17 00:00:00 2001 From: Jin Pan Date: Thu, 4 Jun 2026 15:57:28 +0000 Subject: [PATCH] fix(run_benchmark): report base norm bandwidth, not the last variant The norm-style parser in _py_parse_and_emit kept the LAST "Bandwidth:" line (`for m_bw in re.finditer(...): pass`). Since #549 made test_layernorm.py run six variants from __main__ (base, fused_add, dynamicquant, smoothquant, fused_add_dynamicquant, fused_add_smoothquant), each printing its own "Bandwidth:" line, the parser reported the slow scalar fused_add_smoothquant path (~1.69 TB/s) as "layernorm" instead of the base fast 128b path (~5.6 TB/s). softmax/rmsnorm were unaffected only because their __main__ runs a single base test (first == last). Take the FIRST match instead: the base op is always benchmarked first; any later "Bandwidth:" lines are fused/quant variants. Verified on MI350X / gfx950 (32768x8192 bf16): layernorm 1.69 -> 5.56 TB/s; softmax 5.69 and rmsnorm 5.85 unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) --- scripts/run_benchmark.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/run_benchmark.sh b/scripts/run_benchmark.sh index 53cbda2cfa..b3fa007704 100755 --- a/scripts/run_benchmark.sh +++ b/scripts/run_benchmark.sh @@ -454,11 +454,14 @@ if tbps is None or tflops is None: tflops = float(m.group(1)) tbps = float(m.group(2)) -# Softmax/Norm-style: "Kernel avg time: X ms" + "Bandwidth: Y GB/s" +# Softmax/Norm-style: "Kernel avg time: X ms" + "Bandwidth: Y GB/s". +# Use the FIRST match: the base op (softmax/layernorm/rmsnorm) is benchmarked +# first, so any later "Bandwidth:" lines come from fused/quant variants printed +# by the same test (e.g. test_layernorm.py also runs fused_add/dynamicquant/ +# smoothquant). Taking the last match reported the slow scalar smoothquant path +# as "layernorm" (~1.69 vs the real ~5.6 TB/s base). if tbps is None: - m_bw = None - for m_bw in re.finditer(r"Bandwidth:\s*([0-9.]+)\s*GB/s", txt): - pass + m_bw = next(re.finditer(r"Bandwidth:\s*([0-9.]+)\s*GB/s", txt), None) if m_bw: tbps = float(m_bw.group(1)) / 1000.0