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:
1 parent
9e167a44f6
commit
b623b16a6d
37 files changed
+4314
-214
No files matched your search
@@ -2,7 +2,7 @@ import { readFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { withAuth } from "@/lib/api-auth";
|
||||
import { apiError } from "@/lib/api-errors";
|
||||
import { RESULTS_FILE, runDir } from "@/lib/benchmark-paths";
|
||||
import { AB_FILE, RESULTS_FILE, runDir } from "@/lib/benchmark-paths";
|
||||
import { getBenchmark } from "@/lib/benchmarks";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
@@ -11,15 +11,19 @@ export const dynamic = "force-dynamic";
|
||||
export const GET = withAuth<RouteContext<"/api/benchmarks/[id]/results">>(async (_req, { params }) => {
|
||||
const run = await getBenchmark((await params).id);
|
||||
if (!run) return apiError(404, "not_found", "Benchmark not found.");
|
||||
const raw = await readFile(join(runDir(run.id), RESULTS_FILE), "utf8").catch(() => null);
|
||||
const ab = run.kind === "ab";
|
||||
const raw = await readFile(join(runDir(run.id), ab ? AB_FILE : RESULTS_FILE), "utf8").catch(() => null);
|
||||
if (!raw) return apiError(404, "not_found", "This run has no results file.");
|
||||
// Like launch80's L80 CLI: the endpoint URL and host name never leave the machine.
|
||||
const data = JSON.parse(raw) as { env?: Record<string, unknown> };
|
||||
const data = JSON.parse(raw) as { env?: Record<string, unknown>; endpoint_a?: unknown; endpoint_b?: unknown };
|
||||
if (data.env) {
|
||||
delete data.env.endpoint;
|
||||
delete data.env.endpoint_b;
|
||||
delete data.env.host;
|
||||
}
|
||||
delete data.endpoint_a;
|
||||
delete data.endpoint_b;
|
||||
const json = JSON.stringify(data, null, 2);
|
||||
const name = `betterbench-${run.snapshot.deploymentName.replace(/[^\w.-]+/g, "-")}-${run.id.slice(-6).toLowerCase()}.json`;
|
||||
const name = `betterbench-${ab ? "ab-" : ""}${run.snapshot.deploymentName.replace(/[^\w.-]+/g, "-")}-${run.id.slice(-6).toLowerCase()}.json`;
|
||||
return new Response(json, { headers: { "Content-Type": "application/json", "Content-Disposition": `attachment; filename="${name}"` } });
|
||||
});
|
||||
Reference in new issue
Block a user