diff --git a/CHANGELOG.md b/CHANGELOG.md index bb2d608..b6771a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,52 @@ All notable changes to this project are documented here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); each milestone of step 1 (Hugging Face downloader) is released as a minor version. +## [0.15.0] - 2026-10-26 + +Kaname is back to two jobs: downloading models, and benchmarking the servers that run them. It no +longer starts servers itself. Benchmarks run against **endpoints**, any OpenAI-compatible server you +add by URL (llama.cpp, vLLM, SGLang, Ollama, …), wherever it runs. The state before this release is +kept in the branch `backup` and the tag `backup-0.14.3`. + +**Upgrading:** replace `compose.yaml` with the new one from `deploy/` (the `docker-proxy` service and +`DOCKER_HOST` are gone; a `sandbox` service and its volume are new) and run `docker compose up -d +--remove-orphans`. Containers Kaname started for deployments keep running; stop them yourself if +you don't need them. The database migrates on start: runtimes, deployments, sweeps, API tokens and +their settings are deleted; benchmark runs, models and downloads stay. + +### Added + +- **Endpoints** (new top-level page): name, URL, optional API key, the model to benchmark, and + **hardware notes** (GPUs, VRAM, PCIe link, P2P, ReBAR, driver, CPU, RAM, OS, virtualization, + engine name/version, image, quant, KV cache, context, parallel slots, free text). **Test + connection** lists the models the server serves and detects llama.cpp, vLLM, SGLang and Ollama + with their version, context and slots where the server tells. The API key never reaches the + browser, logs or runs; it goes to BetterBench only through its environment. +- Runs against endpoints: BetterBench speed runs, paired A/B between two endpoints serving the same + model (each with its own API key), and the quality eval. Kaname asks the server before queuing and + again when the run starts; what it reports and the hardware notes are recorded with the run and + go into BetterBench's notes and launch80 previews (never the URL or the endpoint's name). +- A **sandbox** container for the quality eval's coding section: no network, read-only, no + capabilities, memory/CPU/process limits, and only an exchange folder shared with the worker + (replaces the throwaway containers the worker used to start through Docker). +- Model pages list the benchmark runs of that model (when the endpoint serves it under its repo id). + +### Removed + +- Runtimes, deployments (and their logs, chat, stats), sweeps, the llama.cpp/vLLM presets and the + resource/GPU telemetry sampled from deployment containers. +- Hardware detection (Settings → Hardware, the probe containers, `pci.ids` in the image): Kaname + can't see the machine behind an endpoint; describe it in the endpoint's hardware notes instead. +- The API for programs and agents (`/api/v1`, API tokens, guardrails, approvals, the activity log, + the agent skills and `docs/api.md`). Every route now requires the login. +- Docker access: `DOCKER_HOST`, `KANAME_DOCKER_NETWORK`, `KANAME_MODELS_SOURCE` and the + `docker-proxy` service. + +### Changed + +- Runs from before this release stay readable (with the deployment they measured), but can't be + run again. + ## [0.14.3] - 2026-10-22 ### Fixed diff --git a/Dockerfile b/Dockerfile index 035149f..3d52ff3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,6 @@ # syntax=docker/dockerfile:1.7 -# One image for both services; the first argument picks the role: `web` (default) or `worker`. +# One image for all services; the first argument picks the role: `web` (default), `worker` or +# `sandbox` (runs the quality eval's coding answers, see compose.yaml). FROM node:24-trixie-slim AS node @@ -16,17 +17,14 @@ RUN npm run build \ # --- runtime ----------------------------------------------------------------- # Python base (provides the official `hf` CLI) plus the Node binary. The Python image already -# has CA certificates and libstdc++; apt only adds the PCI ID database (GPU names for benchmarks). +# has CA certificates and libstdc++, so no apt. FROM python:3.13-slim-trixie AS runtime COPY --from=node /usr/local/bin/node /usr/local/bin/node -RUN apt-get update \ - && apt-get install -y --no-install-recommends pci.ids \ - && rm -rf /var/lib/apt/lists/* # Pinned: the worker relies on the CLI's on-disk layout (see src/worker/hf-layout.ts); # re-verify that before bumping. ARG HF_HUB_VERSION=2.1.1 -# BetterBench (Apache-2.0), the benchmark run against deployments. Not on PyPI: the release +# BetterBench (Apache-2.0), the benchmark run against endpoints. Not on PyPI: the release # archive is pinned by checksum; flags used by src/worker/betterbench.ts are verified per version. ARG BETTERBENCH_VERSION=0.6.1 ADD --checksum=sha256:f0a9d7fcc411c809ff87a0a22e2d76f6662b426431d2ae9fa273bc2644464db7 \ @@ -49,8 +47,8 @@ RUN python -m venv /opt/hf \ && /opt/betterbench/bin/pip install --no-cache-dir /tmp/betterbench.tar.gz \ && rm -rf /root/.cache /tmp/betterbench.tar.gz \ && useradd --uid 1000 --create-home --shell /usr/sbin/nologin app \ - && mkdir -p /data /models \ - && chown app:app /data /models + && mkdir -p /data /models /sandbox \ + && chown app:app /data /models /sandbox ARG APP_VERSION=dev ENV PATH=/opt/hf/bin:$PATH \ diff --git a/README.md b/README.md index 33848b9..fdc6f0b 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,11 @@ Kaname: self-hosted model manager for Hugging Face

