Release 0.13.0: agent API for deployments and benchmarks
Release / release (push) Successful in 3m0s
Release / release (push) Successful in 3m0s
Scopes deployments:read/write and benchmarks:read/run; /api/v1 endpoints for runtimes, deployments (create with dry run, edit, start, stop, delete own ones), benchmark runs, A/B, sweeps and comparisons; ?wait= on all status endpoints. Guardrails: approval, agent deployments at once, one GPU job at a time, time limits, sweep variants, runtime and argument allowlists, host port range, memory/CPU caps, protected deployments with a VRAM check. Requested-by filters, approval bars, per-token activity log, scope editing, docs/agent/SKILL-tuning.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e007a35143
commit
716bd8f2f0
62 files changed
+6091
-219
No files matched your search
@@ -0,0 +1,179 @@
|
||||
---
|
||||
name: kaname-tuning
|
||||
description: Deploy local LLMs on the user's Kaname server and benchmark them 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.
|
||||
|
||||
## 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 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,
|
||||
"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 | VRAM peak | Notes |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| f16 | 58.1 | 1910 | 88 | 11.2 GB | baseline |
|
||||
| q8_0 | 57.6 | 1880 | 90 | 9.4 GB | −1 %, 1.8 GB less VRAM |
|
||||
|
||||
Name the winner and why (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. |
|
||||
+11
-6
@@ -12,7 +12,9 @@ required_environment_variables:
|
||||
|
||||
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: tell the user when they need one of those.
|
||||
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:
|
||||
|
||||
@@ -94,17 +96,20 @@ Answer:
|
||||
## 4. Follow it
|
||||
|
||||
```bash
|
||||
kaname "$KANAME_URL/api/v1/jobs/<jobId>"
|
||||
kaname -m 660 "$KANAME_URL/api/v1/jobs/<jobId>?wait=600"
|
||||
```
|
||||
|
||||
`state`: `pending_approval` → `queued` → `downloading` → `verifying` → `completed`. Every check
|
||||
costs a full round of your context, so check rarely:
|
||||
`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`:** check at most once, around the reported
|
||||
`etaSeconds`; if there is no ETA, once after about 10 minutes. Never loop in short intervals.
|
||||
- **`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.
|
||||
|
||||
Reference in new issue
Block a user