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:
Pascal LinxweilerandClaude Opus 5.5 committed 2026-10-10 20:54:38 +02:00
1 parent f0b4adda63
commit 9e167a44f6
61 files changed
+9898 -194

No files matched your search

+39 -8
View File
@@ -2,7 +2,7 @@
// containers and by the UI for the live preview. Flags verified against llama.cpp build 11429
// (`llama-server --help`) and vLLM v0.31.0 (`vllm serve --help=all`).
import type { DeploymentOptions, RuntimeEngine } from "@/lib/db/schema";
import type { DeploymentOptions, RuntimeAccelerator, RuntimeEngine } from "@/lib/db/schema";
/** Where the models folder is mounted inside every runtime container (read-only). */
export const CONTAINER_MODELS_DIR = "/models";
@@ -13,7 +13,8 @@ export type CommandInput = {
engine: RuntimeEngine;
options: DeploymentOptions;
model: { repoId: string; localPath: string };
runtime: { env: Record<string, string>; extraArgs: string[] };
/** `accelerator` unset: CPU. */
runtime: { env: Record<string, string>; extraArgs: string[]; accelerator?: RuntimeAccelerator };
/** Keys from Settings → API keys; used when `options.requireApiKey` is set. */
apiKeys?: string[];
};
@@ -42,6 +43,7 @@ function withoutFlag(args: string[], flag: string): string[] {
export function buildCommand({ engine, options: o, model, runtime, apiKeys = [] }: CommandInput): ContainerCommand {
const port = ENGINE_PORT[engine];
const keys = o.requireApiKey ? apiKeys : [];
const gpu = !!runtime.accelerator && runtime.accelerator !== "cpu";
if (engine === "llama.cpp") {
// The image's entrypoint is llama-server, so these are its arguments.
const args = [
@@ -62,9 +64,16 @@ export function buildCommand({ engine, options: o, model, runtime, apiKeys = []
...str("-ctk", o.cacheTypeK),
...str("-ctv", o.cacheTypeV),
...str("-fa", o.flashAttn),
...num("-cram", o.cacheRamMb),
...(o.mmproj ? ["--mmproj", inModels(model.localPath, o.mmproj)] : []),
...(o.draftFile ? ["-md", inModels(model.localPath, o.draftFile), "--spec-type", o.draftType ?? "draft-simple"] : []),
...(o.webui === false ? ["--no-webui"] : []),
// GPU offload (-ngl defaults to "auto", which fits layers into free VRAM).
...(gpu ? str("-ngl", o.gpuLayers && o.gpuLayers !== "auto" ? o.gpuLayers : null) : []),
...(gpu ? str("-sm", o.splitMode) : []),
...(gpu ? str("-ts", o.tensorSplit) : []),
...(gpu && o.cpuMoe ? ["-cmoe"] : []),
...(gpu && !o.cpuMoe ? num("-ncmoe", o.nCpuMoe) : []),
"--metrics",
...runtime.extraArgs,
...o.extraArgs,
@@ -76,7 +85,7 @@ export function buildCommand({ engine, options: o, model, runtime, apiKeys = []
// vLLM: the image's entrypoint is `vllm serve`; the model is the repo folder.
const env = { ...runtime.env };
if (o.kvCacheGb != null) env.VLLM_CPU_KVCACHE_SPACE = String(o.kvCacheGb);
if (!gpu && o.kvCacheGb != null) env.VLLM_CPU_KVCACHE_SPACE = String(o.kvCacheGb);
// VLLM_API_KEY holds a single key; more than one needs --api-key.
if (keys.length === 1) env.VLLM_API_KEY = keys[0];
const args = [
@@ -89,6 +98,8 @@ export function buildCommand({ engine, options: o, model, runtime, apiKeys = []
model.repoId,
...num("--max-model-len", o.contextSize),
...num("--max-num-seqs", o.maxNumSeqs),
...(gpu ? num("--tensor-parallel-size", o.tensorParallel) : []),
...(gpu ? num("--gpu-memory-utilization", o.gpuMemoryUtilization) : []),
...(keys.length > 1 ? ["--api-key", ...keys] : []),
// A deployment's dtype replaces the runtime's default instead of repeating the flag.
...(o.dtype ? withoutFlag(runtime.extraArgs, "--dtype") : runtime.extraArgs),
@@ -112,11 +123,31 @@ export function renderCommand(image: string, cmd: ContainerCommand): string {
}
/** Rough memory need: model files plus KV cache and runtime overhead. */
export function estimateMemoryMb(fileBytes: number, contextSize: number, engine: RuntimeEngine, kvCacheGb?: number | null): number {
/** llama-server's default --cache-ram (MiB): prompts kept in RAM for reuse. */
export const LLAMA_DEFAULT_CACHE_RAM_MB = 8192;
const KV_TYPE_FACTOR: Record<string, number> = { f32: 2, f16: 1, bf16: 1, q8_0: 0.53, q5_0: 0.34, q5_1: 0.38, q4_0: 0.28, q4_1: 0.31, iq4_nl: 0.28 };
/**
* Rough RAM need of a deployment in MiB, for the memory limit. Without the GGUF header the KV size
* per token is a heuristic: ~110 KiB (f16) for sub-1B models up to ~250 KiB around 70B with GQA.
* Measured (llama.cpp b11429, Qwen3-0.6B Q4_K_M, ctx 4096): ~1.2 GiB without the prompt cache.
*/
export function estimateMemoryMb(
fileBytes: number,
contextSize: number,
engine: RuntimeEngine,
o: Pick<DeploymentOptions, "kvCacheGb" | "cacheRamMb" | "cacheTypeK" | "cacheTypeV"> & { accelerator?: RuntimeAccelerator } = {},
): number {
const model = fileBytes / 2 ** 20;
const gpu = !!o.accelerator && o.accelerator !== "cpu";
// vLLM CPU: API server, engine core and worker each load torch (~3 GiB measured with v0.31.0).
if (engine === "vllm") return Math.ceil(model + (kvCacheGb ?? 4) * 1024 + 3072);
// llama.cpp: ~ctx/8 MiB of f16 KV cache per 4k tokens for small models is too model-specific to
// compute without the GGUF header; a margin that scales with context is a safe default.
return Math.ceil(model * 1.1 + 512 + contextSize / 16);
// On a GPU the weights and KV cache live in VRAM; RAM holds the processes.
if (engine === "vllm") return Math.ceil(gpu ? 6144 : model + (o.kvCacheGb ?? 4) * 1024 + 3072);
const perTokenKiB = 96 + 24 * Math.sqrt(model / 1024);
const kvFactor = ((KV_TYPE_FACTOR[o.cacheTypeK ?? "f16"] ?? 1) + (KV_TYPE_FACTOR[o.cacheTypeV ?? "f16"] ?? 1)) / 2;
const kv = (contextSize * perTokenKiB * kvFactor) / 1024;
const cache = o.cacheRamMb == null ? LLAMA_DEFAULT_CACHE_RAM_MB : o.cacheRamMb < 0 ? LLAMA_DEFAULT_CACHE_RAM_MB : o.cacheRamMb;
// The memory-mapped model counts against the container's limit (page cache), even when offloaded.
return Math.ceil(model + (gpu ? 0 : kv) + cache + 768);
}