Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
267 changes: 256 additions & 11 deletions dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,45 @@
background: var(--btn);
margin: 1rem 0;
}
.headline-metrics {
margin: 1rem 0 1.5rem;
padding: 0.5rem 1rem;
border: 1px solid var(--line);
border-radius: 8px;
background: var(--btn);
}
.headline-list {
margin: 0;
}
.headline-row {
display: grid;
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
gap: 0.35rem 1rem;
padding: 0.65rem 0;
}
.headline-row + .headline-row {
border-top: 1px solid var(--line);
}
.headline-row dt {
font-weight: 600;
}
.headline-row dd {
margin: 0;
}
.headline-value {
font-variant-numeric: tabular-nums;
}
.headline-note {
display: block;
color: var(--muted);
font-size: 0.75rem;
margin-top: 0.2rem;
}
@media (max-width: 40rem) {
.headline-row {
grid-template-columns: minmax(0, 1fr);
}
}
.context p {
margin: 0.2rem 0;
}
Expand Down Expand Up @@ -939,7 +978,137 @@
return "diagnostic";
return "main";
}
const api = { implementation, describe, category };
// Explicit producer keys only: a component sum, first call, compiler memory
// estimate or total batch wall time is never a likelihood headline.
const headlineMetrics = [
{
id: "total",
label: "Likelihood Run Time Total",
axis: "runtime",
unit: "s",
keys: [
"single_jit_block",
"single_jit_median",
"cube_single_jit",
"single_call",
"direct_call",
"full_call.per_call_s",
"full_pipeline.per_call_s",
"full_call.mean_s",
"full_pipeline.mean_s",
"full_call.median_s",
"full_pipeline.median_s",
],
},
{
id: "batched",
label: "Likelihood Run Time Batched",
axis: "runtime",
unit: "s",
keys: ["vmap.per_call", "batch_per_call"],
},
{
id: "compile",
label: "JAX Compile Time",
axis: "compile",
unit: "s",
keys: ["full_pipeline.compile", "cold_compile", "compile"],
},
{
id: "vram",
label: "VRAM Use",
axis: "memory",
unit: "GB",
keys: ["device_peak_allocated"],
},
{
id: "memory",
label: "Memory Use",
axis: "memory",
unit: "GB",
keys: ["host_peak_rss"],
},
];
const memoryUnits = {
B: 1e-9,
bytes: 1e-9,
KiB: 1024 / 1e9,
MiB: 1024 ** 2 / 1e9,
GiB: 1024 ** 3 / 1e9,
kB: 1e-6,
MB: 1e-3,
GB: 1,
};
const canonical = (value) =>
JSON.stringify(value, (_, v) =>
v && typeof v === "object" && !Array.isArray(v)
? Object.fromEntries(
Object.entries(v).sort(([a], [b]) => a.localeCompare(b)),
)
: v,
);
function headlines(setup, records, backend = implementation(setup, records)) {
const definitions = headlineMetrics.filter(
(d) => backend !== "numba" || !["compile", "vram"].includes(d.id),
);
const candidates = definitions.map((d) =>
records.filter(
(r) =>
r.setup_id === setup.id &&
r.axis === d.axis &&
d.keys.includes(r.metric) &&
(d.unit === "s"
? r.unit === "s"
: Object.hasOwn(memoryUnits, r.unit)) &&
Number.isFinite(r.measurement?.[r.metric]) &&
r.measurement[r.metric] >= 0,
),
);
// A headline must not silently assemble different runs or hardware/software
// identities into a synthetic result. Keep those observations in details.
const cohorts = new Set(
candidates
.flat()
.map((r) => canonical([r.run_id, r.identity, r.provenance?.host])),
);
return definitions.map((d, i) => {
const rows = candidates[i];
const result = { ...d, status: "Not measured yet" };
if (!rows.length) {
if (d.id === "batched" && backend === "numba")
result.status = "Not applicable";
return result;
}
if (cohorts.size > 1)
return { ...result, status: "Multiple runs — see details" };
const key = d.keys.find((key) => rows.some((r) => r.metric === key));
const selected = rows.filter((r) => r.metric === key);
if (selected.length !== 1)
return { ...result, status: "Multiple measurements — see details" };
const record = selected[0];
const value =
record.measurement[key] *
(d.unit === "GB" ? memoryUnits[record.unit] : 1);
const batch = ["vmap_batch", "vmap_batch_size", "batch_size"]
.map((key) => setup.configuration?.[key]?.value)
.find((n) => Number.isFinite(n) && n > 0);
const note =
d.id === "batched"
? "Per likelihood" +
(batch ? ` · batch size ${batch}` : " · batch size not recorded")
: d.id === "memory"
? "Peak host RSS"
: d.id === "vram"
? "Peak device allocation"
: d.id === "compile" &&
setup.configuration?.transform?.value === "vmap"
? "Batched compilation" +
(batch ? ` · batch size ${batch}` : "")
: record.method?.statistic || "";
return { ...result, status: null, value, record, note };
});
}
const api = { implementation, describe, category, headlines };
globalThis.PulsePresentation = api;
if (typeof module !== "undefined") module.exports = api;
})();
Expand Down Expand Up @@ -1141,17 +1310,86 @@
];
}
function configurationLabel(s) {
const axisNames = axesFor(s)
.map((a) => axes[a])
.join(" + ");
const pixels = s.configuration.source_pixels?.value;
return [
"float64",
pixels == null ? null : pixels + " source pixels",
axisNames,
]
return [pixels == null ? null : pixels + " source pixels", "float64"]
.filter(Boolean)
.join(" · ");
.join(" - ");
}
function configurationOptions(variants) {
const options = variants.map((s) => {
let text = configurationLabel(s);
if (
variants.filter((other) => configurationLabel(other) === text)
.length > 1
) {
const detail = axesFor(s)
.filter((axis) => axis !== "runtime")
.map((axis) => axes[axis]);
for (const key of [
"transform",
"solver",
"vmap_batch_size",
"batch_size",
]) {
const value = s.configuration[key]?.value;
if (
value != null &&
variants.some(
(other) => other.configuration[key]?.value !== value,
)
)
detail.push(`${label(key)}: ${value}`);
}
if (detail.length) text += " — " + detail.join(" · ");
}
return [s.id, text];
});
// Keep otherwise indistinguishable evidence choices selectable without
// changing their IDs or treating them as one configuration.
return options.map(([id, text]) => [
id,
options.filter(([, other]) => other === text).length > 1
? text +
" — " +
variants
.find((s) => s.id === id)
.evidence.path.split("/")
.at(-1)
: text,
]);
}
function headlinePanel(parent, setup, records, message) {
parent.replaceChildren();
const metrics = presentation.headlines(
setup || {},
records,
state.implementation,
);
const list = append(parent, "dl", "", "headline-list");
for (const metric of metrics) {
const row = append(list, "div", "", "headline-row");
row.dataset.headline = metric.id;
append(row, "dt", metric.label);
const cell = append(row, "dd");
const text = message || metric.status;
const value = append(
cell,
"strong",
text || Number(metric.value.toPrecision(4)) + " " + metric.unit,
"headline-value",
);
if (!text) {
value.dataset.value = String(metric.value);
value.dataset.unit = metric.unit;
value.title = `Recorded: ${metric.record.measurement[metric.record.metric]} ${metric.record.unit} · ${metric.record.metric} · Run: ${metric.record.run_id}`;
if (metric.note) append(cell, "span", metric.note, "headline-note");
const provenance = append(cell, "span", "", "headline-note");
if (metric.record.evidence?.path)
link(provenance, metric.record.evidence.path, "Source");
if (!metric.record.provenance?.qualified)
append(provenance, "span", " · Unqualified measurement");
}
}
}

