Benchmarks with BetterBench, launch80-style reports and publishing, GPU support
- Benchmarks: BetterBench 0.6.1 (pinned by checksum) runs against a running deployment, one at a time; quick/full/custom passes, phase selection, live step and output, cancel, run again, compare runs side by side. - Report page after launch80's bench.betterbench.v1: headline tiles, "Read these first" caveats (quick, sample gate, max_tokens truncation, batched streams, failures, skipped depths, prefix-cache hits), charts, full tables with daggered under-sampled cells, method text. All figures come from BetterBench's own report functions. - Publish to launch80 as a double opt-in: L80 dry run builds the exact payload for inspection, an explicit confirmation publishes that file (L80 CLI 0.4.0 pinned by checksum, L80_TOKEN worker-only). Endpoint and host never leave. - GPUs: runtime accelerator (CPU, NVIDIA, /dev/dri, ROCm) with presets for the official CUDA/Vulkan/Intel/ROCm builds; NVIDIA GPUs probed via nvidia-smi in a short-lived container; per-deployment GPU picking, -ngl, split mode, tensor split, MoE offload, vLLM tensor parallel and GPU memory share. - llama.cpp --cache-ram option (1 GiB for new deployments) and a memory estimate that counts it and the KV cache: the 8 GiB default made containers thrash at their memory limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f0b4adda63
commit
9e167a44f6
61 files changed
+9898
-194
No files matched your search
@@ -0,0 +1,127 @@
|
||||
import "server-only";
|
||||
import { readFile, rm } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { and, desc, eq } from "drizzle-orm";
|
||||
import { z } from "zod";
|
||||
import { runDir } from "@/lib/benchmark-paths";
|
||||
import { db } from "@/lib/db/client";
|
||||
import { benchmarkPublications, benchmarkRuns, settings } from "@/lib/db/schema";
|
||||
|
||||
export class PublicationError extends Error {
|
||||
constructor(
|
||||
public code: "invalid" | "not_found" | "busy",
|
||||
message: string,
|
||||
public status: number,
|
||||
) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
||||
/** Limits of the L80 CLI (internal/betterbench: maxTitle, maxSummary). */
|
||||
export const PreviewBody = z.object({
|
||||
title: z.string().trim().max(120).nullable().optional(),
|
||||
summary: z.string().trim().max(600).nullable().optional(),
|
||||
});
|
||||
|
||||
export type L80Status = { version: string | null; tokenSet: boolean; apiBase: string; checkedAt: string } | null;
|
||||
|
||||
export async function getL80Status(): Promise<L80Status> {
|
||||
const row = await db().query.settings.findFirst({ where: eq(settings.key, "l80.status") });
|
||||
return (row?.value as L80Status) ?? null;
|
||||
}
|
||||
|
||||
export type PublicationRow = typeof benchmarkPublications.$inferSelect;
|
||||
|
||||
export async function listPublications(runId: string): Promise<PublicationRow[]> {
|
||||
return db().select().from(benchmarkPublications).where(eq(benchmarkPublications.runId, runId)).orderBy(desc(benchmarkPublications.createdAt));
|
||||
}
|
||||
|
||||
async function getPublication(runId: string, pubId: string) {
|
||||
const p = await db().query.benchmarkPublications.findFirst({ where: and(eq(benchmarkPublications.id, pubId), eq(benchmarkPublications.runId, runId)) });
|
||||
if (!p) throw new PublicationError("not_found", "Publication not found.", 404);
|
||||
return p;
|
||||
}
|
||||
|
||||
/** Opt-in 1: build the exact payload with a dry run (nothing leaves the machine). */
|
||||
export async function requestPreview(runId: string, input: z.infer<typeof PreviewBody>) {
|
||||
const run = await db().query.benchmarkRuns.findFirst({ columns: { state: true }, where: eq(benchmarkRuns.id, runId) });
|
||||
if (!run) throw new PublicationError("not_found", "Benchmark not found.", 404);
|
||||
if (run.state !== "completed") throw new PublicationError("invalid", "Only completed runs can be published.", 409);
|
||||
const status = await getL80Status();
|
||||
if (!status?.version) throw new PublicationError("invalid", "The L80 CLI isn't available in this installation.", 409);
|
||||
const [row] = await db()
|
||||
.insert(benchmarkPublications)
|
||||
.values({ runId, title: input.title || null, summary: input.summary || null })
|
||||
.returning({ id: benchmarkPublications.id });
|
||||
return row;
|
||||
}
|
||||
|
||||
/** Opt-in 2: an explicit confirmation of a previewed payload. */
|
||||
export async function confirmPublication(runId: string, pubId: string, by: string | null) {
|
||||
const p = await getPublication(runId, pubId);
|
||||
if (p.state !== "previewed") throw new PublicationError("invalid", "Only a finished preview can be published.", 409);
|
||||
const status = await getL80Status();
|
||||
if (!status?.tokenSet) throw new PublicationError("invalid", "No launch80 token is configured (L80_TOKEN).", 409);
|
||||
await db()
|
||||
.update(benchmarkPublications)
|
||||
.set({ state: "publish", confirmedBy: by, confirmedAt: new Date() })
|
||||
.where(and(eq(benchmarkPublications.id, pubId), eq(benchmarkPublications.state, "previewed")));
|
||||
}
|
||||
|
||||
/** Throw away a preview (published ones stay as a record). */
|
||||
export async function discardPublication(runId: string, pubId: string) {
|
||||
const p = await getPublication(runId, pubId);
|
||||
if (p.state === "published" || p.state === "publish") throw new PublicationError("busy", "Published pages can't be withdrawn from here; they expire after 5 days.", 409);
|
||||
await db().delete(benchmarkPublications).where(eq(benchmarkPublications.id, pubId));
|
||||
await rm(payloadFile(runId, pubId), { force: true });
|
||||
}
|
||||
|
||||
export function payloadFile(runId: string, pubId: string): string {
|
||||
// Ids come from the URL; only ULIDs become a path.
|
||||
if (!/^[0-9A-HJKMNP-TV-Z]{26}$/.test(pubId)) throw new PublicationError("not_found", "Publication not found.", 404);
|
||||
return join(runDir(runId), "publications", `${pubId}.json`);
|
||||
}
|
||||
|
||||
export type PayloadPreview = {
|
||||
template: string;
|
||||
bytes: number;
|
||||
title: string | null;
|
||||
summary: string | null;
|
||||
model: string | null;
|
||||
notes: Record<string, string>;
|
||||
/** Top-level keys that will be sent, and env keys (endpoint/host must be absent). */
|
||||
keys: string[];
|
||||
envKeys: string[];
|
||||
hostRemoved: boolean;
|
||||
categories: string[];
|
||||
phases: string[];
|
||||
};
|
||||
|
||||
/** What the dry-run payload contains, read from the exact file that would be sent. */
|
||||
export async function readPayloadPreview(runId: string, pubId: string): Promise<PayloadPreview | null> {
|
||||
const p = await getPublication(runId, pubId);
|
||||
const raw = await readFile(payloadFile(runId, p.id), "utf8").catch(() => null);
|
||||
if (!raw) return null;
|
||||
const data = JSON.parse(raw) as Record<string, unknown> & {
|
||||
$template?: string;
|
||||
env?: Record<string, unknown>;
|
||||
l80?: { title?: string; summary?: string };
|
||||
single_stream?: Record<string, unknown>;
|
||||
prefill?: unknown[];
|
||||
concurrency?: unknown[];
|
||||
};
|
||||
const env = data.env ?? {};
|
||||
return {
|
||||
template: data.$template ?? p.template,
|
||||
bytes: Buffer.byteLength(raw),
|
||||
title: data.l80?.title ?? null,
|
||||
summary: data.l80?.summary ?? null,
|
||||
model: typeof env.model === "string" ? env.model : null,
|
||||
notes: (env.notes as Record<string, string>) ?? {},
|
||||
keys: Object.keys(data),
|
||||
envKeys: Object.keys(env),
|
||||
hostRemoved: !("endpoint" in env) && !("host" in env),
|
||||
categories: Object.keys(data.single_stream ?? {}),
|
||||
phases: [data.single_stream ? "decode" : null, data.prefill?.length ? "prefill" : null, data.concurrency?.length ? "concurrency" : null].filter(Boolean) as string[],
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user