From 7cd30e106efd943641414041dc7993e0028d2faa Mon Sep 17 00:00:00 2001 From: Yangwook Kang Date: Sat, 4 Apr 2026 22:25:40 -0700 Subject: [PATCH] =?UTF-8?q?Fix=20Router=E2=86=92HBM=5FCTRL=20lines=20visib?= =?UTF-8?q?ility=20in=20cube=5Fview?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Draw HBM connection lines last (on top of component blocks). PE routers: thicker (1.5px, opacity 0.6) with dashed style. Relay routers: thinner (0.7px, opacity 0.2). Co-Authored-By: Claude Opus 4.6 (1M context) --- docs/diagrams/cube_view.svg | 64 ++++++++++++++-------------- src/kernbench/topology/visualizer.py | 35 ++++++++++----- 2 files changed, 56 insertions(+), 43 deletions(-) diff --git a/docs/diagrams/cube_view.svg b/docs/diagrams/cube_view.svg index befc33c..522b909 100644 --- a/docs/diagrams/cube_view.svg +++ b/docs/diagrams/cube_view.svg @@ -126,7 +126,6 @@ r0c0 - PE0 @@ -139,7 +138,6 @@ 256GB/s r0c1 - PE1 @@ -149,19 +147,15 @@ 256GB/s r0c2 - r0c3 - r0c4 - UCIe-N.c2 r0c5 - UCIe-E.c0 @@ -170,29 +164,23 @@ r1c0 - UCIe-W.c1 r1c1 - r1c2 - r1c3 - r1c4 - PE2 256GB/s r1c5 - PE3 @@ -202,37 +190,28 @@ 256GB/s r2c0 - M_CPU r2c1 - r2c4 - r2c5 - r3c0 - SRAM r3c1 - r3c4 - r3c5 - r4c0 - PE4 @@ -242,29 +221,23 @@ 256GB/s r4c1 - PE5 256GB/s r4c2 - r4c3 - r4c4 - r4c5 - UCIe-E.c2 r5c0 - UCIe-W.c3 @@ -273,19 +246,15 @@ r5c1 - UCIe-S.c1 r5c2 - r5c3 - r5c4 - PE6 @@ -295,7 +264,6 @@ 256GB/s r5c5 - PE7 @@ -306,6 +274,38 @@ UCIe-S.c3 256GB/s + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PE Router diff --git a/src/kernbench/topology/visualizer.py b/src/kernbench/topology/visualizer.py index e3f4105..39965e6 100644 --- a/src/kernbench/topology/visualizer.py +++ b/src/kernbench/topology/visualizer.py @@ -563,16 +563,7 @@ def _render_cube_view_svg(view: ViewGraph, spec: dict) -> str: f'{rkey}' ) - # ── Router → HBM_CTRL line (all routers connect to HBM) ── - hbm_edge_y = hbm_y if py < hbm_y else hbm_y + hbm_h - r_edge_y = py + r_size if py < hbm_y else py - r_size - # Only draw if not inside HBM zone - if abs(r_edge_y - hbm_edge_y) > 10: - parts.append( - f' ' - ) + # ── Router → HBM_CTRL line (deferred, drawn after component blocks) ── # ── Attached component blocks ── # Collect components to draw, positioned outward from router @@ -672,14 +663,36 @@ def _render_cube_view_svg(view: ViewGraph, spec: dict) -> str: # ── PE router → HBM BW annotation ── if pe_items: + pe_hbm_edge = hbm_y if py < hbm_y else hbm_y + hbm_h + pe_r_edge = py + r_size if py < hbm_y else py - r_size bw_x = px + 14 - bw_y = (r_edge_y + hbm_edge_y) / 2 + bw_y = (pe_r_edge + pe_hbm_edge) / 2 parts.append( f' ' f'{agg_bw:.0f}GB/s' ) + # ── Router → HBM_CTRL lines (drawn last, on top of everything) ── + for rkey, rval in routers.items(): + if rval is None: + continue + rx, ry = rval["pos_mm"] + px, py = mm2px(rx, ry) + hbm_edge_y = hbm_y if py < hbm_y else hbm_y + hbm_h + r_edge_y = py + r_size if py < hbm_y else py - r_size + if abs(r_edge_y - hbm_edge_y) > 10: + has_pe = any(a.endswith(".dma") for a in rval.get("attach", [])) + # PE routers: thicker, more visible + sw = "1.5" if has_pe else "0.7" + op = "0.6" if has_pe else "0.2" + parts.append( + f' ' + ) + # ── Legend ── ly = h_px - 35 legend_items = [