Kaname keeps two jobs: the model downloader and benchmarks. Benchmarks now run against endpoints (any OpenAI-compatible server added by URL, with an optional server-side API key and hand-written hardware notes) instead of deployments Kaname started itself. Removed: runtimes, deployments, sweeps, resource telemetry, hardware detection, the /api/v1 API with tokens and guardrails, and all Docker access. The quality eval's coding tests run in a network-less sandbox container that shares only an exchange folder with the worker. The previous state is kept in branch backup / tag backup-0.14.3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1d2f908b75
commit
276108932d
199 files changed
+5462
-15961
No files matched your search
+61
-88
@@ -1,9 +1,9 @@
|
||||
// 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.
|
||||
// What a benchmark run records about its setup (RunMeta, SystemSummary) and the BetterBench notes
|
||||
// made from it. Kaname can't see the machine behind an endpoint, so both come from the endpoint's
|
||||
// hardware notes plus what the server reports. 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";
|
||||
import type { EndpointEngine, EndpointHardware, EndpointSnapshot, RunMeta, SystemSummary } from "@/lib/db/schema";
|
||||
import { formatLink, formatLinkPair, onOff, parseLinkText, systemSummaryText } from "@/lib/hardware";
|
||||
|
||||
/** "ghcr.io/org/img:tag@sha256:…" → "tag" (null: no tag, i.e. "latest" or digest only). */
|
||||
export function imageTag(ref: string): string | null {
|
||||
@@ -13,82 +13,69 @@ export function imageTag(ref: string): string | null {
|
||||
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);
|
||||
const NAME_QUANT = /[-_.:]((?:UD-)?(?:I?Q\d(?:_[A-Z0-9]+)*|BF16|F16|F32|MXFP4(?:_MOE)?|TQ\d_\d))$/i;
|
||||
|
||||
/** The quant named in a model name: a GGUF quant tag ("Q4_K_M", "IQ3_XXS") or FP8, AWQ, … */
|
||||
export function quantFromName(name: string): string | null {
|
||||
const base = name.trim().replace(/\.gguf$/i, "").replace(/-\d{5}-of-\d{5}$/, "");
|
||||
const gguf = base.match(NAME_QUANT);
|
||||
if (gguf) return gguf[1];
|
||||
const m = base.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}`;
|
||||
}
|
||||
export const ENGINE_LABEL: Record<EndpointEngine, string> = { "llama.cpp": "llama.cpp", vllm: "vLLM", sglang: "SGLang", ollama: "Ollama", other: "OpenAI-compatible server" };
|
||||
|
||||
/** 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";
|
||||
/** The run's setup from the endpoint snapshot: the hardware notes win over what the server reported. */
|
||||
export function endpointRunMeta(s: EndpointSnapshot): RunMeta {
|
||||
const h = s.hardware;
|
||||
const count = h.gpuName?.trim() ? Math.max(1, h.gpuCount ?? 1) : 0;
|
||||
const link = h.pcie ? parseLinkText(h.pcie) : null;
|
||||
const engine = s.engine ?? "other";
|
||||
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,
|
||||
gpus: Array.from({ length: count }, () => ({
|
||||
name: h.gpuName!.trim(),
|
||||
vramMb: h.vramGb ? Math.round(h.vramGb * 1024) : null,
|
||||
linkCurrent: link,
|
||||
linkMax: link,
|
||||
rebar: h.rebar ?? null,
|
||||
})),
|
||||
// Typed in by the user, not sampled at idle.
|
||||
linkUnderLoad: true,
|
||||
p2p: count < 2 ? "n/a" : (h.p2p ?? null),
|
||||
rebar: count ? (h.rebar ?? null) : 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,
|
||||
image: h.image?.trim() ?? "",
|
||||
tag: h.image?.trim() ? imageTag(h.image.trim()) : null,
|
||||
digest: null,
|
||||
engine,
|
||||
engineName: h.engineName?.trim() || ENGINE_LABEL[engine],
|
||||
engineVersion: h.engineVersion?.trim() || s.engineVersion,
|
||||
},
|
||||
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 ?? [],
|
||||
model: { repoId: s.model, file: null, quant: h.quant?.trim() || quantFromName(s.model), kvCache: h.kvCache?.trim() || null },
|
||||
contextSize: h.contextSize ?? s.contextSize,
|
||||
concurrency: h.concurrency ?? s.slots ?? null,
|
||||
overridden: [],
|
||||
};
|
||||
}
|
||||
|
||||
/** The publishable system summary from the notes: CPU, RAM, OS, driver, virtualization, Kaname. */
|
||||
export function endpointSystem(h: EndpointHardware, kaname: string): SystemSummary {
|
||||
const virt = h.virtualization?.trim() || null;
|
||||
const bare = !!virt && /bare[\s-]*metal/i.test(virt);
|
||||
return {
|
||||
cpu: { model: h.cpu?.trim() || null, cores: null, threads: null },
|
||||
// GB as entered (formatBytes shows decimal units too).
|
||||
memoryBytes: h.memoryGb ? Math.round(h.memoryGb * 1e9) : null,
|
||||
storage: null,
|
||||
os: h.os?.trim() || null,
|
||||
kernel: null,
|
||||
gpuDrivers: h.gpuDriver?.trim() ? [h.gpuDriver.trim()] : [],
|
||||
virtualization: { vm: virt ? !bare : null, hypervisor: virt && !bare ? virt : null, gpuPassthrough: null },
|
||||
kaname,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -117,19 +104,6 @@ export function pcieMaxLabel(m: RunMeta): string | null {
|
||||
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" */
|
||||
@@ -146,8 +120,8 @@ export function metaRows(m: RunMeta): { key: string; label: string; value: strin
|
||||
...(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" },
|
||||
...(m.runtime.image ? [{ key: "image", label: "Image", value: m.runtime.image }] : []),
|
||||
...(m.runtime.digest ? [{ key: "digest", label: "Digest", value: m.runtime.digest }] : []),
|
||||
{ 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" },
|
||||
@@ -161,7 +135,7 @@ export function metaRows(m: RunMeta): { key: string; label: string; value: strin
|
||||
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.image ? { 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 } : {}),
|
||||
@@ -170,7 +144,6 @@ export function metaNotes(m: RunMeta, system: SystemSummary | null, description:
|
||||
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);
|
||||
|
||||
Reference in new issue
Block a user