-**Kaname** (要, "the pivot") is a self-hosted web app for downloading and managing local LLMs from -Hugging Face. Look up a repo, pick the quant you want, and Kaname downloads exactly those files with -the official `hf` CLI, pinned to a specific commit so every download is reproducible. +**Kaname** (要, "the pivot") is a self-hosted web app for downloading local LLMs from Hugging Face +and benchmarking the servers that run them. Look up a repo, pick the quant you want, and Kaname +downloads exactly those files with the official `hf` CLI, pinned to a specific commit so every +download is reproducible. Point it at your llama.cpp, vLLM, SGLang or Ollama servers and it measures +their speed and answer quality with [BetterBench](https://github.com/GGZ14/BetterBench). - **Pick files, not whole repos:** one-click quant selection for GGUF repos, or include/exclude globs. - **Pinned and reproducible:** every model is pinned to the exact commit SHA you reviewed. @@ -12,8 +14,11 @@ the official `hf` CLI, pinned to a specific commit so every download is reproduc the browser; cancel any time. - **Find things again:** search and filter by author, model family (e.g. Qwen, Gemma), quant, status and your own tags like `roleplay` or `security`. -- **Homelab-friendly:** two containers, SQLite, OIDC single sign-on (e.g. Pocket ID), models on any - folder or NAS share. +- **Benchmark your endpoints:** speed runs, paired A/B tests and a quality eval against any + OpenAI-compatible server, with the hardware you describe recorded next to every number; publish + results to [launch80](https://launch80.com) if you like. +- **Homelab-friendly:** a few containers, SQLite, OIDC single sign-on (e.g. Pocket ID), models on any + folder or NAS share. Kaname needs no access to Docker. ## Install @@ -82,24 +87,29 @@ More guides are in the [wiki](https://git.linxweiler.xyz/pascallinxweiler/Kaname updating is always your click. If a repo (or its pinned commit) disappears from Hugging Face, the model is flagged and your local copy is kept. - **Delete:** removes the model and, if you want, its files from disk. -- **Runtimes:** register llama.cpp, vLLM or your own fork images and pull them from Settings → Runtimes - (groundwork for testing model configs). See the - [wiki](https://git.linxweiler.xyz/pascallinxweiler/Kaname/wiki/Runtimes). - **Jobs:** each download has a page with per-file progress and the full `hf` log. -- **API for agents:** create a token in Settings → API tokens and let a program or AI agent look up - repos, list models and request downloads at `/api/v1`, and deploy and benchmark models to tune - their launch options, within guardrails you set (approval, sizes and limits, one GPU job at a time, - allowed runtimes and arguments, protected deployments). See [docs/api.md](docs/api.md) (also how to - let `/api/v1/` past a forward-auth proxy) and the agent skills [docs/agent/SKILL.md](docs/agent/SKILL.md) - and [docs/agent/SKILL-tuning.md](docs/agent/SKILL-tuning.md). +- **Endpoints:** add the URL (and API key, if any) of an OpenAI-compatible server under Endpoints. + **Test connection** shows the models it serves and, where it tells, the engine, version and context. + Describe the machine behind it (GPUs, PCIe link, CPU, RAM, OS, engine build, quant, KV cache): + Kaname can't see it, and these notes go into every run so results stay comparable. The API key + stays on the server. +- **Benchmarks:** from an endpoint's page, start a BetterBench **speed** run (generation, prompt + processing, parallel requests), a paired **A/B** against another endpoint serving the same model, + or the **quality** eval (tool calling, coding, long-context retrieval; deterministic). Runs go one + at a time. Select runs on the Benchmarks page to compare them; publish a run to launch80 after a + preview and an explicit confirmation (needs `L80_TOKEN`). No host names or addresses are published. ## How it works -Two containers from the same image share one SQLite database: +Three containers from the same image; web and worker share one SQLite database: - **web:** Next.js UI and API, OIDC login (Auth.js); live updates via Server-Sent Events. - **worker:** runs the download queue, spawns `hf download --revision --include `, and - measures progress from bytes on disk. Only one worker runs at a time. + measures progress from bytes on disk; runs benchmarks against endpoints (BetterBench, the quality + eval). Only one worker runs at a time. +- **sandbox:** runs the quality eval's coding answers (Python written by the model under test) with + no network, a read-only filesystem, no capabilities and small limits. It shares only an exchange + folder with the worker. Optional: without it the eval skips the coding section. Notes on the `hf` CLI (huggingface_hub 2.1.1, pinned in the image): @@ -132,7 +142,7 @@ the image locally. | `npm test` | unit tests | | `npm run typecheck`, `npm run lint` | checks | | `npm run db:generate` | new migration after changing `src/lib/db/schema.ts` | -| `npm run build:worker` | bundle worker + migrate script into `dist/` (used by the image) | +| `npm run build:worker` | bundle worker, sandbox and migrate script into `dist/` (used by the image) | **Releases:** bump `version` in `package.json`, add a `## [X.Y.Z]` section to [`CHANGELOG.md`](CHANGELOG.md), commit and push a `vX.Y.Z` tag. Gitea Actions diff --git a/compose.yaml b/compose.yaml index bf95e6f..e0fcb39 100644 --- a/compose.yaml +++ b/compose.yaml @@ -20,31 +20,32 @@ services: DATABASE_URL: file:/data/app.db MODELS_DIR: /models HF_HOME: /data/hf-home - DOCKER_HOST: tcp://docker-proxy:2375 - volumes: [data:/data, models:/models] + SANDBOX_DIR: /sandbox + volumes: [data:/data, models:/models, sandbox:/sandbox] web: <<: *app ports: ["${WEB_PORT:-3000}:3000"] volumes: [data:/data] - # Docker API for runtimes (llama.cpp / vLLM containers), limited to what Kaname needs: - # containers, images, networks, info. Not reachable from outside the compose network. - # Remove this service (and DOCKER_HOST on the worker) to run Kaname as a pure downloader. - docker-proxy: - image: tecnativa/docker-socket-proxy:v0.5.0 - environment: - CONTAINERS: 1 - IMAGES: 1 - INFO: 1 - NETWORKS: 1 - POST: 1 - ALLOW_START: 1 - ALLOW_STOP: 1 - volumes: - - /var/run/docker.sock:/var/run/docker.sock:ro + # Runs the quality eval's coding answers (Python written by the model under test) with no + # network, a read-only root, no capabilities and small limits. It shares only the exchange folder + # with the worker. Optional: without it the quality eval skips the coding section. + sandbox: + image: kaname:local + command: sandbox + network_mode: none + read_only: true + tmpfs: ["/tmp:size=64m,mode=1777"] + cap_drop: [ALL] + security_opt: ["no-new-privileges:true"] + mem_limit: 512m + pids_limit: 64 + cpus: 1 + volumes: [sandbox:/sandbox] restart: unless-stopped volumes: data: models: + sandbox: diff --git a/deploy/compose.yaml b/deploy/compose.yaml index f166c81..5763cfa 100644 --- a/deploy/compose.yaml +++ b/deploy/compose.yaml @@ -9,10 +9,11 @@ services: command: worker env_file: .env environment: - DOCKER_HOST: tcp://docker-proxy:2375 + SANDBOX_DIR: /sandbox volumes: - ${KANAME_DATA_DIR:-./data}:/data # SQLite DB, shared with web (local disk, not NFS) - ${KANAME_MODELS_DIR:-./models}:/models # downloaded models (a host-mounted NAS share works) + - sandbox:/sandbox # exchange folder with the code sandbox restart: unless-stopped web: @@ -23,19 +24,22 @@ services: - ${KANAME_DATA_DIR:-./data}:/data restart: unless-stopped - # Docker API for runtimes (llama.cpp / vLLM containers), limited to what Kaname needs: - # containers, images, networks, info. Not reachable from outside the compose network. - # Remove this service (and DOCKER_HOST on the worker) to run Kaname as a pure downloader. - docker-proxy: - image: tecnativa/docker-socket-proxy:v0.5.0 - environment: - CONTAINERS: 1 - IMAGES: 1 - INFO: 1 - NETWORKS: 1 - POST: 1 - ALLOW_START: 1 - ALLOW_STOP: 1 - volumes: - - /var/run/docker.sock:/var/run/docker.sock:ro + # Runs the quality eval's coding answers (Python written by the model under test) with no + # network, a read-only root, no capabilities and small limits. It shares only the exchange folder + # with the worker. Optional: without it the quality eval skips the coding section. + sandbox: + image: git.linxweiler.xyz/pascallinxweiler/kaname:${KANAME_VERSION:-latest} + command: sandbox + network_mode: none + read_only: true + tmpfs: ["/tmp:size=64m,mode=1777"] + cap_drop: [ALL] + security_opt: ["no-new-privileges:true"] + mem_limit: 512m + pids_limit: 64 + cpus: 1 + volumes: [sandbox:/sandbox] restart: unless-stopped + +volumes: + sandbox: diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 94df04d..760834a 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Usage: docker run [web|worker|] (default: web) +# Usage: docker run [web|worker|sandbox|] (default: web) set -e role="${1:-web}" @@ -25,5 +25,10 @@ esac case "$role" in web) exec node_modules/.bin/next start ;; worker) exec node dist/worker.mjs ;; + sandbox) + echo sandbox > /tmp/kaname-role + require_writable "${SANDBOX_DIR:-/sandbox}" + exec node dist/sandbox.mjs + ;; *) exec "$@" ;; esac diff --git a/docker-healthcheck.sh b/docker-healthcheck.sh index 7da7f89..64687ca 100644 --- a/docker-healthcheck.sh +++ b/docker-healthcheck.sh @@ -3,6 +3,8 @@ case "$(cat /tmp/kaname-role 2>/dev/null)" in # The worker touches this file on every heartbeat (every 5s). worker) find /tmp/kaname-worker-alive -mmin -1 | grep -q . ;; + # The sandbox touches this every 2s. + sandbox) find "${SANDBOX_DIR:-/sandbox}/.alive" -mmin -1 | grep -q . ;; web) node -e 'fetch("http://127.0.0.1:" + (process.env.PORT || 3000) + "/login").then((r) => process.exit(r.ok ? 0 : 1), () => process.exit(1))' ;; *) exit 0 ;; esac diff --git a/docs/agent/SKILL-tuning.md b/docs/agent/SKILL-tuning.md deleted file mode 100644 index 3a266fe..0000000 --- a/docs/agent/SKILL-tuning.md +++ /dev/null @@ -1,192 +0,0 @@ ---- -name: kaname-tuning -description: Deploy local LLMs on the user's Kaname server, benchmark their speed and check their answer quality to find good launch options (context, KV cache type, batch sizes, GPU layers, runtime) for the hardware. Use when the user asks to deploy, test, benchmark, tune or compare a model's settings, or to find the fastest setup for a model. -required_environment_variables: - - name: KANAME_URL - prompt: Kaname base URL (no trailing slash) - - name: KANAME_TOKEN - prompt: Kaname API token (kn_…) with the deployments and benchmarks scopes ---- - -# Kaname: deploy and tune models - -Kaname runs models in containers (llama.cpp or vLLM) and measures them with BetterBench. With this -skill you deploy a downloaded model, benchmark it, change **one** launch option at a time and report -which setup is best. To find or download models, use the `kaname-models` skill (`SKILL.md`). - -You may only change and benchmark deployments your own token created. You **cannot** touch the -user's deployments (especially protected ones), change settings, runtimes or tokens, or delete -models. Tell the user when something needs one of those. - -Every call needs `KANAME_URL` and `KANAME_TOKEN` (never print the token or put it in a URL), and the -`kaname` helper (a `curl` wrapper that adds the token and JSON headers; see `SKILL.md` → Setup). If -`kaname` is missing, write out -`curl -sS -H "Authorization: Bearer $KANAME_TOKEN" -H "Content-Type: application/json" …` instead. - -Errors are `{"error": {"code", "message"}}`; the message says what to do. - -## Rules - -- **No polling loops.** Status calls take `?wait=S` (max 900): Kaname holds the request until the - state settles. Make one call, with `-m` (curl's time limit) a bit above the wait. -- **Approval:** by default every start, run and sweep waits for the user (`state: - pending_approval`). Then **stop**: tell the user what you asked for and that it awaits their - approval in Kaname. Don't retry, don't poll. Continue when the user says it's approved. -- **Never work around a guardrail** (another token, splitting a sweep, renaming things). Report the - error message and stop. -- **One GPU job at a time:** one of your deployments running at once (unless the user raised the - limit), one run or sweep at a time. Stop your deployment when you're done. -- **Change one variable at a time**, so a difference has one cause. - -## 1. Know your limits - -```bash -kaname "$KANAME_URL/api/v1" -``` - -`deploymentGuardrails`: approval mode, how many of your deployments may run, run/sweep time limits, -max sweep variants, caps, host ports. Your scopes must include `deployments:write` and -`benchmarks:run`; if not, tell the user. - -## 2. Pick a model and a runtime - -```bash -kaname "$KANAME_URL/api/v1/models?status=ready&q=qwen3" -kaname "$KANAME_URL/api/v1/models/" # its files (pick a .gguf for llama.cpp) -kaname "$KANAME_URL/api/v1/runtimes" -``` - -Runtimes say what they serve (llama.cpp: a GGUF file, vLLM: a safetensors repo), whether you may use -them (`"allowed": true`) and which extra argument flags you may pass (`allowedExtraArgs`). `gpus` -lists the host's GPUs and their VRAM. - -Previous results for this model, to start from what is known: - -```bash -kaname "$KANAME_URL/api/v1/benchmarks?limit=10" -``` - -## 3. Deploy - -Check first (nothing is created; you get the exact command and the memory/VRAM estimates): - -```bash -kaname -X POST "$KANAME_URL/api/v1/deployments" -d '{ - "runtimeId": "", "modelId": "", "dryRun": true, - "options": { "modelFile": "Qwen3-8B-Q4_K_M.gguf", "contextSize": 16384, "gpuLayers": "auto", - "cacheTypeK": "q8_0", "cacheTypeV": "q8_0", "parallel": 1, "extraArgs": [] } -}' -``` - -If `estimates.vramMb` is above `estimates.gpuVramMb`, lower the context, quantize the KV cache or -pick a smaller quant. Then the same body without `"dryRun"`: - -- `state: pending_approval` → tell the user and stop (see Rules). -- `state: starting` → wait until it is ready: - -```bash -kaname -m 660 "$KANAME_URL/api/v1/deployments/?wait=600" -``` - -`state: running` → go on. `state: failed` → read `error` (and `?log=50`), fix the options -(`PATCH`, below) and start again; don't repeat the same failing options. - -## 4. Benchmark - -```bash -kaname -X POST "$KANAME_URL/api/v1/benchmarks" -d '{ - "deploymentId": "", "quick": true, "label": "Q4_K_M ctx16k q8_0 KV", - "description": "Baseline for tuning Qwen3-8B on this GPU" -}' -kaname -m 960 "$KANAME_URL/api/v1/benchmarks/?wait=900" -``` - -- `quick: true` (5 passes) to screen options; `quick: false` (20 passes) to confirm the winner. -- `phases` (`decode`, `prefill`, `concurrency`) narrows what is measured; leave it out for all. -- The result's `headline` has `decodeTps` (generation speed), `prefillTps` (prompt processing at the - deepest prompt), `ttftMs` (time to first token) and `peakParallelTps`; `setup` lists GPU, PCIe, - engine version, model/quant/KV cache, context and concurrency; `resources` has VRAM, power and - temperature. `?full=1` only when you need the per-category details. -- If the wait times out, the run is still going: one more call with `?wait=900`, then report. - -Then check that the answers are still right (speed alone can hide a broken setup): - -```bash -kaname -X POST "$KANAME_URL/api/v1/benchmarks" -d '{"kind": "eval", "deploymentId": "", "label": "Q4_K_M ctx16k q8_0 KV"}' -kaname -m 960 "$KANAME_URL/api/v1/benchmarks/?wait=900" -``` - -`quality.score` (0–100) and per section (`tools`, `coding`, `retrieval`). Add `?full=1` to see which -items failed. A drop of more than a few points against the baseline means the change hurt quality, -however fast it is. - -## 5. Change one variable and compare - -Stop, change one option, start, wait, benchmark again: - -```bash -kaname -X POST "$KANAME_URL/api/v1/deployments//stop" -kaname -m 120 "$KANAME_URL/api/v1/deployments/?wait=60" -kaname -X PATCH "$KANAME_URL/api/v1/deployments/" -d '{"options": {"cacheTypeK": "f16", "cacheTypeV": "f16"}}' -kaname -X POST "$KANAME_URL/api/v1/deployments//start" -``` - -Or let Kaname do it: a **sweep** deploys each variant of one or two settings, benchmarks it (with -`"quality": true` also runs the quality eval) and removes it again (stop your own deployment first; -it counts as one run): - -```bash -kaname -X POST "$KANAME_URL/api/v1/sweeps" -d '{ - "baseDeploymentId": "", "quick": true, "quality": true, - "params": [{ "key": "kvCache", "values": ["f16", "q8_0", "q4_0"] }] -}' -kaname -m 960 "$KANAME_URL/api/v1/sweeps/?wait=900" -``` - -Keys: `contextSize`, `modelFile`, `kvCache`, `threads`, `parallel`, `batchSize`, `ubatchSize`, -`flashAttn`, `cacheRamMb`, `gpuLayers` (llama.cpp); `dtype`, `maxNumSeqs`, `gpuMemoryUtilization` -(vLLM); `cpus`. A sweep can take long: after a timed-out wait, report progress instead of waiting -again and again. - -Compare runs side by side: - -```bash -kaname "$KANAME_URL/api/v1/benchmarks/compare?ids=,," -``` - -Differences under ~2 % between separate runs are noise. For a small difference that matters, run -an A/B (two deployments of the same model at once, if the user allows 2 agent deployments): -`{"kind": "ab", "deploymentId": "", "deploymentBId": ""}`. - -## 6. Report and clean up - -Report a compact table, one row per setup, the varied option first: - -| KV cache | Decode t/s | Prefill t/s | TTFT ms | Quality | VRAM peak | Notes | -| --- | --- | --- | --- | --- | --- | --- | -| f16 | 58.1 | 1910 | 88 | 86.1 | 11.2 GB | baseline | -| q8_0 | 57.6 | 1880 | 90 | 86.1 | 9.4 GB | −1 % speed, same quality, 1.8 GB less VRAM | - -Name the winner and why: speed and quality together (and what stayed the same: GPU, engine version, -quant, context). Then stop -your deployment (or delete it if the user doesn't need it): - -```bash -kaname -X POST "$KANAME_URL/api/v1/deployments//stop" -``` - -## When something is refused - -| `error.code` | What to do | -| --- | --- | -| `too_many_deployments` | Stop your other deployment first, or tell the user. | -| `gpu_busy` | Another agent job is running or a deployment is loading: wait once with `?wait=`, then retry once; otherwise report and stop. | -| `vram_protected` | It would crowd the user's protected deployment out of VRAM: smaller quant, context or quantized KV cache, or tell the user. | -| `arg_not_allowed` | That flag isn't allowed; use the structured option if there is one (`contextSize`, `gpuLayers`, `cacheTypeK`, …) or drop it. | -| `limit_exceeded` | Over the memory/CPU cap: smaller model or context. | -| `port_not_allowed` | Leave out `hostPort`. | -| `runtime_not_allowed`, `runtime_not_pulled` | Pick another runtime from `GET /api/v1/runtimes`, or tell the user. | -| `protected`, `not_owner` | Not your deployment: deploy your own. | -| `too_many_variants` | Vary fewer values. | -| `busy` | Stop the deployment before changing it. | -| `unauthorized`, `forbidden` | Token wrong, revoked or missing a scope: tell the user. | diff --git a/docs/agent/SKILL.md b/docs/agent/SKILL.md deleted file mode 100644 index 6c22e20..0000000 --- a/docs/agent/SKILL.md +++ /dev/null @@ -1,133 +0,0 @@ ---- -name: kaname-models -description: Find, request and track downloads of local LLMs (Hugging Face models, GGUF quants) on the user's Kaname server. Use when the user asks to get, download, add or check a model, or asks which models are available locally or how much disk space is left. -required_environment_variables: - - name: KANAME_URL - prompt: Kaname base URL (no trailing slash) - - name: KANAME_TOKEN - prompt: Kaname API token (kn_…) ---- - -# Kaname: local model downloads - -Kaname manages the user's local LLM library. You can look up Hugging Face repos, see what is -already downloaded, request a download and follow it. You **cannot** delete anything, change -settings, or start models with this skill: tell the user when they need one of those. To deploy and -benchmark models (with a token that has the deployments and benchmarks scopes), see -`SKILL-tuning.md`. - -Every call needs two environment variables: - -- `KANAME_URL`: e.g. `https://models.example.com` (no trailing slash) -- `KANAME_TOKEN`: the API token (`kn_…`). Never print it or put it in a URL. - -## Setup - -The examples use `kaname`, a small wrapper around `curl` that adds the token and JSON headers. The -user installs it once: - -```bash -mkdir -p ~/.local/bin && curl -fsSL https://git.linxweiler.xyz/pascallinxweiler/Kaname/raw/branch/main/docs/agent/kaname -o ~/.local/bin/kaname && chmod +x ~/.local/bin/kaname -``` - -If `kaname` is not found, write out the full command in each call instead: -`curl -sS -H "Authorization: Bearer $KANAME_TOKEN" -H "Content-Type: application/json" …` -(every command runs in a fresh shell, so don't define a shell function for it). - -All responses are JSON. Errors are `{"error": {"code", "message"}}`; the message says what to do. - -## 0. Know your limits - -```bash -kaname "$KANAME_URL/api/v1" -``` - -Shows your token name, scopes and the guardrails. The defaults: - -- **approvalMode `approve`**: your requests wait until the user approves them. That's normal. -- **maxRequestSize** (60 GB): one request may download at most this much. -- **minFreeSize** (100 GB): this much must stay free on disk after the download. -- **maxOpenAgentJobs** (2): at most this many of your requests pending or running at once. -- **allowedAuthors**: if not empty, only repos from these Hugging Face authors. - -## 1. Is it already here? - -```bash -kaname "$KANAME_URL/api/v1/models?q=qwen3%208b" -kaname "$KANAME_URL/api/v1/models?author=unsloth&quant=Q4_K_M&status=ready" -``` - -Filters: `q`, `author`, `family`, `quant`, `tag`, `status`, `requested_by` (comma-separate values). -If the model is there with `status: ready`, you're done. Don't request it again. - -## 2. Look up the repo - -```bash -kaname "$KANAME_URL/api/v1/hub/lookup?repo=unsloth/Qwen3-8B-GGUF" -``` - -Note `sha` (the commit) and pick a quant from `quants` (each has a `size`). Choose one that fits the -user's request and the limits: check `size` against `maxRequestSize`, and check space with: - -```bash -kaname "$KANAME_URL/api/v1/disk" # availableForRequests = what a request may still use -``` - -If `gated` is not `false`, the download only works if the user's Hugging Face account has access. - -## 3. Request the download - -```bash -kaname -X POST "$KANAME_URL/api/v1/downloads" \ - -d '{"repoId":"unsloth/Qwen3-8B-GGUF","sha":"","quant":"Q4_K_M"}' -``` - -For repos without GGUF quants (safetensors), use `"include": ["*.safetensors", "*.json"]` instead -of `quant`. Optional: `"tags": ["…"]`. - -Answer: - -- `201`, `state: pending_approval`: **waiting for the user.** Tell them what you requested and that - it needs their approval in Kaname. **Do not retry or re-request.** -- `201`, `state: queued`: it will start on its own. -- `200`, `created: false`: you (or someone) already requested exactly this; you get the existing - job. Don't request it again. - -## 4. Follow it - -```bash -kaname -m 660 "$KANAME_URL/api/v1/jobs/?wait=600" -``` - -`state`: `pending_approval` → `queued` → `downloading` → `verifying` → `completed`. With `?wait=600` -Kaname holds the request until the job is finished (or 600 s have passed; then `timedOut` is -`true`), so one call replaces a polling loop. Keep `-m` (curl's time limit) a bit above the wait. -Every call costs a full round of your context, so call rarely: - -- **`pending_approval`:** do **not** poll. Tell the user what you requested and that it awaits - their approval in Kaname, then stop. Check again only when the user says it's approved, or, if - the user asks for it, schedule a single one-off check later with your cron/scheduling tool. -- **`queued` / `downloading` / `verifying`:** one call with `?wait=600`. If it comes back with - `timedOut: true` and the ETA is long, tell the user it is still downloading instead of waiting - again and again. Never loop in short intervals. -- **`completed`:** tell the user it's ready. -- **`cancelled`:** the user rejected or cancelled it. Don't ask again unless the user says so. -- **`failed`:** report `error.message` to the user. Don't loop on retries. - -Add `?log=20` only when you need to explain a failure. - -## When a request is refused - -| `error.code` | What to do | -| --- | --- | -| `too_large` | Pick a smaller quant (or fewer files) that fits `maxRequestSize`. | -| `disk_space` | Pick a smaller quant, or tell the user the disk is full. | -| `too_many_jobs` | Don't wait in a loop: tell the user your earlier downloads are still pending or running, and stop. Request again later when the user asks. | -| `author_not_allowed` | Find the model from an allowed author, or ask the user. | -| `already_exists` | The repo is in the library at another commit; the user updates it in Kaname. | -| `busy` | That model has a download in progress; tell the user and stop. | -| `gated_no_access`, `gated_no_token` | The user must accept the model's terms on Hugging Face. | -| `disk_unknown` | Kaname's worker is offline; tell the user and stop. | -| `unauthorized`, `forbidden` | Your token is wrong, revoked or lacks a scope: tell the user. | - -Never try to work around a guardrail (e.g. by splitting one big download into several requests). diff --git a/docs/agent/kaname b/docs/agent/kaname deleted file mode 100755 index 8f0a34f..0000000 --- a/docs/agent/kaname +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -exec curl -sS -H "Authorization: Bearer $KANAME_TOKEN" -H "Content-Type: application/json" "$@" diff --git a/docs/api.md b/docs/api.md deleted file mode 100644 index 8c83466..0000000 --- a/docs/api.md +++ /dev/null @@ -1,419 +0,0 @@ -# Kaname API (`/api/v1`) - -A small JSON API for programs and AI agents: look up Hugging Face repos, list the local library, -request downloads, deploy models and benchmark them to tune launch options. Everything an agent can -do here is bounded by [guardrails](#guardrails); it can't delete models or files, change settings, -manage runtimes or tokens, or touch deployments it didn't create. - -The rest of Kaname (the web UI and its internal `/api/*` routes) stays behind your OIDC login. Only -`/api/v1` accepts tokens, and it accepts *only* tokens (a browser session doesn't work there). - -- [Authentication](#authentication) -- [Errors](#errors) -- [Endpoints](#endpoints): models and downloads, [deployments](#deployments), [benchmarks](#benchmarks) -- [Waiting instead of polling](#waiting-instead-of-polling) -- [Guardrails](#guardrails) -- [Behind a forward-auth proxy (Traefik)](#behind-a-forward-auth-proxy-traefik) - -## Authentication - -Create a token in **Settings → API tokens**. It is shown once; Kaname stores only its SHA-256. -Send it with every request: - -``` -Authorization: Bearer kn_… -``` - -| Scope | Allows | -| --- | --- | -| `models:read` | Hub lookup, list models, read jobs (and their log), disk space | -| `downloads:create` | `POST /api/v1/downloads`, within the guardrails | -| `deployments:read` | List runtimes and deployments, read a deployment's state and log | -| `deployments:write` | Create deployments; edit, start, stop and delete **its own** ones, within the guardrails | -| `benchmarks:read` | Read runs, sweeps and comparisons | -| `benchmarks:run` | Start runs, A/B runs and sweeps on **its own** deployments; cancel its own | - -Tokens created before 0.13 keep the scopes they had; grant new ones with **Scopes** next to the -token in Settings → API tokens. - -A missing, unknown or revoked token gets `401`; a token without the needed scope gets `403`. The -settings page shows when each token was last used; **Revoke** stops it immediately. - -Everything a token requests is marked with its name ("requested by hermes") on the model and job -pages and in the library, where you can filter by it. - -## Errors - -Errors are JSON with a message meant to be read and acted on: - -```json -{ "error": { "code": "too_large", "message": "exceeds max size per request 60.0 GB: requested 74.2 GB. Pick a smaller quant or fewer files." } } -``` - -| Status | Codes | -| --- | --- | -| 400 | `invalid_request` (also unknown fields), `invalid_json`, `empty_selection` (quant or globs match nothing), `invalid_repo_id`, `invalid` | -| 401 / 403 | `unauthorized`, `forbidden` (scope), `author_not_allowed`, `gated_no_token`, `gated_no_access`, `runtime_not_allowed`, `arg_not_allowed`, `port_not_allowed`, `protected`, `not_owner` | -| 404 | `not_found`, `repo_not_found`, `revision_not_found` | -| 409 | `already_exists` (repo is in the library at another commit), `busy` (a model with an open job; a deployment that must be stopped first), `runtime_not_pulled`, `vram_protected`, `invalid` (e.g. benchmarking a stopped deployment) | -| 422 | `too_large`, `limit_exceeded`, `too_many_variants` | -| 429 | `too_many_jobs`, `too_many_deployments`, `gpu_busy`, `rate_limited` (Hugging Face) | -| 503 / 507 | `disk_unknown` (worker offline), `disk_space` | - -Sizes appear as bytes plus a readable `"… GB"` field (decimal GB, like the Hub). - -## Endpoints - -### `GET /api/v1` - -Any valid token. Who you are, your scopes, the current guardrails and the endpoint list. - -```bash -curl -s -H "Authorization: Bearer $KANAME_TOKEN" "$KANAME_URL/api/v1" -``` - -```json -{ - "token": { "name": "hermes", "scopes": ["models:read", "downloads:create"] }, - "guardrails": { "approvalMode": "approve", "maxRequestBytes": 60000000000, "maxRequestSize": "60.0 GB", - "minFreeBytes": 100000000000, "minFreeSize": "100.0 GB", "maxOpenAgentJobs": 2, "allowedAuthors": [] }, - "endpoints": ["…"] -} -``` - -### `GET /api/v1/hub/lookup?repo=org/name[&revision=main][&files=all]` - -`models:read`. Resolves the revision to a commit SHA and lists quants and files, the same data as -the Add model dialog. `repo` may also be a Hub URL. Up to 200 files are listed unless `files=all`. - -```json -{ - "repoId": "unsloth/Qwen3-8B-GGUF", "revision": "main", "sha": "9e6855bc…", "gated": false, - "lastModified": "2026-05-01T10:00:00.000Z", - "inLibrary": null, - "quants": [{ "quant": "Q4_K_M", "files": 1, "bytes": 5027783488, "size": "5.0 GB" }, "…"], - "fileCount": 31, "totalBytes": 104000000000, - "files": [{ "path": "Qwen3-8B-Q4_K_M.gguf", "bytes": 5027783488 }, "…"], - "filesTruncated": false -} -``` - -`inLibrary` is `{ modelId, pinnedSha, status }` when the repo is already in Kaname. - -### `GET /api/v1/models` - -`models:read`. The library, filtered like the library page: - -| Parameter | Meaning | -| --- | --- | -| `q` | Search text; every word must match (repo, author, family, quant, tags, …) | -| `author`, `family`, `quant`, `tag` | Facets; repeat or comma-separate values (OR within a facet, AND across) | -| `status` | `pending`, `downloading`, `ready`, `incomplete`, `failed`, `deleting`, `pending_approval`, `update_available`, `repo_missing`, `commit_missing` | -| `requested_by` | Token name | - -```json -{ "count": 1, "models": [{ "id": "01M…", "repoId": "unsloth/Qwen3-8B-GGUF", "status": "ready", "pendingApproval": false, - "pinnedSha": "9e68…", "quants": ["Q4_K_M"], "tags": ["agent"], "selectedFiles": 1, "selectedBytes": 5027783488, - "onDiskBytes": 5027783488, "onDisk": "5.0 GB", "updateAvailable": false, "hubState": "available", - "requestedBy": "hermes", "createdAt": "…", "downloadedAt": "…" }] } -``` - -### `GET /api/v1/models/{id}` - -`models:read`. One model with its selected files (path, bytes, state) and latest job. - -### `POST /api/v1/downloads` - -`downloads:create`. Request a download of a repo **at a pinned commit**: take `sha` from the lookup. - -| Field | | -| --- | --- | -| `repoId` | `"org/name"` | -| `sha` | Full 40-character commit SHA | -| `quant` | e.g. `"Q4_K_M"`: that quant's weight files (all split parts) plus the companion files ticked in Settings → Downloads (chat template, mmproj, …), as in the Add model dialog | -| `include` | Instead of `quant`: glob patterns, e.g. `["*.safetensors", "*.json"]` | -| `tags` | Optional user tags for the model | -| `revision` | Optional branch to track for update checks (default `main`) | - -```bash -curl -s -X POST -H "Authorization: Bearer $KANAME_TOKEN" -H "Content-Type: application/json" \ - -d '{"repoId":"unsloth/Qwen3-8B-GGUF","sha":"9e6855bc…","quant":"Q4_K_M"}' \ - "$KANAME_URL/api/v1/downloads" -``` - -```json -{ "created": true, "modelId": "01M…", "jobId": "01M…", "state": "pending_approval", - "requestedBytes": 5027783488, "requestedSize": "5.0 GB", "files": ["Qwen3-8B-Q4_K_M.gguf"], - "message": "Requested; waiting for the user to approve it in Kaname. Do not retry or poll; tell the user and stop." } -``` - -- **201**: a new job, `state` `pending_approval` (approval mode `approve`) or `queued` (`auto`). -- **200** with `"created": false`: the same repo, commit and files were requested before; you get the - existing model and its latest job. Nothing is queued twice. -- If the repo is already in the library at the same commit, the request adds the files that are - missing from its selection (only the added bytes count against the guardrails). At another commit - it is refused: updating a model is done in the UI. - -It uses the same code path as the Add model dialog (the file list is fetched again from the Hub at -that commit; the client's list isn't trusted). - -### `GET /api/v1/jobs/{id}[?wait=S][&log=N]` - -`models:read`. Compact job state: - -```json -{ "id": "01M…", "modelId": "01M…", "repoId": "unsloth/Qwen3-8B-GGUF", "kind": "download", "purpose": "initial", - "state": "downloading", "cancelRequested": false, "requestedBy": "hermes", - "progress": { "doneBytes": 3000000000, "totalBytes": 5027783488, "percent": 59.7, "done": "3.0 GB", "total": "5.0 GB", - "speedBytesPerSecond": 52000000, "etaSeconds": 39 }, - "error": null, - "files": [{ "path": "Qwen3-8B-Q4_K_M.gguf", "state": "downloading", "doneBytes": 3000000000, "totalBytes": 5027783488 }], - "createdAt": "…", "startedAt": "…", "finishedAt": null, - "next": "Downloading; check again in a minute." } -``` - -States: `pending_approval`, `queued`, `downloading`, `verifying`, `completed`, `failed`, `cancelled` -(also when the user rejected the request), `interrupted`. The `hf` log is only included with -`?log=N` (the last N lines, at most 200). `?wait=S` returns once the job is finished (or right away -while it waits for approval); see [Waiting instead of polling](#waiting-instead-of-polling). - -### `GET /api/v1/disk` - -`models:read`. Space on the models folder, as reported by the worker every few seconds: - -```json -{ "workerOnline": true, "freeBytes": 945600000000, "totalBytes": 2000000000000, "usedBytes": 1054400000000, - "reservedBytes": 105454144, "minFreeBytes": 100000000000, "availableForRequestsBytes": 845494545856, - "free": "945.6 GB", "total": "2000.0 GB", "availableForRequests": "845.5 GB" } -``` - -`reservedBytes` is what open downloads still have to fetch; `availableForRequests` is what a request -may use before hitting the minimum-free guardrail. - -### Deployments - -A deployment is a model served by a runtime container. Agents use the same validation, estimates and -`docker run` command as the UI; they can only edit, start, stop, delete and benchmark deployments their -own token created, and never [protected](#protected-deployments) ones. - -#### `GET /api/v1/runtimes` - -`deployments:read`. Runtimes with a pulled image: engine (`llama.cpp` or `vllm`), accelerator -(`cpu`, `nvidia`, `dri` for Intel/AMD), what they serve, whether agents may use them (`allowed`) and -the extra argument flags agents may pass (`allowedExtraArgs`); plus the host's GPUs. - -#### `GET /api/v1/deployments[?mine=1]`, `GET /api/v1/deployments/{id}[?wait=S][&log=N]` - -`deployments:read`. State (`stopped`, `pending_approval`, `starting`, `running`, `stopping`, -`failed`), `mine`, `protected`, runtime, model, options, limits, the endpoint inside the Docker -network, what the server reported once ready (version, slots, context), live CPU/RAM, error and a -`next` hint. `?wait=S` returns once it is running, stopped or failed (or right away while the start -waits for approval). `?log=N` adds the last N log lines (max 200). - -#### `POST /api/v1/deployments` - -`deployments:write`. - -| Field | | -| --- | --- | -| `runtimeId`, `modelId` | From `GET /api/v1/runtimes` and `GET /api/v1/models` | -| `options` | The deployment form's launch options: `modelFile` (llama.cpp: the `.gguf`; vLLM: `""`), `contextSize`, `parallel`, `cacheTypeK`/`cacheTypeV`, `flashAttn`, `gpuLayers`, `batchSize`/`ubatchSize`, `maxNumSeqs`, `gpuMemoryUtilization`, … and `extraArgs` (only [allowed flags](#deployments-and-benchmarks)). Unknown fields are refused. | -| `cpus`, `memoryMb` | Optional limits within the caps; without `memoryMb` the estimate is used | -| `hostPort` | Optional, only inside the configured range (none by default) | -| `name` | Optional | -| `start` | Default `true`; with approval mode `approve` the start waits for the user | -| `dryRun` | `true`: only validate; returns the command and estimates, creates nothing | - -```json -{ "created": true, "id": "01M…", "state": "pending_approval", - "command": "docker run -v :/models:ro ghcr.io/ggml-org/llama.cpp:server-intel -m /models/… -c 16384 -ctk q8_0 …", - "estimates": { "memoryMb": 9800, "vramMb": 7900, "gpuVramMb": 32768 }, "limits": { "memoryMb": 9800, "cpus": null }, - "message": "Created; the start waits for the user's approval in Kaname. Don't retry or poll; tell the user and stop." } -``` - -#### `PATCH /api/v1/deployments/{id}`, `POST …/start`, `POST …/stop`, `DELETE …` - -`deployments:write`, own deployments only. `PATCH` takes `options` (merged into the current ones), -`cpus`, `memoryMb`, `hostPort`, `name`, and only while the deployment is stopped; it returns the new -command and estimates. `start` goes through the same guardrails as creating one (and approval); -`stop` and `DELETE` never need approval. - -### Benchmarks - -#### `POST /api/v1/benchmarks` - -`benchmarks:run`. A [BetterBench](https://github.com/GGZ14/BetterBench) run against the token's own -**running** deployment. - -| Field | | -| --- | --- | -| `kind` | `run` (default, BetterBench speed), `ab` (paired A/B with `deploymentBId`, same model; needs 2 agent deployments) or `eval` (the [quality eval](#quality-eval)) | -| `deploymentId`, `deploymentBId` | Own, running deployments | -| `quick` | `true`: 5 passes, a smoke check; default `false`: 20 passes, comparable | -| `passes`, `phases` | Optional: passes per category; phases `decode`, `prefill`, `concurrency` (default all) | -| `label`, `description` | Optional; the description goes into the report and the launch80 preview | -| `sections` | `eval` only: `tools`, `coding`, `retrieval` (default all) | - -Answers `201` with `state` `pending_approval` (default) or `queued`, and the run's time limit. - -#### `GET /api/v1/benchmarks/{id}[?wait=S][&full=1]`, `GET /api/v1/benchmarks[?deployment=&requested_by=&limit=]` - -`benchmarks:read`. Compact result: - -```json -{ "id": "01M…", "kind": "run", "state": "completed", "label": "q8_0 KV", "mine": true, - "headline": { "decodeTps": 61.3, "prefillTps": 1840, "prefillDepth": 16000, "ttftMs": 92, "peakParallelTps": 155.2, "peakParallelLevel": 8 }, - "setup": { "gpus": "1× Intel Arc Pro B65 (32 GiB)", "pcie": "Gen5 x8 of Gen5 x16", "p2p": "n/a", "rebar": "on", - "engine": "llama.cpp b11541-f2918cabb", "image": "ghcr.io/ggml-org/llama.cpp:server-intel", "digest": "sha256:…", - "model": "Qwen3-8B-GGUF Q4_K_M with q8_0 KV cache", "ctx": "16,384", "concurrency": "4" }, - "resources": { "cpuAvgCores": 1.1, "ramPeakBytes": 2100000000, - "gpus": [{ "name": "Intel Arc Pro B65", "vramPeakMb": 9100, "vramTotalMb": 32768, "utilAvg": 88.5, "powerAvgW": 151.2, "tempPeakC": 71 }] }, - "error": null, "next": "Done. Compare runs with GET /api/v1/benchmarks/compare?ids=…" } -``` - -`?full=1` adds BetterBench's complete summary (per category, per prompt depth, per concurrency -level). A/B runs add `ab` (pairs, verdict, decode difference with its confidence interval). Eval runs -have `quality` instead of `headline`: -`{"evalSet": "kaname-eval-1", "score": 83.3, "sections": {"tools": "11/12", "coding": "6/8", "retrieval": "8/9"}}`, -and with `?full=1` the `failed` items with the reason. -`POST /api/v1/benchmarks/{id}/cancel` cancels an own run. - -#### `GET /api/v1/benchmarks/compare?ids=a,b,…` - -`benchmarks:read`. 2–16 runs: headline numbers side by side, the setup values that differ per run -(`differs`) and the ones they share (`same`). - -#### `POST /api/v1/sweeps`, `GET /api/v1/sweeps/{id}[?wait=S]`, `POST /api/v1/sweeps/{id}/cancel` - -`benchmarks:run` / `benchmarks:read`. One or two settings varied from an own base deployment, e.g. -`{"baseDeploymentId": "…", "params": [{"key": "kvCache", "values": ["f16", "q8_0"]}], "quick": true}`; -`"quality": true` also runs the quality eval on each variant. -Keys: `contextSize`, `modelFile`, `kvCache`, `threads`, `parallel`, `batchSize`, `ubatchSize`, -`flashAttn`, `cacheRamMb`, `gpuLayers`, `dtype`, `maxNumSeqs`, `kvCacheGb`, `gpuMemoryUtilization`, -`cpus` (per engine, as in the UI). Each variant is deployed, benchmarked and removed again. The -answer lists every variant with its headline numbers and setup. - -#### Quality eval - -BetterBench measures speed only. `kind: "eval"` checks what a deployment answers, deterministically -(greedy decoding, temperature 0, fixed seed, thinking turned off where the chat template supports -it), so a quant, KV cache type or build that changes quality shows up next to the speed numbers: - -| Section | Items | Passes when | -| --- | --- | --- | -| `tools` | 12 requests with 3 tools each | exactly one tool call, valid JSON arguments, the right function and the expected arguments | -| `coding` | 8 short Python functions | the answer's code passes its unit tests, run in a throwaway container (no network, read-only, unprivileged) | -| `retrieval` | a six-digit code hidden at 10 %, 50 % and 90 % depth in texts of 25 %, 50 % and 100 % of the context | the answer contains the code | - -The score is the mean pass rate of the sections that could run (a server that refuses tool calls, -e.g. vLLM without a tool-call parser, doesn't count as 0). The eval set is versioned (`evalSet`); -only results of the same version compare. - -## Waiting instead of polling - -Every status call costs an agent a round of its context. The status endpoints (`/jobs/{id}`, -`/deployments/{id}`, `/benchmarks/{id}`, `/sweeps/{id}`) take `?wait=S` (seconds, at most 900): the -request is held until the state is settled (finished, running, failed, cancelled) or the time is up, -then answers with the current state plus `waitedSeconds` and `timedOut`. Something that waits for the -user's approval answers right away: there is nothing to wait for. Use one waiting call instead of a -polling loop, with a wait shorter than your HTTP client's timeout (and any proxy's). - -## Guardrails - -### Downloads - -Settings → API tokens → **Guardrails for API downloads**. They apply to every token together; -downloads started in the UI aren't affected. - -| Setting | Default | Rejection | -| --- | --- | --- | -| Approval | **Ask me**: requests wait as *pending approval* until you approve or reject them on the model or job page | (not an error; `state: pending_approval`) | -| Max size per request | 60 GB | `422 too_large` | -| Keep free on the models folder | 100 GB, after the download and after what other open downloads still need | `507 disk_space` (`503 disk_unknown` if the worker is offline) | -| Agent jobs at once | 2 (pending approval, queued or running) | `429 too_many_jobs` | -| Allowed authors | empty = any; e.g. `unsloth, ggml-org, Qwen` (case-insensitive) | `403 author_not_allowed` | - -Rejecting a request cancels its job. A model that only that request added leaves the library again; -for a request that added files to an existing model, the previous selection is restored. - -### Deployments and benchmarks - -Settings → API tokens → **Guardrails for API deployments and benchmarks**, for every token together: - -| Setting | Default | Rejection | -| --- | --- | --- | -| Approval | **Ask me**: starts, runs and sweeps wait as *pending approval* on the deployment, run or sweep page. Creating or editing a stopped deployment, stopping and deleting own ones need none. | (not an error) | -| Agent deployments at once | 1 (running, starting or waiting to start); 2 for A/B runs | `429 too_many_deployments` | -| One GPU job at a time | No agent start while an agent run or sweep is pending or running, or another agent deployment is still loading; one agent run or sweep at a time; no sweep while an agent deployment runs (the sweep deploys its variants itself) | `429 gpu_busy` | -| Max minutes per run / sweep | 30 / 180, then the worker stops it | (`failed` with the reason) | -| Max variants per sweep | 8 | `422 too_many_variants` | -| Runtimes | Any with a pulled image, or an allowlist | `403 runtime_not_allowed`, `409 runtime_not_pulled` | -| Extra arguments | Tuning flags only, per engine (editable list); values can't be paths or URLs | `403 arg_not_allowed`, naming the argument | -| Host ports | None (Kaname reaches deployments over the Docker network), or a range | `403 port_not_allowed` | -| Memory / CPU caps | The host's size, or what you set; agent deployments always get a memory limit (the estimate if they don't give one) | `422 limit_exceeded` | -| Own deployments only | Agents change and benchmark only what their token created | `403 not_owner` | - -Docker options (devices, volumes, privileges, capabilities, network) are never arguments: they belong -to the runtime, which tokens can't change. - -### Protected deployments - -The **Protect** button on a deployment's page: agents can't edit, start, stop, delete or benchmark -it, and can't start a deployment on the same GPUs if the estimated VRAM of everything running there -plus the new one (and 1 GiB to spare) exceeds the GPUs' VRAM (`409 vram_protected`). When the need -can't be estimated (only some layers on the GPU), such a start is refused too. - -### Activity - -Settings → API tokens → **Activity** next to each token lists what it did: every request that -creates or changes something, waits for approval, or was refused (with the error code). - -## Behind a forward-auth proxy (Traefik) - -If Kaname sits behind forward auth (e.g. Traefik with Tinyauth or Pocket ID), the proxy would answer -API calls with a login redirect. Let `/api/v1/` through without forward auth; Kaname checks the -bearer token itself there. Everything else keeps forward auth. - -Two routers for the same host, the API one with a higher priority and no auth middleware: - -```yaml -# docker compose labels on the kaname "web" service -labels: - - traefik.enable=true - - traefik.http.services.kaname.loadbalancer.server.port=3000 - - # UI and internal API: forward auth as before - - traefik.http.routers.kaname.rule=Host(`models.example.com`) - - traefik.http.routers.kaname.entrypoints=websecure - - traefik.http.routers.kaname.tls=true - - traefik.http.routers.kaname.middlewares=tinyauth - - traefik.http.routers.kaname.service=kaname - - # Token API: no forward auth (bearer tokens are checked by Kaname) - - traefik.http.routers.kaname-api.rule=Host(`models.example.com`) && PathPrefix(`/api/v1/`) - - traefik.http.routers.kaname-api.entrypoints=websecure - - traefik.http.routers.kaname-api.tls=true - - traefik.http.routers.kaname-api.priority=100 - - traefik.http.routers.kaname-api.service=kaname -``` - -The same in a file provider: - -```yaml -http: - routers: - kaname-api: - rule: Host(`models.example.com`) && PathPrefix(`/api/v1/`) - entryPoints: [websecure] - tls: {} - priority: 100 - service: kaname -``` - -Notes: - -- Use `PathPrefix(`/api/v1/`)` with the trailing slash, so nothing else that starts with `/api/v1` - slips past forward auth. Kaname's own login gate also excludes exactly `/api/v1` and `/api/v1/…`. -- Don't exempt `/api` as a whole: the internal routes rely on the login session. -- Agents on the same network can also call Kaname directly (`http://:3000/api/v1/…`) without - going through the proxy. diff --git a/drizzle/0021_slim_down.sql b/drizzle/0021_slim_down.sql new file mode 100644 index 0000000..c10ae78 --- /dev/null +++ b/drizzle/0021_slim_down.sql @@ -0,0 +1,23 @@ +-- Approvals were for API requests, which are gone; anything still waiting is cancelled. +UPDATE `jobs` SET `state` = 'cancelled', `finished_at` = unixepoch() * 1000 WHERE `state` = 'pending_approval';--> statement-breakpoint +UPDATE `benchmark_runs` SET `state` = 'cancelled', `finished_at` = unixepoch() * 1000 WHERE `state` = 'pending_approval';--> statement-breakpoint +DELETE FROM `settings` WHERE `key` IN ('agent.guardrails', 'agent.tuning', 'hardware.overrides', 'runtimes.presetsSeeded', 'runtimes.cudaPresetSeeded', 'runtimes.intelPresetSeeded');--> statement-breakpoint +DROP TABLE `agent_activity`;--> statement-breakpoint +DROP TABLE `api_keys`;--> statement-breakpoint +DROP TABLE `api_tokens`;--> statement-breakpoint +DROP TABLE `benchmark_sweeps`;--> statement-breakpoint +DROP TABLE `deployment_logs`;--> statement-breakpoint +DROP TABLE `deployments`;--> statement-breakpoint +DROP TABLE `runtimes`;--> statement-breakpoint +ALTER TABLE `benchmark_runs` DROP COLUMN `deployment_id`;--> statement-breakpoint +ALTER TABLE `benchmark_runs` DROP COLUMN `deployment_b_id`;--> statement-breakpoint +ALTER TABLE `benchmark_runs` DROP COLUMN `resources`;--> statement-breakpoint +ALTER TABLE `benchmark_runs` DROP COLUMN `sweep_id`;--> statement-breakpoint +ALTER TABLE `benchmark_runs` DROP COLUMN `requested_by_token_id`;--> statement-breakpoint +ALTER TABLE `benchmark_runs` DROP COLUMN `requested_by`;--> statement-breakpoint +ALTER TABLE `benchmark_runs` DROP COLUMN `time_limit_s`;--> statement-breakpoint +ALTER TABLE `jobs` DROP COLUMN `requested_by_token_id`;--> statement-breakpoint +ALTER TABLE `jobs` DROP COLUMN `requested_by`;--> statement-breakpoint +ALTER TABLE `models` DROP COLUMN `requested_by_token_id`;--> statement-breakpoint +ALTER TABLE `models` DROP COLUMN `requested_by`;--> statement-breakpoint +ALTER TABLE `worker_state` DROP COLUMN `docker`; \ No newline at end of file diff --git a/drizzle/0022_endpoints.sql b/drizzle/0022_endpoints.sql new file mode 100644 index 0000000..7cf5f9f --- /dev/null +++ b/drizzle/0022_endpoints.sql @@ -0,0 +1,16 @@ +CREATE TABLE `endpoints` ( + `id` text PRIMARY KEY NOT NULL, + `name` text NOT NULL, + `base_url` text NOT NULL, + `api_key` text, + `model` text, + `engine` text, + `hardware` text DEFAULT '{}' NOT NULL, + `probe` text, + `created_at` integer NOT NULL, + `updated_at` integer NOT NULL +); +--> statement-breakpoint +CREATE UNIQUE INDEX `endpoints_name_uq` ON `endpoints` (`name`);--> statement-breakpoint +ALTER TABLE `benchmark_runs` ADD `endpoint_id` text;--> statement-breakpoint +ALTER TABLE `benchmark_runs` ADD `endpoint_b_id` text; \ No newline at end of file diff --git a/drizzle/meta/0021_snapshot.json b/drizzle/meta/0021_snapshot.json new file mode 100644 index 0000000..2ccb922 --- /dev/null +++ b/drizzle/meta/0021_snapshot.json @@ -0,0 +1,1395 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "d56120b6-d3a2-4c16-8a63-60ba7ce28ce7", + "prevId": "6178621d-8b10-484d-aa7e-e85eaf0ecfdd", + "tables": { + "benchmark_logs": { + "name": "benchmark_logs", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "run_id": { + "name": "run_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ts": { + "name": "ts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "stream": { + "name": "stream", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "line": { + "name": "line", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "benchmark_logs_idx": { + "name": "benchmark_logs_idx", + "columns": [ + "run_id", + "id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "benchmark_publications": { + "name": "benchmark_publications", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "run_id": { + "name": "run_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "state": { + "name": "state", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'preview'" + }, + "template": { + "name": "template", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'bench.betterbench.v1'" + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payload_bytes": { + "name": "payload_bytes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "previewed_at": { + "name": "previewed_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "confirmed_by": { + "name": "confirmed_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "confirmed_at": { + "name": "confirmed_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "guid": { + "name": "guid", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "published_at": { + "name": "published_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "benchmark_publications_run_idx": { + "name": "benchmark_publications_run_idx", + "columns": [ + "run_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "benchmark_runs": { + "name": "benchmark_runs", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "model_id": { + "name": "model_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "tool": { + "name": "tool", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'betterbench'" + }, + "settings": { + "name": "settings", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "snapshot": { + "name": "snapshot", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "state": { + "name": "state", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'queued'" + }, + "phase": { + "name": "phase", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cancel_requested_at": { + "name": "cancel_requested_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "started_at": { + "name": "started_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "finished_at": { + "name": "finished_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "has_report": { + "name": "has_report", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'run'" + }, + "snapshot_b": { + "name": "snapshot_b", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "ab": { + "name": "ab", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "quality": { + "name": "quality", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "meta": { + "name": "meta", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "meta_b": { + "name": "meta_b", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "system": { + "name": "system", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "benchmark_runs_created_idx": { + "name": "benchmark_runs_created_idx", + "columns": [ + "created_at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "job_files": { + "name": "job_files", + "columns": { + "job_id": { + "name": "job_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "model_file_id": { + "name": "model_file_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expected_bytes": { + "name": "expected_bytes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "done_bytes": { + "name": "done_bytes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "state": { + "name": "state", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": { + "job_files_job_id_jobs_id_fk": { + "name": "job_files_job_id_jobs_id_fk", + "tableFrom": "job_files", + "tableTo": "jobs", + "columnsFrom": [ + "job_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "job_files_model_file_id_model_files_id_fk": { + "name": "job_files_model_file_id_model_files_id_fk", + "tableFrom": "job_files", + "tableTo": "model_files", + "columnsFrom": [ + "model_file_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "job_files_job_id_model_file_id_pk": { + "columns": [ + "job_id", + "model_file_id" + ], + "name": "job_files_job_id_model_file_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "job_logs": { + "name": "job_logs", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "job_id": { + "name": "job_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ts": { + "name": "ts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "stream": { + "name": "stream", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "line": { + "name": "line", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "job_logs_job_idx": { + "name": "job_logs_job_idx", + "columns": [ + "job_id", + "id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "job_logs_job_id_jobs_id_fk": { + "name": "job_logs_job_id_jobs_id_fk", + "tableFrom": "job_logs", + "tableTo": "jobs", + "columnsFrom": [ + "job_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "jobs": { + "name": "jobs", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "model_id": { + "name": "model_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "purpose": { + "name": "purpose", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "target_sha": { + "name": "target_sha", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "state": { + "name": "state", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'queued'" + }, + "attempt": { + "name": "attempt", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "total_bytes": { + "name": "total_bytes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "done_bytes": { + "name": "done_bytes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "speed_bps": { + "name": "speed_bps", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "eta_seconds": { + "name": "eta_seconds", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "exit_code": { + "name": "exit_code", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "error_code": { + "name": "error_code", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "result": { + "name": "result", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cancel_requested_at": { + "name": "cancel_requested_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "started_at": { + "name": "started_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "finished_at": { + "name": "finished_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "jobs_state_idx": { + "name": "jobs_state_idx", + "columns": [ + "state" + ], + "isUnique": false + }, + "jobs_model_idx": { + "name": "jobs_model_idx", + "columns": [ + "model_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "jobs_model_id_models_id_fk": { + "name": "jobs_model_id_models_id_fk", + "tableFrom": "jobs", + "tableTo": "models", + "columnsFrom": [ + "model_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "local_folders": { + "name": "local_folders", + "columns": { + "path": { + "name": "path", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "files": { + "name": "files", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "file_count": { + "name": "file_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "total_bytes": { + "name": "total_bytes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "commit": { + "name": "commit", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "scanned_at": { + "name": "scanned_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "model_files": { + "name": "model_files", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "model_id": { + "name": "model_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "blob_oid": { + "name": "blob_oid", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "lfs_sha256": { + "name": "lfs_sha256", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "selected": { + "name": "selected", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "state": { + "name": "state", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'pending'" + }, + "checked_at": { + "name": "checked_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "model_files_model_path_uq": { + "name": "model_files_model_path_uq", + "columns": [ + "model_id", + "path" + ], + "isUnique": true + } + }, + "foreignKeys": { + "model_files_model_id_models_id_fk": { + "name": "model_files_model_id_models_id_fk", + "tableFrom": "model_files", + "tableTo": "models", + "columnsFrom": [ + "model_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "model_revisions": { + "name": "model_revisions", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "model_id": { + "name": "model_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sha": { + "name": "sha", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "pinned_at": { + "name": "pinned_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "superseded_at": { + "name": "superseded_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "model_revisions_model_idx": { + "name": "model_revisions_model_idx", + "columns": [ + "model_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "model_revisions_model_id_models_id_fk": { + "name": "model_revisions_model_id_models_id_fk", + "tableFrom": "model_revisions", + "tableTo": "models", + "columnsFrom": [ + "model_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "model_tags": { + "name": "model_tags", + "columns": { + "model_id": { + "name": "model_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tag_id": { + "name": "tag_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "model_tags_tag_idx": { + "name": "model_tags_tag_idx", + "columns": [ + "tag_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "model_tags_model_id_models_id_fk": { + "name": "model_tags_model_id_models_id_fk", + "tableFrom": "model_tags", + "tableTo": "models", + "columnsFrom": [ + "model_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "model_tags_tag_id_tags_id_fk": { + "name": "model_tags_tag_id_tags_id_fk", + "tableFrom": "model_tags", + "tableTo": "tags", + "columnsFrom": [ + "tag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "model_tags_model_id_tag_id_pk": { + "columns": [ + "model_id", + "tag_id" + ], + "name": "model_tags_model_id_tag_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "models": { + "name": "models", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "repo_type": { + "name": "repo_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'model'" + }, + "repo_id": { + "name": "repo_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tracked_revision": { + "name": "tracked_revision", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'main'" + }, + "pinned_sha": { + "name": "pinned_sha", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "local_path": { + "name": "local_path", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "include_patterns": { + "name": "include_patterns", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "exclude_patterns": { + "name": "exclude_patterns", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'pending'" + }, + "remote_sha": { + "name": "remote_sha", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_checked_at": { + "name": "last_checked_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_check_error": { + "name": "last_check_error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "hub_state": { + "name": "hub_state", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "hub_missing_since": { + "name": "hub_missing_since", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "update_diff": { + "name": "update_diff", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_verified_at": { + "name": "last_verified_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "downloaded_at": { + "name": "downloaded_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "base_models": { + "name": "base_models", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "base_relation": { + "name": "base_relation", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "author_avatar_url": { + "name": "author_avatar_url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "architecture": { + "name": "architecture", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "pipeline_tag": { + "name": "pipeline_tag", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "license": { + "name": "license", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "hub_tags": { + "name": "hub_tags", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "metadata_fetched_at": { + "name": "metadata_fetched_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "models_repo_uq": { + "name": "models_repo_uq", + "columns": [ + "repo_type", + "repo_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "settings": { + "name": "settings", + "columns": { + "key": { + "name": "key", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "tags": { + "name": "tags", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "tags_slug_uq": { + "name": "tags_slug_uq", + "columns": [ + "slug" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "worker_state": { + "name": "worker_state", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "instance_id": { + "name": "instance_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "pid": { + "name": "pid", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "hf_version": { + "name": "hf_version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "models_dir_free_bytes": { + "name": "models_dir_free_bytes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "models_dir_total_bytes": { + "name": "models_dir_total_bytes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "started_at": { + "name": "started_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "heartbeat_at": { + "name": "heartbeat_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "scan_requested_at": { + "name": "scan_requested_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + } + }, + "views": {}, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "indexes": {} + } +} \ No newline at end of file diff --git a/drizzle/meta/0022_snapshot.json b/drizzle/meta/0022_snapshot.json new file mode 100644 index 0000000..6358a8a --- /dev/null +++ b/drizzle/meta/0022_snapshot.json @@ -0,0 +1,1498 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "67d09da3-db4d-4665-95a9-3fb44079e886", + "prevId": "d56120b6-d3a2-4c16-8a63-60ba7ce28ce7", + "tables": { + "benchmark_logs": { + "name": "benchmark_logs", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "run_id": { + "name": "run_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ts": { + "name": "ts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "stream": { + "name": "stream", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "line": { + "name": "line", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "benchmark_logs_idx": { + "name": "benchmark_logs_idx", + "columns": [ + "run_id", + "id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "benchmark_publications": { + "name": "benchmark_publications", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "run_id": { + "name": "run_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "state": { + "name": "state", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'preview'" + }, + "template": { + "name": "template", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'bench.betterbench.v1'" + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payload_bytes": { + "name": "payload_bytes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "previewed_at": { + "name": "previewed_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "confirmed_by": { + "name": "confirmed_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "confirmed_at": { + "name": "confirmed_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "guid": { + "name": "guid", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "published_at": { + "name": "published_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "benchmark_publications_run_idx": { + "name": "benchmark_publications_run_idx", + "columns": [ + "run_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "benchmark_runs": { + "name": "benchmark_runs", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "endpoint_id": { + "name": "endpoint_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "endpoint_b_id": { + "name": "endpoint_b_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "model_id": { + "name": "model_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "tool": { + "name": "tool", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'betterbench'" + }, + "settings": { + "name": "settings", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "snapshot": { + "name": "snapshot", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "state": { + "name": "state", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'queued'" + }, + "phase": { + "name": "phase", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cancel_requested_at": { + "name": "cancel_requested_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "started_at": { + "name": "started_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "finished_at": { + "name": "finished_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "has_report": { + "name": "has_report", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'run'" + }, + "snapshot_b": { + "name": "snapshot_b", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "ab": { + "name": "ab", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "quality": { + "name": "quality", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "meta": { + "name": "meta", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "meta_b": { + "name": "meta_b", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "system": { + "name": "system", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "benchmark_runs_created_idx": { + "name": "benchmark_runs_created_idx", + "columns": [ + "created_at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "endpoints": { + "name": "endpoints", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "base_url": { + "name": "base_url", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "api_key": { + "name": "api_key", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "engine": { + "name": "engine", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "hardware": { + "name": "hardware", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'{}'" + }, + "probe": { + "name": "probe", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "endpoints_name_uq": { + "name": "endpoints_name_uq", + "columns": [ + "name" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "job_files": { + "name": "job_files", + "columns": { + "job_id": { + "name": "job_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "model_file_id": { + "name": "model_file_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expected_bytes": { + "name": "expected_bytes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "done_bytes": { + "name": "done_bytes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "state": { + "name": "state", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'pending'" + } + }, + "indexes": {}, + "foreignKeys": { + "job_files_job_id_jobs_id_fk": { + "name": "job_files_job_id_jobs_id_fk", + "tableFrom": "job_files", + "tableTo": "jobs", + "columnsFrom": [ + "job_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "job_files_model_file_id_model_files_id_fk": { + "name": "job_files_model_file_id_model_files_id_fk", + "tableFrom": "job_files", + "tableTo": "model_files", + "columnsFrom": [ + "model_file_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "job_files_job_id_model_file_id_pk": { + "columns": [ + "job_id", + "model_file_id" + ], + "name": "job_files_job_id_model_file_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "job_logs": { + "name": "job_logs", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "job_id": { + "name": "job_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ts": { + "name": "ts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "stream": { + "name": "stream", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "line": { + "name": "line", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "job_logs_job_idx": { + "name": "job_logs_job_idx", + "columns": [ + "job_id", + "id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "job_logs_job_id_jobs_id_fk": { + "name": "job_logs_job_id_jobs_id_fk", + "tableFrom": "job_logs", + "tableTo": "jobs", + "columnsFrom": [ + "job_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "jobs": { + "name": "jobs", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "model_id": { + "name": "model_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "purpose": { + "name": "purpose", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "target_sha": { + "name": "target_sha", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "state": { + "name": "state", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'queued'" + }, + "attempt": { + "name": "attempt", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "total_bytes": { + "name": "total_bytes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "done_bytes": { + "name": "done_bytes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "speed_bps": { + "name": "speed_bps", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "eta_seconds": { + "name": "eta_seconds", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "exit_code": { + "name": "exit_code", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "error_code": { + "name": "error_code", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "result": { + "name": "result", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cancel_requested_at": { + "name": "cancel_requested_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "started_at": { + "name": "started_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "finished_at": { + "name": "finished_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "jobs_state_idx": { + "name": "jobs_state_idx", + "columns": [ + "state" + ], + "isUnique": false + }, + "jobs_model_idx": { + "name": "jobs_model_idx", + "columns": [ + "model_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "jobs_model_id_models_id_fk": { + "name": "jobs_model_id_models_id_fk", + "tableFrom": "jobs", + "tableTo": "models", + "columnsFrom": [ + "model_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "local_folders": { + "name": "local_folders", + "columns": { + "path": { + "name": "path", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "files": { + "name": "files", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "file_count": { + "name": "file_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "total_bytes": { + "name": "total_bytes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "commit": { + "name": "commit", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "scanned_at": { + "name": "scanned_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "model_files": { + "name": "model_files", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "model_id": { + "name": "model_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "blob_oid": { + "name": "blob_oid", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "lfs_sha256": { + "name": "lfs_sha256", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "selected": { + "name": "selected", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "state": { + "name": "state", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'pending'" + }, + "checked_at": { + "name": "checked_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "model_files_model_path_uq": { + "name": "model_files_model_path_uq", + "columns": [ + "model_id", + "path" + ], + "isUnique": true + } + }, + "foreignKeys": { + "model_files_model_id_models_id_fk": { + "name": "model_files_model_id_models_id_fk", + "tableFrom": "model_files", + "tableTo": "models", + "columnsFrom": [ + "model_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "model_revisions": { + "name": "model_revisions", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "model_id": { + "name": "model_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sha": { + "name": "sha", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "pinned_at": { + "name": "pinned_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "superseded_at": { + "name": "superseded_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "model_revisions_model_idx": { + "name": "model_revisions_model_idx", + "columns": [ + "model_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "model_revisions_model_id_models_id_fk": { + "name": "model_revisions_model_id_models_id_fk", + "tableFrom": "model_revisions", + "tableTo": "models", + "columnsFrom": [ + "model_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "model_tags": { + "name": "model_tags", + "columns": { + "model_id": { + "name": "model_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tag_id": { + "name": "tag_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "model_tags_tag_idx": { + "name": "model_tags_tag_idx", + "columns": [ + "tag_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "model_tags_model_id_models_id_fk": { + "name": "model_tags_model_id_models_id_fk", + "tableFrom": "model_tags", + "tableTo": "models", + "columnsFrom": [ + "model_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "model_tags_tag_id_tags_id_fk": { + "name": "model_tags_tag_id_tags_id_fk", + "tableFrom": "model_tags", + "tableTo": "tags", + "columnsFrom": [ + "tag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "model_tags_model_id_tag_id_pk": { + "columns": [ + "model_id", + "tag_id" + ], + "name": "model_tags_model_id_tag_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "models": { + "name": "models", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "repo_type": { + "name": "repo_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'model'" + }, + "repo_id": { + "name": "repo_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tracked_revision": { + "name": "tracked_revision", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'main'" + }, + "pinned_sha": { + "name": "pinned_sha", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "local_path": { + "name": "local_path", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "include_patterns": { + "name": "include_patterns", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "exclude_patterns": { + "name": "exclude_patterns", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'pending'" + }, + "remote_sha": { + "name": "remote_sha", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_checked_at": { + "name": "last_checked_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_check_error": { + "name": "last_check_error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "hub_state": { + "name": "hub_state", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "hub_missing_since": { + "name": "hub_missing_since", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "update_diff": { + "name": "update_diff", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_verified_at": { + "name": "last_verified_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "downloaded_at": { + "name": "downloaded_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "base_models": { + "name": "base_models", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "base_relation": { + "name": "base_relation", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "author_avatar_url": { + "name": "author_avatar_url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "architecture": { + "name": "architecture", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "pipeline_tag": { + "name": "pipeline_tag", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "license": { + "name": "license", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "hub_tags": { + "name": "hub_tags", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "metadata_fetched_at": { + "name": "metadata_fetched_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "models_repo_uq": { + "name": "models_repo_uq", + "columns": [ + "repo_type", + "repo_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "settings": { + "name": "settings", + "columns": { + "key": { + "name": "key", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "tags": { + "name": "tags", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "tags_slug_uq": { + "name": "tags_slug_uq", + "columns": [ + "slug" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "worker_state": { + "name": "worker_state", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "instance_id": { + "name": "instance_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "pid": { + "name": "pid", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "hf_version": { + "name": "hf_version", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "models_dir_free_bytes": { + "name": "models_dir_free_bytes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "models_dir_total_bytes": { + "name": "models_dir_total_bytes", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "started_at": { + "name": "started_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "heartbeat_at": { + "name": "heartbeat_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "scan_requested_at": { + "name": "scan_requested_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + } + }, + "views": {}, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "indexes": {} + } +} \ No newline at end of file diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json index 67cebaf..674dc10 100644 --- a/drizzle/meta/_journal.json +++ b/drizzle/meta/_journal.json @@ -148,6 +148,20 @@ "when": 1792588720328, "tag": "0020_quality_eval", "breakpoints": true + }, + { + "idx": 21, + "version": "6", + "when": 1793045191010, + "tag": "0021_slim_down", + "breakpoints": true + }, + { + "idx": 22, + "version": "6", + "when": 1793045228739, + "tag": "0022_endpoints", + "breakpoints": true } ] } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index a72fe3d..9c2825d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "kaname", - "version": "0.14.3", + "version": "0.15.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "kaname", - "version": "0.14.3", + "version": "0.15.0", "dependencies": { "@base-ui/react": "^1.8.0", "@libsql/client": "^0.18.0", diff --git a/package.json b/package.json index 0085b33..fff0fcb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "kaname", - "version": "0.14.3", + "version": "0.15.0", "private": true, "scripts": { "dev": "concurrently -k -n web,worker -c blue,magenta \"npm:dev:web\" \"npm:dev:worker\"", @@ -14,7 +14,7 @@ "db:generate": "drizzle-kit generate", "db:migrate": "dotenv -e .env -- tsx src/lib/db/migrate-cli.ts", "test": "tsx --conditions=react-server --test \"src/**/*.test.ts\"", - "build:worker": "esbuild src/worker/index.ts --bundle --platform=node --target=node24 --format=esm --packages=external --outfile=dist/worker.mjs && esbuild src/lib/db/migrate-cli.ts --bundle --platform=node --target=node24 --format=esm --packages=external --outfile=dist/migrate.mjs" + "build:worker": "esbuild src/worker/index.ts --bundle --platform=node --target=node24 --format=esm --packages=external --outfile=dist/worker.mjs && esbuild src/lib/db/migrate-cli.ts --bundle --platform=node --target=node24 --format=esm --packages=external --outfile=dist/migrate.mjs && esbuild src/sandbox/index.ts --bundle --platform=node --target=node24 --format=esm --packages=external --outfile=dist/sandbox.mjs" }, "dependencies": { "@base-ui/react": "^1.8.0", diff --git a/scripts/intel-probe.sh b/scripts/intel-probe.sh deleted file mode 100755 index 425da33..0000000 --- a/scripts/intel-probe.sh +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/env bash -# Read-only diagnostics for Intel GPU support (Arc / Arc Pro B-series) on a Kaname host. -# Shows which telemetry sources this kernel and driver offer, so Kaname uses ones that exist. -# Changes nothing. Run it on the Docker host (or VM) that has the GPU: -# -# bash scripts/intel-probe.sh # as your user: what an unprivileged container can see -# sudo bash scripts/intel-probe.sh # adds lspci's link/ReBAR capability details -# -# Paste the output back. It contains no hostname, IP addresses or user names. - -set -u -section() { printf '\n=== %s ===\n' "$1"; } -show() { [ -e "$1" ] && printf '%s: %s\n' "$1" "$(tr '\n' ' ' < "$1" 2>/dev/null || echo '(not readable)')"; } - -section "System" -echo "kernel: $(uname -r)" -grep -E '^(PRETTY_NAME|VERSION_ID)=' /etc/os-release 2>/dev/null -command -v systemd-detect-virt >/dev/null && echo "virt: $(systemd-detect-virt 2>/dev/null)" -show /sys/class/dmi/id/sys_vendor -show /sys/class/dmi/id/product_name -echo "running as uid $(id -u)" - -section "Intel display devices" -gpus=() -for d in /sys/bus/pci/devices/*; do - [ "$(cat "$d/vendor" 2>/dev/null)" = "0x8086" ] || continue - case "$(cat "$d/class" 2>/dev/null)" in 0x03*) gpus+=("$(basename "$d")") ;; esac -done -[ ${#gpus[@]} -eq 0 ] && echo "no Intel GPU found on the PCI bus" - -for a in "${gpus[@]}"; do - d=$(readlink -f "/sys/bus/pci/devices/$a") - section "GPU $a" - echo "sysfs path: $d" - show "$d/device" - show "$d/subsystem_device" - echo "driver: $(basename "$(readlink "$d/driver" 2>/dev/null)" 2>/dev/null)" - command -v lspci >/dev/null && lspci -nn -s "$a" - echo "-- link per level (GPU up to the root port):" - p=$d - while [[ $(basename "$p") =~ ^[0-9a-f]{4}:[0-9a-f]{2}:[0-9a-f]{2}\.[0-7]$ ]]; do - printf '%s vendor=%s cur=%s x%s max=%s x%s\n' "$(basename "$p")" "$(cat "$p/vendor" 2>/dev/null)" \ - "$(cat "$p/current_link_speed" 2>/dev/null)" "$(cat "$p/current_link_width" 2>/dev/null)" \ - "$(cat "$p/max_link_speed" 2>/dev/null)" "$(cat "$p/max_link_width" 2>/dev/null)" - p=$(dirname "$p") - done - echo "-- BARs (start end flags):" - head -6 "$d/resource" 2>/dev/null - echo "-- VRAM / memory files:" - find "$d" -maxdepth 3 \( -iname '*vram*' -o -iname '*lmem*' -o -iname '*mem_info*' \) 2>/dev/null | while read -r f; do - [ -f "$f" ] && show "$f" - done - ls "$d/tile0" 2>/dev/null | head -30 - echo "-- hwmon:" - for h in "$d"/hwmon/hwmon*; do - [ -d "$h" ] || continue - show "$h/name" - for f in "$h"/*_input "$h"/*_label "$h"/*_crit "$h"/power*_max; do [ -f "$f" ] && show "$f"; done - done - if [ "$(id -u)" = 0 ] && command -v lspci >/dev/null; then - echo "-- lspci capabilities:" - lspci -vvv -s "$a" | grep -E 'LnkCap:|LnkSta:|Resizable BAR|BAR [0-9]: current size|Region' - fi -done - -section "/dev/dri" -ls -ln /dev/dri 2>/dev/null -for n in /dev/dri/renderD*; do [ -e "$n" ] && echo "$n gid=$(stat -c %g "$n") group=$(stat -c %G "$n")"; done -getent group render video | cut -d: -f1,3 - -section "DRM fdinfo (per-process VRAM / engine time)" -found=0 -for f in /proc/[0-9]*/fdinfo/*; do - grep -q '^drm-driver:' "$f" 2>/dev/null || continue - found=1 - echo "readable example: $f" - grep -E '^drm-(driver|client-id|engine-|cycles-|total-cycles-|memory-|total-|resident-)' "$f" | head -25 - break -done -[ $found = 0 ] && echo "no readable DRM fdinfo (no GPU process running, or not permitted for this user)" - -section "Tools" -for t in xpu-smi intel_gpu_top clinfo sycl-ls vulkaninfo docker; do - printf '%s: %s\n' "$t" "$(command -v "$t" || echo missing)" -done -command -v docker >/dev/null && docker version --format 'docker server {{.Server.Version}}' 2>/dev/null diff --git a/src/app/(app)/[org]/[repo]/download-card.tsx b/src/app/(app)/[org]/[repo]/download-card.tsx index d015bb0..a963d7f 100644 --- a/src/app/(app)/[org]/[repo]/download-card.tsx +++ b/src/app/(app)/[org]/[repo]/download-card.tsx @@ -2,9 +2,7 @@ import { DownloadIcon, ShieldCheckIcon, WrenchIcon } from "lucide-react"; import Link from "next/link"; -import { useRouter } from "next/navigation"; import { useState } from "react"; -import { ApprovalBar } from "@/components/approval-bar"; import { cancelJob, startDownload, startRepair, startVerify } from "@/components/job-actions"; import { JobProgress, JobStateBadge } from "@/components/job-progress"; import { Button } from "@/components/ui/button"; @@ -35,8 +33,6 @@ export function DownloadCard({ const jobs = snapshot?.jobs ?? []; const latest = jobs[0]; const open = latest && OPEN.includes(latest.state) ? latest : undefined; - const pending = latest?.state === "pending_approval" ? latest : undefined; - const router = useRouter(); const files = open ? groupJobFiles(snapshot?.files ?? []) : []; // The newest verify, unless a download ran after it (its result would be stale). const lastCheck = jobs.find((j) => VERIFY_KINDS.includes(j.kind) || j.kind === "download"); @@ -62,13 +58,12 @@ export function DownloadCard({ : latest?.state === "failed" && latest.kind === "download" ? "Retry" : "Download missing"; - const canDownload = !open && !pending && !hubMissing && status !== "ready" && status !== "deleting" && !!snapshot; - const canVerify = !open && !pending && !neverRan && status !== "deleting" && !!snapshot; - const needsRepair = !open && !pending && !hubMissing && status !== "deleting" && (verifyProblems > 0 || status === "incomplete"); + const canDownload = !open && !hubMissing && status !== "ready" && status !== "deleting" && !!snapshot; + const canVerify = !open && !neverRan && status !== "deleting" && !!snapshot; + const needsRepair = !open && !hubMissing && status !== "deleting" && (verifyProblems > 0 || status === "incomplete"); let hint = "Downloads the selected files at the pinned commit."; - if (pending) hint = "Requested through the API; waits for your approval."; - else if (open?.state === "queued") hint = snapshot?.worker.online ? "Waiting for a free slot." : "Queued, but the worker is offline."; + if (open?.state === "queued") hint = snapshot?.worker.online ? "Waiting for a free slot." : "Queued, but the worker is offline."; else if (open) hint = "Runs in the background; you can close this page."; else if (status === "deleting") hint = "Deleting…"; else if (hubMissing && status !== "ready") hint = "Can't download: no longer available on Hugging Face. Local files are kept."; @@ -88,9 +83,7 @@ export function DownloadCard({

{hint}

- {pending && router.push("/")} />} - - {showProgress && !pending && } + {showProgress && } {latest?.state === "failed" && latest.errorMessage && (
diff --git a/src/app/(app)/[org]/[repo]/page.tsx b/src/app/(app)/[org]/[repo]/page.tsx
index f725da3..43a4edc 100644
--- a/src/app/(app)/[org]/[repo]/page.tsx
+++ b/src/app/(app)/[org]/[repo]/page.tsx
@@ -9,8 +9,7 @@ import {
   LanguagesIcon,
   ListChecksIcon,
   MessagesSquareIcon,
-  PlusIcon,
-  RocketIcon,
+  GaugeIcon,
   ScaleIcon,
   SparklesIcon,
   TriangleAlertIcon,
@@ -19,15 +18,15 @@ import type { Metadata } from "next";
 import Link from "next/link";
 import { notFound, redirect } from "next/navigation";
 import { CopyButton } from "@/components/copy-button";
-import { DeploymentStateBadge } from "@/components/deployment-state";
+import { BenchmarkStateBadge } from "@/components/benchmark-state";
 import { HubStateBadge } from "@/components/hub-state-badge";
 import { LocalTime } from "@/components/local-time";
 import { ModelStatusBadge } from "@/components/model-status-badge";
-import { RequestedByBadge } from "@/components/requested-by-badge";
 import { buttonVariants } from "@/components/ui/button";
 import { cn } from "@/lib/utils";
 import { formatBytes, shortSha } from "@/lib/format";
-import { deploymentsByModel, listDeployableModels } from "@/lib/deployments";
+import { listBenchmarks } from "@/lib/benchmarks";
+import { headline, targetName } from "@/lib/benchmark-view";
 import { fetchModelCard } from "@/lib/hub/client";
 import { modelFamilies } from "@/lib/hub/metadata";
 import { listModelJobs } from "@/lib/jobs";
@@ -102,17 +101,14 @@ export default async function ModelPage({ params, searchParams }: PageProps<"/[o
   const hubTags = model.hubTags ?? [];
   const hubMissing = model.hubState === "repo_missing" || model.hubState === "commit_missing";
 
-  const [tags, related, card, worker, recentJobs, byModel, deployable] = await Promise.all([
+  const [tags, related, card, worker, recentJobs, runs] = await Promise.all([
     modelTagList(model.id),
     relatedModels(model.id, baseModels),
     tab === "card" ? fetchModelCard(model.repoId, model.pinnedSha).catch(() => undefined) : Promise.resolve(undefined),
     getWorkerStatus(),
     listModelJobs(model.id, 1),
-    deploymentsByModel(),
-    listDeployableModels(),
+    listBenchmarks({ modelId: model.id }),
   ]);
-  const modelDeployments = byModel.get(model.id) ?? [];
-  const canDeploy = deployable.some((m) => m.id === model.id);
   const update =
     !hubMissing && model.updateDiff && model.updateDiff.sha === model.remoteSha && model.remoteSha !== model.pinnedSha
       ? model.updateDiff
@@ -146,22 +142,12 @@ export default async function ModelPage({ params, searchParams }: PageProps<"/[o
           
           
           
-          
           {update && (
             
               update available
             
           )}
           
- {canDeploy && ( - - - Deploy - - )} - {(modelDeployments.length > 0 || canDeploy) && ( - -
- {modelDeployments.length === 0 ? ( -

Not deployed yet.

- ) : ( - modelDeployments.map((d) => ( - + {runs.length > 0 && ( + +
+ {runs.slice(0, 5).map((r) => { + const h = headline(r.summary); + return ( + - {d.name} - {d.runtimeName} + {r.label ?? targetName(r.snapshot)} + + {r.kind === "eval" ? (r.quality?.score != null ? `quality ${r.quality.score}%` : "quality eval") : h.decode != null ? `${h.decode.toFixed(1)} t/s decode` : r.kind === "ab" ? "A/B" : "run"} + - + - )) - )} - {canDeploy && ( - - - New deployment - - )} + ); + })} + + All runs of this model → +
)} diff --git a/src/app/(app)/benchmarks/[id]/ab-report.tsx b/src/app/(app)/benchmarks/[id]/ab-report.tsx index 81c8e97..b633451 100644 --- a/src/app/(app)/benchmarks/[id]/ab-report.tsx +++ b/src/app/(app)/benchmarks/[id]/ab-report.tsx @@ -1,7 +1,6 @@ import { TriangleAlertIcon } from "lucide-react"; -import { BenchmarkResources } from "@/components/benchmark-resources"; import { abCaveats, abHeadline, abMethod, abSummaryText, halfWidth } from "@/lib/ab-report"; -import { CONFIG_ROWS } from "@/lib/benchmark-view"; +import { CONFIG_ROWS, targetName } from "@/lib/benchmark-view"; import type { PairedResult } from "@/lib/db/schema"; import { cn } from "@/lib/utils"; import type { ListRow } from "../benchmark-list"; @@ -75,8 +74,8 @@ export function AbReport({ run }: { run: ListRow }) { BetterBench {ab.betterbenchVersion} · paired A/B · {ab.pairs} pairs -

{run.label ?? `${a.deploymentName} vs ${b.deploymentName}`}

-

{abSummaryText(ab, a.deploymentName, b.deploymentName)}

+

{run.label ?? `${targetName(a)} vs ${targetName(b)}`}

+

{abSummaryText(ab, targetName(a), targetName(b))}

@@ -99,8 +98,8 @@ export function AbReport({ run }: { run: ListRow }) {
- - + +
Pairs {ab.pairs} @@ -136,8 +135,8 @@ export function AbReport({ run }: { run: ListRow }) { - A · {a.deploymentName} - B · {b.deploymentName} + A · {targetName(a)} + B · {targetName(b)} @@ -161,13 +160,6 @@ export function AbReport({ run }: { run: ListRow }) { {same.length > 0 &&

Same on both: {same.map((x) => `${x.row.label.toLowerCase()} ${x.va}`).join(" · ")}.

} - {run.resources && ( -
-

Resources

- -
- )} -

Method

diff --git a/src/app/(app)/benchmarks/[id]/benchmark-detail.tsx b/src/app/(app)/benchmarks/[id]/benchmark-detail.tsx index d144407..c073f51 100644 --- a/src/app/(app)/benchmarks/[id]/benchmark-detail.tsx +++ b/src/app/(app)/benchmarks/[id]/benchmark-detail.tsx @@ -31,10 +31,8 @@ import { Button, buttonVariants } from "@/components/ui/button"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { reportSummary, weightsLabel } from "@/lib/benchmark-report"; -import { CONFIG_ROWS, describeSettings } from "@/lib/benchmark-view"; +import { CONFIG_ROWS, describeSettings, engineName, isEndpointSnapshot, modelName, targetName } from "@/lib/benchmark-view"; import type { ListRow } from "../benchmark-list"; -import { AgentApprovalBar } from "@/components/approval-bar"; -import { RequestedByBadge } from "@/components/requested-by-badge"; import { RunMetaCard } from "@/components/run-meta"; import { cancelBenchmark, deleteBenchmark, describeBenchmark, renameBenchmark } from "../actions"; import { AbReport } from "./ab-report"; @@ -63,7 +61,7 @@ export function BenchmarkDetail({ initial }: { initial: ListRow }) { const [now, setNow] = useState(() => Date.now()); const [label, setLabel] = useState(initial.label ?? ""); const [description, setDescription] = useState(initial.description ?? ""); - const active = r.state === "pending_approval" || r.state === "queued" || r.state === "running"; + const active = r.state === "queued" || r.state === "running"; useEffect(() => { if (!active) return; @@ -78,13 +76,14 @@ export function BenchmarkDetail({ initial }: { initial: ListRow }) { }, [active, r.id]); async function again() { - if (!r.deploymentId) return; + if (!r.endpointId) return; const res = await fetch("/api/benchmarks", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ - deploymentId: r.deploymentId, - deploymentBId: r.kind === "ab" ? r.deploymentBId : null, + endpointId: r.endpointId, + endpointBId: r.kind === "ab" ? r.endpointBId : null, + model: modelName(r.snapshot), kind: r.kind, label: r.label, description: r.description, @@ -100,7 +99,18 @@ export function BenchmarkDetail({ initial }: { initial: ListRow }) { } const s = r.snapshot; + const sB = r.snapshotB; const sum = r.summary; + // Runs from before 0.15 measured a deployment (gone now); newer ones an endpoint. + const legacy = !isEndpointSnapshot(s); + const endpointLink = (id: string | null, name: string) => + legacy ? name : id ? ( + + {name} + + ) : ( + `${name} (deleted)` + ); const took = duration(r.startedAt, r.finishedAt, now); return ( @@ -110,10 +120,7 @@ export function BenchmarkDetail({ initial }: { initial: ListRow }) {

- {r.label ?? - (r.kind === "ab" - ? `${s.deploymentName} vs ${r.snapshotB?.deploymentName}` - : s.deploymentName)} + {r.label ?? (r.kind === "ab" && sB ? `${targetName(s)} vs ${targetName(sB)}` : targetName(s))}

{r.kind === "ab" && ( @@ -124,54 +131,21 @@ export function BenchmarkDetail({ initial }: { initial: ListRow }) { state={r.state} cancelling={!!r.cancelRequestedAt} /> -

- {r.deploymentId ? ( - - {s.deploymentName} - - ) : ( - `${s.deploymentName} (deleted)` - )}{" "} - ·{" "} + {endpointLink(r.endpointId, targetName(s))} ·{" "} {r.modelId ? ( - - {s.repoId} + + {modelName(s)} ) : ( - s.repoId + modelName(s) )}{" "} - · {s.runtimeName} - {r.kind === "ab" && r.snapshotB && ( + · {engineName(s)} + {r.kind === "ab" && sB && ( <> {" "} - · B:{" "} - {r.deploymentBId ? ( - - {r.snapshotB.deploymentName} - - ) : ( - r.snapshotB.deploymentName - )} - - )} - {r.sweepId && ( - <> - {" "} - ·{" "} - - part of a sweep - + · B: {endpointLink(r.endpointBId, targetName(sB))} ({engineName(sB)}) )}

@@ -218,12 +192,12 @@ export function BenchmarkDetail({ initial }: { initial: ListRow }) { Cancel ) : ( - r.deploymentId && - !r.sweepId && ( + r.endpointId && + (r.kind !== "ab" || r.endpointBId) && (
)} - {run.resources && ( -
- -
- )} -
{sum.single.length > 0 && (
diff --git a/src/app/(app)/benchmarks/[id]/page.tsx b/src/app/(app)/benchmarks/[id]/page.tsx index 96290c0..5a1b30b 100644 --- a/src/app/(app)/benchmarks/[id]/page.tsx +++ b/src/app/(app)/benchmarks/[id]/page.tsx @@ -1,13 +1,15 @@ import type { Metadata } from "next"; import { notFound } from "next/navigation"; import { getBenchmark } from "@/lib/benchmarks"; +import { targetName } from "@/lib/benchmark-view"; import { BenchmarkDetail } from "./benchmark-detail"; + export const dynamic = "force-dynamic"; export async function generateMetadata({ params }: PageProps<"/benchmarks/[id]">): Promise { const run = await getBenchmark((await params).id); - return { title: run ? `${run.label ?? run.snapshot.deploymentName} · Benchmark` : "Benchmark" }; + return { title: run ? `${run.label ?? targetName(run.snapshot)} · Benchmark` : "Benchmark" }; } export default async function BenchmarkPage({ params }: PageProps<"/benchmarks/[id]">) { diff --git a/src/app/(app)/benchmarks/benchmark-list.tsx b/src/app/(app)/benchmarks/benchmark-list.tsx index 43a6f00..88f4894 100644 --- a/src/app/(app)/benchmarks/benchmark-list.tsx +++ b/src/app/(app)/benchmarks/benchmark-list.tsx @@ -4,7 +4,6 @@ import { GaugeIcon, GitCompareIcon } from "lucide-react"; import Link from "next/link"; import { useEffect, useState } from "react"; import { BenchmarkStateBadge } from "@/components/benchmark-state"; -import { RequestedByBadge } from "@/components/requested-by-badge"; import { NativeSelect } from "@/components/ui/native-select"; import { LocalTime } from "@/components/local-time"; import { buttonVariants } from "@/components/ui/button"; @@ -19,7 +18,7 @@ import { TableRow, } from "@/components/ui/table"; import type { BenchmarkRow } from "@/lib/benchmarks"; -import { configChips, describeSettings, headline } from "@/lib/benchmark-view"; +import { configChips, describeSettings, engineName, headline, modelName, targetName } from "@/lib/benchmark-view"; import { cn } from "@/lib/utils"; export type ListRow = Omit< @@ -40,41 +39,40 @@ const fmt = (v: number | null | undefined, digits = 1) => export function BenchmarkList({ rows: initial, compact, + filter, }: { rows: ListRow[]; compact?: boolean; + /** The list's filter, kept when polling: an endpoint's or a model's runs. */ + filter?: { endpoint?: string; model?: string }; }) { const [rows, setRows] = useState(initial); const [selected, setSelected] = useState([]); - // "" = everything, "-" = started in Kaname, else a token name. + // "" = every endpoint, else an endpoint's name. const [by, setBy] = useState(""); const busy = rows.some((r) => r.state === "queued" || r.state === "running"); - const tokens = [ - ...new Set(rows.map((r) => r.requestedBy).filter((x): x is string => !!x)), - ].sort(); - const shown = rows.filter( - (r) => !by || (by === "-" ? !r.requestedBy : r.requestedBy === by), - ); + const targets = [...new Set(rows.map((r) => targetName(r.snapshot)))].sort(); + const shown = rows.filter((r) => !by || targetName(r.snapshot) === by); + + const query = new URLSearchParams(Object.entries(filter ?? {}).filter((e): e is [string, string] => !!e[1])).toString(); useEffect(() => { if (!busy || compact) return; const t = setInterval(async () => { - const res = await fetch("/api/benchmarks", { cache: "no-store" }).catch( - () => null, - ); + const res = await fetch(`/api/benchmarks${query ? `?${query}` : ""}`, { cache: "no-store" }).catch(() => null); if (res?.ok) setRows(await res.json()); }, 3_000); return () => clearInterval(t); - }, [busy, compact]); + }, [busy, compact, query]); if (rows.length === 0) { return (

- No benchmarks yet. Open a running{" "} - - deployment + No benchmarks yet. Open an{" "} + + endpoint {" "} and start one there.

@@ -94,7 +92,7 @@ export function BenchmarkList({ return (
- {!compact && (comparable.length > 1 || tokens.length > 0) && ( + {!compact && (comparable.length > 1 || targets.length > 1) && (
{selected.length === 0 @@ -102,18 +100,17 @@ export function BenchmarkList({ : `${selected.length} selected (up to ${MAX_COMPARE}).`} - {tokens.length > 0 && ( + {targets.length > 1 && ( setBy(e.target.value)} className="h-8 text-xs" - aria-label="Requested by" + aria-label="Endpoint" > - - - {tokens.map((t) => ( + + {targets.map((t) => ( ))} @@ -181,7 +178,7 @@ export function BenchmarkList({ checked={selected.includes(r.id)} disabled={r.state !== "completed"} onCheckedChange={() => toggle(r.id)} - aria-label={`Select ${r.label ?? s.deploymentName} for comparison`} + aria-label={`Select ${r.label ?? targetName(s)} for comparison`} /> )} @@ -190,21 +187,17 @@ export function BenchmarkList({ href={`/benchmarks/${r.id}`} className="font-medium hover:underline" > - {r.label ?? s.deploymentName} + {r.label ?? targetName(s)}
- {r.label && `${s.deploymentName} · `} - {s.repoId} · - + {r.label && `${targetName(s)} · `} + {modelName(s)} ·
- {s.runtimeName} + {engineName(s)} {configChips(s).map((c) => ( ( - {r.label ?? r.snapshot.deploymentName} + {r.label ?? targetName(r.snapshot)}
{i === 0 && baseline} diff --git a/src/app/(app)/benchmarks/page.tsx b/src/app/(app)/benchmarks/page.tsx index de3aeee..51ed0a2 100644 --- a/src/app/(app)/benchmarks/page.tsx +++ b/src/app/(app)/benchmarks/page.tsx @@ -1,21 +1,44 @@ import type { Metadata } from "next"; +import Link from "next/link"; import { listBenchmarks } from "@/lib/benchmarks"; +import { getModel } from "@/lib/library"; import { BenchmarkList } from "./benchmark-list"; export const dynamic = "force-dynamic"; export const metadata: Metadata = { title: "Benchmarks" }; -export default async function BenchmarksPage() { - const rows = await listBenchmarks(); +export default async function BenchmarksPage({ searchParams }: PageProps<"/benchmarks">) { + const modelId = (await searchParams).model; + const model = typeof modelId === "string" ? await getModel(modelId) : null; + const rows = await listBenchmarks({ modelId: model?.model.id }); return (

Benchmarks

- BetterBench runs against your deployments. Start one from a running deployment; select runs to compare their settings and numbers. + {model ? ( + <> + Runs of{" "} + + {model.model.repoId} + + .{" "} + + Show all + + + ) : ( + <> + Speed (BetterBench), A/B and quality runs against your{" "} + + endpoints + + . Start one from an endpoint; select runs to compare their settings and numbers. + + )}

- +
); } diff --git a/src/app/(app)/benchmarks/sweeps/[id]/page.tsx b/src/app/(app)/benchmarks/sweeps/[id]/page.tsx deleted file mode 100644 index 816fb4e..0000000 --- a/src/app/(app)/benchmarks/sweeps/[id]/page.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import type { Metadata } from "next"; -import { notFound } from "next/navigation"; -import { getSweep } from "@/lib/sweeps"; -import { SweepDetail } from "./sweep-detail"; - -export const dynamic = "force-dynamic"; -export const metadata: Metadata = { title: "Sweep · Benchmarks" }; - -export default async function SweepPage({ params }: PageProps<"/benchmarks/sweeps/[id]">) { - const data = await getSweep((await params).id); - if (!data) notFound(); - return ; -} diff --git a/src/app/(app)/benchmarks/sweeps/[id]/sweep-detail.tsx b/src/app/(app)/benchmarks/sweeps/[id]/sweep-detail.tsx deleted file mode 100644 index 6c28e95..0000000 --- a/src/app/(app)/benchmarks/sweeps/[id]/sweep-detail.tsx +++ /dev/null @@ -1,305 +0,0 @@ -"use client"; - -import { GitCompareIcon, Grid3x3Icon, SquareIcon, Trash2Icon } from "lucide-react"; -import Link from "next/link"; -import { useRouter } from "next/navigation"; -import { useEffect, useState } from "react"; -import { toast } from "sonner"; -import { BarChart } from "@/components/bar-chart"; -import { BenchmarkStateBadge } from "@/components/benchmark-state"; -import { Button, buttonVariants } from "@/components/ui/button"; -import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; -import { AgentApprovalBar } from "@/components/approval-bar"; -import { RequestedByBadge } from "@/components/requested-by-badge"; -import { metaRows } from "@/lib/benchmark-meta"; -import { describeSettings, headline } from "@/lib/benchmark-view"; -import type { benchmarkSweeps, BenchmarkSummary, QualityResult, ResourceStats, RunMeta, SweepVariant } from "@/lib/db/schema"; -import { formatBytes } from "@/lib/format"; -import { cn } from "@/lib/utils"; - -type Sweep = typeof benchmarkSweeps.$inferSelect; -type Run = { - id: string; - state: string; - summary: BenchmarkSummary | null; - resources: ResourceStats | null; - phase: string | null; - error: string | null; - meta: RunMeta | null; - quality: QualityResult | null; -}; -export type SweepData = { sweep: Sweep; runs: Run[] }; - -const VARIANT_STATE: Record = { - pending: "Waiting", - deploying: "Deploying", - benchmarking: "Benchmarking", - evaluating: "Quality eval", - done: "Done", - failed: "Failed", - skipped: "Skipped", -}; - -type Row = { - v: SweepVariant; - run: Run | null; - decode: number | null; - ttft: number | null; - prefill: number | null; - peak: number | null; - cpu: number | null; - ram: number | null; - vram: number | null; - power: number | null; - temp: number | null; - quality: number | null; -}; - -function rowsOf(data: SweepData): Row[] { - return data.sweep.variants.map((v) => { - const run = data.runs.find((r) => r.id === v.runId) ?? null; - const ev = data.runs.find((r) => r.id === v.evalRunId) ?? null; - const h = headline(run?.summary ?? null); - const c = run?.resources?.containers.find((x) => x.side === "a"); - const g = run?.resources?.gpus ?? []; - return { - v, - run, - decode: h.decode, - ttft: h.ttftMs, - prefill: h.prefill?.tps ?? null, - peak: h.peak?.tps ?? null, - cpu: c?.cpuAvg ?? null, - ram: c?.memPeakBytes ?? null, - vram: g.some((x) => x.vramPeakMb != null) ? g.reduce((s, x) => s + (x.vramPeakMb ?? 0), 0) : null, - power: g.some((x) => x.powerAvgW != null) ? g.reduce((s, x) => s + (x.powerAvgW ?? 0), 0) : null, - temp: g.some((x) => x.tempPeakC != null) ? Math.max(...g.map((x) => x.tempPeakC ?? -Infinity)) : null, - quality: ev?.quality?.score ?? null, - }; - }); -} - -/** - * Recorded setup (GPU, PCIe, engine version, quant, KV cache, context, concurrency): values shared by - * every variant go above the table, the ones that differ become columns. - */ -function setupOf(rows: Row[]) { - const per = rows.map((r) => (r.run?.meta ? metaRows(r.run.meta).filter((x) => x.key !== "image" && x.key !== "digest") : null)); - const keys = [...new Map(per.flatMap((x) => x ?? []).map((x) => [x.key, x.label])).entries()]; - const recorded = per.filter((x) => x != null); - const value = (i: number, key: string) => per[i]?.find((x) => x.key === key)?.value ?? null; - const differs = keys.filter(([key]) => new Set(recorded.map((x) => x.find((y) => y.key === key)?.value ?? "")).size > 1); - const shared = keys.filter((k) => !differs.includes(k)).map(([key, label]) => ({ label, value: recorded[0]?.find((y) => y.key === key)?.value ?? null })); - return { shared: recorded.length ? shared : [], columns: differs.map(([key, label]) => ({ key, label })), value }; -} - -/** Best value per column (higher or lower is better), to set it in bold. */ -function best(rows: Row[], key: keyof Row, higher: boolean): number | null { - const vals = rows.map((r) => r[key]).filter((x): x is number => typeof x === "number"); - if (vals.length < 2) return null; - return higher ? Math.max(...vals) : Math.min(...vals); -} - -export function SweepDetail({ initial }: { initial: SweepData }) { - const router = useRouter(); - const [data, setData] = useState(initial); - const [busy, setBusy] = useState(false); - const { sweep } = data; - const active = sweep.state === "pending_approval" || sweep.state === "queued" || sweep.state === "running"; - - useEffect(() => { - if (!active) return; - const t = setInterval(async () => { - const res = await fetch(`/api/sweeps/${sweep.id}`, { cache: "no-store" }).catch(() => null); - if (res?.ok) setData(await res.json()); - }, 3_000); - return () => clearInterval(t); - }, [sweep.id, active]); - - async function act(path: string, method: string, done: () => void) { - setBusy(true); - try { - const res = await fetch(path, { method }); - const json = await res.json().catch(() => ({})); - if (!res.ok) return toast.error(json.error?.message ?? `Failed (${res.status})`); - done(); - } finally { - setBusy(false); - } - } - - const rows = rowsOf(data); - const setup = setupOf(rows); - const finished = rows.filter((r) => r.decode != null); - const runIds = rows.map((r) => r.v.runId).filter((x): x is string => !!x && rows.some((r) => r.run?.id === x && r.run.state === "completed")); - const bestOf = { - decode: best(rows, "decode", true), - ttft: best(rows, "ttft", false), - prefill: best(rows, "prefill", true), - peak: best(rows, "peak", true), - cpu: best(rows, "cpu", false), - ram: best(rows, "ram", false), - vram: best(rows, "vram", false), - power: best(rows, "power", false), - temp: best(rows, "temp", false), - quality: best(rows, "quality", true), - }; - const hasQuality = !!sweep.settings.quality; - const cell = (v: number | null, b: number | null, fmt: (x: number) => string) => ( - {v != null ? fmt(v) : "—"} - ); - const done = rows.filter((r) => r.v.state === "done" || r.v.state === "failed" || r.v.state === "skipped").length; - - return ( -
-
-
-

- - {sweep.label ?? `Sweep of ${sweep.base.name}`} -

-

- {sweep.params.map((p) => p.key).join(" × ")} · {rows.length} variants · {describeSettings(sweep.settings)} ·{" "} - {sweep.baseDeploymentId ? ( - - {sweep.base.name} - - ) : ( - sweep.base.name - )} -

-
-
- - - {runIds.length >= 2 && ( - - - Compare in detail - - )} - {active ? ( - - ) : ( - - )} -
-
- - {active && ( -

- {done} of {rows.length} variants finished. Each variant is deployed, benchmarked and removed again, one after another. -

- )} - {sweep.state === "pending_approval" && ( - `${p.key}: ${p.values.join(", ")}`).join("; ")}${sweep.timeLimitS ? `, at most ${Math.round(sweep.timeLimitS / 60)} min` : ""}); each variant is deployed, benchmarked and removed`} - base={`/api/sweeps/${sweep.id}`} - /> - )} - {sweep.error &&

{sweep.error}

} - - {finished.length > 0 && ( - - - Generation speed by variant - Single-stream decode, tokens per second (BetterBench combined score). Higher is better. - - - ({ - label: r.v.label, - value: r.decode, - valueLabel: r.decode!.toFixed(1), - details: [r.ttft != null ? `TTFT ${r.ttft.toFixed(0)} ms` : "", r.ram != null ? `Peak RAM ${formatBytes(r.ram)}` : ""].filter(Boolean), - }))} - /> - - - )} - - - - Variants - Best value per column in bold. Resource figures are averages/peaks over the run. - {setup.shared.length > 0 && ( -

- {setup.shared - .filter((x) => x.value) - .map((x) => `${x.label}: ${x.value}`) - .join(" · ")} -

- )} -
- - - - - - - {setup.columns.map((c) => ( - - ))} - - {hasQuality && } - - - - - - - - - - - - {rows.map((r, i) => ( - - - - {setup.columns.map((c) => ( - - ))} - {cell(r.decode, bestOf.decode, (x) => x.toFixed(1))} - {hasQuality && cell(r.quality, bestOf.quality, (x) => `${x}%`)} - {cell(r.ttft, bestOf.ttft, (x) => x.toFixed(0))} - {cell(r.prefill, bestOf.prefill, (x) => x.toFixed(0))} - {cell(r.peak, bestOf.peak, (x) => x.toFixed(1))} - {cell(r.cpu, bestOf.cpu, (x) => x.toFixed(2))} - {cell(r.ram, bestOf.ram, (x) => formatBytes(x))} - {cell(r.vram, bestOf.vram, (x) => `${(x / 1024).toFixed(1)} GiB`)} - {cell(r.power, bestOf.power, (x) => `${Math.round(x)} W`)} - {cell(r.temp, bestOf.temp, (x) => `${Math.round(x)} °C`)} - - ))} - -
VariantState - {c.label} - Decode t/sQualityTTFT msPrefill t/sPeak t/sCPU coresPeak RAMPeak VRAMGPU powerPeak temp
- {r.v.runId ? ( - - {r.v.label} - - ) : ( - r.v.label - )} - - {VARIANT_STATE[r.v.state]} - {r.v.state === "benchmarking" && r.run?.phase ? ` · ${r.run.phase}` : ""} - {(r.v.error || r.run?.error) && r.v.state === "failed" ? ` · ${(r.v.error ?? r.run?.error ?? "").slice(0, 60)}` : ""} - - {setup.value(i, c.key) ?? "–"} -
-
-
-
- ); -} diff --git a/src/app/(app)/benchmarks/sweeps/new/page.tsx b/src/app/(app)/benchmarks/sweeps/new/page.tsx deleted file mode 100644 index 38843c9..0000000 --- a/src/app/(app)/benchmarks/sweeps/new/page.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import type { Metadata } from "next"; -import { listDeployableModels, listDeployments } from "@/lib/deployments"; -import { SweepForm, type SweepBase } from "./sweep-form"; - -export const dynamic = "force-dynamic"; -export const metadata: Metadata = { title: "New sweep" }; - -export default async function NewSweepPage({ searchParams }: PageProps<"/benchmarks/sweeps/new">) { - const { deployment } = await searchParams; - const [deployments, models] = await Promise.all([listDeployments(), listDeployableModels()]); - const bases: SweepBase[] = deployments - .filter((d) => !d.sweepId) - .map((d) => ({ - id: d.id, - name: d.name, - engine: d.engine, - accelerator: d.accelerator, - repoId: d.repoId, - options: d.options, - cpus: d.cpus, - memoryMb: d.memoryMb, - ggufFiles: models.find((m) => m.id === d.modelId)?.candidates.gguf.map((g) => g.path) ?? [], - })); - return ( -
-
-

New sweep

-

- Vary one or two settings of a deployment. Kaname deploys each variant in turn, benchmarks it with BetterBench, removes it again and compares all of them, - including the resources each one used. -

-
- -
- ); -} diff --git a/src/app/(app)/benchmarks/sweeps/new/sweep-form.tsx b/src/app/(app)/benchmarks/sweeps/new/sweep-form.tsx deleted file mode 100644 index 877635f..0000000 --- a/src/app/(app)/benchmarks/sweeps/new/sweep-form.tsx +++ /dev/null @@ -1,257 +0,0 @@ -"use client"; - -import { Grid3x3Icon, PlusIcon, XIcon } from "lucide-react"; -import { useRouter } from "next/navigation"; -import { useState } from "react"; -import { toast } from "sonner"; -import { Button } from "@/components/ui/button"; -import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; -import { Checkbox } from "@/components/ui/checkbox"; -import { Input } from "@/components/ui/input"; -import { Label } from "@/components/ui/label"; -import { NativeSelect } from "@/components/ui/native-select"; -import type { BenchmarkPhase, DeploymentOptions, RuntimeAccelerator, RuntimeEngine } from "@/lib/db/schema"; -import { quantGroup } from "@/lib/selection"; -import { expandSweep, MAX_SWEEP_VARIANTS, splitValues, SweepError, sweepKeysFor } from "@/lib/sweep"; - -export type SweepBase = { - id: string; - name: string; - engine: RuntimeEngine; - accelerator: RuntimeAccelerator; - repoId: string; - options: DeploymentOptions; - cpus: number | null; - memoryMb: number | null; - ggufFiles: string[]; -}; - -const PHASES: { id: BenchmarkPhase; label: string }[] = [ - { id: "decode", label: "Generation" }, - { id: "prefill", label: "Prompt processing" }, - { id: "concurrency", label: "Parallel requests" }, -]; - -/** The base's current value of a sweep key, shown as a hint. */ -function currentValue(base: SweepBase, key: string): string { - const o = base.options; - const v: Record = { - contextSize: o.contextSize, - modelFile: o.modelFile, - kvCache: o.cacheTypeK ?? "f16", - threads: o.threads ?? "auto", - parallel: o.parallel ?? "auto", - batchSize: o.batchSize ?? "default", - ubatchSize: o.ubatchSize ?? "default", - flashAttn: o.flashAttn ?? "auto", - cacheRamMb: o.cacheRamMb ?? "8192 (default)", - gpuLayers: o.gpuLayers ?? "auto", - dtype: o.dtype ?? "runtime default", - maxNumSeqs: o.maxNumSeqs ?? "default", - kvCacheGb: o.kvCacheGb ?? "runtime default", - gpuMemoryUtilization: o.gpuMemoryUtilization ?? "0.9", - cpus: base.cpus ?? "no limit", - }; - return String(v[key] ?? ""); -} - -type Param = { key: string; text: string; files: string[] }; - -export function SweepForm({ bases, initialBaseId }: { bases: SweepBase[]; initialBaseId?: string }) { - const router = useRouter(); - const [baseId, setBaseId] = useState(initialBaseId && bases.some((b) => b.id === initialBaseId) ? initialBaseId : (bases[0]?.id ?? "")); - const base = bases.find((b) => b.id === baseId) ?? null; - const keys = base ? sweepKeysFor(base.engine, base.accelerator) : []; - const [params, setParams] = useState([{ key: "contextSize", text: "", files: [] }]); - const [label, setLabel] = useState(""); - const [quality, setQuality] = useState(false); - const [mode, setMode] = useState("quick"); - const [passes, setPasses] = useState("10"); - const [phases, setPhases] = useState(["decode", "prefill", "concurrency"]); - const [busy, setBusy] = useState(false); - - const values = (p: Param) => (p.key === "modelFile" ? p.files : splitValues(p.text)); - let preview: { variants: ReturnType | null; error: string | null } = { variants: null, error: null }; - if (base) { - try { - preview = { variants: expandSweep(params.map((p) => ({ key: p.key, values: values(p) })), base.engine, base.accelerator, { modelFiles: base.ggufFiles }), error: null }; - } catch (err) { - preview = { variants: null, error: err instanceof SweepError ? err.message : String(err) }; - } - } - - const setParam = (i: number, patch: Partial) => setParams((ps) => ps.map((p, j) => (j === i ? { ...p, ...patch } : p))); - - async function submit() { - if (!base || !preview.variants) return; - setBusy(true); - try { - const res = await fetch("/api/sweeps", { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ - baseDeploymentId: base.id, - label: label.trim() || null, - params: params.map((p) => ({ key: p.key, values: values(p) })), - quick: mode === "quick", - passes: mode === "custom" ? Number(passes) || 10 : null, - phases: phases.length === PHASES.length ? [] : phases, - quality, - }), - }); - const json = await res.json().catch(() => ({})); - if (!res.ok) return toast.error(json.error?.message ?? `Could not start (${res.status})`); - router.push(`/benchmarks/sweeps/${json.id}`); - } finally { - setBusy(false); - } - } - - if (bases.length === 0) return

Create a deployment first; a sweep varies its settings.

; - - return ( -
-
- - - Base deployment - Every variant starts from its settings. It doesn't need to be running. - - - setBaseId(e.target.value)} aria-label="Base deployment"> - {bases.map((b) => ( - - ))} - - - - - - - What to vary - One or two settings; every combination becomes a variant (up to {MAX_SWEEP_VARIANTS}). - - - {base && - params.map((p, i) => { - const def = keys.find((k) => k.key === p.key); - return ( -
-
- setParam(i, { key: e.target.value, text: "", files: [] })} aria-label={`Setting ${i + 1}`}> - {keys - .filter((k) => k.key === p.key || !params.some((q) => q.key === k.key)) - .map((k) => ( - - ))} - - {params.length > 1 && ( - - )} -
- {p.key === "modelFile" ? ( -
- {base.ggufFiles.map((f) => ( - - ))} - {base.ggufFiles.length < 2 &&

Only one GGUF file is downloaded; download more quants to compare them.

} -
- ) : ( - setParam(i, { text: e.target.value })} placeholder={def?.hint} aria-label="Values" className="font-mono text-sm" /> - )} -

Base value: {currentValue(base, p.key)}

-
- ); - })} - {params.length < 2 && base && ( - - )} -
-
- - - - Benchmark per variant - - -
- setMode(e.target.value)} aria-label="Run length"> - - - - - {mode === "custom" && setPasses(e.target.value.replace(/\D/g, ""))} inputMode="numeric" className="w-16" aria-label="Passes" />} -
-
- {PHASES.map((p) => ( - - ))} -
- -
- - setLabel(e.target.value)} maxLength={80} placeholder="e.g. context vs KV cache (optional)" /> -
-
-
-
- - - - - - {preview.variants ? `${preview.variants.length} variants` : "Variants"} - - - - {preview.error ? ( -

{preview.error}

- ) : ( -
    - {preview.variants?.map((v) => ( -
  1. - {v.index + 1} - {v.label} -
  2. - ))} -
- )} -

- Variants run one after another, each in its own temporary deployment{base?.memoryMb ? " (memory limit: the base's, raised where a variant needs more)" : ""}. - {mode !== "quick" && " Full runs on a CPU can take hours per variant."} -

- -
-
-
- ); -} diff --git a/src/app/(app)/deployments/[id]/benchmark-card.tsx b/src/app/(app)/deployments/[id]/benchmark-card.tsx deleted file mode 100644 index a28afaf..0000000 --- a/src/app/(app)/deployments/[id]/benchmark-card.tsx +++ /dev/null @@ -1,286 +0,0 @@ -"use client"; - -import { BadgeCheckIcon, GaugeIcon, GitCompareArrowsIcon, Grid3x3Icon } from "lucide-react"; -import Link from "next/link"; -import { useRouter } from "next/navigation"; -import { useEffect, useState } from "react"; -import { toast } from "sonner"; -import { BenchmarkStateBadge } from "@/components/benchmark-state"; -import { Button, buttonVariants } from "@/components/ui/button"; -import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; -import { Checkbox } from "@/components/ui/checkbox"; -import { Input } from "@/components/ui/input"; -import { NativeSelect } from "@/components/ui/native-select"; -import { abHeadline } from "@/lib/ab-report"; -import { headline } from "@/lib/benchmark-view"; -import type { BenchmarkPhase } from "@/lib/db/schema"; -import { QUALITY_SECTIONS, type QualitySection } from "@/lib/db/schema"; -import { SECTION_HINT, SECTION_LABEL } from "@/lib/quality-view"; -import { cn } from "@/lib/utils"; -import type { ListRow } from "../../benchmarks/benchmark-list"; - -const PHASES: { id: BenchmarkPhase; label: string; hint: string }[] = [ - { id: "decode", label: "Generation", hint: "single request, 8 prompt categories" }, - { id: "prefill", label: "Prompt processing", hint: "growing input lengths, up to the context size" }, - { id: "concurrency", label: "Parallel requests", hint: "1, 2, 4 and 8 at once" }, -]; - -type Mode = "run" | "ab" | "quality" | "sweep"; -type Peer = { id: string; name: string; state: string; modelId: string }; - -/** Benchmark this deployment: a single run, a paired A/B against another one, or a sweep. */ -export function BenchmarkCard({ deploymentId, modelId, running, initial }: { deploymentId: string; modelId: string; running: boolean; initial: ListRow[] }) { - const router = useRouter(); - const [tab, setTab] = useState("run"); - const [mode, setMode] = useState("quick"); - const [passes, setPasses] = useState("10"); - const [phases, setPhases] = useState(["decode", "prefill", "concurrency"]); - const [label, setLabel] = useState(""); - const [description, setDescription] = useState(""); - const [busy, setBusy] = useState(false); - const [runs, setRuns] = useState(initial); - const [peers, setPeers] = useState(null); - const [peerId, setPeerId] = useState(""); - const [mde, setMde] = useState("1"); - const [maxPairs, setMaxPairs] = useState("200"); - const [sections, setSections] = useState([...QUALITY_SECTIONS]); - - const active = runs.some((r) => r.state === "queued" || r.state === "running"); - useEffect(() => { - const t = setInterval( - async () => { - const res = await fetch(`/api/benchmarks?deployment=${deploymentId}`, { cache: "no-store" }).catch(() => null); - if (res?.ok) setRuns(await res.json()); - }, - active ? 3_000 : 15_000, - ); - return () => clearInterval(t); - }, [deploymentId, active]); - - // Other deployments of the same model (A/B partners). - useEffect(() => { - if (tab !== "ab") return; - let stop = false; - void fetch("/api/deployments", { cache: "no-store" }) - .then((r) => (r.ok ? r.json() : [])) - .then((rows: Peer[]) => { - if (stop) return; - const list = rows.filter((p) => p.modelId === modelId && p.id !== deploymentId); - setPeers(list); - setPeerId((cur) => cur || list.find((p) => p.state === "running")?.id || ""); - }); - return () => { - stop = true; - }; - }, [tab, modelId, deploymentId]); - - async function start(body: Record) { - setBusy(true); - try { - const res = await fetch("/api/benchmarks", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ deploymentId, label: label.trim() || null, description: description.trim() || null, ...body }) }); - const json = await res.json().catch(() => ({})); - if (!res.ok) return toast.error(json.error?.message ?? `Could not start (${res.status})`); - router.push(`/benchmarks/${json.id}`); - } finally { - setBusy(false); - } - } - - const peer = peers?.find((p) => p.id === peerId); - const TABS: { id: Mode; label: string; icon: typeof GaugeIcon }[] = [ - { id: "run", label: "Run", icon: GaugeIcon }, - { id: "ab", label: "A/B", icon: GitCompareArrowsIcon }, - { id: "quality", label: "Quality", icon: BadgeCheckIcon }, - { id: "sweep", label: "Sweep", icon: Grid3x3Icon }, - ]; - - return ( - - - - - Benchmark - - - -
- {TABS.map((t) => ( - - ))} -
- - {tab === "run" && ( - <> -
- setMode(e.target.value)} aria-label="Run length"> - - - - - {mode === "custom" && ( - setPasses(e.target.value.replace(/\D/g, ""))} inputMode="numeric" className="w-16" aria-label="Passes per category" /> - )} -
-
- {PHASES.map((p) => ( - - ))} -
- setLabel(e.target.value)} maxLength={120} placeholder="Label, e.g. q8_0 KV cache (optional)" /> - setDescription(e.target.value)} maxLength={4000} placeholder="Description: what this run tries out (optional, published with it)" /> - -

- {running ? "On a CPU a full run can take hours. Avoid other load on the server while it runs." : "Start the deployment to benchmark it."} -

- - )} - - {tab === "ab" && ( - <> -

- Paired A/B: the same prompts go to this deployment (A) and another one of the same model (B), alternating, until the difference is known to ±the target. Both - must be running and fit in memory together. -

- {peers === null ? ( -

Loading…

- ) : peers.length === 0 ? ( -

- No other deployment of this model. Create one with the setting you want to compare (e.g. a different KV cache type), or run a sweep. -

- ) : ( - <> - setPeerId(e.target.value)} aria-label="Deployment B"> - - {peers.map((p) => ( - - ))} - - {peer && peer.state !== "running" && ( -

- {peer.name} isn't running.{" "} - - Start it - {" "} - first. -

- )} -
- - -
- setLabel(e.target.value)} maxLength={120} placeholder="Label, e.g. f16 vs q8_0 KV (optional)" /> - setDescription(e.target.value)} maxLength={4000} placeholder="Description: what this run tries out (optional, published with it)" /> - - - )} - {!running &&

Start this deployment (A) first.

} - - )} - - {tab === "quality" && ( - <> -

- A short, deterministic check of the answers (greedy decoding, fixed seed, thinking off): to see whether a quant, KV cache type or build changes quality, - next to the speed numbers. -

-
- {QUALITY_SECTIONS.map((s) => ( - - ))} -
- setLabel(e.target.value)} maxLength={120} placeholder="Label, e.g. q8_0 KV cache (optional)" /> - - {!running &&

Start the deployment to evaluate it.

} - - )} - - {tab === "sweep" && ( - <> -

- Vary one or two settings (context size, KV cache type, threads, quant, GPU layers, …). Kaname deploys each variant in turn, benchmarks it, removes it again, and - compares all of them. This deployment doesn't need to run. -

- - - Set up a sweep - - - )} - - {runs.length > 0 && ( -
- {runs.slice(0, 5).map((r) => { - const h = headline(r.summary); - return ( - - - {r.kind !== "run" && {r.kind === "ab" ? "A/B" : "quality"}} - {r.label ?? new Date(r.createdAt).toLocaleString()} - - - {r.kind === "ab" - ? r.ab && abHeadline(r.ab.decode_tps) - : r.kind === "eval" - ? r.quality?.score != null && `${r.quality.score}%` - : h.decode != null && `${h.decode.toFixed(1)} t/s`} - - - - ); - })} - - All benchmarks → - -
- )} -
-
- ); -} diff --git a/src/app/(app)/deployments/[id]/deployment-detail.tsx b/src/app/(app)/deployments/[id]/deployment-detail.tsx deleted file mode 100644 index 29da38a..0000000 --- a/src/app/(app)/deployments/[id]/deployment-detail.tsx +++ /dev/null @@ -1,403 +0,0 @@ -"use client"; - -import { ExternalLinkIcon, PencilIcon, PlayIcon, SendIcon, ShieldCheckIcon, ShieldIcon, SquareIcon, Trash2Icon } from "lucide-react"; -import { toast } from "sonner"; -import { AgentApprovalBar } from "@/components/approval-bar"; -import { RequestedByBadge } from "@/components/requested-by-badge"; -import Link from "next/link"; -import { useRouter } from "next/navigation"; -import { useEffect, useState } from "react"; -import { CopyButton } from "@/components/copy-button"; -import { DeploymentStateBadge } from "@/components/deployment-state"; -import { LiveLog } from "@/components/live-log"; -import { LocalTime } from "@/components/local-time"; -import { - AlertDialog, - AlertDialogAction, - AlertDialogCancel, - AlertDialogContent, - AlertDialogDescription, - AlertDialogFooter, - AlertDialogHeader, - AlertDialogTitle, - AlertDialogTrigger, -} from "@/components/ui/alert-dialog"; -import { Button, buttonVariants } from "@/components/ui/button"; -import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; -import { Progress } from "@/components/ui/progress"; -import { useHostname, webUiUrl } from "@/hooks/use-hostname"; -import { ENGINE_PORT } from "@/lib/deploy-command"; -import { ACCELERATOR_LABEL } from "@/lib/runtimes-shared"; -import type { DeploymentRow } from "@/lib/deployments"; -import { formatBytes, percent } from "@/lib/format"; -import { quantGroup } from "@/lib/selection"; -import { cn } from "@/lib/utils"; -import { deleteDeployment, startDeployment, stopDeployment } from "../actions"; -import type { ListRow } from "../../benchmarks/benchmark-list"; -import { BenchmarkCard } from "./benchmark-card"; - -type Deployment = Omit & { - startedAt: string | null; - readyAt: string | null; - stoppedAt: string | null; - createdAt: string; -}; - -function Stat({ label, value, children }: { label: string; value: React.ReactNode; children?: React.ReactNode }) { - return ( -
- {label} - {value} - {children} -
- ); -} - -export function DeploymentDetail({ initial, benchmarks }: { initial: Deployment; benchmarks: ListRow[] }) { - const router = useRouter(); - const [d, setD] = useState(initial); - const [now, setNow] = useState(() => Date.now()); - const active = d.desiredState === "running" || d.state === "starting" || d.state === "running" || d.state === "stopping"; - - useEffect(() => { - const t = setInterval(async () => { - setNow(Date.now()); - const res = await fetch(`/api/deployments/${d.id}`, { cache: "no-store" }).catch(() => null); - if (res?.status === 404) router.push("/deployments"); - else if (res?.ok) setD(await res.json()); - }, 2_000); - return () => clearInterval(t); - }, [d.id, router]); - - const file = d.options.modelFile ? (quantGroup(d.options.modelFile) ?? d.options.modelFile) : null; - const loadSecs = d.readyAt && d.startedAt ? (new Date(d.readyAt).getTime() - new Date(d.startedAt).getTime()) / 1000 : null; - const startingSecs = d.state === "starting" && d.startedAt ? Math.max(0, (now - new Date(d.startedAt).getTime()) / 1000) : null; - const port = ENGINE_PORT[d.engine]; - const internal = d.containerName ? `http://${d.containerName}:${port}/v1` : null; - const hostname = useHostname(); - const published = d.hostPort && hostname ? `http://${hostname}:${d.hostPort}/v1` : null; - const webUi = webUiUrl(d, hostname); - - return ( -
- - -
-
-

{d.name}

- - - {d.protected && ( - - - protected - - )} -
-

- - {d.repoId} - - {file && ` · ${file}`} - {d.options.mmproj && " · vision"} - {d.options.draftFile && ` · ${d.options.draftType === "draft-mtp" ? "MTP" : "draft"}`} · {d.runtimeName} -

- {d.runtimeImage} -
-
- {webUi && ( - - - Web UI - - )} - {active ? ( - - ) : ( - - )} - - - - Edit - - - }> - - Delete - - - - Delete {d.name}? - The container is stopped and removed. The model files stay in the library. - - - Cancel - { - if (await deleteDeployment(d.id)) router.push("/deployments"); - }} - > - Delete - - - - -
-
-
- {d.startRequestedAt && ( - - )} - - {d.state === "failed" && d.error && ( -
{d.error}
- )} - -
-
- - - - {d.cpus ? `limit ${d.cpus}` : "no limit"} - - - {d.stats && d.state === "running" && d.memoryMb ? ( - - ) : ( - {d.memoryMb ? `limit ${formatBytes(d.memoryMb * 2 ** 20)}` : "no limit"} - )} - - - until /health answered - - - - {d.engine === "vllm" ? `seqs ${d.options.maxNumSeqs ?? "default"}` : `slots ${d.options.parallel ?? "auto"}`} - - - - - - -
- -
- - - - - Endpoint - - - {internal ? ( -
- {internal} - -
- ) : ( - Not started yet. - )} - On the Docker network, for Kaname and other containers. - {published && ( -
- {published} - -
- )} - - OpenAI-compatible; model name {d.repoId}. - {d.options.requireApiKey && ( - <> - {" "} - Requires one of the{" "} - - API keys - {" "} - as Authorization: Bearer. - - )} - -
-
- - - Details - - -
-
Container
-
{d.containerName ?? "–"}
-
Runs on
-
- {ACCELERATOR_LABEL[d.accelerator]} - {d.accelerator === "nvidia" && ` · ${d.options.gpus?.length ? `${d.options.gpus.length} selected GPU${d.options.gpus.length === 1 ? "" : "s"}` : "all GPUs"}`} -
-
Started
-
- -
-
Stopped
-
- -
- {d.command && ( - <> -
Arguments
-
- {d.command.join(" ")} - -
- - )} -
-
-
-
-
-
- ); -} - -/** Live container log (polls new lines every 1.5 s). */ -/** Smoke test over the OpenAI API: streams the answer and measures time to first token and speed. */ -function Chat({ id, running }: { id: string; running: boolean }) { - const [prompt, setPrompt] = useState("Write one sentence about the sea."); - const [answer, setAnswer] = useState(""); - const [busy, setBusy] = useState(false); - const [stats, setStats] = useState<{ ttft: number | null; total: number; tokens: number | null; promptTokens: number | null } | null>(null); - const [error, setError] = useState(null); - - async function send() { - setBusy(true); - setAnswer(""); - setError(null); - setStats(null); - const t0 = performance.now(); - let first: number | null = null; - let usage: { completion_tokens?: number; prompt_tokens?: number } | null = null; - let chunks = 0; - try { - const res = await fetch(`/api/deployments/${id}/chat`, { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ messages: [{ role: "user", content: prompt }], maxTokens: 256 }), - }); - if (!res.ok || !res.body) { - const body = await res.json().catch(() => ({})); - throw new Error(body.error?.message ?? `HTTP ${res.status}`); - } - const reader = res.body.pipeThrough(new TextDecoderStream()).getReader(); - let buf = ""; - for (;;) { - const { value, done } = await reader.read(); - if (done) break; - buf += value; - let nl: number; - while ((nl = buf.indexOf("\n")) >= 0) { - const line = buf.slice(0, nl).trim(); - buf = buf.slice(nl + 1); - if (!line.startsWith("data:")) continue; - const data = line.slice(5).trim(); - if (data === "[DONE]") continue; - const j = JSON.parse(data); - if (j.usage) usage = j.usage; - const delta: string = j.choices?.[0]?.delta?.content ?? j.choices?.[0]?.delta?.reasoning_content ?? ""; - if (delta) { - first ??= performance.now(); - chunks++; - setAnswer((a) => a + delta); - } - } - } - const total = (performance.now() - t0) / 1000; - setStats({ ttft: first ? (first - t0) / 1000 : null, total, tokens: usage?.completion_tokens ?? chunks, promptTokens: usage?.prompt_tokens ?? null }); - } catch (err) { - setError(err instanceof Error ? err.message : String(err)); - } finally { - setBusy(false); - } - } - - const genSecs = stats && stats.ttft != null ? stats.total - stats.ttft : null; - return ( - - - Try it - - -