analytical-viz: Physical Layout scope filter for stage tables

Clicking one of the three Physical Layout tab buttons now persists the
chosen scope in session_state["_pl_active_scope"] and filters the
per-stage latency tables accordingly:

  - attn scope → show only "Attention" stage table
  - ffn scope  → show only "FFN" stage table
  - full scope → show both (default; also matches a fresh sidebar-driven
                  config with no button click yet)

Added a "Layout scope: {label}" header so the user can tell at a glance
which scope's config is loaded.

The pipeline diagram + topology map + weight/tensor sharding + PE
layout continue to show the full model layout — those diagrams give
context that stays useful even when the user is focusing on attn or
FFN. Deeper filtering (e.g., attention-only pipeline stripe) can come
later if needed.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-07-28 14:21:27 -07:00
parent 1a6d52c58a
commit bccc90db82
+15 -2
View File
@@ -521,6 +521,9 @@ with tab_layout:
}
st.session_state["ffn_scope_label"] = \
_pl_ffn_map[_pl_best.ffn_shard_scope]
# Persist the chosen scope so subsequent layout renders filter
# stage tables (attn/ffn/full).
st.session_state["_pl_active_scope"] = _pl_scope
st.success(
f"Loaded latency-optimal {_pl_lbl} config: CP={_pl_best.cp} "
f"TP={_pl_best.tp} PP={_pl_best.pp} DP={_pl_best.dp}"
@@ -529,6 +532,14 @@ with tab_layout:
)
st.rerun()
# Determine the effective scope for filtering the tables below. Default
# to "full" so a fresh page load / sidebar-driven config shows everything.
_pl_active_scope = st.session_state.get("_pl_active_scope", "full")
_pl_show_attn = _pl_active_scope in ("attn", "full")
_pl_show_ffn = _pl_active_scope in ("ffn", "full")
_pl_active_label = _pl_scope_meta[_pl_active_scope][2]
st.markdown(f"### Layout scope: **{_pl_active_label}**")
st.divider()
# Row A: pipeline diagram (color-coded) + per-stage table (formulas).
@@ -688,8 +699,10 @@ with tab_layout:
f"blue=compute, orange=memory, red=comm, grey=trivial."
)
_render_table(_stages_attn, "Attention")
_render_table(_stages_ffn, "FFN")
if _pl_show_attn:
_render_table(_stages_attn, "Attention")
if _pl_show_ffn:
_render_table(_stages_ffn, "FFN")
with st.expander("Symbol glossary (what does T_q, d_h, div... mean?)",
expanded=False):