Files
Kaname/src/worker/engine-info.ts
T
Pascal LinxweilerandClaude Opus 5.5 ee6c623e2a
Release / release (push) Successful in 3m25s
Release 0.11.0: benchmark metadata and system info
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>
2026-10-20 19:07:04 +02:00

46 lines
2.3 KiB
TypeScript

// What a ready inference server says about itself: version, slots and context. llama.cpp: GET /props
// (build_info "b11429-d81235049", total_slots, default_generation_settings.n_ctx; checked with build
// 11429). vLLM: GET /version and GET /v1/models (max_model_len). Startup log lines as a fallback.
import type { EngineInfo, RuntimeEngine } from "@/lib/db/schema";
type Json = Record<string, unknown>;
const int = (v: unknown) => (typeof v === "number" && Number.isInteger(v) && v > 0 ? v : null);
const str = (v: unknown) => (typeof v === "string" && v.trim() ? v.trim().slice(0, 100) : null);
export function parseLlamaProps(props: Json | null): Omit<EngineInfo, "at"> {
const gen = (props?.default_generation_settings ?? {}) as Json;
return { version: str(props?.build_info), slots: int(props?.total_slots), contextSize: int(gen.n_ctx) };
}
export function parseVllm(version: Json | null, models: Json | null): Omit<EngineInfo, "at"> {
const data = Array.isArray(models?.data) ? (models.data as Json[]) : [];
return { version: str(version?.version), slots: null, contextSize: int(data[0]?.max_model_len) };
}
/** "build: 11429 (d8123504)" (llama.cpp), "vLLM API server version 0.31.0" (vLLM and most forks). */
export function versionFromLog(engine: RuntimeEngine, lines: string[]): string | null {
const re = engine === "llama.cpp" ? /\bbuild[:=]\s*(\d+)\s*\(([0-9a-f]+)\)/ : /\bversion\s+v?(\d+\.\d+[\w.+-]*)/i;
for (const l of lines) {
const m = l.match(re);
if (m) return engine === "llama.cpp" ? `b${m[1]}-${m[2]}` : m[1];
}
return null;
}
async function getJson(url: string, key: string | null): Promise<Json | null> {
try {
const res = await fetch(url, { headers: key ? { Authorization: `Bearer ${key}` } : {}, signal: AbortSignal.timeout(3_000) });
return res.ok ? ((await res.json()) as Json) : null;
} catch {
return null;
}
}
/** Ask the server at http://name:port; `key` when the deployment requires an API key. */
export async function fetchEngineInfo(engine: RuntimeEngine, base: string, key: string | null): Promise<Omit<EngineInfo, "at">> {
if (engine === "llama.cpp") return parseLlamaProps(await getJson(`${base}/props`, key));
const [version, models] = await Promise.all([getJson(`${base}/version`, key), getJson(`${base}/v1/models`, key)]);
return parseVllm(version, models);
}