analytical-viz: buttons pick smallest-fit Pareto point, not fastest

Sidebar Attention/FFN/Attn+FFN buttons and Physical Layout tab buttons
now select the SMALLEST-FIT config from the scope's Pareto set — key
changed from (latency ↑, pes_used ↑, hbm_utilization ↑) to (pes_used ↑,
hbm_utilization ↑, latency ↑). Answers "smallest deployment that's
still Pareto-optimal for this scope" instead of "fastest deployment
achievable".

Left unchanged:
  - "Best latency" metric displays in Auto Suggest / Auto Hardware tabs
    still show the fastest number (informational; the metric labels say
    "Best latency").
  - auto_hardware._best_parallelism_for_hw stays latency-min: it's
    inside HW co-design, where "how fast can each HW candidate go" is
    the primary question.

Verified: 24 pytest tests pass.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-07-28 22:23:34 -07:00
parent 5d7ef48b14
commit 1bce080d79
+12 -9
View File
@@ -237,12 +237,15 @@ with st.sidebar.expander("Parallelism", expanded=True):
"`pe_hbm_gb` or reducing `s_kv`." "`pe_hbm_gb` or reducing `s_kv`."
) )
else: else:
# Compound key: min latency, then fewer PEs, then lower HBM %. # Smallest-fit Pareto point: fewest PEs first, then lowest
# Prefer smaller-footprint configs when they tie on latency. # HBM utilization, then fastest latency as final tiebreaker.
# Gives the smallest deployment that's still Pareto-optimal
# for the chosen scope (matches how the memory-min autosuggest
# thinks — but restricted to this scope's Pareto set).
_sb_best = min(_sb_res.pareto_scores, _sb_best = min(_sb_res.pareto_scores,
key=lambda s: (s.total_latency_ns, key=lambda s: (s.pes_used,
s.pes_used, s.hbm_utilization,
s.hbm_utilization)) s.total_latency_ns))
st.session_state["cp"] = _snap(_sb_best.cp, _CP_OPTS) st.session_state["cp"] = _snap(_sb_best.cp, _CP_OPTS)
st.session_state["tp"] = _snap(_sb_best.tp, _TP_OPTS) st.session_state["tp"] = _snap(_sb_best.tp, _TP_OPTS)
st.session_state["pp"] = _snap(_sb_best.pp, _PP_OPTS) st.session_state["pp"] = _snap(_sb_best.pp, _PP_OPTS)
@@ -584,11 +587,11 @@ with tab_layout:
"`s_kv`." "`s_kv`."
) )
else: else:
# Compound tiebreaker: min latency, then fewer PEs, then lower HBM %. # Smallest-fit Pareto point (see sidebar apply comment).
_pl_best = min(_pl_res.pareto_scores, _pl_best = min(_pl_res.pareto_scores,
key=lambda s: (s.total_latency_ns, key=lambda s: (s.pes_used,
s.pes_used, s.hbm_utilization,
s.hbm_utilization)) s.total_latency_ns))
# Load the winning config into the sidebar's session state. # Load the winning config into the sidebar's session state.
st.session_state["cp"] = _pl_best.cp st.session_state["cp"] = _pl_best.cp
st.session_state["tp"] = _pl_best.tp st.session_state["tp"] = _pl_best.tp