"use client"; import { useRouter } from "next/navigation"; import { useState } from "react"; import { toast } from "sonner"; import { LocalTime } from "@/components/local-time"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { NativeSelect } from "@/components/ui/native-select"; import type { HardwareOverrides, HostHardware } from "@/lib/db/schema"; import { formatBytes } from "@/lib/format"; import { formatLink, onOff } from "@/lib/hardware"; type GpuForm = { name: string; vramMb: string; linkCurrent: string; linkMax: string; rebar: "" | "on" | "off" }; const toForm = (o: NonNullable[string] | undefined): GpuForm => ({ name: o?.name ?? "", vramMb: o?.vramMb != null ? String(o.vramMb) : "", linkCurrent: o?.linkCurrent ?? "", linkMax: o?.linkMax ?? "", rebar: o?.rebar == null ? "" : o.rebar ? "on" : "off", }); const STORAGE_KIND: Record = { nvme: "NVMe", ssd: "SSD", hdd: "HDD", virtual: "virtual disk" }; /** What Kaname detected on the Docker host, with manual values for what it can't see. */ export function HardwareSettings({ detected, overrides, summary, dockerConnected, }: { detected: HostHardware | null; overrides: HardwareOverrides; summary: string[]; dockerConnected: boolean; }) { const router = useRouter(); const [gpus, setGpus] = useState>(() => Object.fromEntries((detected?.gpus ?? []).map((g) => [g.pciAddress, toForm(overrides.gpus?.[g.pciAddress])]))); const [p2p, setP2p] = useState(overrides.p2p ?? ""); const [storage, setStorage] = useState(overrides.storage ?? ""); const [hypervisor, setHypervisor] = useState(overrides.hypervisor ?? ""); const [passthrough, setPassthrough] = useState(overrides.gpuPassthrough == null ? "" : overrides.gpuPassthrough ? "yes" : "no"); const [gpuDriver, setGpuDriver] = useState(overrides.gpuDriver ?? ""); const [busy, setBusy] = useState(false); const setGpu = (addr: string, patch: Partial) => setGpus((g) => ({ ...g, [addr]: { ...g[addr], ...patch } })); async function save() { setBusy(true); try { const body: HardwareOverrides = { gpus: Object.fromEntries( Object.entries(gpus).map(([addr, g]) => [ addr, { name: g.name || undefined, vramMb: g.vramMb ? Number(g.vramMb) : undefined, linkCurrent: g.linkCurrent || undefined, linkMax: g.linkMax || undefined, rebar: g.rebar ? g.rebar === "on" : undefined, }, ]), ), p2p: (p2p || undefined) as HardwareOverrides["p2p"], storage: storage || undefined, hypervisor: hypervisor || undefined, gpuPassthrough: passthrough ? passthrough === "yes" : undefined, gpuDriver: gpuDriver || undefined, }; const res = await fetch("/api/settings/hardware", { method: "PUT", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) }); const out = await res.json().catch(() => ({})); if (!res.ok) return void toast.error(out.error?.message ?? `Could not save (${res.status})`); toast.success("Saved; new benchmark runs use these values"); router.refresh(); } finally { setBusy(false); } } if (!detected) { return ( Hardware {dockerConnected ? "The worker hasn't reported its hardware yet (it checks every few minutes)." : "Hardware is detected by the worker once Docker is connected (Settings → Runtimes)."} ); } const v = detected.virtualization; return (
{ e.preventDefault(); void save(); }} > GPUs Recorded with every benchmark run. Detected from sysfs as the worker sees it; in a VM the PCIe link is the one the VM sees, which may not be the physical slot. Fill in a field to replace the detected value (empty = detected). {detected.gpus.length === 0 &&

No NVIDIA, Intel or AMD GPU found.

} {detected.gpus.map((g) => { const f = gpus[g.pciAddress]; return (
{g.name ?? "Unknown GPU"} {" "} · {g.pciAddress} · {g.driver ?? "no driver"} {g.driverVersion ? ` ${g.driverVersion}` : ""}
setGpu(g.pciAddress, { name: x })} /> setGpu(g.pciAddress, { vramMb: x.replace(/\D/g, "") })} />
setGpu(g.pciAddress, { rebar: e.target.value as GpuForm["rebar"] })}>

Largest BAR {g.barMb != null ? formatBytes(g.barMb * 2 ** 20) : "unknown"}

setGpu(g.pciAddress, { linkCurrent: x })} /> setGpu(g.pciAddress, { linkMax: x })} />
); })} {detected.gpus.length > 1 && (
setP2p(e.target.value as typeof p2p)}>
)}
System Part of the system summary recorded with each run, passed to BetterBench and shown in the launch80 preview.
setPassthrough(e.target.value)}>
[g.driver, g.driverVersion].filter(Boolean).join(" ")))].join(", ") || null} value={gpuDriver} placeholderHint="e.g. xe, compute runtime 25.35" onChange={setGpuDriver} />
System summary Exactly what runs record and publish (after saving). Never the hostname, IP addresses, users or paths. Checked .
    {summary.map((l) => (
  • {l}
  • ))}
); } function Field({ id, label, detected, value, onChange, placeholderHint, }: { id: string; label: string; detected: string | null; value: string; onChange: (v: string) => void; placeholderHint?: string; }) { return (
onChange(e.target.value)} placeholder={detected ?? placeholderHint ?? "unknown"} maxLength={120} />

Detected: {detected ?? "unknown"}

); }