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
+94
-362
@@ -3,7 +3,6 @@ import {
|
||||
index,
|
||||
integer,
|
||||
primaryKey,
|
||||
real,
|
||||
sqliteTable,
|
||||
text,
|
||||
uniqueIndex,
|
||||
@@ -73,8 +72,6 @@ export type JobResult = {
|
||||
removePaths?: string[];
|
||||
/** Delete jobs: files that were kept because they don't belong to the repo. */
|
||||
kept?: string[];
|
||||
/** API "add files" requests: the selection rule before, restored if the request is rejected. */
|
||||
previousRule?: { include: string[]; exclude: string[] };
|
||||
};
|
||||
|
||||
export const models = sqliteTable(
|
||||
@@ -126,9 +123,6 @@ export const models = sqliteTable(
|
||||
/** Hub tags, minus noise like arxiv:/region:/deploy:. */
|
||||
hubTags: text("hub_tags", { mode: "json" }).$type<string[]>(),
|
||||
metadataFetchedAt: ts("metadata_fetched_at"),
|
||||
/** Added through the API: the token that asked for it, and its name at the time. */
|
||||
requestedByTokenId: text("requested_by_token_id"),
|
||||
requestedBy: text("requested_by"),
|
||||
createdAt: createdAt(),
|
||||
updatedAt: updatedAt(),
|
||||
},
|
||||
@@ -229,7 +223,6 @@ export const JOB_PURPOSES = ["initial", "add", "import", "repair", "update"] as
|
||||
export type JobPurpose = (typeof JOB_PURPOSES)[number];
|
||||
|
||||
export const JOB_STATES = [
|
||||
"pending_approval", // requested through the API, waits for a human to approve it
|
||||
"queued",
|
||||
"downloading",
|
||||
"verifying",
|
||||
@@ -275,9 +268,6 @@ export const jobs = sqliteTable(
|
||||
result: text("result", { mode: "json" }).$type<JobResult>(),
|
||||
/** Set by the web app; the worker picks it up and stops the job. */
|
||||
cancelRequestedAt: ts("cancel_requested_at"),
|
||||
/** Requested through the API: the token, and its name at the time. */
|
||||
requestedByTokenId: text("requested_by_token_id"),
|
||||
requestedBy: text("requested_by"),
|
||||
startedAt: ts("started_at"),
|
||||
finishedAt: ts("finished_at"),
|
||||
createdAt: createdAt(),
|
||||
@@ -352,150 +342,11 @@ export const workerState = sqliteTable("worker_state", {
|
||||
heartbeatAt: ts("heartbeat_at").notNull(),
|
||||
/** Set by the web app ("Rescan"); the worker scans MODELS_DIR when this is newer than its last scan. */
|
||||
scanRequestedAt: ts("scan_requested_at"),
|
||||
/** Docker connection and host facts, reported by the worker (null: no DOCKER_HOST). */
|
||||
docker: text("docker", { mode: "json" }).$type<DockerHostInfo>(),
|
||||
});
|
||||
|
||||
export type DockerHostInfo = {
|
||||
connected: boolean;
|
||||
error: string | null;
|
||||
serverVersion: string | null;
|
||||
os: string | null;
|
||||
architecture: string | null;
|
||||
cpus: number | null;
|
||||
memoryBytes: number | null;
|
||||
cpuModel: string | null;
|
||||
/** Relevant CPU features (avx2, avx512f, avx512_bf16, amx_bf16, …). */
|
||||
cpuFeatures: string[];
|
||||
/** Docker network inference containers join, so the worker can reach them. */
|
||||
network: string | null;
|
||||
/** Where the models come from on the Docker host (bind path or volume name), mounted read-only. */
|
||||
modelsSource: { type: "bind" | "volume"; source: string } | null;
|
||||
/** Docker has the NVIDIA runtime / CDI devices, so GPUs can be requested. */
|
||||
nvidia?: boolean;
|
||||
/** GPUs found by a probe container (nvidia-smi); empty when none or not probed. */
|
||||
gpus?: HostGpu[];
|
||||
gpuError?: string | null;
|
||||
gpuCheckedAt?: string | null;
|
||||
/** Group IDs owning /dev/dri on the host (render, video); given to Intel/AMD runtime containers. */
|
||||
driGroups?: number[];
|
||||
/** PCIe, ReBAR, system facts from sysfs/procfs (what the worker's container sees of the host). */
|
||||
hardware?: HostHardware | null;
|
||||
checkedAt: string;
|
||||
};
|
||||
|
||||
export type HostGpu = {
|
||||
vendor: "nvidia";
|
||||
index: number;
|
||||
uuid: string;
|
||||
name: string;
|
||||
memoryMb: number;
|
||||
driver: string;
|
||||
pciAddress?: string | null;
|
||||
/** PCIe link as nvidia-smi reports it (also where sysfs isn't visible, e.g. WSL2). */
|
||||
linkCurrent?: PcieLink | null;
|
||||
linkMax?: PcieLink | null;
|
||||
};
|
||||
|
||||
/** A PCIe link: generation (1 = 2.5 GT/s … 6 = 64 GT/s) and lanes. */
|
||||
export type PcieLink = { gen: number | null; width: number | null };
|
||||
|
||||
export type GpuVendor = "nvidia" | "intel" | "amd";
|
||||
|
||||
/** A GPU as found on the PCI bus. The link is the card's upstream link (behind on-card switches). */
|
||||
export type HardwareGpu = {
|
||||
vendor: GpuVendor;
|
||||
pciAddress: string;
|
||||
name: string | null;
|
||||
vramMb: number | null;
|
||||
/** Kernel driver (nvidia, xe, i915, amdgpu) and its version (the kernel's for in-tree drivers). */
|
||||
driver: string | null;
|
||||
driverVersion: string | null;
|
||||
linkCurrent: PcieLink | null;
|
||||
linkMax: PcieLink | null;
|
||||
/** Largest memory BAR in MiB; Resizable BAR is on when it covers the VRAM. */
|
||||
barMb: number | null;
|
||||
rebar: boolean | null;
|
||||
};
|
||||
|
||||
export type HostHardware = {
|
||||
gpus: HardwareGpu[];
|
||||
/** Peer-to-peer between GPUs (NVIDIA: nvidia-smi topo); null = unknown or a single GPU. */
|
||||
p2p: "on" | "off" | "partial" | null;
|
||||
cpu: { model: string | null; cores: number | null; threads: number | null };
|
||||
memoryBytes: number | null;
|
||||
kernel: string | null;
|
||||
virtualization: { vm: boolean | null; hypervisor: string | null };
|
||||
/** The disk holding the models folder. */
|
||||
storage: { model: string | null; kind: "nvme" | "ssd" | "hdd" | "virtual" | null; sizeBytes: number | null } | null;
|
||||
checkedAt: string;
|
||||
};
|
||||
|
||||
/** Settings → Hardware: manual values where detection can't see the truth (VMs, new GPUs). */
|
||||
export type HardwareOverrides = {
|
||||
gpus?: Record<string, { name?: string; vramMb?: number; linkCurrent?: string; linkMax?: string; rebar?: boolean }>;
|
||||
p2p?: "on" | "off" | "partial";
|
||||
storage?: string;
|
||||
hypervisor?: string;
|
||||
gpuPassthrough?: boolean;
|
||||
gpuDriver?: string;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Runtimes: container images that serve models (llama.cpp, vLLM, forks, …)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/** How Kaname builds the command line and talks to the server. */
|
||||
export const RUNTIME_ENGINES = ["llama.cpp", "vllm"] as const;
|
||||
export type RuntimeEngine = (typeof RUNTIME_ENGINES)[number];
|
||||
|
||||
/**
|
||||
* What the image computes on. nvidia: GPUs requested through Docker (NVIDIA Container Toolkit);
|
||||
* dri: Intel/AMD GPUs via /dev/dri (Vulkan, SYCL, XPU); rocm: AMD via /dev/kfd + /dev/dri.
|
||||
*/
|
||||
export const RUNTIME_ACCELERATORS = ["cpu", "nvidia", "dri", "rocm"] as const;
|
||||
export type RuntimeAccelerator = (typeof RUNTIME_ACCELERATORS)[number];
|
||||
|
||||
export const IMAGE_STATES = ["unknown", "missing", "pulling", "present", "failed"] as const;
|
||||
export type ImageState = (typeof IMAGE_STATES)[number];
|
||||
|
||||
export const runtimes = sqliteTable("runtimes", {
|
||||
id: id(),
|
||||
name: text("name").notNull(),
|
||||
engine: text("engine", { enum: RUNTIME_ENGINES }).notNull(),
|
||||
accelerator: text("accelerator", { enum: RUNTIME_ACCELERATORS }).notNull().default("cpu"),
|
||||
/** Full image reference, e.g. "ghcr.io/ggml-org/llama.cpp:server". */
|
||||
image: text("image").notNull(),
|
||||
description: text("description"),
|
||||
/** Environment variables for the container. */
|
||||
env: text("env", { mode: "json" }).$type<Record<string, string>>().notNull().default(sql`'{}'`),
|
||||
/** Appended to the generated command line (fork-specific flags). */
|
||||
extraArgs: text("extra_args", { mode: "json" }).$type<string[]>().notNull().default(sql`'[]'`),
|
||||
/** Host devices to pass through, e.g. "/dev/dri" (later: Intel GPUs). */
|
||||
devices: text("devices", { mode: "json" }).$type<string[]>().notNull().default(sql`'[]'`),
|
||||
shmSizeMb: integer("shm_size_mb"),
|
||||
/** vLLM's NUMA optimizations: adds CAP_SYS_NICE and seccomp=unconfined. Off unless enabled. */
|
||||
numaTuning: integer("numa_tuning", { mode: "boolean" }).notNull().default(false),
|
||||
/** Preset this runtime was created from, if any. */
|
||||
preset: text("preset"),
|
||||
imageState: text("image_state", { enum: IMAGE_STATES }).notNull().default("unknown"),
|
||||
imageId: text("image_id"),
|
||||
imageSize: integer("image_size"),
|
||||
imageCreated: text("image_created"),
|
||||
/** Set by "Pull"; the worker pulls when this is newer than the last pull. */
|
||||
pullRequestedAt: ts("pull_requested_at"),
|
||||
pullStartedAt: ts("pull_started_at"),
|
||||
pullProgress: text("pull_progress", { mode: "json" }).$type<{ doneBytes: number; totalBytes: number; status: string }>(),
|
||||
pullError: text("pull_error"),
|
||||
imageCheckedAt: ts("image_checked_at"),
|
||||
/** Registry digest of the pulled image (sha256:…), from its RepoDigests. */
|
||||
imageDigest: text("image_digest"),
|
||||
/** Shown instead of the engine type for forks, e.g. "vllm-radiance". */
|
||||
engineName: text("engine_name"),
|
||||
createdAt: createdAt(),
|
||||
updatedAt: updatedAt(),
|
||||
});
|
||||
|
||||
/**
|
||||
* Folders in MODELS_DIR (`<org>/<name>`, like `hf download --local-dir` layouts) that no model uses,
|
||||
* found by the worker's scan. Rewritten on every scan; the web app offers them for import.
|
||||
@@ -513,14 +364,14 @@ export const localFolders = sqliteTable("local_folders", {
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Deployments: a model served by a runtime container
|
||||
// Before 0.15 Kaname ran the servers itself (runtimes, deployments). Benchmark runs from then keep
|
||||
// a snapshot of the deployment; these types describe it.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/** What the worker is doing with the container. */
|
||||
export const DEPLOYMENT_STATES = ["stopped", "starting", "running", "stopping", "failed"] as const;
|
||||
export type DeploymentState = (typeof DEPLOYMENT_STATES)[number];
|
||||
export type RuntimeEngine = "llama.cpp" | "vllm";
|
||||
export type RuntimeAccelerator = "cpu" | "nvidia" | "dri" | "rocm";
|
||||
|
||||
/** Launch options. Engine-specific fields are ignored by the other engine. */
|
||||
/** A deployment's launch options (legacy). */
|
||||
export type DeploymentOptions = {
|
||||
/** Model file (llama.cpp: the GGUF, first part of a split) or "" for the repo folder (vLLM). */
|
||||
modelFile: string;
|
||||
@@ -564,131 +415,85 @@ export type DeploymentOptions = {
|
||||
extraArgs: string[];
|
||||
};
|
||||
|
||||
export type DeploymentStats = { cpuPercent: number; memoryBytes: number; memoryLimitBytes: number; at: string };
|
||||
// ---------------------------------------------------------------------------
|
||||
// Endpoints: OpenAI-compatible servers to benchmark (llama.cpp, vLLM, SGLang, …), run elsewhere
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export const deployments = sqliteTable("deployments", {
|
||||
id: id(),
|
||||
name: text("name").notNull(),
|
||||
runtimeId: text("runtime_id")
|
||||
.notNull()
|
||||
.references(() => runtimes.id),
|
||||
modelId: text("model_id")
|
||||
.notNull()
|
||||
.references(() => models.id),
|
||||
options: text("options", { mode: "json" }).$type<DeploymentOptions>().notNull(),
|
||||
/** CPU limit in cores (fractions allowed) and memory limit; null = no limit. */
|
||||
cpus: real("cpus"),
|
||||
memoryMb: integer("memory_mb"),
|
||||
/** Publish the API on this host port (optional; Kaname itself uses the Docker network). */
|
||||
hostPort: integer("host_port"),
|
||||
/** Set by the web app; the worker starts/stops the container to match. */
|
||||
desiredState: text("desired_state", { enum: ["running", "stopped"] }).notNull().default("stopped"),
|
||||
state: text("state", { enum: DEPLOYMENT_STATES }).notNull().default("stopped"),
|
||||
/** Delete requested: the worker removes the container, then the row. */
|
||||
deleteRequestedAt: ts("delete_requested_at"),
|
||||
containerId: text("container_id"),
|
||||
containerName: text("container_name"),
|
||||
/** Command line the container was started with (for display and reproducibility). */
|
||||
command: text("command", { mode: "json" }).$type<string[]>(),
|
||||
imageId: text("image_id"),
|
||||
startedAt: ts("started_at"),
|
||||
readyAt: ts("ready_at"),
|
||||
stoppedAt: ts("stopped_at"),
|
||||
exitCode: integer("exit_code"),
|
||||
error: text("error"),
|
||||
stats: text("stats", { mode: "json" }).$type<DeploymentStats>(),
|
||||
/** Version, slots and context the server reported once ready. */
|
||||
engineInfo: text("engine_info", { mode: "json" }).$type<EngineInfo>(),
|
||||
/** Temporary deployment created by a benchmark sweep (removed when its variant is done). */
|
||||
sweepId: text("sweep_id"),
|
||||
/** Created through the API: the token and its name at the time. */
|
||||
requestedByTokenId: text("requested_by_token_id"),
|
||||
requestedBy: text("requested_by"),
|
||||
/** Agents can't edit, stop, delete or benchmark it, nor start anything that would crowd it out of VRAM. */
|
||||
protected: integer("protected", { mode: "boolean" }).notNull().default(false),
|
||||
/** An agent asked to start it; it starts once someone approves (approval mode "approve"). */
|
||||
startRequestedAt: ts("start_requested_at"),
|
||||
createdAt: createdAt(),
|
||||
updatedAt: updatedAt(),
|
||||
});
|
||||
|
||||
export const deploymentLogs = sqliteTable(
|
||||
"deployment_logs",
|
||||
{
|
||||
id: integer("id").primaryKey({ autoIncrement: true }),
|
||||
deploymentId: text("deployment_id")
|
||||
.notNull()
|
||||
.references(() => deployments.id),
|
||||
ts: ts("ts")
|
||||
.notNull()
|
||||
.$defaultFn(() => new Date()),
|
||||
stream: text("stream", { enum: LOG_STREAMS }).notNull(),
|
||||
line: text("line").notNull(),
|
||||
},
|
||||
(t) => [index("deployment_logs_idx").on(t.deploymentId, t.id)],
|
||||
);
|
||||
export const ENDPOINT_ENGINES = ["llama.cpp", "vllm", "sglang", "ollama", "other"] as const;
|
||||
export type EndpointEngine = (typeof ENDPOINT_ENGINES)[number];
|
||||
|
||||
/**
|
||||
* API keys that deployments with `requireApiKey` accept. Stored in plain text because the worker
|
||||
* hands them to the runtime container; never logged or written into a stored command line.
|
||||
* What runs behind an endpoint, as the user describes it (Kaname can't see that machine). Copied into
|
||||
* every run; goes into BetterBench notes and launch80. Nothing here may identify the host.
|
||||
*/
|
||||
export const apiKeys = sqliteTable("api_keys", {
|
||||
id: id(),
|
||||
name: text("name").notNull(),
|
||||
key: text("key").notNull().unique(),
|
||||
createdAt: createdAt(),
|
||||
});
|
||||
export type EndpointHardware = {
|
||||
gpuName?: string | null;
|
||||
gpuCount?: number | null;
|
||||
/** Per GPU. */
|
||||
vramGb?: number | null;
|
||||
/** e.g. "Gen4 x16". */
|
||||
pcie?: string | null;
|
||||
p2p?: "on" | "off" | "partial" | null;
|
||||
rebar?: boolean | null;
|
||||
gpuDriver?: string | null;
|
||||
cpu?: string | null;
|
||||
memoryGb?: number | null;
|
||||
os?: string | null;
|
||||
/** e.g. "Proxmox VM with GPU passthrough". */
|
||||
virtualization?: string | null;
|
||||
/** Shown instead of the detected engine, e.g. "ik_llama.cpp". */
|
||||
engineName?: string | null;
|
||||
engineVersion?: string | null;
|
||||
image?: string | null;
|
||||
quant?: string | null;
|
||||
kvCache?: string | null;
|
||||
contextSize?: number | null;
|
||||
/** Parallel slots / max sequences. */
|
||||
concurrency?: number | null;
|
||||
/** Free text: launch flags, anything else worth knowing. */
|
||||
description?: string | null;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// API tokens: machine clients (e.g. an AI agent) calling /api/v1 with a bearer token
|
||||
// ---------------------------------------------------------------------------
|
||||
/** The last "Test connection" (or check before a run). */
|
||||
export type EndpointProbe = {
|
||||
ok: boolean;
|
||||
at: string;
|
||||
error: string | null;
|
||||
latencyMs: number | null;
|
||||
/** Model names from /v1/models. */
|
||||
models: string[];
|
||||
engine: EndpointEngine | null;
|
||||
engineVersion: string | null;
|
||||
contextSize: number | null;
|
||||
slots: number | null;
|
||||
};
|
||||
|
||||
/** What a token may do. Nothing can delete, change settings or manage runtimes/tokens. */
|
||||
export const TOKEN_SCOPES = ["models:read", "downloads:create", "deployments:read", "deployments:write", "benchmarks:read", "benchmarks:run"] as const;
|
||||
export type TokenScope = (typeof TOKEN_SCOPES)[number];
|
||||
|
||||
export const apiTokens = sqliteTable(
|
||||
"api_tokens",
|
||||
export const endpoints = sqliteTable(
|
||||
"endpoints",
|
||||
{
|
||||
id: id(),
|
||||
name: text("name").notNull(),
|
||||
/** First characters of the token, shown in the UI to tell tokens apart. */
|
||||
prefix: text("prefix").notNull(),
|
||||
/** SHA-256 of the token (hex); the token itself is never stored. */
|
||||
hash: text("hash").notNull().unique(),
|
||||
scopes: text("scopes", { mode: "json" }).$type<TokenScope[]>().notNull(),
|
||||
lastUsedAt: ts("last_used_at"),
|
||||
revokedAt: ts("revoked_at"),
|
||||
/** Server root, e.g. "http://gpu-box:8080" (Kaname appends /v1). */
|
||||
baseUrl: text("base_url").notNull(),
|
||||
/** Sent as a bearer token; never leaves the server (not shown, logged or put into a run). */
|
||||
apiKey: text("api_key"),
|
||||
/** Model to benchmark; null: the only one the server lists. */
|
||||
model: text("model"),
|
||||
/** null: detect from the server. */
|
||||
engine: text("engine", { enum: ENDPOINT_ENGINES }),
|
||||
hardware: text("hardware", { mode: "json" }).$type<EndpointHardware>().notNull().default(sql`'{}'`),
|
||||
probe: text("probe", { mode: "json" }).$type<EndpointProbe>(),
|
||||
createdAt: createdAt(),
|
||||
updatedAt: updatedAt(),
|
||||
},
|
||||
(t) => [uniqueIndex("api_tokens_name_uq").on(t.name)],
|
||||
);
|
||||
|
||||
/** What tokens did: every request that creates or changes something, and refusals by a guardrail. */
|
||||
export const agentActivity = sqliteTable(
|
||||
"agent_activity",
|
||||
{
|
||||
id: id(),
|
||||
tokenId: text("token_id").notNull(),
|
||||
tokenName: text("token_name").notNull(),
|
||||
/** e.g. "deployment.create", "deployment.start", "benchmark.run", "sweep.create", "download.request". */
|
||||
action: text("action").notNull(),
|
||||
targetType: text("target_type"),
|
||||
targetId: text("target_id"),
|
||||
/** ok, pending_approval or refused (then `code` is the error code). */
|
||||
outcome: text("outcome", { enum: ["ok", "pending_approval", "refused"] }).notNull(),
|
||||
code: text("code"),
|
||||
message: text("message"),
|
||||
createdAt: createdAt(),
|
||||
},
|
||||
(t) => [index("agent_activity_token_idx").on(t.tokenId, t.createdAt)],
|
||||
(t) => [uniqueIndex("endpoints_name_uq").on(t.name)],
|
||||
);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Benchmarks (BetterBench runs against a running deployment)
|
||||
// Benchmarks (BetterBench runs against an endpoint)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export const BENCHMARK_STATES = ["pending_approval", "queued", "running", "completed", "failed", "cancelled"] as const;
|
||||
export const BENCHMARK_STATES = ["queued", "running", "completed", "failed", "cancelled"] as const;
|
||||
export type BenchmarkState = (typeof BENCHMARK_STATES)[number];
|
||||
|
||||
export const BENCHMARK_PHASES = ["decode", "prefill", "concurrency"] as const;
|
||||
@@ -703,9 +508,8 @@ export type BenchmarkSettings = {
|
||||
/** A/B: target minimum detectable effect in % (BetterBench --mde, default 1) and pair ceiling. */
|
||||
mdePct?: number | null;
|
||||
maxPairs?: number | null;
|
||||
/** eval: which sections (empty: all). Sweeps: also run the quality eval for each variant. */
|
||||
/** eval: which sections (empty: all). */
|
||||
evalSections?: QualitySection[];
|
||||
quality?: boolean;
|
||||
};
|
||||
|
||||
export const QUALITY_SECTIONS = ["tools", "coding", "retrieval"] as const;
|
||||
@@ -766,42 +570,23 @@ export type AbSummary = {
|
||||
config: { greedy?: boolean | null; temperature?: number | null; warmup?: number | null; unique_nonce?: boolean | null; ab_min_pairs?: number | null };
|
||||
};
|
||||
|
||||
/** Resource use sampled during a run (every ~2 s), per deployment and per GPU. */
|
||||
export type ResourceStats = {
|
||||
samples: number;
|
||||
seconds: number;
|
||||
containers: {
|
||||
side: "a" | "b";
|
||||
cpuAvg: number | null;
|
||||
cpuPeak: number | null;
|
||||
memAvgBytes: number | null;
|
||||
memPeakBytes: number | null;
|
||||
memLimitBytes: number | null;
|
||||
}[];
|
||||
/** Fastest PCIe link seen per GPU (PCI address) during the run. */
|
||||
links?: Record<string, PcieLink>;
|
||||
/**
|
||||
* Whole-GPU figures, not per process: nvidia-smi; hwmon/sysfs for AMD; hwmon plus the DRM fdinfo
|
||||
* of all processes for Intel. null where a source doesn't report it.
|
||||
*/
|
||||
gpus: {
|
||||
index: number;
|
||||
name: string;
|
||||
pciAddress?: string;
|
||||
vramTotalMb: number | null;
|
||||
vramPeakMb: number | null;
|
||||
vramAvgMb: number | null;
|
||||
utilAvg: number | null;
|
||||
utilPeak: number | null;
|
||||
powerAvgW: number | null;
|
||||
powerPeakW: number | null;
|
||||
tempAvgC?: number | null;
|
||||
tempPeakC?: number | null;
|
||||
}[];
|
||||
/** The endpoint as it was when the run started, so results stay comparable after edits. */
|
||||
export type EndpointSnapshot = {
|
||||
type: "endpoint";
|
||||
endpointName: string;
|
||||
/** The model name sent to the server (what /v1/models lists). */
|
||||
model: string;
|
||||
engine: EndpointEngine | null;
|
||||
engineVersion: string | null;
|
||||
contextSize: number | null;
|
||||
/** Parallel slots the server reported (llama.cpp). */
|
||||
slots?: number | null;
|
||||
hardware: EndpointHardware;
|
||||
};
|
||||
|
||||
/** The deployment as it was when the run started, so results stay comparable after edits. */
|
||||
export type BenchmarkSnapshot = {
|
||||
/** Runs before 0.15: the deployment Kaname ran, as it was when the run started. */
|
||||
export type DeploymentSnapshot = {
|
||||
type?: "deployment";
|
||||
deploymentName: string;
|
||||
repoId: string;
|
||||
runtimeName: string;
|
||||
@@ -820,7 +605,9 @@ export type BenchmarkSnapshot = {
|
||||
command: string;
|
||||
};
|
||||
|
||||
/** What was measured on what, recorded when a run starts (Settings → Hardware overrides applied). */
|
||||
export type BenchmarkSnapshot = EndpointSnapshot | DeploymentSnapshot;
|
||||
|
||||
/** What was measured on what, recorded when a run starts (from the endpoint's hardware notes). */
|
||||
export type RunMeta = {
|
||||
v: 1;
|
||||
gpus: { pciAddress?: string; name: string | null; vramMb: number | null; linkCurrent: PcieLink | null; linkMax: PcieLink | null; rebar: boolean | null }[];
|
||||
@@ -833,12 +620,12 @@ export type RunMeta = {
|
||||
p2p: "on" | "off" | "partial" | "n/a" | null;
|
||||
/** On for every GPU used; null = unknown. */
|
||||
rebar: boolean | null;
|
||||
runtime: { image: string; tag: string | null; digest: string | null; engine: RuntimeEngine; engineName: string; engineVersion: string | null };
|
||||
runtime: { image: string; tag: string | null; digest: string | null; engine: string; engineName: string; engineVersion: string | null };
|
||||
model: { repoId: string; file: string | null; quant: string | null; kvCache: string | null };
|
||||
contextSize: number | null;
|
||||
/** Parallel slots (llama.cpp) or max sequences (vLLM); reported by the server where it can. */
|
||||
concurrency: number | null;
|
||||
/** Fields taken from Settings → Hardware instead of detection. */
|
||||
/** Runs before 0.15: fields taken from Settings → Hardware instead of detection. */
|
||||
overridden: string[];
|
||||
};
|
||||
|
||||
@@ -947,8 +734,11 @@ export const benchmarkRuns = sqliteTable(
|
||||
"benchmark_runs",
|
||||
{
|
||||
id: id(),
|
||||
/** Null once the deployment is deleted; the snapshot keeps what was measured. */
|
||||
deploymentId: text("deployment_id"),
|
||||
/** Null once the endpoint is deleted; the snapshot keeps what was measured. */
|
||||
endpointId: text("endpoint_id"),
|
||||
/** A/B: the second endpoint (B); `endpointId` is A. */
|
||||
endpointBId: text("endpoint_b_id"),
|
||||
/** A downloaded model the endpoint serves (matched by repo id), if any. */
|
||||
modelId: text("model_id"),
|
||||
tool: text("tool").notNull().default("betterbench"),
|
||||
settings: text("settings", { mode: "json" }).$type<BenchmarkSettings>().notNull(),
|
||||
@@ -965,20 +755,10 @@ export const benchmarkRuns = sqliteTable(
|
||||
/** Files under BENCHMARKS_DIR/<id>/: results.json and results.html. */
|
||||
hasReport: integer("has_report", { mode: "boolean" }).notNull().default(false),
|
||||
kind: text("kind", { enum: BENCHMARK_KINDS }).notNull().default("run"),
|
||||
/** A/B: the second deployment (B); `deploymentId` is A. */
|
||||
deploymentBId: text("deployment_b_id"),
|
||||
snapshotB: text("snapshot_b", { mode: "json" }).$type<BenchmarkSnapshot>(),
|
||||
ab: text("ab", { mode: "json" }).$type<AbSummary>(),
|
||||
resources: text("resources", { mode: "json" }).$type<ResourceStats>(),
|
||||
/** kind "eval": the quality eval's result. */
|
||||
quality: text("quality", { mode: "json" }).$type<QualityResult>(),
|
||||
/** Run of a sweep variant. */
|
||||
sweepId: text("sweep_id"),
|
||||
/** Requested through the API: the token and its name at the time. */
|
||||
requestedByTokenId: text("requested_by_token_id"),
|
||||
requestedBy: text("requested_by"),
|
||||
/** Agent runs: cancelled after this many seconds of running. */
|
||||
timeLimitS: integer("time_limit_s"),
|
||||
/** Hardware, runtime and model facts (A, and B of an A/B), recorded at the start. */
|
||||
meta: text("meta", { mode: "json" }).$type<RunMeta>(),
|
||||
metaB: text("meta_b", { mode: "json" }).$type<RunMeta>(),
|
||||
@@ -1037,51 +817,3 @@ export const benchmarkPublications = sqliteTable(
|
||||
},
|
||||
(t) => [index("benchmark_publications_run_idx").on(t.runId)],
|
||||
);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Benchmark sweeps: one base deployment, one or two settings varied, a run per variant
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export const SWEEP_STATES = ["pending_approval", "queued", "running", "completed", "failed", "cancelled"] as const;
|
||||
export type SweepState = (typeof SWEEP_STATES)[number];
|
||||
|
||||
/** A setting a sweep varies; values are strings as entered (parsed per key). */
|
||||
export type SweepParam = { key: string; values: string[] };
|
||||
|
||||
export type SweepVariant = {
|
||||
index: number;
|
||||
/** Option overrides for this variant, e.g. { contextSize: 8192, cacheTypeK: "q8_0", cacheTypeV: "q8_0" }. */
|
||||
overrides: Record<string, unknown>;
|
||||
label: string;
|
||||
state: "pending" | "deploying" | "benchmarking" | "evaluating" | "done" | "failed" | "skipped";
|
||||
deploymentId?: string | null;
|
||||
runId?: string | null;
|
||||
/** The quality eval run of this variant (sweeps with quality: true). */
|
||||
evalRunId?: string | null;
|
||||
error?: string | null;
|
||||
};
|
||||
|
||||
export const benchmarkSweeps = sqliteTable("benchmark_sweeps", {
|
||||
id: id(),
|
||||
label: text("label"),
|
||||
/** The deployment the variants are copied from (may be deleted later; `base` keeps it). */
|
||||
baseDeploymentId: text("base_deployment_id"),
|
||||
base: text("base", { mode: "json" })
|
||||
.$type<{ name: string; runtimeId: string; modelId: string; options: DeploymentOptions; cpus: number | null; memoryMb: number | null }>()
|
||||
.notNull(),
|
||||
params: text("params", { mode: "json" }).$type<SweepParam[]>().notNull(),
|
||||
settings: text("settings", { mode: "json" }).$type<BenchmarkSettings>().notNull(),
|
||||
variants: text("variants", { mode: "json" }).$type<SweepVariant[]>().notNull(),
|
||||
state: text("state", { enum: SWEEP_STATES }).notNull().default("queued"),
|
||||
cancelRequestedAt: ts("cancel_requested_at"),
|
||||
startedAt: ts("started_at"),
|
||||
finishedAt: ts("finished_at"),
|
||||
error: text("error"),
|
||||
/** Requested through the API: the token and its name at the time. */
|
||||
requestedByTokenId: text("requested_by_token_id"),
|
||||
requestedBy: text("requested_by"),
|
||||
/** Agent sweeps: the sweep is stopped after this many seconds, each of its runs after runTimeLimitS. */
|
||||
timeLimitS: integer("time_limit_s"),
|
||||
runTimeLimitS: integer("run_time_limit_s"),
|
||||
createdAt: createdAt(),
|
||||
});
|
||||
Reference in new issue
Block a user