A deterministic quality eval as a run type next to BetterBench: tool calling (12 requests), coding (8 Python functions checked by unit tests in a locked-down sandbox container) and long-context retrieval (needle at 3 depths in 3 lengths up to the context). Versioned eval set in src/evals/v1, score stored per run, shown on the run page, in compare views, the benchmark list and sweep tables (optional eval per variant); API kind "eval", quality in run/sweep/compare answers; skill updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
716bd8f2f0
commit
6b67c653b5
33 files changed
+3822
-79
No files matched your search
+105
-15
@@ -11,7 +11,22 @@ import { engineLabel, metaNotes, modelLabel, withLoadLinks } from "@/lib/benchma
|
||||
import { REPORT_FILE, RESULTS_FILE, runDir } from "@/lib/benchmark-paths";
|
||||
import { effectiveHardware, runSetup } from "@/lib/benchmark-snapshot";
|
||||
import { db } from "@/lib/db/client";
|
||||
import { apiKeys, benchmarkLogs, benchmarkRuns, type BenchmarkSummary, deployments, type LogStream, type RunMeta, runtimes } from "@/lib/db/schema";
|
||||
import {
|
||||
apiKeys,
|
||||
type BenchmarkKind,
|
||||
benchmarkLogs,
|
||||
benchmarkRuns,
|
||||
type BenchmarkSummary,
|
||||
deployments,
|
||||
type LogStream,
|
||||
QUALITY_SECTIONS,
|
||||
type QualityResult,
|
||||
type QualitySection,
|
||||
type RunMeta,
|
||||
runtimes,
|
||||
type SystemSummary,
|
||||
} from "@/lib/db/schema";
|
||||
import { EVAL_SEED, EVAL_SET_VERSION, SECTION_LABEL } from "@/lib/quality";
|
||||
import { ENGINE_PORT } from "@/lib/deploy-command";
|
||||
import { coreEnv } from "@/lib/env";
|
||||
import { abSummary } from "./ab-summary";
|
||||
@@ -21,13 +36,16 @@ import { log } from "./log";
|
||||
import { normalizePciAddress } from "./hardware";
|
||||
import { errorCauses } from "./log-causes";
|
||||
import { type GpuTargets, ResourceSampler } from "./resources";
|
||||
import { runQualityEval } from "./quality";
|
||||
import { docker, workerImage } from "./runtimes";
|
||||
|
||||
type Current = {
|
||||
runId: string;
|
||||
kind: "run" | "ab";
|
||||
kind: BenchmarkKind;
|
||||
deploymentIds: string[];
|
||||
child: ChildProcess;
|
||||
/** BetterBench (runs, A/B); null for a quality eval, which runs in-process and stops via `abort`. */
|
||||
child: ChildProcess | null;
|
||||
abort: AbortController | null;
|
||||
sampler: ResourceSampler | null;
|
||||
/** Recorded at the start; the PCIe links are replaced by the ones seen under load at the end. */
|
||||
meta: RunMeta | null;
|
||||
@@ -204,6 +222,7 @@ async function start(run: typeof benchmarkRuns.$inferSelect) {
|
||||
const setup = await runSetup([a.id, b?.id ?? null]);
|
||||
const [meta, metaB] = setup.metas;
|
||||
const metaNotesA = meta ? metaNotes(meta, setup.system, run.description) : {};
|
||||
if (run.kind === "eval") return startEval(run, a, keys, meta, setup.system);
|
||||
const args =
|
||||
run.kind === "ab" && b
|
||||
? abArgs({
|
||||
@@ -278,6 +297,7 @@ async function start(run: typeof benchmarkRuns.$inferSelect) {
|
||||
kind: run.kind,
|
||||
deploymentIds: [a.id, ...(b ? [b.id] : [])],
|
||||
child,
|
||||
abort: null,
|
||||
sampler,
|
||||
meta,
|
||||
metaB,
|
||||
@@ -296,13 +316,8 @@ async function start(run: typeof benchmarkRuns.$inferSelect) {
|
||||
log.info(`benchmark ${run.id}: started (${run.kind}) for ${s.deploymentName}`);
|
||||
}
|
||||
|
||||
async function done(cur: Current, code: number | null, signal: NodeJS.Signals | null) {
|
||||
const id = cur.runId;
|
||||
for (const stream of ["stdout", "stderr"] as const) {
|
||||
const rest = partial.get(`${id}:${stream}`);
|
||||
if (rest?.trim()) addLog(id, stream, rest, cur.secrets);
|
||||
partial.delete(`${id}:${stream}`);
|
||||
}
|
||||
/** Stop the resource sampler; record the PCIe links seen under load in the run's meta. */
|
||||
async function stopSampling(cur: Current) {
|
||||
const resources = (await cur.sampler?.stop().catch(() => null)) ?? null;
|
||||
if (current === cur) current = null;
|
||||
if (resources?.links) {
|
||||
@@ -310,9 +325,82 @@ async function done(cur: Current, code: number | null, signal: NodeJS.Signals |
|
||||
await db()
|
||||
.update(benchmarkRuns)
|
||||
.set({ meta: loaded(cur.meta), metaB: loaded(cur.metaB) })
|
||||
.where(eq(benchmarkRuns.id, id))
|
||||
.catch((err) => log.warn(`benchmark ${id}: link update failed: ${message(err)}`));
|
||||
.where(eq(benchmarkRuns.id, cur.runId))
|
||||
.catch((err) => log.warn(`benchmark ${cur.runId}: link update failed: ${message(err)}`));
|
||||
}
|
||||
return resources;
|
||||
}
|
||||
|
||||
/** Kaname's quality eval: in-process against the deployment, coding answers in the sandbox. */
|
||||
async function startEval(run: typeof benchmarkRuns.$inferSelect, a: Target, keys: string[], meta: RunMeta | null, system: SystemSummary) {
|
||||
const s = run.snapshot;
|
||||
const sections = run.settings.evalSections?.length ? run.settings.evalSections : [...QUALITY_SECTIONS];
|
||||
const dep = await db().query.deployments.findFirst({ columns: { engineInfo: true, options: true }, where: eq(deployments.id, a.id) });
|
||||
const contextTokens = dep?.engineInfo?.contextSize ?? dep?.options.contextSize ?? s.options.contextSize ?? null;
|
||||
addLog(run.id, "system", `Quality eval ${EVAL_SET_VERSION} of ${s.deploymentName} (${s.repoId} on ${s.runtimeName}): ${sections.join(", ")}; greedy, seed ${EVAL_SEED}`);
|
||||
await db().update(benchmarkRuns).set({ state: "running", startedAt: new Date(), error: null, phase: null, meta, system }).where(eq(benchmarkRuns.id, run.id));
|
||||
|
||||
const c = docker();
|
||||
const sampler = c ? new ResourceSampler(c, [{ side: "a" as const, containerId: a.containerId }], await gpuTargets([meta, null])) : null;
|
||||
await sampler?.start().catch((err) => log.warn(`resource sampling failed: ${message(err)}`));
|
||||
const cur: Current = {
|
||||
runId: run.id,
|
||||
kind: "eval",
|
||||
deploymentIds: [a.id],
|
||||
child: null,
|
||||
abort: new AbortController(),
|
||||
sampler,
|
||||
meta,
|
||||
metaB: null,
|
||||
maxPairs: null,
|
||||
cancelled: false,
|
||||
lost: null,
|
||||
secrets: keys,
|
||||
};
|
||||
current = cur;
|
||||
log.info(`benchmark ${run.id}: quality eval started for ${s.deploymentName}`);
|
||||
const onLine = (line: string) => {
|
||||
addLog(run.id, "stdout", line, keys);
|
||||
const m = line.match(/^(tools|coding|retrieval): starting$/);
|
||||
if (m) void db().update(benchmarkRuns).set({ phase: `Quality: ${SECTION_LABEL[m[1] as QualitySection]}` }).where(eq(benchmarkRuns.id, run.id)).then(() => {}, () => {});
|
||||
};
|
||||
runQualityEval(
|
||||
{ base: `http://${a.containerName}:${ENGINE_PORT[a.engine]}`, model: s.repoId, engine: a.engine, apiKey: keys[0] ?? null, contextTokens },
|
||||
{ sections, signal: cur.abort!.signal, log: onLine, docker: c, sandboxImage: workerImage() },
|
||||
).then(
|
||||
(q) => doneEval(cur, q, null),
|
||||
(err) => doneEval(cur, null, err),
|
||||
);
|
||||
}
|
||||
|
||||
async function doneEval(cur: Current, quality: QualityResult | null, err: unknown) {
|
||||
const id = cur.runId;
|
||||
const resources = await stopSampling(cur);
|
||||
if (cur.cancelled) {
|
||||
addLog(id, "system", "Cancelled.");
|
||||
await finish(id, { state: "cancelled", quality, resources });
|
||||
} else if (cur.lost) {
|
||||
addLog(id, "system", cur.lost);
|
||||
await finish(id, { state: "failed", error: cur.lost, quality, resources });
|
||||
} else if (err || !quality) {
|
||||
await finish(id, { state: "failed", error: `The quality eval failed: ${message(err)}`, resources });
|
||||
} else {
|
||||
addLog(id, "system", `Done: score ${quality.score ?? "–"} (${quality.sections.map((x) => `${x.section} ${x.unsupported ? "n/a" : `${x.passed}/${x.total}`}`).join(", ")}).`);
|
||||
await finish(id, { state: "completed", quality, resources });
|
||||
}
|
||||
tails.delete(id);
|
||||
await flushBenchmarkLogs().catch(() => {});
|
||||
log.info(`benchmark ${id}: quality eval ${cur.cancelled ? "cancelled" : cur.lost || err ? "failed" : `done, score ${quality?.score}`}`);
|
||||
}
|
||||
|
||||
async function done(cur: Current, code: number | null, signal: NodeJS.Signals | null) {
|
||||
const id = cur.runId;
|
||||
for (const stream of ["stdout", "stderr"] as const) {
|
||||
const rest = partial.get(`${id}:${stream}`);
|
||||
if (rest?.trim()) addLog(id, stream, rest, cur.secrets);
|
||||
partial.delete(`${id}:${stream}`);
|
||||
}
|
||||
const resources = await stopSampling(cur);
|
||||
const dir = runDir(id);
|
||||
const results = join(dir, cur.kind === "ab" ? AB_FILE : RESULTS_FILE);
|
||||
const hasReport = cur.kind === "run" && (await exists(join(dir, REPORT_FILE)));
|
||||
@@ -357,9 +445,11 @@ async function done(cur: Current, code: number | null, signal: NodeJS.Signals |
|
||||
}
|
||||
|
||||
function stop(cur: Current) {
|
||||
if (cur.child.exitCode !== null) return;
|
||||
cur.child.kill("SIGTERM");
|
||||
setTimeout(() => cur.child.exitCode === null && cur.child.kill("SIGKILL"), 10_000).unref();
|
||||
const child = cur.child;
|
||||
if (!child) return void cur.abort?.abort();
|
||||
if (child.exitCode !== null) return;
|
||||
child.kill("SIGTERM");
|
||||
setTimeout(() => child.exitCode === null && child.kill("SIGKILL"), 10_000).unref();
|
||||
}
|
||||
|
||||
/** Start the next queued run, stop the current one on cancel or when its deployment goes away. */
|
||||
|
||||
Reference in new issue
Block a user