Release / release (push) Successful in 12m32s
Kaname keeps two jobs: the model downloader and benchmarks. Benchmarks now run against endpoints (any OpenAI-compatible server added by URL, with an optional server-side API key and hand-written hardware notes) instead of deployments Kaname started itself. Removed: runtimes, deployments, sweeps, resource telemetry, hardware detection, the /api/v1 API with tokens and guardrails, and all Docker access. The quality eval's coding tests run in a network-less sandbox container that shares only an exchange folder with the worker. The previous state is kept in branch backup / tag backup-0.14.3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
235 lines
11 KiB
TypeScript
235 lines
11 KiB
TypeScript
import type { Metadata } from "next";
|
||
import Link from "next/link";
|
||
import { BenchmarkStateBadge } from "@/components/benchmark-state";
|
||
import { Card } from "@/components/ui/card";
|
||
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
|
||
import { getBenchmarks } from "@/lib/benchmarks";
|
||
import { metaRows } from "@/lib/benchmark-meta";
|
||
import { SECTION_LABEL } from "@/lib/quality-view";
|
||
import { CONFIG_ROWS, deltaPct, describeSettings, headline, targetName } from "@/lib/benchmark-view";
|
||
import type { BenchmarkSummary } from "@/lib/db/schema";
|
||
import { cn } from "@/lib/utils";
|
||
|
||
export const dynamic = "force-dynamic";
|
||
export const metadata: Metadata = { title: "Compare benchmarks" };
|
||
|
||
type Metric = { label: string; unit: string; higherIsBetter: boolean; digits: number; get: (s: BenchmarkSummary | null, runIndex?: number) => number | null };
|
||
|
||
/** Differences smaller than this are shown without color: below what a single run can resolve. */
|
||
const NOISE_PCT = 2;
|
||
|
||
function Delta({ v, base, higherIsBetter }: { v: number | null; base: number | null; higherIsBetter: boolean }) {
|
||
const d = deltaPct(v, base);
|
||
if (d == null) return null;
|
||
const good = higherIsBetter ? d > 0 : d < 0;
|
||
return (
|
||
<span
|
||
className={cn(
|
||
"ml-1.5 text-[11px] tabular-nums",
|
||
Math.abs(d) < NOISE_PCT ? "text-muted-foreground" : good ? "text-emerald-600 dark:text-emerald-400" : "text-destructive",
|
||
)}
|
||
>
|
||
{d > 0 ? "+" : ""}
|
||
{d.toFixed(1)}%
|
||
</span>
|
||
);
|
||
}
|
||
|
||
export default async function ComparePage({ searchParams }: PageProps<"/benchmarks/compare">) {
|
||
const { ids } = await searchParams;
|
||
const runs = await getBenchmarks(
|
||
String(ids ?? "")
|
||
.split(",")
|
||
.filter(Boolean)
|
||
.slice(0, 16),
|
||
);
|
||
if (runs.length < 2) {
|
||
return (
|
||
<p className="text-sm text-muted-foreground">
|
||
Pick at least two completed runs on the{" "}
|
||
<Link href="/benchmarks" className="underline">
|
||
Benchmarks
|
||
</Link>{" "}
|
||
page.
|
||
</p>
|
||
);
|
||
}
|
||
|
||
const sums = runs.map((r) => r.summary);
|
||
const depths = [...new Set(sums.flatMap((s) => s?.prefill.filter((p) => !p.skipped).map((p) => p.target_depth) ?? []))].sort((a, b) => a - b);
|
||
const levels = [...new Set(sums.flatMap((s) => s?.concurrency.map((c) => c.level) ?? []))].sort((a, b) => a - b);
|
||
const categories = [...new Set(sums.flatMap((s) => s?.single.map((c) => c.category) ?? []))];
|
||
|
||
const groups: { group: string; rows: Metric[] }[] = [
|
||
{
|
||
group: "Headline",
|
||
rows: [
|
||
{ label: "Prefill (deepest prompt)", unit: "t/s", higherIsBetter: true, digits: 0, get: (s) => headline(s).prefill?.tps ?? null },
|
||
{ label: "Decode (weighted)", unit: "t/s", higherIsBetter: true, digits: 1, get: (s) => headline(s).decode },
|
||
{ label: "Time to first token", unit: "ms", higherIsBetter: false, digits: 0, get: (s) => headline(s).ttftMs },
|
||
],
|
||
},
|
||
{
|
||
group: "Decode per category",
|
||
rows: categories.map((c) => ({ label: c, unit: "t/s", higherIsBetter: true, digits: 1, get: (s) => s?.single.find((x) => x.category === c)?.decode_med ?? null })),
|
||
},
|
||
{
|
||
group: "Prompt processing",
|
||
rows: depths.map((d) => ({
|
||
label: `${d.toLocaleString()} tokens`,
|
||
unit: "t/s",
|
||
higherIsBetter: true,
|
||
digits: 0,
|
||
get: (s) => s?.prefill.find((p) => p.target_depth === d && !p.skipped)?.pp_med ?? null,
|
||
})),
|
||
},
|
||
{
|
||
group: "Parallel requests (total)",
|
||
rows: levels.map((l) => ({ label: `${l} parallel`, unit: "t/s", higherIsBetter: true, digits: 1, get: (s) => s?.concurrency.find((c) => c.level === l)?.aggregate_tps ?? null })),
|
||
},
|
||
];
|
||
// Quality evals: the score and each section's pass rate (only when some of the runs are evals).
|
||
const quality = runs.map((r) => r.quality);
|
||
if (quality.some(Boolean)) {
|
||
const sections = [...new Set(quality.flatMap((q) => q?.sections.map((s) => s.section) ?? []))];
|
||
groups.push({
|
||
group: `Quality (${[...new Set(quality.filter(Boolean).map((q) => q!.evalSet))].join(", ")})`,
|
||
rows: [
|
||
{ label: "Score", unit: "%", higherIsBetter: true, digits: 1, get: (_s, i) => quality[i!]?.score ?? null },
|
||
...sections.map((sec) => ({
|
||
label: SECTION_LABEL[sec],
|
||
unit: "%",
|
||
higherIsBetter: true,
|
||
digits: 1,
|
||
get: (_s: BenchmarkSummary | null, i?: number) => quality[i!]?.sections.find((x) => x.section === sec)?.score ?? null,
|
||
})),
|
||
],
|
||
});
|
||
}
|
||
const metrics = groups.filter((g) => g.rows.length > 0);
|
||
|
||
// Hardware, runtime version, model/quant/KV, context and concurrency as recorded at the start of each run.
|
||
const metaByRun = runs.map((r) => (r.meta ? metaRows(r.meta) : null));
|
||
const metaKeys = [...new Map(metaByRun.flatMap((rows) => rows ?? []).map((x) => [x.key, x.label])).entries()];
|
||
const metaTable = metaKeys.map(([key, label]) => ({ key, label, values: metaByRun.map((rows) => (rows ? (rows.find((x) => x.key === key)?.value ?? null) : null)) }));
|
||
const configRows = CONFIG_ROWS.map((row) => ({ row, values: runs.map((r) => row.value(r.snapshot)) })).filter((x) => x.values.some((v) => v != null));
|
||
const corpora = new Set(sums.map((s) => s?.corpusVersion).filter(Boolean));
|
||
const anyQuick = runs.some((r) => r.summary?.quick);
|
||
|
||
return (
|
||
<div className="flex flex-col gap-4">
|
||
<div className="flex flex-col gap-1">
|
||
<h1 className="text-xl font-semibold">Compare benchmarks</h1>
|
||
<p className="text-sm text-muted-foreground">
|
||
Differences are against the first run. Separate runs aren't paired in time, so differences below ~{NOISE_PCT}% are within normal noise.
|
||
</p>
|
||
{corpora.size > 1 && <p className="text-sm text-destructive">These runs used different prompt sets (corpus versions), so their numbers aren't comparable.</p>}
|
||
{anyQuick && <p className="text-sm text-amber-700 dark:text-amber-300">Some runs are quick runs (5 passes); their numbers are rough.</p>}
|
||
</div>
|
||
|
||
<Card className="py-0">
|
||
<Table>
|
||
<TableHeader>
|
||
<TableRow>
|
||
<TableHead className="w-48" />
|
||
{runs.map((r, i) => (
|
||
<TableHead key={r.id} className="align-top whitespace-normal">
|
||
<Link href={`/benchmarks/${r.id}`} className="font-medium text-foreground hover:underline">
|
||
{r.label ?? targetName(r.snapshot)}
|
||
</Link>
|
||
<div className="flex flex-wrap items-center gap-1 py-1 text-[11px] font-normal">
|
||
{i === 0 && <span className="rounded-4xl bg-primary px-1.5 text-primary-foreground">baseline</span>}
|
||
<BenchmarkStateBadge state={r.state} />
|
||
</div>
|
||
<div className="text-[11px] font-normal text-muted-foreground">{describeSettings(r.settings)}</div>
|
||
</TableHead>
|
||
))}
|
||
</TableRow>
|
||
</TableHeader>
|
||
<TableBody>
|
||
{metaTable.length > 0 && (
|
||
<>
|
||
<TableRow className="bg-muted/40 hover:bg-muted/40">
|
||
<TableCell colSpan={runs.length + 1} className="text-xs font-medium tracking-wide text-muted-foreground uppercase">
|
||
Hardware & runtime
|
||
</TableCell>
|
||
</TableRow>
|
||
{metaTable.map(({ key, label, values }) => {
|
||
const differs = new Set(values.map((v) => v ?? "")).size > 1;
|
||
return (
|
||
<TableRow key={`meta-${key}`} className={cn(differs && "bg-amber-500/5")}>
|
||
<TableCell className={cn("text-xs", differs ? "font-medium" : "text-muted-foreground")}>{label}</TableCell>
|
||
{values.map((v, i) => (
|
||
<TableCell key={i} className={cn("font-mono text-xs break-all whitespace-normal", differs && i > 0 && v !== values[0] && "text-amber-700 dark:text-amber-300")}>
|
||
{v ?? <span className="text-muted-foreground">not recorded</span>}
|
||
</TableCell>
|
||
))}
|
||
</TableRow>
|
||
);
|
||
})}
|
||
</>
|
||
)}
|
||
<TableRow className="bg-muted/40 hover:bg-muted/40">
|
||
<TableCell colSpan={runs.length + 1} className="text-xs font-medium tracking-wide text-muted-foreground uppercase">
|
||
Settings
|
||
</TableCell>
|
||
</TableRow>
|
||
{configRows.map(({ row, values }) => {
|
||
const differs = new Set(values.map((v) => v ?? "")).size > 1;
|
||
return (
|
||
<TableRow key={row.key} className={cn(differs && "bg-amber-500/5")}>
|
||
<TableCell className={cn("text-xs", differs ? "font-medium" : "text-muted-foreground")}>{row.label}</TableCell>
|
||
{values.map((v, i) => (
|
||
<TableCell key={i} className={cn("font-mono text-xs break-all whitespace-normal", differs && i > 0 && v !== values[0] && "text-amber-700 dark:text-amber-300")}>
|
||
{v ?? <span className="text-muted-foreground">default</span>}
|
||
</TableCell>
|
||
))}
|
||
</TableRow>
|
||
);
|
||
})}
|
||
{metrics.map((g) => (
|
||
<MetricGroup key={g.group} group={g.group} rows={g.rows} sums={sums} cols={runs.length} />
|
||
))}
|
||
</TableBody>
|
||
</Table>
|
||
</Card>
|
||
</div>
|
||
);
|
||
}
|
||
|
||
function MetricGroup({ group, rows, sums, cols }: { group: string; rows: Metric[]; sums: (BenchmarkSummary | null)[]; cols: number }) {
|
||
return (
|
||
<>
|
||
<TableRow className="bg-muted/40 hover:bg-muted/40">
|
||
<TableCell colSpan={cols + 1} className="text-xs font-medium tracking-wide text-muted-foreground uppercase">
|
||
{group}
|
||
</TableCell>
|
||
</TableRow>
|
||
{rows.map((m) => {
|
||
const vals = sums.map((s, i) => m.get(s, i));
|
||
const present = vals.filter((v): v is number => v != null);
|
||
const best = present.length > 1 ? (m.higherIsBetter ? Math.max(...present) : Math.min(...present)) : null;
|
||
return (
|
||
<TableRow key={m.label}>
|
||
<TableCell className="text-xs">{m.label}</TableCell>
|
||
{vals.map((v, i) => (
|
||
<TableCell key={i} className="tabular-nums whitespace-nowrap">
|
||
{v == null ? (
|
||
<span className="text-muted-foreground">–</span>
|
||
) : (
|
||
<>
|
||
<span className={cn(v === best && "font-semibold")}>
|
||
{v.toFixed(m.digits)} <span className="text-[11px] text-muted-foreground">{m.unit}</span>
|
||
</span>
|
||
{i > 0 && <Delta v={v} base={vals[0]} higherIsBetter={m.higherIsBetter} />}
|
||
</>
|
||
)}
|
||
</TableCell>
|
||
))}
|
||
</TableRow>
|
||
);
|
||
})}
|
||
</>
|
||
);
|
||
}
|