analytical-viz: compound tiebreaker — fewer PEs / lower HBM% when latency ties
Every place that picks a single "best" config from the Pareto set now
uses a compound sort key: (latency_ns ↑, pes_used ↑, hbm_utilization ↑).
Primary = latency; when configs tie on latency (common — cp_ring
variants, some placement variants often produce identical numbers),
prefer smaller-footprint picks.
Places updated:
- app.py: sidebar Apply Attn/FFN/Attn+FFN button
- app.py: Physical Layout tab Attn/FFN/Attn+FFN button
- app.py: Auto Suggest tab "Best latency" metric
- app.py: Auto Hardware tab "Best latency" metric (uses parallelism.pes_used
+ parallelism.hbm_utilization since JointScore wraps ConfigScore)
- auto_hardware.py: _best_parallelism_for_hw iteration key
No behavior change when there's a strict latency winner. When there are
ties, the picked config uses fewer PEs and lower HBM utilization.
Verified: all 24 pytest tests pass (default include_attention=True and
include_ffn=True paths unchanged).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -245,14 +245,19 @@ def _best_parallelism_for_hw(
|
||||
matches the caller's attention/FFN/full choice.
|
||||
"""
|
||||
best: ConfigScore | None = None
|
||||
best_key: tuple | None = None
|
||||
for topo in _iter_reduced_parallelism(model, s_kv, mode):
|
||||
cfg = FullConfig(model=model, topo=topo, machine=machine)
|
||||
s = score_config(cfg, include_attention=include_attention,
|
||||
include_ffn=include_ffn)
|
||||
if not (s.fits_memory and s.placement_valid):
|
||||
continue
|
||||
if best is None or s.total_latency_ns < best.total_latency_ns:
|
||||
# Compound tiebreaker: prefer fewer PEs and lower HBM % when latency
|
||||
# ties across variant knobs (cp_ring, placement, kv_shard_mode, etc.).
|
||||
_k = (s.total_latency_ns, s.pes_used, s.hbm_utilization)
|
||||
if best is None or _k < best_key:
|
||||
best = s
|
||||
best_key = _k
|
||||
return best
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user