analytical-viz: PE view keeps CP rank locator visible at TP>=8
The Per-PE layout diagram used to color-code + label CP ranks only
when cp_placement=='pe' (CP packed intra-cube). At TP>=8 the TP dim
fills the cube, cp_placement gets pushed to 'cube', the intra-cube CP
branch is skipped, and the CP rank tag silently disappeared from
cubes, per-PE headers, and the figure title. Users at TP>=8 had no
way to tell which of the CP groups the diagram was drawing.
Fix: when cp_placement=='cube' and CP>1, add
- cube header suffix: '[CP rank 0 of {CP}]'
- per-PE header suffix: ' | CP=0'
- figure title: 'CP={CP} (showing 1 of CP groups; others identical)'
Behavior at cp_placement=='pe' is unchanged — the existing per-CP-rank
palette + 'CP={rank}' label still fire. CP=1 adds no locators at all.
test_pe_weight_layout covers four cases: TP=8/CP=4 (cube placement,
locator appears), TP=2/CP=4 forced to pe placement (regression:
per-rank labels still there, cube tag not added), CP=1 (no locators),
TP=16/CP=2 (both spilled cubes carry the CP-rank-0 tag).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -114,6 +114,14 @@ def draw_pe_layout(cfg: FullConfig, ax=None):
|
||||
cube_h = 6.0
|
||||
cube_gap = 0.6
|
||||
|
||||
# When TP fills the cube (TP>=8), cp_placement is "cube" and CP
|
||||
# ranks span cubes — the intra-cube CP-color branch below is
|
||||
# skipped. Surface which CP rank this figure is showing so users
|
||||
# aren't guessing which of `CP` groups is drawn.
|
||||
_cube_place_tag = ""
|
||||
if cfg.topo.cp_placement == "cube" and cfg.topo.cp > 1:
|
||||
_cube_place_tag = f" [CP rank 0 of {cfg.topo.cp}]"
|
||||
|
||||
for cube_idx in range(n_cubes):
|
||||
x0 = cube_idx * (cube_w + cube_gap)
|
||||
y0 = 0
|
||||
@@ -125,7 +133,8 @@ def draw_pe_layout(cfg: FullConfig, ax=None):
|
||||
)
|
||||
ax.add_patch(rect)
|
||||
ax.text(x0 + cube_w / 2, y0 + cube_h + 0.1,
|
||||
f"Cube {cube_idx} (PEs {cube_idx*8}-{cube_idx*8+7})",
|
||||
f"Cube {cube_idx} (PEs {cube_idx*8}-{cube_idx*8+7})"
|
||||
+ _cube_place_tag,
|
||||
ha="center", va="bottom", fontsize=11, fontweight="bold")
|
||||
|
||||
pe_pad_x = 0.15
|
||||
@@ -180,7 +189,14 @@ def draw_pe_layout(cfg: FullConfig, ax=None):
|
||||
_tp_rank = pe_id_in_group % tp
|
||||
_fc = "#f0f7ff"
|
||||
_ec = "#3a86ff"
|
||||
_cp_label = ""
|
||||
# cp_placement=="cube" with CP>1: the whole cube is
|
||||
# one CP rank (rank 0 by convention — see cube title
|
||||
# tag above). Add the locator so users know what
|
||||
# rank this per-PE data belongs to.
|
||||
if _cp_place == "cube" and _cp_val > 1:
|
||||
_cp_label = " | CP=0"
|
||||
else:
|
||||
_cp_label = ""
|
||||
|
||||
pe_rect = patches.Rectangle(
|
||||
(px, py), pe_w, pe_h,
|
||||
@@ -250,9 +266,12 @@ def draw_pe_layout(cfg: FullConfig, ax=None):
|
||||
ax.set_aspect("equal")
|
||||
ax.axis("off")
|
||||
|
||||
_title_cp = f", CP={cfg.topo.cp}"
|
||||
if cfg.topo.cp_placement == "cube" and cfg.topo.cp > 1:
|
||||
_title_cp += " (showing 1 of CP groups; others identical)"
|
||||
title = (
|
||||
f"Per-PE layout of one CP group "
|
||||
f"(TP={tp}, H_q={cfg.model.h_q}, H_kv={cfg.model.h_kv})"
|
||||
f"(TP={tp}{_title_cp}, H_q={cfg.model.h_q}, H_kv={cfg.model.h_kv})"
|
||||
f" | KV mode: {cfg.topo.kv_shard_mode}"
|
||||
)
|
||||
ax.set_title(title, fontsize=11, fontweight="bold")
|
||||
|
||||
Reference in New Issue
Block a user