Every run records GPUs (PCIe link under load and maximum, ReBAR, P2P), runtime image/tag/digest and the engine version the server reports, model, quant, KV cache, context and concurrency, plus a whitelisted system summary and a description. Shown on the run page, compare and sweep views; passed to BetterBench as notes and to the launch80 preview as sections. Settings -> Hardware for manual values. Also: scripts/intel-probe.sh (read-only diagnostics for Intel hosts), and --quick is no longer passed together with --passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
981c4170fc
commit
ee6c623e2a
45 files changed
+4627
-60
No files matched your search
@@ -0,0 +1,181 @@
|
||||
// What a benchmark run records about its setup (RunMeta) and the BetterBench notes made from it.
|
||||
// Pure; shared by the worker, the web app and tests.
|
||||
|
||||
import type { DeploymentOptions, EngineInfo, HardwareGpu, HostGpu, PcieLink, RunMeta, RuntimeAccelerator, RuntimeEngine, SystemSummary } from "@/lib/db/schema";
|
||||
import { type EffectiveHardware, formatLink, formatLinkPair, onOff, systemSummaryText } from "@/lib/hardware";
|
||||
import { quantGroup } from "@/lib/selection";
|
||||
|
||||
/** "ghcr.io/org/img:tag@sha256:…" → "tag" (null: no tag, i.e. "latest" or digest only). */
|
||||
export function imageTag(ref: string): string | null {
|
||||
const noDigest = ref.split("@")[0];
|
||||
const last = noDigest.slice(noDigest.lastIndexOf("/") + 1);
|
||||
const i = last.indexOf(":");
|
||||
return i >= 0 ? last.slice(i + 1) : null;
|
||||
}
|
||||
|
||||
/** Value of `--flag v` or `--flag=v` in an argument list (last one wins). */
|
||||
export function argValue(args: string[], ...flags: string[]): string | null {
|
||||
let v: string | null = null;
|
||||
for (let i = 0; i < args.length; i++) {
|
||||
for (const f of flags) {
|
||||
if (args[i] === f && i + 1 < args.length) v = args[i + 1];
|
||||
else if (args[i].startsWith(`${f}=`)) v = args[i].slice(f.length + 1);
|
||||
}
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
const REPO_QUANT = /(?:^|[-_.])(nvfp4|mxfp4|fp8(?:[-_]dynamic)?|int8|int4|w8a8|w4a16|awq|gptq|bnb[-_]?4bit|bf16|fp16)(?=$|[-_.])/i;
|
||||
|
||||
/** Quant: the GGUF's quant tag, vLLM's --quantization, or one named in the repo (FP8, AWQ, …). */
|
||||
export function quantOf(engine: RuntimeEngine, file: string | null, repoId: string, args: string[]): string | null {
|
||||
if (engine === "llama.cpp" && file) return quantGroup(file);
|
||||
const q = argValue(args, "--quantization", "-q");
|
||||
if (q) return q;
|
||||
const m = repoId.split("/").pop()?.match(REPO_QUANT);
|
||||
return m ? m[1].toUpperCase().replace("_", "-") : null;
|
||||
}
|
||||
|
||||
/** KV cache type: llama.cpp -ctk/-ctv (f16 default), vLLM --kv-cache-dtype ("auto": the model's dtype). */
|
||||
export function kvCacheOf(engine: RuntimeEngine, o: Pick<DeploymentOptions, "cacheTypeK" | "cacheTypeV">, args: string[]): string {
|
||||
if (engine === "vllm") return argValue(args, "--kv-cache-dtype") ?? "auto";
|
||||
const k = argValue(args, "-ctk", "--cache-type-k") ?? o.cacheTypeK ?? "f16";
|
||||
const v = argValue(args, "-ctv", "--cache-type-v") ?? o.cacheTypeV ?? "f16";
|
||||
return k === v ? k : `K ${k} / V ${v}`;
|
||||
}
|
||||
|
||||
/** The GPUs a deployment gets: NVIDIA by UUID (all when none picked), /dev/dri ones by vendor. */
|
||||
export function gpusUsed(hw: EffectiveHardware | null, accelerator: RuntimeAccelerator | undefined, options: Pick<DeploymentOptions, "gpus">, nvidia: HostGpu[]): HardwareGpu[] {
|
||||
const all = hw?.gpus ?? [];
|
||||
if (accelerator === "nvidia") {
|
||||
const picked = options.gpus?.length ? nvidia.filter((g) => options.gpus!.includes(g.uuid)).map((g) => g.pciAddress) : null;
|
||||
return all.filter((g) => g.vendor === "nvidia" && (!picked || picked.includes(g.pciAddress)));
|
||||
}
|
||||
if (accelerator === "dri") return all.filter((g) => g.vendor === "intel" || g.vendor === "amd");
|
||||
if (accelerator === "rocm") return all.filter((g) => g.vendor === "amd");
|
||||
return [];
|
||||
}
|
||||
|
||||
export function buildRunMeta(x: {
|
||||
hardware: EffectiveHardware | null;
|
||||
gpus: HardwareGpu[];
|
||||
runtime: { image: string; digest: string | null; engine: RuntimeEngine; engineName: string | null; extraArgs: string[] };
|
||||
repoId: string;
|
||||
options: DeploymentOptions;
|
||||
engineInfo: EngineInfo | null;
|
||||
}): RunMeta {
|
||||
const args = [...x.runtime.extraArgs, ...x.options.extraArgs];
|
||||
const llama = x.runtime.engine === "llama.cpp";
|
||||
return {
|
||||
v: 1,
|
||||
gpus: x.gpus.map((g) => ({ pciAddress: g.pciAddress, name: g.name, vramMb: g.vramMb, linkCurrent: g.linkCurrent, linkMax: g.linkMax, rebar: g.rebar })),
|
||||
linkUnderLoad: false,
|
||||
p2p: x.gpus.length < 2 ? "n/a" : (x.hardware?.p2p ?? null),
|
||||
rebar: x.gpus.length === 0 ? null : x.gpus.every((g) => g.rebar === true) ? true : x.gpus.some((g) => g.rebar === false) ? false : null,
|
||||
runtime: {
|
||||
image: x.runtime.image,
|
||||
tag: imageTag(x.runtime.image),
|
||||
digest: x.runtime.digest,
|
||||
engine: x.runtime.engine,
|
||||
engineName: x.runtime.engineName?.trim() || x.runtime.engine,
|
||||
engineVersion: x.engineInfo?.version ?? null,
|
||||
},
|
||||
model: {
|
||||
repoId: x.repoId,
|
||||
file: x.options.modelFile || null,
|
||||
quant: quantOf(x.runtime.engine, x.options.modelFile || null, x.repoId, args),
|
||||
kvCache: kvCacheOf(x.runtime.engine, x.options, args),
|
||||
},
|
||||
contextSize: x.engineInfo?.contextSize ?? x.options.contextSize ?? null,
|
||||
concurrency: x.engineInfo?.slots ?? (llama ? x.options.parallel : x.options.maxNumSeqs) ?? null,
|
||||
overridden: x.hardware?.overridden ?? [],
|
||||
};
|
||||
}
|
||||
|
||||
/** "2× NVIDIA RTX 4090 (24 GiB)", "1× Intel Arc Pro B65 (32 GiB) + 1× …"; null without GPUs. */
|
||||
export function gpuLabel(m: RunMeta): string | null {
|
||||
if (m.gpus.length === 0) return null;
|
||||
const counts = new Map<string, number>();
|
||||
for (const g of m.gpus) {
|
||||
const name = `${g.name ?? "unknown GPU"}${g.vramMb ? ` (${Math.round(g.vramMb / 1024)} GiB)` : ""}`;
|
||||
counts.set(name, (counts.get(name) ?? 0) + 1);
|
||||
}
|
||||
return [...counts].map(([name, n]) => `${n}× ${name}`).join(" + ");
|
||||
}
|
||||
|
||||
/** The PCIe links of the GPUs used, deduplicated; "(idle)" when not measured under load. */
|
||||
export function pcieLabel(m: RunMeta): string | null {
|
||||
const links = [...new Set(m.gpus.map((g) => formatLinkPair(g.linkCurrent, g.linkMax) ?? "unknown"))];
|
||||
if (!links.length) return null;
|
||||
const idle = !m.linkUnderLoad && m.gpus.some((g) => g.linkCurrent);
|
||||
return `${links.join(", ")}${idle ? " (at idle)" : ""}`;
|
||||
}
|
||||
|
||||
/** Maximum links only ("Gen5 x16"): known before the run, unlike the link under load. */
|
||||
export function pcieMaxLabel(m: RunMeta): string | null {
|
||||
const links = [...new Set(m.gpus.map((g) => formatLink(g.linkMax) ?? "unknown"))];
|
||||
return links.length ? links.join(", ") : null;
|
||||
}
|
||||
|
||||
/** The run's meta with the fastest links seen during the run as the current links (when sampled). */
|
||||
export function withLoadLinks(m: RunMeta | null, links: Record<string, PcieLink> | null | undefined, overridden: boolean): RunMeta | null {
|
||||
if (!m || !links || overridden) return m;
|
||||
let hit = false;
|
||||
const gpus = m.gpus.map((g) => {
|
||||
const l = g.pciAddress ? links[g.pciAddress] : undefined;
|
||||
if (!l) return g;
|
||||
hit = true;
|
||||
return { ...g, linkCurrent: l };
|
||||
});
|
||||
return hit ? { ...m, gpus, linkUnderLoad: true } : m;
|
||||
}
|
||||
|
||||
export const engineLabel = (m: RunMeta) => [m.runtime.engineName, m.runtime.engineVersion].filter(Boolean).join(" ");
|
||||
|
||||
/** "Qwen3-8B-GGUF Q4_K_M with q8_0 KV cache" */
|
||||
export function modelLabel(m: RunMeta): string {
|
||||
const name = m.model.repoId.split("/").pop() ?? m.model.repoId;
|
||||
return `${name}${m.model.quant ? ` ${m.model.quant}` : ""}${m.model.kvCache ? ` with ${m.model.kvCache} KV cache` : ""}`;
|
||||
}
|
||||
|
||||
/** Rows for the run page, compare views and sweeps (label → value, "unknown" where not known). */
|
||||
export function metaRows(m: RunMeta): { key: string; label: string; value: string }[] {
|
||||
return [
|
||||
{ key: "gpus", label: "GPUs", value: gpuLabel(m) ?? "none (CPU)" },
|
||||
...(m.gpus.length ? [{ key: "pcie", label: "PCIe", value: pcieLabel(m) ?? "unknown" }] : []),
|
||||
...(m.gpus.length ? [{ key: "p2p", label: "P2P", value: m.p2p ?? "unknown" }] : []),
|
||||
...(m.gpus.length ? [{ key: "rebar", label: "ReBAR", value: onOff(m.rebar) }] : []),
|
||||
{ key: "engine", label: "Engine", value: engineLabel(m) || "unknown" },
|
||||
{ key: "image", label: "Image", value: m.runtime.image },
|
||||
{ key: "digest", label: "Digest", value: m.runtime.digest ?? "unknown" },
|
||||
{ key: "model", label: "Model", value: modelLabel(m) },
|
||||
{ key: "ctx", label: "Context", value: m.contextSize != null ? m.contextSize.toLocaleString("en-US") : "unknown" },
|
||||
{ key: "concurrency", label: "Concurrency", value: m.concurrency != null ? String(m.concurrency) : "server default" },
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* BetterBench --note values (recorded in results.json, shown in its report and published to
|
||||
* launch80). `engine` is the key launch80 uses to name the stack.
|
||||
*/
|
||||
export function metaNotes(m: RunMeta, system: SystemSummary | null, description: string | null): Record<string, string> {
|
||||
const notes: Record<string, string> = {
|
||||
engine: engineLabel(m) || m.runtime.engine,
|
||||
image: m.runtime.image,
|
||||
...(m.runtime.digest ? { digest: m.runtime.digest } : {}),
|
||||
...(m.model.quant ? { quant: m.model.quant } : {}),
|
||||
...(m.model.kvCache ? { kv_cache: m.model.kvCache } : {}),
|
||||
...(m.contextSize != null ? { ctx: String(m.contextSize) } : {}),
|
||||
...(m.concurrency != null ? { concurrency: String(m.concurrency) } : {}),
|
||||
gpus: gpuLabel(m) ?? "none",
|
||||
};
|
||||
if (m.gpus.length) {
|
||||
// The link under load is only known after the run (idle GPUs drop to a slower link).
|
||||
notes.pcie_max = pcieMaxLabel(m) ?? "unknown";
|
||||
notes.p2p = m.p2p ?? "unknown";
|
||||
notes.rebar = onOff(m.rebar);
|
||||
}
|
||||
if (system) notes.system = systemSummaryText(system);
|
||||
if (description?.trim()) notes.description = description.trim().replace(/\s+/g, " ").slice(0, 2000);
|
||||
return notes;
|
||||
}
|
||||
Reference in new issue
Block a user