Tune page: visual SPSA parameter panel
Each parameter gets a range track (min to max) with its start tick, current value and the drift between them. The panel header shows iteration progress. Parameters can be filtered by name and sorted by how far they moved. The old table stays below as "Parameter details". Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TyAt5S5MAwLBY2idan1SwU
This commit is contained in:
1 parent
4fffbf50b4
commit
9aa7678b62
4 files changed
+410
-1
No files matched your search
@@ -0,0 +1,225 @@
|
|||||||
|
/* SPSA parameter panel (Tune pages).
|
||||||
|
|
||||||
|
One row per parameter. The track is the parameter's allowed range, the hollow
|
||||||
|
tick is where tuning started, the dot is where it is now, and the bar between
|
||||||
|
them is how far it has travelled. A parameter pressed against its limit gets
|
||||||
|
a warm dot, because that usually means the range is too tight. */
|
||||||
|
|
||||||
|
.spsa-panel {
|
||||||
|
--spsa-line: var(--line, #2a303a);
|
||||||
|
--spsa-muted: var(--muted, var(--color-font3, #8b95a7));
|
||||||
|
--spsa-ink: var(--color-font1, #e6e9ef);
|
||||||
|
--spsa-fill: var(--accent, #4c8dff);
|
||||||
|
--spsa-limit: #e8955a;
|
||||||
|
--spsa-mono: var(--font-mono, 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------- Progress ---------- */
|
||||||
|
|
||||||
|
.spsa-summary {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: auto 1fr auto;
|
||||||
|
align-items: end;
|
||||||
|
gap: 8px 28px;
|
||||||
|
padding: 4px 0 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spsa-iter { display: flex; flex-direction: column; gap: 2px; }
|
||||||
|
|
||||||
|
.spsa-big {
|
||||||
|
font-family: var(--spsa-mono);
|
||||||
|
font-size: 30px;
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 1;
|
||||||
|
color: var(--spsa-ink);
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spsa-of { font-size: 13px; color: var(--spsa-muted); }
|
||||||
|
|
||||||
|
.spsa-bar {
|
||||||
|
height: 6px;
|
||||||
|
margin-bottom: 7px;
|
||||||
|
background: var(--spsa-line);
|
||||||
|
border-radius: 3px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spsa-bar > span {
|
||||||
|
display: block;
|
||||||
|
height: 100%;
|
||||||
|
background: var(--spsa-fill);
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spsa-facts { display: flex; gap: 22px; margin: 0; }
|
||||||
|
.spsa-facts div { text-align: right; }
|
||||||
|
.spsa-facts dt { font-size: 12.5px; color: var(--spsa-muted); }
|
||||||
|
.spsa-facts dd {
|
||||||
|
margin: 0;
|
||||||
|
font-family: var(--spsa-mono);
|
||||||
|
font-size: 15px;
|
||||||
|
color: var(--spsa-ink);
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------- Tools ---------- */
|
||||||
|
|
||||||
|
.spsa-tools {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 10px;
|
||||||
|
padding: 12px 0;
|
||||||
|
border-top: 1px solid var(--spsa-line);
|
||||||
|
}
|
||||||
|
|
||||||
|
.spsa-tools input[type=search],
|
||||||
|
.spsa-tools select {
|
||||||
|
min-height: 36px;
|
||||||
|
padding: 0 10px;
|
||||||
|
color: var(--spsa-ink);
|
||||||
|
background: transparent;
|
||||||
|
border: 1px solid var(--spsa-line);
|
||||||
|
border-radius: 4px;
|
||||||
|
font: inherit;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spsa-tools input[type=search] { flex: 1 1 200px; max-width: 320px; }
|
||||||
|
|
||||||
|
.spsa-tools :focus-visible,
|
||||||
|
.spsa-row:focus-visible {
|
||||||
|
outline: 2px solid var(--spsa-fill);
|
||||||
|
outline-offset: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------- Rows ---------- */
|
||||||
|
|
||||||
|
.spsa-rows { list-style: none; margin: 0; padding: 0; }
|
||||||
|
|
||||||
|
.spsa-row {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: minmax(8ch, 18ch) minmax(140px, 1fr) 10ch 9ch;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px 18px;
|
||||||
|
padding: 11px 0;
|
||||||
|
border-top: 1px solid var(--spsa-line);
|
||||||
|
}
|
||||||
|
|
||||||
|
.spsa-row[hidden] { display: none; }
|
||||||
|
|
||||||
|
.spsa-name {
|
||||||
|
font-family: var(--spsa-mono);
|
||||||
|
font-size: 13.5px;
|
||||||
|
color: var(--spsa-ink);
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spsa-track-wrap { min-width: 0; }
|
||||||
|
|
||||||
|
.spsa-track {
|
||||||
|
position: relative;
|
||||||
|
height: 4px;
|
||||||
|
margin: 8px 6px 6px;
|
||||||
|
background: var(--spsa-line);
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spsa-drift {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
background: var(--spsa-fill);
|
||||||
|
opacity: .55;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spsa-start {
|
||||||
|
position: absolute;
|
||||||
|
top: -5px;
|
||||||
|
width: 2px;
|
||||||
|
height: 14px;
|
||||||
|
margin-left: -1px;
|
||||||
|
background: var(--spsa-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.spsa-now {
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
width: 12px;
|
||||||
|
height: 12px;
|
||||||
|
margin: -6px 0 0 -6px;
|
||||||
|
background: var(--spsa-fill);
|
||||||
|
border: 2px solid var(--color2, #1a1d22);
|
||||||
|
border-radius: 50%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spsa-row.at-bound .spsa-now { background: var(--spsa-limit); }
|
||||||
|
|
||||||
|
.spsa-scale {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
font-family: var(--spsa-mono);
|
||||||
|
font-size: 11px;
|
||||||
|
color: var(--spsa-muted);
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spsa-value {
|
||||||
|
font-family: var(--spsa-mono);
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 600;
|
||||||
|
text-align: right;
|
||||||
|
color: var(--spsa-ink);
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spsa-delta {
|
||||||
|
font-family: var(--spsa-mono);
|
||||||
|
font-size: 13px;
|
||||||
|
text-align: right;
|
||||||
|
color: var(--spsa-muted);
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spsa-row.at-bound .spsa-delta { color: var(--spsa-limit); }
|
||||||
|
|
||||||
|
.spsa-empty { padding: 18px 0; color: var(--spsa-muted); }
|
||||||
|
|
||||||
|
.spsa-key {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 6px 20px;
|
||||||
|
padding-top: 12px;
|
||||||
|
border-top: 1px solid var(--spsa-line);
|
||||||
|
font-size: 12.5px;
|
||||||
|
color: var(--spsa-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.spsa-key i {
|
||||||
|
display: inline-block;
|
||||||
|
vertical-align: middle;
|
||||||
|
margin-right: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spsa-key .k-start { width: 2px; height: 12px; background: var(--spsa-muted); }
|
||||||
|
.spsa-key .k-now { width: 10px; height: 10px; border-radius: 50%; background: var(--spsa-fill); }
|
||||||
|
.spsa-key .k-limit { width: 10px; height: 10px; border-radius: 50%; background: var(--spsa-limit); }
|
||||||
|
|
||||||
|
/* ---------- Narrow screens ---------- */
|
||||||
|
|
||||||
|
@media (max-width: 720px) {
|
||||||
|
|
||||||
|
.spsa-summary { grid-template-columns: 1fr; }
|
||||||
|
.spsa-facts div { text-align: left; }
|
||||||
|
|
||||||
|
.spsa-row {
|
||||||
|
grid-template-columns: 1fr auto auto;
|
||||||
|
gap: 6px 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spsa-name { grid-column: 1; }
|
||||||
|
.spsa-value { grid-column: 2; }
|
||||||
|
.spsa-delta { grid-column: 3; min-width: 7ch; }
|
||||||
|
.spsa-track-wrap { grid-column: 1 / -1; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
/* SPSA parameter panel: filter by name, sort by how far a parameter moved. */
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
|
||||||
|
var list = document.getElementById('spsa-rows');
|
||||||
|
var search = document.getElementById('spsa-filter');
|
||||||
|
var order = document.getElementById('spsa-sort');
|
||||||
|
var empty = document.getElementById('spsa-empty');
|
||||||
|
|
||||||
|
if (!list || !search || !order)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var rows = Array.prototype.slice.call(list.children);
|
||||||
|
|
||||||
|
function apply() {
|
||||||
|
|
||||||
|
var term = search.value.trim().toLowerCase();
|
||||||
|
var shown = 0;
|
||||||
|
|
||||||
|
rows.sort(function (a, b) {
|
||||||
|
if (order.value === 'drift')
|
||||||
|
return parseFloat(b.dataset.drift) - parseFloat(a.dataset.drift);
|
||||||
|
if (order.value === 'name')
|
||||||
|
return a.dataset.name.localeCompare(b.dataset.name);
|
||||||
|
return parseInt(a.dataset.index, 10) - parseInt(b.dataset.index, 10);
|
||||||
|
});
|
||||||
|
|
||||||
|
rows.forEach(function (row) {
|
||||||
|
var match = row.dataset.name.indexOf(term) !== -1;
|
||||||
|
row.hidden = !match;
|
||||||
|
shown += match ? 1 : 0;
|
||||||
|
list.appendChild(row);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (empty)
|
||||||
|
empty.hidden = shown !== 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
search.addEventListener('input', apply);
|
||||||
|
order.addEventListener('change', apply);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (document.readyState === 'loading')
|
||||||
|
document.addEventListener('DOMContentLoaded', init);
|
||||||
|
else
|
||||||
|
init();
|
||||||
|
|
||||||
|
})();
|
||||||
@@ -544,6 +544,84 @@ def spsa_optimal_values(workload):
|
|||||||
return '\n'.join(lines)
|
return '\n'.join(lines)
|
||||||
|
|
||||||
|
|
||||||
|
def spsa_param_panel(workload):
|
||||||
|
|
||||||
|
# Data for the visual parameter panel on a Tune's page. Positions are
|
||||||
|
# percentages along each parameter's [min, max] range, and every string is
|
||||||
|
# formatted here so a locale can never turn a decimal point into a comma.
|
||||||
|
|
||||||
|
spsa = workload.spsa
|
||||||
|
pairs = max(spsa['pairs_per'] * 2, 1)
|
||||||
|
total = int(spsa['iterations'])
|
||||||
|
complete = int(workload.games / pairs)
|
||||||
|
|
||||||
|
iteration = 1 + workload.games / pairs
|
||||||
|
c_compression = iteration ** spsa['Gamma']
|
||||||
|
r_compression = (spsa['A'] + iteration) ** spsa['Alpha']
|
||||||
|
|
||||||
|
def place(value, lo, span):
|
||||||
|
return max(0.0, min(100.0, (value - lo) / span * 100.0))
|
||||||
|
|
||||||
|
# Maintain the original order, if there was one
|
||||||
|
keys = sorted(
|
||||||
|
spsa['parameters'].keys(),
|
||||||
|
key=lambda x: spsa['parameters'][x].get('index', -1)
|
||||||
|
)
|
||||||
|
|
||||||
|
entries = []
|
||||||
|
for name in keys:
|
||||||
|
|
||||||
|
param = spsa['parameters'][name]
|
||||||
|
is_float = bool(param['float'])
|
||||||
|
|
||||||
|
lo, hi = float(param['min']), float(param['max'])
|
||||||
|
span = (hi - lo) or 1.0
|
||||||
|
value, start = float(param['value']), float(param['start'])
|
||||||
|
|
||||||
|
now_pos = place(value, lo, span)
|
||||||
|
start_pos = place(start, lo, span)
|
||||||
|
|
||||||
|
c = max(param['c'] / c_compression, 0.00 if is_float else 0.50)
|
||||||
|
r = param['a'] / r_compression / c ** 2
|
||||||
|
|
||||||
|
fmt = '%.4f' if is_float else '%d'
|
||||||
|
dfmt = '%+.4f' if is_float else '%+d'
|
||||||
|
|
||||||
|
shown_value = value if is_float else round(value)
|
||||||
|
shown_start = start if is_float else round(start)
|
||||||
|
|
||||||
|
bound = ''
|
||||||
|
if now_pos <= 1.0: bound = 'min'
|
||||||
|
elif now_pos >= 99.0: bound = 'max'
|
||||||
|
|
||||||
|
entries.append({
|
||||||
|
'name' : name,
|
||||||
|
'value' : fmt % shown_value,
|
||||||
|
'start' : fmt % shown_start,
|
||||||
|
'min' : fmt % lo,
|
||||||
|
'max' : fmt % hi,
|
||||||
|
'delta' : dfmt % (shown_value - shown_start),
|
||||||
|
'moved' : shown_value != shown_start,
|
||||||
|
'bound' : bound,
|
||||||
|
'now' : '%.2f' % now_pos,
|
||||||
|
'from' : '%.2f' % start_pos,
|
||||||
|
'left' : '%.2f' % min(now_pos, start_pos),
|
||||||
|
'width' : '%.2f' % abs(now_pos - start_pos),
|
||||||
|
'drift' : '%.3f' % (abs(value - start) / span * 100.0),
|
||||||
|
'c' : '%.4f' % c,
|
||||||
|
'r' : '%.4f' % r,
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
'params' : entries,
|
||||||
|
'count' : len(entries),
|
||||||
|
'moved' : sum(1 for e in entries if e['moved']),
|
||||||
|
'complete' : complete,
|
||||||
|
'iterations' : total,
|
||||||
|
'pct' : '%.1f' % (max(0.0, min(100.0, complete / total * 100.0)) if total else 0.0),
|
||||||
|
'games' : int(workload.games),
|
||||||
|
}
|
||||||
|
|
||||||
def book_download_link(workload):
|
def book_download_link(workload):
|
||||||
if workload.book_name in OpenBench.config.OPENBENCH_CONFIG['books']:
|
if workload.book_name in OpenBench.config.OPENBENCH_CONFIG['books']:
|
||||||
return OpenBench.config.OPENBENCH_CONFIG['books'][workload.book_name]['source']
|
return OpenBench.config.OPENBENCH_CONFIG['books'][workload.book_name]['source']
|
||||||
@@ -609,6 +687,7 @@ register.filter('spsa_param_digest', spsa_param_digest)
|
|||||||
register.filter('spsa_param_digest_headers', spsa_param_digest_headers)
|
register.filter('spsa_param_digest_headers', spsa_param_digest_headers)
|
||||||
register.filter('spsa_original_input', spsa_original_input)
|
register.filter('spsa_original_input', spsa_original_input)
|
||||||
register.filter('spsa_optimal_values', spsa_optimal_values)
|
register.filter('spsa_optimal_values', spsa_optimal_values)
|
||||||
|
register.filter('spsa_param_panel', spsa_param_panel)
|
||||||
|
|
||||||
register.filter('book_download_link', book_download_link)
|
register.filter('book_download_link', book_download_link)
|
||||||
register.filter('network_download_link', network_download_link)
|
register.filter('network_download_link', network_download_link)
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
<link rel="stylesheet" href="{% static 'workload.css' %}?{{ static_version }}">
|
<link rel="stylesheet" href="{% static 'workload.css' %}?{{ static_version }}">
|
||||||
|
<link rel="stylesheet" href="{% static 'spsa_panel.css' %}?{{ static_version }}">
|
||||||
|
<script src="{% static 'spsa_panel.js' %}?{{ static_version }}" defer></script>
|
||||||
<script src="{% static 'copy_text.js' %}?{{ static_version }}"></script>
|
<script src="{% static 'copy_text.js' %}?{{ static_version }}"></script>
|
||||||
<script src="{% static 'llr_history.js' %}?{{ static_version }}" defer></script>
|
<script src="{% static 'llr_history.js' %}?{{ static_version }}" defer></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -212,8 +214,61 @@
|
|||||||
|
|
||||||
<!-- SPSA Paramater Summary, for Tunes -->
|
<!-- SPSA Paramater Summary, for Tunes -->
|
||||||
{% if type == "TUNE" %}
|
{% if type == "TUNE" %}
|
||||||
|
{% with panel=workload|spsa_param_panel %}
|
||||||
|
<section id="spsa-panel" class="card spsa-panel">
|
||||||
|
<header class="card-head"><h2 class="card-title">Tuning progress</h2></header>
|
||||||
|
|
||||||
|
<div class="spsa-summary">
|
||||||
|
<div class="spsa-iter">
|
||||||
|
<span class="spsa-big">{{ panel.complete }}</span>
|
||||||
|
<span class="spsa-of">of {{ panel.iterations }} iterations</span>
|
||||||
|
</div>
|
||||||
|
<div class="spsa-bar" role="progressbar" aria-label="Iterations completed" aria-valuemin="0" aria-valuemax="100" aria-valuenow="{{ panel.pct }}"><span style="width: {{ panel.pct }}%"></span></div>
|
||||||
|
<dl class="spsa-facts">
|
||||||
|
<div><dt>Parameters</dt><dd>{{ panel.count }}</dd></div>
|
||||||
|
<div><dt>Moved</dt><dd>{{ panel.moved }}</dd></div>
|
||||||
|
<div><dt>Games</dt><dd>{{ panel.games|insertCommas }}</dd></div>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="spsa-tools">
|
||||||
|
<input id="spsa-filter" type="search" placeholder="Filter parameters" aria-label="Filter parameters by name" autocomplete="off">
|
||||||
|
<select id="spsa-sort" aria-label="Sort parameters">
|
||||||
|
<option value="index">Original order</option>
|
||||||
|
<option value="drift">Moved the most</option>
|
||||||
|
<option value="name">Name</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ol id="spsa-rows" class="spsa-rows">
|
||||||
|
{% for p in panel.params %}
|
||||||
|
<li class="spsa-row{% if p.bound %} at-bound{% endif %}" data-name="{{ p.name|lower }}" data-drift="{{ p.drift }}" data-index="{{ forloop.counter0 }}">
|
||||||
|
<span class="spsa-name">{{ p.name }}</span>
|
||||||
|
<div class="spsa-track-wrap">
|
||||||
|
<div class="spsa-track" role="img" aria-label="{{ p.name }} is {{ p.value }}, within {{ p.min }} to {{ p.max }}, started at {{ p.start }}{% if p.bound %}, at its {{ p.bound }} limit{% endif %}" title="Start {{ p.start }}, now {{ p.value }}, C {{ p.c }}, R {{ p.r }}{% if p.bound %}. At its {{ p.bound }} limit.{% endif %}">
|
||||||
|
<span class="spsa-drift" style="left: {{ p.left }}%; width: {{ p.width }}%"></span>
|
||||||
|
<span class="spsa-start" style="left: {{ p.from }}%"></span>
|
||||||
|
<span class="spsa-now" style="left: {{ p.now }}%"></span>
|
||||||
|
</div>
|
||||||
|
<div class="spsa-scale"><span>{{ p.min }}</span><span>{{ p.max }}</span></div>
|
||||||
|
</div>
|
||||||
|
<span class="spsa-value">{{ p.value }}</span>
|
||||||
|
<span class="spsa-delta">{% if p.moved %}{{ p.delta }}{% else %}unchanged{% endif %}</span>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ol>
|
||||||
|
<p id="spsa-empty" class="spsa-empty" hidden>No parameter matches that name.</p>
|
||||||
|
|
||||||
|
<div class="spsa-key">
|
||||||
|
<span><i class="k-start"></i>Start value</span>
|
||||||
|
<span><i class="k-now"></i>Current value</span>
|
||||||
|
<span><i class="k-limit"></i>At a limit of its range</span>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
{% endwith %}
|
||||||
|
|
||||||
<div id="parameters" class="card">
|
<div id="parameters" class="card">
|
||||||
<header class="card-head"><h2 class="card-title">SPSA Parameters</h2></header>
|
<header class="card-head"><h2 class="card-title">Parameter details</h2></header>
|
||||||
<table class="stripes wrappable">
|
<table class="stripes wrappable">
|
||||||
|
|
||||||
<tr class="table-header">
|
<tr class="table-header">
|
||||||
|
|||||||
Reference in new issue
Block a user