analytical-viz: memory-min buttons reset stale placement/mode session keys

auto_suggest only explores (cp, tp, pp, cp_placement); every other
TopologyConfig field is left at its dataclass default when the score
is computed. The sidebar's memory-min apply used to update only
cp/tp/pp/dp/cp_placement, so any stale session_state value from a
previous user interaction (most damaging: tp_placement="cube") would
carry over into the rerun and produce a topology the memory-min search
never scored — visibly, cubes_used could balloon (e.g. Llama 3 70B
Attn scope: auto_suggest picks 1 cube; stale tp_placement="cube" made
the applied config span 8 cubes).

Fix: after picking a Suggestion, reset tp_placement, kv_mode,
cp_ring_variant, ep back to their TopologyConfig defaults, and drop
the ffn_scope_label key (dynamic string; falls back to the TP+CP
default index on re-render). Now the sliders + placement + mode state
after apply exactly reproduce the topology auto_suggest scored.

test_auto_suggest_cubes_match_default_topology asserts, across four
model/skv combinations and all three scopes, that a TopologyConfig
built from (cp, tp, pp, cp_placement) plus dataclass defaults has the
same cubes_used the Suggestion reports.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-07-28 23:45:38 -07:00
parent 4ded67a443
commit 9c5062bdfb
2 changed files with 47 additions and 1 deletions
+12
View File
@@ -252,7 +252,19 @@ with st.sidebar.expander("Parallelism", expanded=True):
st.session_state["tp"] = _snap(_sb_sug.tp, _TP_OPTS)
st.session_state["pp"] = _snap(_sb_sug.pp, _PP_OPTS)
st.session_state["dp"] = 1
st.session_state["ep"] = 1
st.session_state["cp_placement"] = _sb_sug.cp_placement
# auto_suggest only explores (cp, tp, pp, cp_placement); reset
# every other TopologyConfig field to its dataclass default so
# the applied topology matches what memory-min actually scored
# (else stale tp_placement="cube" etc. explodes cubes_used).
st.session_state["tp_placement"] = "pe"
st.session_state["kv_mode"] = "split"
st.session_state["cp_ring_variant"] = "kv"
# ffn_scope_label is a dynamic string (embeds current tp/cp) —
# dropping the key lets the radio fall back to index=1 which is
# "TP+CP", the TopologyConfig default.
st.session_state.pop("ffn_scope_label", None)
st.session_state["_pl_active_scope"] = _sb_scope
st.rerun()