Release / release (push) Successful in 3m25s
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>
382 lines
16 KiB
TypeScript
382 lines
16 KiB
TypeScript
"use client";
|
|
|
|
import { ChevronDownIcon, CopyIcon, DownloadCloudIcon, PencilIcon, PlusIcon, ServerIcon, Trash2Icon } from "lucide-react";
|
|
import { useRouter } from "next/navigation";
|
|
import { useEffect, useState } from "react";
|
|
import { toast } from "sonner";
|
|
import { LocalTime } from "@/components/local-time";
|
|
import {
|
|
AlertDialog,
|
|
AlertDialogAction,
|
|
AlertDialogCancel,
|
|
AlertDialogContent,
|
|
AlertDialogDescription,
|
|
AlertDialogFooter,
|
|
AlertDialogHeader,
|
|
AlertDialogTitle,
|
|
AlertDialogTrigger,
|
|
} from "@/components/ui/alert-dialog";
|
|
import { Button } from "@/components/ui/button";
|
|
import { Card, CardAction, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
|
import {
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuGroup,
|
|
DropdownMenuItem,
|
|
DropdownMenuLabel,
|
|
DropdownMenuSeparator,
|
|
DropdownMenuTrigger,
|
|
} from "@/components/ui/dropdown-menu";
|
|
import { Progress } from "@/components/ui/progress";
|
|
import type { DockerHostInfo, runtimes } from "@/lib/db/schema";
|
|
import { formatBytes, percent } from "@/lib/format";
|
|
import { ACCELERATOR_LABEL, RUNTIME_PRESETS, type RuntimeInput } from "@/lib/runtimes-shared";
|
|
import { cn } from "@/lib/utils";
|
|
import { RuntimeForm } from "./runtime-form";
|
|
|
|
type Runtime = typeof runtimes.$inferSelect;
|
|
|
|
const FEATURE_LABEL: Record<string, string> = {
|
|
avx2: "AVX2",
|
|
avx512f: "AVX-512",
|
|
avx512_bf16: "AVX-512 BF16",
|
|
avx512_vnni: "AVX-512 VNNI",
|
|
avx512bw: "AVX-512 BW",
|
|
amx_bf16: "AMX BF16",
|
|
amx_int8: "AMX INT8",
|
|
f16c: "F16C",
|
|
fma: "FMA",
|
|
};
|
|
|
|
async function send(url: string, method: string, body?: unknown): Promise<boolean> {
|
|
const res = await fetch(url, {
|
|
method,
|
|
headers: body ? { "Content-Type": "application/json" } : undefined,
|
|
body: body ? JSON.stringify(body) : undefined,
|
|
});
|
|
if (res.ok) return true;
|
|
const json = await res.json().catch(() => ({}));
|
|
toast.error(json.error?.message ?? `Request failed (${res.status})`);
|
|
return false;
|
|
}
|
|
|
|
const toInput = (r: Runtime): RuntimeInput => ({
|
|
name: r.name,
|
|
engine: r.engine,
|
|
accelerator: r.accelerator,
|
|
image: r.image,
|
|
description: r.description,
|
|
engineName: r.engineName,
|
|
env: r.env,
|
|
extraArgs: r.extraArgs,
|
|
devices: r.devices,
|
|
shmSizeMb: r.shmSizeMb,
|
|
numaTuning: r.numaTuning,
|
|
});
|
|
|
|
export function RuntimesView({ runtimes, docker, workerOnline }: { runtimes: Runtime[]; docker: DockerHostInfo | null; workerOnline: boolean }) {
|
|
const router = useRouter();
|
|
const [creating, setCreating] = useState<(RuntimeInput & { preset?: string }) | null>(null);
|
|
const [editing, setEditing] = useState<string | null>(null);
|
|
const anyPulling = runtimes.some((r) => r.imageState === "pulling" || (r.pullRequestedAt && (!r.pullStartedAt || r.pullRequestedAt > r.pullStartedAt)));
|
|
|
|
// While a pull runs, refresh the server data every 2 s for its progress.
|
|
useEffect(() => {
|
|
if (!anyPulling) return;
|
|
const t = setInterval(() => router.refresh(), 2_000);
|
|
return () => clearInterval(t);
|
|
}, [anyPulling, router]);
|
|
|
|
return (
|
|
<div className="flex flex-col gap-4">
|
|
<HostCard docker={docker} workerOnline={workerOnline} />
|
|
|
|
<Card>
|
|
<CardHeader>
|
|
<CardTitle>Runtimes</CardTitle>
|
|
<CardDescription>
|
|
Container images that serve models: official llama.cpp and vLLM builds, or your own forks from any registry. Kaname
|
|
only starts images registered here, with the models mounted read-only.
|
|
</CardDescription>
|
|
<CardAction>
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger render={<Button size="sm" />}>
|
|
<PlusIcon />
|
|
Add runtime
|
|
<ChevronDownIcon className="opacity-70" />
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent align="end" className="w-72">
|
|
<DropdownMenuGroup>
|
|
<DropdownMenuLabel>From a preset</DropdownMenuLabel>
|
|
{RUNTIME_PRESETS.map((p) => (
|
|
<DropdownMenuItem key={p.id} onClick={() => setCreating({ ...p, name: p.name, preset: p.id })} className="flex-col items-start gap-0">
|
|
<span>{p.name}</span>
|
|
<span className="text-xs text-muted-foreground">{p.summary}</span>
|
|
</DropdownMenuItem>
|
|
))}
|
|
</DropdownMenuGroup>
|
|
<DropdownMenuSeparator />
|
|
<DropdownMenuItem onClick={() => setCreating({ name: "", engine: "vllm", image: "" })}>Custom image (fork)…</DropdownMenuItem>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
</CardAction>
|
|
</CardHeader>
|
|
<CardContent className="flex flex-col gap-3">
|
|
{creating && (
|
|
<div className="rounded-lg p-4 ring-1 ring-primary/40">
|
|
<RuntimeForm
|
|
initial={creating}
|
|
submitLabel="Add runtime"
|
|
onCancel={() => setCreating(null)}
|
|
onSubmit={async (value) => {
|
|
const ok = await send("/api/runtimes", "POST", { ...value, preset: creating.preset });
|
|
if (ok) {
|
|
toast.success(`Runtime "${value.name}" added`);
|
|
setCreating(null);
|
|
router.refresh();
|
|
}
|
|
return ok;
|
|
}}
|
|
/>
|
|
</div>
|
|
)}
|
|
{runtimes.length === 0 && !creating && <p className="text-sm text-muted-foreground">No runtimes yet. Add one from a preset.</p>}
|
|
{runtimes.map((r) =>
|
|
editing === r.id ? (
|
|
<div key={r.id} className="rounded-lg p-4 ring-1 ring-primary/40">
|
|
<RuntimeForm
|
|
initial={toInput(r)}
|
|
submitLabel="Save"
|
|
onCancel={() => setEditing(null)}
|
|
onSubmit={async (value) => {
|
|
const ok = await send(`/api/runtimes/${r.id}`, "PUT", value);
|
|
if (ok) {
|
|
setEditing(null);
|
|
router.refresh();
|
|
}
|
|
return ok;
|
|
}}
|
|
/>
|
|
</div>
|
|
) : (
|
|
<RuntimeRow
|
|
key={r.id}
|
|
runtime={r}
|
|
dockerReady={!!docker?.connected}
|
|
onEdit={() => setEditing(r.id)}
|
|
onDuplicate={() => setCreating({ ...toInput(r), name: `${r.name} (copy)` })}
|
|
/>
|
|
),
|
|
)}
|
|
</CardContent>
|
|
</Card>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
function HostCard({ docker, workerOnline }: { docker: DockerHostInfo | null; workerOnline: boolean }) {
|
|
return (
|
|
<Card size="sm">
|
|
<CardHeader>
|
|
<CardTitle className="flex items-center gap-2">
|
|
<ServerIcon className="size-4 text-muted-foreground" />
|
|
Docker host
|
|
</CardTitle>
|
|
<CardDescription>
|
|
{!workerOnline
|
|
? "The worker is offline; these facts may be outdated."
|
|
: !docker
|
|
? "Not connected. Runtimes need the worker to reach Docker through the socket proxy (DOCKER_HOST)."
|
|
: docker.connected
|
|
? `Docker ${docker.serverVersion} on ${docker.os} (${docker.architecture})`
|
|
: `Can't reach Docker: ${docker.error}`}
|
|
</CardDescription>
|
|
</CardHeader>
|
|
{docker && (
|
|
<CardContent>
|
|
<dl className="grid grid-cols-[max-content_1fr] gap-x-6 gap-y-1.5 text-sm">
|
|
<dt className="text-muted-foreground">CPU</dt>
|
|
<dd>
|
|
{docker.cpuModel ?? "unknown"}
|
|
{docker.cpus != null && <span className="text-muted-foreground"> · {docker.cpus} threads</span>}
|
|
</dd>
|
|
<dt className="text-muted-foreground">Features</dt>
|
|
<dd className="flex flex-wrap gap-1">
|
|
{docker.cpuFeatures.length === 0 ? (
|
|
<span className="text-muted-foreground">unknown</span>
|
|
) : (
|
|
docker.cpuFeatures.map((f) => (
|
|
<span
|
|
key={f}
|
|
className={cn(
|
|
"rounded border px-1.5 text-xs",
|
|
f.startsWith("avx512") || f.startsWith("amx") ? "border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300" : "text-muted-foreground",
|
|
)}
|
|
>
|
|
{FEATURE_LABEL[f] ?? f}
|
|
</span>
|
|
))
|
|
)}
|
|
</dd>
|
|
<dt className="text-muted-foreground">Memory</dt>
|
|
<dd>{docker.memoryBytes != null ? formatBytes(docker.memoryBytes) : "unknown"}</dd>
|
|
<dt className="text-muted-foreground">GPUs</dt>
|
|
<dd className="flex flex-col gap-0.5">
|
|
{docker.gpus && docker.gpus.length > 0 ? (
|
|
docker.gpus.map((g) => (
|
|
<span key={g.uuid}>
|
|
{g.index}: {g.name} <span className="text-muted-foreground">· {formatBytes(g.memoryMb * 2 ** 20)} · driver {g.driver}</span>
|
|
</span>
|
|
))
|
|
) : docker.nvidia ? (
|
|
<span className={cn(docker.gpuError && "text-amber-700 dark:text-amber-300")}>
|
|
{docker.gpuError ? `NVIDIA runtime found, but listing GPUs failed: ${docker.gpuError}` : "NVIDIA runtime found, no GPUs listed."}
|
|
</span>
|
|
) : (
|
|
<span className="text-muted-foreground">
|
|
No NVIDIA GPUs (no NVIDIA runtime in Docker). Intel/AMD GPUs aren't listed; pass /dev/dri to a runtime to use them.
|
|
</span>
|
|
)}
|
|
</dd>
|
|
<dt className="text-muted-foreground">Network</dt>
|
|
<dd className={cn("font-mono text-xs", !docker.network && "text-amber-700 dark:text-amber-300")}>
|
|
{docker.network ?? "not detected (set KANAME_DOCKER_NETWORK)"}
|
|
</dd>
|
|
<dt className="text-muted-foreground">Models</dt>
|
|
<dd className={cn("font-mono text-xs break-all", !docker.modelsSource && "text-amber-700 dark:text-amber-300")}>
|
|
{docker.modelsSource ? `${docker.modelsSource.source} (${docker.modelsSource.type}, mounted read-only)` : "not detected (set KANAME_MODELS_SOURCE)"}
|
|
</dd>
|
|
<dt className="text-muted-foreground">Checked</dt>
|
|
<dd>
|
|
<LocalTime value={docker.checkedAt} />
|
|
</dd>
|
|
</dl>
|
|
</CardContent>
|
|
)}
|
|
</Card>
|
|
);
|
|
}
|
|
|
|
function ImageState({ r }: { r: Runtime }) {
|
|
const requested = !!r.pullRequestedAt && (!r.pullStartedAt || r.pullRequestedAt > r.pullStartedAt);
|
|
if (r.imageState === "pulling" || requested) {
|
|
const p = r.pullProgress;
|
|
return (
|
|
<div className="flex min-w-48 flex-col gap-1">
|
|
<span className="text-xs text-muted-foreground">
|
|
{p ? `${p.status} · ${formatBytes(p.doneBytes)}${p.totalBytes ? ` / ${formatBytes(p.totalBytes)}` : ""}` : "Pull queued…"}
|
|
</span>
|
|
<Progress value={p && p.totalBytes ? percent(p.doneBytes, p.totalBytes) : 0} />
|
|
</div>
|
|
);
|
|
}
|
|
if (r.imageState === "present") {
|
|
return (
|
|
<span className="text-xs text-emerald-700 dark:text-emerald-400">
|
|
Pulled · {r.imageSize != null ? formatBytes(r.imageSize) : "?"}
|
|
{r.imageCreated && (
|
|
<span className="text-muted-foreground">
|
|
{" "}
|
|
· built <LocalTime value={r.imageCreated} />
|
|
</span>
|
|
)}
|
|
{r.imageDigest && (
|
|
<span className="font-mono text-muted-foreground" title={r.imageDigest}>
|
|
{" "}
|
|
· {r.imageDigest.slice(0, 19)}…
|
|
</span>
|
|
)}
|
|
</span>
|
|
);
|
|
}
|
|
if (r.imageState === "failed") return <span className="text-xs break-all text-destructive">Pull failed: {r.pullError}</span>;
|
|
if (r.imageState === "missing") return <span className="text-xs text-muted-foreground">Not pulled yet</span>;
|
|
return <span className="text-xs text-muted-foreground">Not checked yet</span>;
|
|
}
|
|
|
|
function RuntimeRow({
|
|
runtime: r,
|
|
dockerReady,
|
|
onEdit,
|
|
onDuplicate,
|
|
}: {
|
|
runtime: Runtime;
|
|
dockerReady: boolean;
|
|
onEdit: () => void;
|
|
onDuplicate: () => void;
|
|
}) {
|
|
const router = useRouter();
|
|
const pulling = r.imageState === "pulling";
|
|
const envCount = Object.keys(r.env).length;
|
|
|
|
return (
|
|
<div className="flex flex-col gap-3 rounded-lg px-4 py-3 ring-1 ring-foreground/10">
|
|
<div className="flex flex-wrap items-start justify-between gap-3">
|
|
<div className="flex min-w-0 flex-col gap-1">
|
|
<div className="flex flex-wrap items-center gap-2">
|
|
<span className="font-medium">{r.name}</span>
|
|
<span className="rounded-md border px-1.5 text-xs text-muted-foreground">{r.engine === "vllm" ? "vLLM" : "llama.cpp"}</span>
|
|
{r.accelerator !== "cpu" && (
|
|
<span className="rounded-md border border-emerald-500/30 px-1.5 text-xs text-emerald-700 dark:text-emerald-300">{ACCELERATOR_LABEL[r.accelerator]}</span>
|
|
)}
|
|
{r.numaTuning && <span className="rounded-md border border-amber-500/30 px-1.5 text-xs text-amber-700 dark:text-amber-300">NUMA tuning</span>}
|
|
</div>
|
|
<code className="font-mono text-xs break-all text-muted-foreground">{r.image}</code>
|
|
{r.description && <p className="text-xs text-muted-foreground">{r.description}</p>}
|
|
</div>
|
|
<div className="flex items-center gap-1">
|
|
<Button
|
|
size="sm"
|
|
variant={r.imageState === "present" ? "ghost" : "outline"}
|
|
disabled={!dockerReady || pulling}
|
|
title={!dockerReady ? "Docker isn't connected" : r.imageState === "present" ? "Pull again to update the tag" : undefined}
|
|
onClick={async () => {
|
|
if (await send(`/api/runtimes/${r.id}/pull`, "POST")) router.refresh();
|
|
}}
|
|
>
|
|
<DownloadCloudIcon />
|
|
{r.imageState === "present" ? "Update" : "Pull"}
|
|
</Button>
|
|
<Button size="icon-sm" variant="ghost" onClick={onEdit} aria-label={`Edit ${r.name}`}>
|
|
<PencilIcon />
|
|
</Button>
|
|
<Button size="icon-sm" variant="ghost" onClick={onDuplicate} aria-label={`Duplicate ${r.name}`}>
|
|
<CopyIcon />
|
|
</Button>
|
|
<AlertDialog>
|
|
<AlertDialogTrigger render={<Button size="icon-sm" variant="ghost" aria-label={`Delete ${r.name}`} />}>
|
|
<Trash2Icon />
|
|
</AlertDialogTrigger>
|
|
<AlertDialogContent>
|
|
<AlertDialogHeader>
|
|
<AlertDialogTitle>Delete runtime “{r.name}”?</AlertDialogTitle>
|
|
<AlertDialogDescription>The pulled image stays in Docker; remove it there if you need the space.</AlertDialogDescription>
|
|
</AlertDialogHeader>
|
|
<AlertDialogFooter>
|
|
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
|
<AlertDialogAction
|
|
variant="destructive"
|
|
onClick={async () => {
|
|
if (await send(`/api/runtimes/${r.id}`, "DELETE")) router.refresh();
|
|
}}
|
|
>
|
|
Delete
|
|
</AlertDialogAction>
|
|
</AlertDialogFooter>
|
|
</AlertDialogContent>
|
|
</AlertDialog>
|
|
</div>
|
|
</div>
|
|
<div className="flex flex-wrap items-center justify-between gap-x-6 gap-y-1 text-xs text-muted-foreground">
|
|
<ImageState r={r} />
|
|
<span>
|
|
{envCount > 0 && `${envCount} env var${envCount === 1 ? "" : "s"}`}
|
|
{r.extraArgs.length > 0 && `${envCount > 0 ? " · " : ""}${r.extraArgs.join(" ")}`}
|
|
{r.shmSizeMb != null && ` · shm ${r.shmSizeMb} MiB`}
|
|
{r.devices.length > 0 && ` · ${r.devices.join(", ")}`}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|