Benchmarks: paired A/B runs, sweeps, resource usage

- A/B with betterbench ab between two deployments of the same model, with verdict, confidence
  interval and caveats.
- Sweeps vary one or two deployment settings, deploy, benchmark and remove each variant, and
  compare them in one table.
- Every run records CPU, RAM, VRAM, GPU utilization and power.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Pascal LinxweilerandClaude Opus 5.5 committed 2026-10-13 10:04:40 +02:00
1 parent 9e167a44f6
commit b623b16a6d
37 files changed
+4314 -214

No files matched your search

@@ -1,6 +1,13 @@
"use client";
import { DownloadIcon, ExternalLinkIcon, RotateCcwIcon, SquareIcon, Trash2Icon, TriangleAlertIcon } from "lucide-react";
import {
DownloadIcon,
ExternalLinkIcon,
RotateCcwIcon,
SquareIcon,
Trash2Icon,
TriangleAlertIcon,
} from "lucide-react";
import Link from "next/link";
import { useRouter } from "next/navigation";
import { useEffect, useState } from "react";
@@ -27,15 +34,23 @@ import { reportSummary, weightsLabel } from "@/lib/benchmark-report";
import { CONFIG_ROWS, describeSettings } from "@/lib/benchmark-view";
import type { ListRow } from "../benchmark-list";
import { cancelBenchmark, deleteBenchmark, renameBenchmark } from "../actions";
import { AbReport } from "./ab-report";
import { BenchmarkReport } from "./benchmark-report";
import { PublishCard } from "./publish-card";
function duration(a: string | null, b: string | null, now: number) {
if (!a) return null;
const s = Math.max(0, ((b ? new Date(b).getTime() : now) - new Date(a).getTime()) / 1000);
const s = Math.max(
0,
((b ? new Date(b).getTime() : now) - new Date(a).getTime()) / 1000,
);
const h = Math.floor(s / 3600);
const m = Math.floor((s % 3600) / 60);
return h ? `${h} h ${m} min` : m ? `${m} min ${Math.round(s % 60)} s` : `${Math.round(s)} s`;
return h
? `${h} h ${m} min`
: m
? `${m} min ${Math.round(s % 60)} s`
: `${Math.round(s)} s`;
}
export function BenchmarkDetail({ initial }: { initial: ListRow }) {
@@ -49,7 +64,9 @@ export function BenchmarkDetail({ initial }: { initial: ListRow }) {
if (!active) return;
const t = setInterval(async () => {
setNow(Date.now());
const res = await fetch(`/api/benchmarks/${r.id}`, { cache: "no-store" }).catch(() => null);
const res = await fetch(`/api/benchmarks/${r.id}`, {
cache: "no-store",
}).catch(() => null);
if (res?.ok) setR(await res.json());
}, 2_000);
return () => clearInterval(t);
@@ -60,10 +77,18 @@ export function BenchmarkDetail({ initial }: { initial: ListRow }) {
const res = await fetch("/api/benchmarks", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ deploymentId: r.deploymentId, label: r.label, ...r.settings }),
body: JSON.stringify({
deploymentId: r.deploymentId,
deploymentBId: r.kind === "ab" ? r.deploymentBId : null,
label: r.label,
...r.settings,
}),
});
const json = await res.json().catch(() => ({}));
if (!res.ok) return toast.error(json.error?.message ?? `Could not start (${res.status})`);
if (!res.ok)
return toast.error(
json.error?.message ?? `Could not start (${res.status})`,
);
router.push(`/benchmarks/${json.id}`);
}
@@ -77,12 +102,28 @@ export function BenchmarkDetail({ initial }: { initial: ListRow }) {
<CardContent className="flex flex-wrap items-start justify-between gap-4">
<div className="flex min-w-0 flex-col gap-1">
<div className="flex flex-wrap items-center gap-2">
<h1 className="text-xl font-semibold">{r.label ?? s.deploymentName}</h1>
<BenchmarkStateBadge state={r.state} cancelling={!!r.cancelRequestedAt} />
<h1 className="text-xl font-semibold">
{r.label ??
(r.kind === "ab"
? `${s.deploymentName} vs ${r.snapshotB?.deploymentName}`
: s.deploymentName)}
</h1>
{r.kind === "ab" && (
<span className="rounded-md border px-1.5 text-xs text-muted-foreground">
A/B
</span>
)}
<BenchmarkStateBadge
state={r.state}
cancelling={!!r.cancelRequestedAt}
/>
</div>
<p className="text-sm text-muted-foreground">
{r.deploymentId ? (
<Link href={`/deployments/${r.deploymentId}`} className="hover:underline">
<Link
href={`/deployments/${r.deploymentId}`}
className="hover:underline"
>
{s.deploymentName}
</Link>
) : (
@@ -97,33 +138,85 @@ export function BenchmarkDetail({ initial }: { initial: ListRow }) {
s.repoId
)}{" "}
· {s.runtimeName}
{r.kind === "ab" && r.snapshotB && (
<>
{" "}
· B:{" "}
{r.deploymentBId ? (
<Link
href={`/deployments/${r.deploymentBId}`}
className="hover:underline"
>
{r.snapshotB.deploymentName}
</Link>
) : (
r.snapshotB.deploymentName
)}
</>
)}
{r.sweepId && (
<>
{" "}
·{" "}
<Link
href={`/benchmarks/sweeps/${r.sweepId}`}
className="hover:underline"
>
part of a sweep
</Link>
</>
)}
</p>
<p className="text-xs text-muted-foreground">
BetterBench · {describeSettings(r.settings)} · created <LocalTime value={r.createdAt} />
{took && ` · ${r.state === "running" ? "running for" : "took"} ${took}`}
BetterBench ·{" "}
{r.kind === "ab"
? `paired A/B, target ±${r.settings.mdePct ?? 1}%, up to ${r.settings.maxPairs ?? 200} pairs`
: describeSettings(r.settings)}{" "}
· created <LocalTime value={r.createdAt} />
{took &&
` · ${r.state === "running" ? "running for" : "took"} ${took}`}
</p>
</div>
<div className="flex flex-wrap items-center gap-2">
{r.hasReport && (
<a href={`/api/benchmarks/${r.id}/report`} target="_blank" rel="noreferrer" className={buttonVariants({ variant: "outline" })}>
<a
href={`/api/benchmarks/${r.id}/report`}
target="_blank"
rel="noreferrer"
className={buttonVariants({ variant: "outline" })}
>
<ExternalLinkIcon />
Full report
</a>
)}
{r.state === "completed" && (
<a href={`/api/benchmarks/${r.id}/results`} className={buttonVariants({ variant: "outline" })}>
<a
href={`/api/benchmarks/${r.id}/results`}
className={buttonVariants({ variant: "outline" })}
>
<DownloadIcon />
results.json
{r.kind === "ab" ? "ab.json" : "results.json"}
</a>
)}
{active ? (
<Button variant="outline" disabled={!!r.cancelRequestedAt} onClick={async () => (await cancelBenchmark(r.id)) && router.refresh()}>
<Button
variant="outline"
disabled={!!r.cancelRequestedAt}
onClick={async () =>
(await cancelBenchmark(r.id)) && router.refresh()
}
>
<SquareIcon />
Cancel
</Button>
) : (
r.deploymentId && (
<Button variant="outline" onClick={again} title="Queue a new run with the same settings (the deployment must be running)">
r.deploymentId &&
!r.sweepId && (
<Button
variant="outline"
onClick={again}
title="Queue a new run with the same settings (the deployment must be running)"
>
<RotateCcwIcon />
Run again
</Button>
@@ -131,7 +224,13 @@ export function BenchmarkDetail({ initial }: { initial: ListRow }) {
)}
<AlertDialog>
<AlertDialogTrigger
render={<Button variant="outline" disabled={r.state === "running"} className="text-destructive hover:bg-destructive/10 hover:text-destructive" />}
render={
<Button
variant="outline"
disabled={r.state === "running"}
className="text-destructive hover:bg-destructive/10 hover:text-destructive"
/>
}
>
<Trash2Icon />
Delete
@@ -139,7 +238,9 @@ export function BenchmarkDetail({ initial }: { initial: ListRow }) {
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Delete this benchmark?</AlertDialogTitle>
<AlertDialogDescription>Its numbers, log, results.json and HTML report are removed.</AlertDialogDescription>
<AlertDialogDescription>
Its numbers, log, results.json and HTML report are removed.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
@@ -164,21 +265,37 @@ export function BenchmarkDetail({ initial }: { initial: ListRow }) {
{r.error && (
<div className="flex gap-3 rounded-xl border border-destructive/30 bg-destructive/10 px-4 py-3 text-sm">
<TriangleAlertIcon className="mt-0.5 size-4 shrink-0 text-destructive" />
<pre className="min-w-0 flex-1 font-sans break-words whitespace-pre-wrap">{r.error}</pre>
<pre className="min-w-0 flex-1 font-sans break-words whitespace-pre-wrap">
{r.error}
</pre>
</div>
)}
{r.state === "queued" && <p className="text-sm text-muted-foreground">Waiting: benchmarks run one at a time.</p>}
{r.state === "running" && r.phase && <p className="text-sm text-muted-foreground">Now: {r.phase}</p>}
{r.state === "queued" && (
<p className="text-sm text-muted-foreground">
Waiting: benchmarks run one at a time.
</p>
)}
{r.state === "running" && r.phase && (
<p className="text-sm text-muted-foreground">Now: {r.phase}</p>
)}
<div className="grid items-start gap-4 lg:grid-cols-[minmax(0,1fr)_340px]">
<div className="flex min-w-0 flex-col gap-4">
<BenchmarkReport run={r} />
<LiveLog url={`/api/benchmarks/${r.id}/logs`} title="BetterBench output" live={active} />
{r.kind === "ab" ? <AbReport run={r} /> : <BenchmarkReport run={r} />}
<LiveLog
url={`/api/benchmarks/${r.id}/logs`}
title="BetterBench output"
live={active}
/>
</div>
<aside className="flex flex-col gap-4">
{r.state === "completed" && r.summary && (
<PublishCard runId={r.id} defaultTitle={r.label ?? `${s.repoId} ${weightsLabel(s)}`} defaultSummary={reportSummary(r)} />
{r.kind === "run" && r.state === "completed" && r.summary && (
<PublishCard
runId={r.id}
defaultTitle={r.label ?? `${s.repoId} ${weightsLabel(s)}`}
defaultSummary={reportSummary(r)}
/>
)}
<Card size="sm">
<CardHeader>
@@ -190,41 +307,52 @@ export function BenchmarkDetail({ initial }: { initial: ListRow }) {
maxLength={120}
placeholder="e.g. q8_0 KV cache"
onChange={(e) => setLabel(e.target.value)}
onBlur={async () => label !== (r.label ?? "") && (await renameBenchmark(r.id, label || null)) && setR({ ...r, label: label.trim() || null })}
onKeyDown={(e) => e.key === "Enter" && (e.target as HTMLInputElement).blur()}
onBlur={async () =>
label !== (r.label ?? "") &&
(await renameBenchmark(r.id, label || null)) &&
setR({ ...r, label: label.trim() || null })
}
onKeyDown={(e) =>
e.key === "Enter" && (e.target as HTMLInputElement).blur()
}
/>
</CardContent>
</Card>
<Card size="sm">
<CardHeader>
<CardTitle>Settings measured</CardTitle>
</CardHeader>
<CardContent className="flex flex-col gap-3">
<dl className="grid grid-cols-[max-content_1fr] gap-x-4 gap-y-1 text-xs">
{CONFIG_ROWS.map((row) => {
const v = row.value(s);
return v == null ? null : (
<div key={row.key} className="contents">
<dt className="text-muted-foreground">{row.label}</dt>
<dd className="min-w-0 font-mono break-all">{v}</dd>
</div>
);
})}
</dl>
<div className="flex flex-col gap-1">
<div className="flex items-center justify-between text-xs text-muted-foreground">
Command
<CopyButton value={s.command} label="Copy command" />
{r.kind === "run" && (
<Card size="sm">
<CardHeader>
<CardTitle>Settings measured</CardTitle>
</CardHeader>
<CardContent className="flex flex-col gap-3">
<dl className="grid grid-cols-[max-content_1fr] gap-x-4 gap-y-1 text-xs">
{CONFIG_ROWS.map((row) => {
const v = row.value(s);
return v == null ? null : (
<div key={row.key} className="contents">
<dt className="text-muted-foreground">{row.label}</dt>
<dd className="min-w-0 font-mono break-all">{v}</dd>
</div>
);
})}
</dl>
<div className="flex flex-col gap-1">
<div className="flex items-center justify-between text-xs text-muted-foreground">
Command
<CopyButton value={s.command} label="Copy command" />
</div>
<pre className="rounded-md bg-muted/60 px-2 py-1.5 font-mono text-[11px] break-all whitespace-pre-wrap">
{s.command}
</pre>
</div>
<pre className="rounded-md bg-muted/60 px-2 py-1.5 font-mono text-[11px] break-all whitespace-pre-wrap">{s.command}</pre>
</div>
{sum && (
<p className="text-[11px] text-muted-foreground">
BetterBench {sum.betterbenchVersion} · corpus v{sum.corpusVersion} · phases: {sum.phases.join(", ") || "–"}
</p>
)}
</CardContent>
</Card>
{sum && (
<p className="text-[11px] text-muted-foreground">
BetterBench {sum.betterbenchVersion} · corpus v
{sum.corpusVersion} · phases: {sum.phases.join(", ") || "–"}
</p>
)}
</CardContent>
</Card>
)}
</aside>
</div>
</div>