Kaname keeps two jobs: the model downloader and benchmarks. Benchmarks now run against endpoints (any OpenAI-compatible server added by URL, with an optional server-side API key and hand-written hardware notes) instead of deployments Kaname started itself. Removed: runtimes, deployments, sweeps, resource telemetry, hardware detection, the /api/v1 API with tokens and guardrails, and all Docker access. The quality eval's coding tests run in a network-less sandbox container that shares only an exchange folder with the worker. The previous state is kept in branch backup / tag backup-0.14.3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1d2f908b75
commit
276108932d
199 files changed
+5462
-15961
No files matched your search
@@ -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/<modelId>" # 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": "<runtimeId>", "modelId": "<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/<id>?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": "<id>", "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/<runId>?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": "<id>", "label": "Q4_K_M ctx16k q8_0 KV"}'
|
||||
kaname -m 960 "$KANAME_URL/api/v1/benchmarks/<runId>?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/<id>/stop"
|
||||
kaname -m 120 "$KANAME_URL/api/v1/deployments/<id>?wait=60"
|
||||
kaname -X PATCH "$KANAME_URL/api/v1/deployments/<id>" -d '{"options": {"cacheTypeK": "f16", "cacheTypeV": "f16"}}'
|
||||
kaname -X POST "$KANAME_URL/api/v1/deployments/<id>/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": "<id>", "quick": true, "quality": true,
|
||||
"params": [{ "key": "kvCache", "values": ["f16", "q8_0", "q4_0"] }]
|
||||
}'
|
||||
kaname -m 960 "$KANAME_URL/api/v1/sweeps/<sweepId>?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=<run1>,<run2>,<run3>"
|
||||
```
|
||||
|
||||
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": "<A>", "deploymentBId": "<B>"}`.
|
||||
|
||||
## 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/<id>/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. |
|
||||
@@ -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":"<sha from lookup>","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/<jobId>?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).
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
exec curl -sS -H "Authorization: Bearer $KANAME_TOKEN" -H "Content-Type: application/json" "$@"
|
||||
Reference in new issue
Block a user