async function verified(path, expected) {
Expand Down Expand Up @@ -1802,7 +2040,7 @@
axis,
}),
);
const configOptions = variants.map((s) => [s.id, configurationLabel(s)]);
const configOptions = configurationOptions(variants);
if (archived)
configOptions.unshift([
requested.id,
Expand All @@ -1816,6 +2054,10 @@
setup?.id || "",
(value) => route({ ...state, setup: value }),
);
const headline = append(results, "section", "", "headline-metrics");
headline.setAttribute("aria-label", "Headline measurements");
headline.setAttribute("aria-live", "polite");
headlinePanel(headline, setup, [], setup ? "Loading…" : null);
if (!setup) {
append(
results,
Expand All @@ -1834,9 +2076,11 @@
const display = (allRecords) => {
const records = allRecords.filter(
(r) =>
r.setup_id === setup.id &&
(!device || r.identity.device === device) &&
(archived || r.identity.precision === "float64"),
);
headlinePanel(headline, setup, records);
panels(records, variants);
advice(setup);
evidence(setup, records);
Expand Down Expand Up @@ -1887,6 +2131,7 @@
if (ticket !== generation) return;
status.textContent = "Evidence unavailable. " + error.message;
status.className = "status-error";
headlinePanel(headline, setup, [], "Evidence unavailable");
const retry = append(results, "button", "Retry evidence", "retry");
retry.type = "button";
retry.onclick = () => {
Expand Down
Loading
Loading