- 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>
390 lines
19 KiB
TypeScript
390 lines
19 KiB
TypeScript
"use client";
|
||
|
||
import { TriangleAlertIcon } from "lucide-react";
|
||
import { BarChart } from "@/components/bar-chart";
|
||
import { BenchmarkResources } from "@/components/benchmark-resources";
|
||
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
|
||
import { f0, f1, isBatched, reportCaveats, reportMethod, reportSubtitle, reportSummary, undersampled, weightsLabel } from "@/lib/benchmark-report";
|
||
import { configChips } from "@/lib/benchmark-view";
|
||
import type { BenchmarkSummary } from "@/lib/db/schema";
|
||
import { cn } from "@/lib/utils";
|
||
import type { ListRow } from "../benchmark-list";
|
||
|
||
function Tile({ label, value, unit, note }: { label: string; value: string; unit: string; note: string }) {
|
||
return (
|
||
<div className="flex flex-col gap-1 rounded-xl bg-muted/50 px-4 py-3">
|
||
<span className="text-[11px] font-medium tracking-wide text-muted-foreground uppercase">{label}</span>
|
||
<span className="text-3xl font-semibold">
|
||
{value}
|
||
<span className="ml-1 text-base font-normal text-muted-foreground">{unit}</span>
|
||
</span>
|
||
<span className="text-xs text-muted-foreground">{note}</span>
|
||
</div>
|
||
);
|
||
}
|
||
|
||
function Section({ title, intro, children }: { title: string; intro?: string; children: React.ReactNode }) {
|
||
return (
|
||
<section className="flex flex-col gap-3">
|
||
<div className="flex flex-col gap-1">
|
||
<h2 className="text-base font-semibold">{title}</h2>
|
||
{intro && <p className="max-w-3xl text-sm text-muted-foreground">{intro}</p>}
|
||
</div>
|
||
{children}
|
||
</section>
|
||
);
|
||
}
|
||
|
||
/** A percentile cell, daggered when it fails BetterBench's sample gate. */
|
||
function Gated({ v, sum, section, k, metric, fmt = f1 }: { v: number | null | undefined; sum: BenchmarkSummary; section: string; k: string | number; metric: string; fmt?: (v: number | null | undefined) => string }) {
|
||
const gated = v != null && undersampled(sum, section, k, metric);
|
||
return (
|
||
<span className={cn(gated && "text-amber-700 dark:text-amber-300")} title={gated ? "Under-sampled: roughly the worst observed, not a percentile" : undefined}>
|
||
{fmt(v)}
|
||
{gated && "†"}
|
||
</span>
|
||
);
|
||
}
|
||
|
||
const date = (iso: string | null | undefined) =>
|
||
iso
|
||
? new Date(iso.replace(/([+-]\d\d)(\d\d)$/, "$1:$2"))
|
||
.toLocaleString("en-GB", { day: "2-digit", month: "short", year: "numeric", hour: "2-digit", minute: "2-digit" })
|
||
.toUpperCase()
|
||
.replace(",", " ·")
|
||
: "";
|
||
|
||
/** The run's report, after launch80's bench.betterbench.v1 page; every figure is one BetterBench reported. */
|
||
export function BenchmarkReport({ run }: { run: ListRow }) {
|
||
const sum = run.summary;
|
||
if (!sum) return null;
|
||
const s = run.snapshot;
|
||
const batched = isBatched(sum);
|
||
const caveats = reportCaveats(run);
|
||
const c = sum.combined;
|
||
const peak = sum.concurrency.length ? sum.concurrency.reduce((a, b) => (b.aggregate_tps > a.aggregate_tps ? b : a)) : null;
|
||
const cfg = sum.config ?? {};
|
||
const chips = [
|
||
sum.corpusVersion && `corpus v${sum.corpusVersion}`,
|
||
sum.single.length && sum.passes ? `${sum.passes} passes/cat` : null,
|
||
cfg.greedy ? "greedy" : cfg.temperature != null ? `temp ${cfg.temperature}` : null,
|
||
cfg.unique_nonce === false ? "warm prefix cache" : "cold prefix cache (nonce)",
|
||
`phases: ${sum.phases.join(", ")}`,
|
||
].filter(Boolean) as string[];
|
||
|
||
return (
|
||
<article className="flex flex-col gap-8 rounded-2xl bg-card px-5 py-6 ring-1 ring-foreground/10 sm:px-8 sm:py-8">
|
||
<header className="flex flex-col gap-3">
|
||
<span className="font-mono text-[11px] tracking-wider text-muted-foreground uppercase">
|
||
BetterBench {sum.betterbenchVersion} · {date(sum.timestamp ?? run.startedAt)}
|
||
</span>
|
||
<div className="flex flex-col gap-1">
|
||
<h2 className="text-2xl font-semibold tracking-tight">{run.label ?? `${s.repoId} ${weightsLabel(s) !== "safetensors" ? weightsLabel(s) : ""}`.trim()}</h2>
|
||
<p className="text-sm text-muted-foreground">{reportSubtitle(run)}</p>
|
||
</div>
|
||
<div className="flex flex-wrap gap-1.5">
|
||
{chips.map((x) => (
|
||
<span key={x} className="rounded-md border px-2 py-0.5 font-mono text-[11px] text-muted-foreground">
|
||
{x}
|
||
</span>
|
||
))}
|
||
<span className="rounded-md border px-2 py-0.5 font-mono text-[11px] text-muted-foreground">{s.runtimeName}</span>
|
||
{configChips(s).map((x) => (
|
||
<span key={x} className="rounded-md bg-muted px-2 py-0.5 font-mono text-[11px] text-muted-foreground">
|
||
{x}
|
||
</span>
|
||
))}
|
||
</div>
|
||
<p className="max-w-3xl text-sm leading-relaxed">{reportSummary(run)}</p>
|
||
</header>
|
||
|
||
{c && (
|
||
<div className="grid gap-3 sm:grid-cols-3">
|
||
<Tile label="Combined decode" value={f1(c.decode)} unit="t/s" note="weighted across categories" />
|
||
{batched ? (
|
||
<Tile label="Combined update p99" value={f1(c.update_p99)} unit="ms" note="gap between stream updates" />
|
||
) : (
|
||
<Tile label="Combined ITL 1% low" value={f1(c.itl_low1)} unit="t/s" note="the trustworthy tail metric" />
|
||
)}
|
||
<Tile label="Combined TTFT p50" value={f0(c.ttft_p50)} unit="ms" note="single-stream, batch = 1" />
|
||
</div>
|
||
)}
|
||
|
||
{caveats.length > 0 && (
|
||
<div className="flex gap-3 rounded-xl border border-amber-500/30 bg-amber-500/10 px-4 py-3 text-sm">
|
||
<TriangleAlertIcon className="mt-0.5 size-4 shrink-0 text-amber-600 dark:text-amber-400" />
|
||
<div className="flex flex-col gap-1.5">
|
||
<span className="font-medium text-amber-800 dark:text-amber-200">Read these first</span>
|
||
{caveats.map((x) => (
|
||
<p key={x} className="text-foreground/80">
|
||
{x}
|
||
</p>
|
||
))}
|
||
</div>
|
||
</div>
|
||
)}
|
||
|
||
{sum.single.length > 0 && (
|
||
<Section
|
||
title="Decode throughput by category"
|
||
intro={`Median per-pass decode t/s at batch = 1, ${sum.passes} passes per category. The vertical line is the weighted combined score.`}
|
||
>
|
||
<BarChart
|
||
axisLabel="Decode t/s (median)"
|
||
reference={c?.decode != null ? { value: c.decode, label: `combined ${f1(c.decode)}` } : null}
|
||
rows={sum.single.map((r) => ({
|
||
label: r.category,
|
||
value: r.decode_med,
|
||
valueLabel: f1(r.decode_med),
|
||
details: [
|
||
`decode ${f1(r.decode_med)} t/s`,
|
||
r.decode_iqr != null ? `IQR ${f1(r.decode_iqr)}` : "",
|
||
r.decode_cv != null ? `CV ${(r.decode_cv * 100).toFixed(1)}%` : "",
|
||
`${r.runs} passes`,
|
||
].filter(Boolean),
|
||
}))}
|
||
/>
|
||
<p className="text-xs text-muted-foreground">Hover a bar for its IQR and coefficient of variation. A high CV means the category's passes disagree, so read small differences there with care.</p>
|
||
</Section>
|
||
)}
|
||
|
||
{sum.single.length > 0 && !batched && sum.single.some((r) => r.itl_low1 != null && r.itl_high99 != null) && (
|
||
<Section
|
||
title="Inter-token latency range by category"
|
||
intro="Each bar spans the 1% low to the 99% high instantaneous token rate, with a tick at the median. Wide bars stutter; narrow bars feel smooth."
|
||
>
|
||
<BarChart
|
||
mode="range"
|
||
axisLabel="Instantaneous t/s"
|
||
rows={sum.single.map((r) => ({
|
||
label: r.category,
|
||
value: r.itl_med ?? null,
|
||
range: r.itl_low1 != null && r.itl_high99 != null ? [r.itl_low1, r.itl_high99] : null,
|
||
valueLabel: r.itl_low1 != null ? `${f1(r.itl_low1)} – ${f1(r.itl_high99)}${undersampled(sum, "single_stream", r.category, "itl_high99") ? "†" : ""}` : undefined,
|
||
details: [`1% low ${f1(r.itl_low1)} t/s`, `median ${f1(r.itl_med)} t/s`, `99% high ${f1(r.itl_high99)} t/s`],
|
||
}))}
|
||
/>
|
||
</Section>
|
||
)}
|
||
|
||
{sum.prefill.some((p) => !p.skipped) && (
|
||
<Section title="Prompt processing by input length" intro="Median prefill t/s (prompt tokens ÷ TTFT) at increasing input depth, cold prefix cache.">
|
||
<BarChart
|
||
axisLabel="Prefill t/s (median)"
|
||
rows={sum.prefill
|
||
.filter((p) => !p.skipped)
|
||
.map((p) => ({
|
||
label: `~${p.target_depth.toLocaleString("en-US")} tok`,
|
||
value: p.pp_med ?? null,
|
||
valueLabel: f0(p.pp_med),
|
||
details: [`prompt ${f0(p.prompt_tokens_med)} tokens`, `TTFT ${f0(p.ttft_p50)} ms`, `1% low ${f0(p.pp_low1)} · 99% high ${f0(p.pp_p99)} t/s`, `${p.pp_n ?? "?"} runs`],
|
||
}))}
|
||
/>
|
||
</Section>
|
||
)}
|
||
|
||
{sum.concurrency.length > 0 && (
|
||
<Section
|
||
title="Throughput under parallel load"
|
||
intro={`Aggregate t/s across all requests at each concurrency level${peak ? `; the knee is where the bars stop growing (peak at ${peak.level})` : ""}.`}
|
||
>
|
||
<BarChart
|
||
axisLabel="Aggregate t/s"
|
||
rows={sum.concurrency.map((x) => ({
|
||
label: `${x.level} parallel`,
|
||
value: x.aggregate_tps,
|
||
valueLabel: f1(x.aggregate_tps),
|
||
details: [`per request ${f1(x.decode_med)} t/s`, `TTFT p50 ${f0(x.ttft_p50)} ms · p99 ${f0(x.ttft_p99)} ms`, `${x.ok}/${x.requests} requests ok`],
|
||
}))}
|
||
/>
|
||
</Section>
|
||
)}
|
||
|
||
{run.resources && (
|
||
<Section title="Resources" intro="What the server used while BetterBench measured it.">
|
||
<BenchmarkResources stats={run.resources} />
|
||
</Section>
|
||
)}
|
||
|
||
<Section title="Full numbers">
|
||
{sum.single.length > 0 && (
|
||
<div className="overflow-x-auto rounded-lg ring-1 ring-foreground/10">
|
||
<Table className="text-xs">
|
||
<TableHeader>
|
||
<TableRow>
|
||
<TableHead className="pl-3">Category</TableHead>
|
||
<TableHead className="text-right">Passes</TableHead>
|
||
<TableHead className="text-right">TTFT p50</TableHead>
|
||
<TableHead className="text-right">TTFT p99</TableHead>
|
||
{batched ? (
|
||
<>
|
||
<TableHead className="text-right">Update p50</TableHead>
|
||
<TableHead className="text-right">Update p99</TableHead>
|
||
<TableHead className="text-right">Tok/update</TableHead>
|
||
</>
|
||
) : (
|
||
<>
|
||
<TableHead className="text-right">ITL 1% low</TableHead>
|
||
<TableHead className="text-right">ITL med</TableHead>
|
||
<TableHead className="text-right">ITL 99% high</TableHead>
|
||
</>
|
||
)}
|
||
<TableHead className="text-right">Decode med</TableHead>
|
||
<TableHead className="text-right">±IQR</TableHead>
|
||
<TableHead className="pr-3 text-right">CV</TableHead>
|
||
</TableRow>
|
||
</TableHeader>
|
||
<TableBody className="tabular-nums">
|
||
{sum.single.map((r) => (
|
||
<TableRow key={r.category}>
|
||
<TableCell className="pl-3">{r.category}</TableCell>
|
||
<TableCell className="text-right">{r.runs}</TableCell>
|
||
<TableCell className="text-right">{f1(r.ttft_p50)}</TableCell>
|
||
<TableCell className="text-right">
|
||
<Gated v={r.ttft_p99} sum={sum} section="single_stream" k={r.category} metric="ttft_p99" />
|
||
</TableCell>
|
||
{batched ? (
|
||
<>
|
||
<TableCell className="text-right">{f1(r.update_p50)}</TableCell>
|
||
<TableCell className="text-right">
|
||
<Gated v={r.update_p99} sum={sum} section="single_stream" k={r.category} metric="update_p99" />
|
||
</TableCell>
|
||
<TableCell className="text-right">{r.tok_per_update != null ? r.tok_per_update.toFixed(2) : "—"}</TableCell>
|
||
</>
|
||
) : (
|
||
<>
|
||
<TableCell className="text-right">{f1(r.itl_low1)}</TableCell>
|
||
<TableCell className="text-right">{f1(r.itl_med)}</TableCell>
|
||
<TableCell className="text-right">
|
||
<Gated v={r.itl_high99} sum={sum} section="single_stream" k={r.category} metric="itl_high99" />
|
||
</TableCell>
|
||
</>
|
||
)}
|
||
<TableCell className="text-right font-medium">{f1(r.decode_med)}</TableCell>
|
||
<TableCell className="text-right">{f1(r.decode_iqr)}</TableCell>
|
||
<TableCell className="pr-3 text-right">{r.decode_cv != null ? `${(r.decode_cv * 100).toFixed(1)}%` : "—"}</TableCell>
|
||
</TableRow>
|
||
))}
|
||
</TableBody>
|
||
</Table>
|
||
</div>
|
||
)}
|
||
<div className="grid gap-4 md:grid-cols-2">
|
||
{sum.concurrency.length > 0 && (
|
||
<div className="overflow-x-auto rounded-lg ring-1 ring-foreground/10">
|
||
<Table className="text-xs">
|
||
<TableHeader>
|
||
<TableRow>
|
||
<TableHead className="pl-3">Concurrency</TableHead>
|
||
<TableHead className="text-right">OK</TableHead>
|
||
<TableHead className="text-right">Aggregate t/s</TableHead>
|
||
<TableHead className="text-right">Decode med</TableHead>
|
||
<TableHead className="text-right">TTFT p50</TableHead>
|
||
<TableHead className="pr-3 text-right">TTFT p99</TableHead>
|
||
</TableRow>
|
||
</TableHeader>
|
||
<TableBody className="tabular-nums">
|
||
{sum.concurrency.map((x) => (
|
||
<TableRow key={x.level}>
|
||
<TableCell className="pl-3">{x.level}</TableCell>
|
||
<TableCell className="text-right">
|
||
{x.ok}/{x.requests}
|
||
</TableCell>
|
||
<TableCell className="text-right font-medium">{f1(x.aggregate_tps)}</TableCell>
|
||
<TableCell className="text-right">{f1(x.decode_med)}</TableCell>
|
||
<TableCell className="text-right">{f1(x.ttft_p50)}</TableCell>
|
||
<TableCell className="pr-3 text-right">
|
||
<Gated v={x.ttft_p99} sum={sum} section="concurrency" k={x.level} metric="ttft_p99" />
|
||
</TableCell>
|
||
</TableRow>
|
||
))}
|
||
</TableBody>
|
||
</Table>
|
||
</div>
|
||
)}
|
||
{sum.prefill.length > 0 && (
|
||
<div className="overflow-x-auto rounded-lg ring-1 ring-foreground/10">
|
||
<Table className="text-xs">
|
||
<TableHeader>
|
||
<TableRow>
|
||
<TableHead className="pl-3">Depth</TableHead>
|
||
<TableHead className="text-right">Prompt tok</TableHead>
|
||
<TableHead className="text-right">TTFT p50</TableHead>
|
||
<TableHead className="text-right">PP 1% low</TableHead>
|
||
<TableHead className="text-right">PP med</TableHead>
|
||
<TableHead className="pr-3 text-right">PP 99%</TableHead>
|
||
</TableRow>
|
||
</TableHeader>
|
||
<TableBody className="tabular-nums">
|
||
{sum.prefill.map((p) => (
|
||
<TableRow key={p.target_depth}>
|
||
<TableCell className="pl-3">~{p.target_depth.toLocaleString("en-US")}</TableCell>
|
||
{p.skipped ? (
|
||
<TableCell colSpan={5} className="pr-3 text-right text-muted-foreground">
|
||
skipped
|
||
</TableCell>
|
||
) : (
|
||
<>
|
||
<TableCell className="text-right">{f0(p.prompt_tokens_med)}</TableCell>
|
||
<TableCell className="text-right">{f1(p.ttft_p50)}</TableCell>
|
||
<TableCell className="text-right">{f1(p.pp_low1)}</TableCell>
|
||
<TableCell className="text-right font-medium">{f1(p.pp_med)}</TableCell>
|
||
<TableCell className="pr-3 text-right">
|
||
<Gated v={p.pp_p99} sum={sum} section="prefill" k={p.target_depth} metric="pp_p99" />
|
||
</TableCell>
|
||
</>
|
||
)}
|
||
</TableRow>
|
||
))}
|
||
</TableBody>
|
||
</Table>
|
||
</div>
|
||
)}
|
||
</div>
|
||
{sum.reasoning && sum.reasoning.length > 0 && (
|
||
<div className="overflow-x-auto rounded-lg ring-1 ring-foreground/10">
|
||
<Table className="text-xs">
|
||
<TableHeader>
|
||
<TableRow>
|
||
<TableHead className="pl-3">Category</TableHead>
|
||
<TableHead className="text-right">Split known</TableHead>
|
||
<TableHead className="text-right">Reasoning share</TableHead>
|
||
<TableHead className="text-right">Never answered</TableHead>
|
||
<TableHead className="pr-3 text-right">Time to first answer p50</TableHead>
|
||
</TableRow>
|
||
</TableHeader>
|
||
<TableBody className="tabular-nums">
|
||
{sum.reasoning.map((x) => (
|
||
<TableRow key={x.category}>
|
||
<TableCell className="pl-3">{x.category}</TableCell>
|
||
<TableCell className="text-right">
|
||
{x.known}/{x.runs}
|
||
</TableCell>
|
||
<TableCell className="text-right">{x.reasoning_share != null ? `${Math.round(x.reasoning_share * 100)}%` : "unknown"}</TableCell>
|
||
<TableCell className="text-right">{x.never_answered}</TableCell>
|
||
<TableCell className="pr-3 text-right">{x.ttfa_p50 != null ? `${f0(x.ttfa_p50)} ms` : "unknown"}</TableCell>
|
||
</TableRow>
|
||
))}
|
||
</TableBody>
|
||
</Table>
|
||
</div>
|
||
)}
|
||
</Section>
|
||
|
||
<Section title="Method">
|
||
<div className="flex max-w-3xl flex-col gap-2 text-sm text-muted-foreground">
|
||
{reportMethod(sum).map((p) => (
|
||
<p key={p}>{p}</p>
|
||
))}
|
||
</div>
|
||
</Section>
|
||
|
||
<footer className="border-t pt-4 text-xs text-muted-foreground">
|
||
Generated by Kaname from a BetterBench {sum.betterbenchVersion} run{sum.corpusVersion ? ` on corpus v${sum.corpusVersion}` : ""}
|
||
{sum.corpusHash ? ` (corpus hash ${sum.corpusHash})` : ""}. Results are only comparable within a corpus version. Every figure comes from BetterBench's own report
|
||
functions; Kaname adds none.
|
||
</footer>
|
||
</article>
|
||
);
|
||
}
|