diff --git a/dashboard.html b/dashboard.html
index 8b46cc9..b510d8c 100644
--- a/dashboard.html
+++ b/dashboard.html
@@ -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;
}
@@ -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;
})();
@@ -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) {
@@ -1802,7 +2040,7 @@
axis,
}),
);
- const configOptions = variants.map((s) => [s.id, configurationLabel(s)]);
+ const configOptions = configurationOptions(variants);
if (archived)
configOptions.unshift([
requested.id,
@@ -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,
@@ -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);
@@ -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 = () => {
diff --git a/pulse/measurement_presentation.js b/pulse/measurement_presentation.js
index 0170e0c..c69f563 100644
--- a/pulse/measurement_presentation.js
+++ b/pulse/measurement_presentation.js
@@ -191,7 +191,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;
})();
diff --git a/pulse/setup_browser.css b/pulse/setup_browser.css
index 5a929b9..740ae65 100644
--- a/pulse/setup_browser.css
+++ b/pulse/setup_browser.css
@@ -92,6 +92,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;
}
diff --git a/pulse/setup_browser.js b/pulse/setup_browser.js
index ce20038..c24a50c 100644
--- a/pulse/setup_browser.js
+++ b/pulse/setup_browser.js
@@ -195,17 +195,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) {
@@ -856,7 +925,7 @@
axis,
}),
);
- const configOptions = variants.map((s) => [s.id, configurationLabel(s)]);
+ const configOptions = configurationOptions(variants);
if (archived)
configOptions.unshift([
requested.id,
@@ -870,6 +939,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,
@@ -888,9 +961,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);
@@ -941,6 +1016,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 = () => {
diff --git a/tests/browser_fixture.py b/tests/browser_fixture.py
index e214360..30b34dd 100644
--- a/tests/browser_fixture.py
+++ b/tests/browser_fixture.py
@@ -49,6 +49,68 @@ def write(destination):
inline.doc.pop("navigation")
(destination / "inline.html").write_text(board.render_html([inline]))
+ headlines = copy.deepcopy(inline)
+ base_setup = headlines.doc["setups"][0]
+ base_setup["configuration"]["vmap_batch_size"] = {"value": 16, "unit": "count"}
+ base_row = headlines.doc["records"][0]
+ for metric, value, axis, unit in [
+ ("vmap.per_call", 0.005, "runtime", "s"),
+ ("device_peak_allocated", 2_000_000_000, "memory", "B"),
+ ]:
+ row = copy.deepcopy(base_row)
+ row.update(id=metric, metric=metric, axis=axis, unit=unit, measurement={metric: value})
+ headlines.doc["records"].append(row)
+ # Same configuration, different device: the selector must replace all values.
+ for original in list(headlines.doc["records"]):
+ row = copy.deepcopy(original)
+ row["id"] += "-gpu"
+ row["identity"]["device"] = "gpu"
+ row["measurement"][row["metric"]] *= 2
+ headlines.doc["records"].append(row)
+ # A distinct compile-only setup remains a distinct selectable configuration.
+ compile_setup = copy.deepcopy(base_setup)
+ compile_setup["id"] = "compile-only"
+ compile_setup["evidence"]["path"] = "results/compile/jax.json"
+ headlines.doc["setups"].append(compile_setup)
+ compile_row = copy.deepcopy(base_row)
+ compile_row.update(
+ id="compile-only-row",
+ setup_id="compile-only",
+ axis="compile",
+ metric="full_pipeline.compile",
+ measurement={"full_pipeline.compile": 7},
+ )
+ headlines.doc["records"].append(compile_row)
+ other_instrument = copy.deepcopy(base_setup)
+ other_instrument.update(id="euclid-fixture", instrument="euclid")
+ headlines.doc["setups"].append(other_instrument)
+ other_row = copy.deepcopy(base_row)
+ other_row.update(
+ id="euclid-runtime", setup_id=other_instrument["id"], measurement={"single_call": 0.25}
+ )
+ headlines.doc["records"].append(other_row)
+ (destination / "headlines.html").write_text(board.render_html([headlines]))
+
+ # Two verified shards with delayed transport exercise rapid selection changes.
+ async_headlines = copy.deepcopy(headlines)
+ async_headlines.doc["evidence_shards"] = []
+ for index, setup in enumerate(headlines.doc["setups"]):
+ detail = copy.deepcopy(headlines.doc)
+ detail["setups"] = [setup]
+ detail["records"] = [r for r in detail["records"] if r["setup_id"] == setup["id"]]
+ raw = json.dumps(detail).encode()
+ name = "catalogue/shards/" + str(index + 1) * 20 + ".json"
+ (destination / name).write_bytes(raw)
+ async_headlines.doc["evidence_shards"].append(
+ {
+ "setup_id": setup["id"],
+ "path": name,
+ "sha256": hashlib.sha256(raw).hexdigest(),
+ "records": len(detail["records"]),
+ }
+ )
+ (destination / "async-headlines.html").write_text(board.render_html([async_headlines]))
+
grouped = copy.deepcopy(inline)
record = grouped.doc["records"][0]
grouped.doc["records"] = []
diff --git a/tests/browser_setup.cjs b/tests/browser_setup.cjs
index 8acb978..ceafba8 100644
--- a/tests/browser_setup.cjs
+++ b/tests/browser_setup.cjs
@@ -45,6 +45,7 @@ const { execFileSync } = require("node:child_process");
);
let corrupt = false,
delay = false,
+ releaseDelayed,
requests = [];
await context.route(
"https://raw.githubusercontent.com/**",
@@ -56,7 +57,10 @@ const { execFileSync } = require("node:child_process");
url.includes("/" + commit + "/dashboard/catalogue/shards/"),
),
);
- if (delay) await new Promise((resolve) => setTimeout(resolve, 250));
+ if (delay && url.endsWith("/" + "1".repeat(20) + ".json"))
+ await new Promise((resolve) => {
+ releaseDelayed = resolve;
+ });
await route.fulfill({
contentType: "application/json",
body: corrupt
@@ -86,6 +90,8 @@ const { execFileSync } = require("node:child_process");
model: "delaunay",
...extra,
});
+ const headlineValue = (target, id) =>
+ target.locator(`[data-headline="${id}"] .headline-value`);
await page.goto(base);
assert.equal(
await page
@@ -124,6 +130,22 @@ const { execFileSync } = require("node:child_process");
.evaluateAll((els) => els.map((e) => e.firstChild.textContent)),
["Instrument", "Device", "Configuration"],
);
+ assert.equal(
+ await detail.locator(".selectors + .headline-metrics").count(),
+ 1,
+ );
+ assert.equal(await headlineValue(detail, "total").textContent(), "0.05 s");
+ assert(await headlineValue(detail, "total").isVisible());
+ assert.equal(
+ await headlineValue(detail, "vram").textContent(),
+ "Not measured yet",
+ );
+ assert.equal(
+ await detail
+ .locator('[data-id="configuration"] option:checked')
+ .textContent(),
+ "1500 source pixels - float64",
+ );
assert.equal(
await detail
.locator('[data-id="results"] > details > summary')
@@ -237,14 +259,101 @@ const { execFileSync } = require("node:child_process");
.evaluateAll((els) => els.map((e) => e.style.width)),
["40%", "20%"],
);
+ assert.match(
+ await headlineValue(page, "total").textContent(),
+ /Multiple runs/,
+ );
+
+ // All headline fields are visible and are replaced when any selector changes.
+ await page.goto(modelURL("/headlines.html"));
+ assert.equal(await headlineValue(page, "total").textContent(), "0.05 s");
+ assert.equal(await headlineValue(page, "batched").textContent(), "0.005 s");
+ assert.match(
+ await page.locator('[data-headline="batched"]').textContent(),
+ /batch size 16/,
+ );
+ assert.equal(await headlineValue(page, "vram").textContent(), "2 GB");
+ assert.match(
+ await page.locator('[data-headline="memory"]').textContent(),
+ /Peak host RSS/,
+ );
+ assert(await page.locator('[data-headline="total"] a').isVisible());
+ await page.selectOption('[data-id="device"]', "gpu");
+ assert.equal(await headlineValue(page, "total").textContent(), "0.1 s");
+ assert.equal(await headlineValue(page, "vram").textContent(), "4 GB");
+ await page.selectOption('[data-id="device"]', "cpu");
+ const configLabels = await page
+ .locator('[data-id="configuration"] option')
+ .allTextContents();
+ assert.equal(new Set(configLabels).size, configLabels.length);
+ assert(configLabels.every((text) => !text.includes("Runtime")));
+ await page.selectOption('[data-id="configuration"]', "compile-only");
+ assert.equal(await headlineValue(page, "compile").textContent(), "7 s");
+ assert.equal(
+ await headlineValue(page, "total").textContent(),
+ "Not measured yet",
+ );
+ assert.equal(
+ await headlineValue(page, "memory").textContent(),
+ "Not measured yet",
+ );
+ await page.selectOption('[data-id="instrument"]', "euclid");
+ assert.equal(await headlineValue(page, "total").textContent(), "0.25 s");
+ assert.equal(
+ await headlineValue(page, "compile").textContent(),
+ "Not measured yet",
+ );
+ await page.goto(
+ modelURL("/headlines.html", {
+ model: "unmeasured",
+ implementation: "jax",
+ }),
+ );
+ assert.equal(await page.locator(".headline-row").count(), 5);
+ assert.equal(
+ await headlineValue(page, "total").textContent(),
+ "Not measured yet",
+ );
+
+ // A late response from the previous selection cannot overwrite a newer one.
+ delay = true;
+ await page.goto(modelURL("/async-headlines.html"));
+ assert.equal(await headlineValue(page, "total").textContent(), "Loading…");
+ await page.selectOption('[data-id="configuration"]', "compile-only");
+ await loaded();
+ assert.equal(await headlineValue(page, "compile").textContent(), "7 s");
+ assert.equal(
+ await headlineValue(page, "total").textContent(),
+ "Not measured yet",
+ );
+ const lateResponse = page.waitForResponse((response) =>
+ response.url().endsWith("/" + "1".repeat(20) + ".json"),
+ );
+ assert(releaseDelayed, "first shard request was held");
+ releaseDelayed();
+ await (await lateResponse).finished();
+ // Allow the obsolete response's digest and render continuation to finish.
+ await page.waitForTimeout(100);
+ assert.equal(await headlineValue(page, "compile").textContent(), "7 s");
+ assert.equal(
+ await headlineValue(page, "total").textContent(),
+ "Not measured yet",
+ );
+ delay = false;
// Hash mismatch must never display measurements; retry re-verifies immutable bytes.
corrupt = true;
await page.goto(modelURL());
await page.waitForSelector(".status-error");
assert.equal(await page.locator(".metric-value").count(), 0);
+ assert.equal(
+ await headlineValue(page, "total").textContent(),
+ "Evidence unavailable",
+ );
+ assert.equal(await page.locator(".headline-value[data-value]").count(), 0);
corrupt = false;
await page.getByRole("button", { name: "Retry evidence" }).click();
await page.waitForSelector(".metric-value", { state: "attached" });
+ assert.equal(await headlineValue(page, "total").textContent(), "0.05 s");
assert(
requests.every((url) => url.includes("/dashboard/catalogue/shards/")),
);
@@ -267,6 +376,10 @@ const { execFileSync } = require("node:child_process");
await page.selectOption('[data-id="device"]', "a100");
await loaded();
assert.equal(await page.locator(".metric-value").count(), 0);
+ assert.equal(
+ await headlineValue(page, "total").textContent(),
+ "Not measured yet",
+ );
assert(
(await page.locator(".empty").first().textContent()).includes(
"No float64 results",
@@ -300,6 +413,14 @@ const { execFileSync } = require("node:child_process");
(await page.locator('[data-id="configuration"] option').count()) <= 4,
);
const before = await page.locator('[data-id="configuration"]').inputValue();
+ assert.equal(
+ await headlineValue(page, "total").getAttribute("data-value"),
+ "0.11771118000033312",
+ );
+ assert.equal(
+ await headlineValue(page, "batched").getAttribute("data-unit"),
+ "s",
+ );
await page.locator('[data-axis="breakdown"] > summary').click();
await page.waitForFunction(
(old) =>
@@ -307,6 +428,10 @@ const { execFileSync } = require("node:child_process");
before,
);
await loaded();
+ assert.equal(
+ await headlineValue(page, "total").textContent(),
+ "Not measured yet",
+ );
assert.equal(
await page.locator('[data-axis="breakdown"] .metric-value').count(),
1,
@@ -401,6 +526,17 @@ const { execFileSync } = require("node:child_process");
await page.locator(".metric-value").getAttribute("data-value"),
"0.4",
);
+ assert.equal(await headlineValue(page, "total").textContent(), "0.4 s");
+ assert.equal(
+ await headlineValue(page, "batched").textContent(),
+ "Not applicable",
+ );
+ assert.equal(
+ await page
+ .locator('[data-headline="compile"], [data-headline="vram"]')
+ .count(),
+ 0,
+ );
await page.goto(
base +
"/readable.html?view=model#instance=lens&dataset=imaging&model=delaunay&setup=numba-cpu",
diff --git a/tests/measurement_presentation.cjs b/tests/measurement_presentation.cjs
index c76048b..3f5455b 100644
--- a/tests/measurement_presentation.cjs
+++ b/tests/measurement_presentation.cjs
@@ -79,3 +79,122 @@ assert.equal(
category(row, [{ metric: "steps_vmap_per_call.Regularized reconstruction" }]),
"main",
);
+
+const { headlines } = require("../pulse/measurement_presentation.js");
+const setup = {
+ id: "selected",
+ configuration: { vmap_batch_size: { value: 16 } },
+};
+const measurement = (
+ metric,
+ value,
+ axis = "runtime",
+ unit = "s",
+ extra = {},
+) => ({
+ setup_id: setup.id,
+ run_id: "same-run",
+ metric,
+ axis,
+ unit,
+ measurement: { [metric]: value },
+ identity: { device: "gpu", backend: "jax", precision: "float64" },
+ provenance: { host: "same-host" },
+ ...extra,
+});
+const selectedMetric = (rows, id = "total", backend = "jax") =>
+ headlines(setup, rows, backend).find((m) => m.id === id);
+const total = measurement("single_jit_block", 0.125);
+const batched = measurement("vmap.per_call", 0.01);
+assert.equal(selectedMetric([total]).value, 0.125);
+assert.equal(selectedMetric([total, batched], "batched").value, 0.01);
+assert.match(selectedMetric([batched], "batched").note, /batch size 16/);
+assert.equal(
+ selectedMetric([total, measurement("single_jit_median", 0.1)]).value,
+ 0.125,
+);
+for (const row of [
+ measurement("component_total", 3, "breakdown"),
+ measurement("full_pipeline.first_call", 3, "compile"),
+ measurement("single_jit_block", 3, "breakdown"),
+ measurement("single_jit_block", 3, "runtime", "MiB"),
+ measurement("single_jit_block", -1),
+ measurement("single_jit_block", Infinity),
+ { ...total, setup_id: "another-setup" },
+])
+ assert.equal(selectedMetric([row]).status, "Not measured yet");
+assert.equal(
+ selectedMetric([measurement("vmap.batch_time", 8)], "batched").status,
+ "Not measured yet",
+);
+assert.equal(
+ selectedMetric(
+ [measurement("full_pipeline.compile", 8, "compile")],
+ "compile",
+ ).value,
+ 8,
+);
+assert.equal(
+ selectedMetric(
+ [measurement("ray_trace_data_jit.compile_s", 8, "compile")],
+ "compile",
+ ).status,
+ "Not measured yet",
+);
+assert.equal(
+ selectedMetric(
+ [measurement("host_peak_rss", 1024, "memory", "MiB")],
+ "memory",
+ ).value,
+ 1.073741824,
+);
+assert.equal(
+ selectedMetric(
+ [measurement("device_peak_allocated", 2e9, "memory", "B")],
+ "vram",
+ ).value,
+ 2,
+);
+assert.equal(
+ selectedMetric(
+ [measurement("static_memory_estimate", 2e9, "memory", "B")],
+ "vram",
+ ).status,
+ "Not measured yet",
+);
+assert.equal(
+ selectedMetric([measurement("host_peak_rss", 0, "memory", "GB")], "memory")
+ .value,
+ 0,
+);
+for (const change of [
+ { run_id: "other-run" },
+ { identity: { ...total.identity, device: "cpu" } },
+ { identity: { ...total.identity, backend: "numpy" } },
+ { identity: { ...total.identity, precision: "float32" } },
+ { provenance: { host: "other-host" } },
+])
+ assert.match(
+ selectedMetric([total, { ...batched, ...change }]).status,
+ /Multiple runs/,
+ );
+assert.match(
+ selectedMetric([total, { ...total, method: { statistic: "median" } }]).status,
+ /Multiple measurements/,
+);
+const numbaMetrics = headlines(
+ setup,
+ [measurement("direct_call", 0.4)],
+ "numba",
+);
+assert.deepEqual(
+ numbaMetrics.map((m) => m.id),
+ ["total", "batched", "memory"],
+);
+assert.equal(numbaMetrics[0].value, 0.4);
+assert.equal(numbaMetrics[1].status, "Not applicable");
+assert.equal(
+ selectedMetric([measurement("batch_per_call", 0.1)], "batched", "numba")
+ .value,
+ 0.1,
+);