Run a real MLX model for basalt — benchmarks, PPL/passkey/memory measurements, speculative-decoding or KV-cache checks, parity runs. Use before launching any run that loads model weights, and when writing the measured-numbers section of a PR.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Basalt Model Runs?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/goodmai-basalt-model-runs)
---
name: basalt-model-runs
description: Run a real MLX model for basalt — benchmarks, PPL/passkey/memory measurements, speculative-decoding or KV-cache checks, parity runs. Use before launching any run that loads model weights, and when writing the measured-numbers section of a PR.
---
# Real-model runs in basalt
The rule is in CONTRIBUTING.md, "Real-model runs". This is how to follow it.
## Pick the runner
1. `PerformanceBenchmark` covers decode/prefill speed: `swift run -c release PerformanceBenchmark -m <repo> --kv-bits 4|8 --speculative-lookup --temperature <t> --seed <n> --print-output`.
2. Quality, memory or behaviour on a real model is an env-gated Swift test: `@Test(.enabled(if: modelPath != nil, "set BASALT_E2E=1 and BASALT_E2E_<X>_MODEL_PATH"))`, following `CacheBlendQualityTests` and `HybridPrefixDriftTests`. Run it with `swift test --filter <Suite>`.
3. Anything that fits neither goes in `scripts/<name>.swift` (see `scripts/build_metal.swift`).
Measure speed at the temperature the workload is used with. Code edits, prose and reasoning run at the model's sampling temperature (0.7 in `scripts/speculative_lookup_bench.swift`), not greedy: a greedy cell is deterministic, so it helps when debugging a drafter, but it is not the number a speculative-decoding claim rests on.
Bash only starts one of these. Don't write `for model in …; do …; done | tail`, and don't decide pass/fail with grep.
## What the runner does
- Calls `basalt models inspect <repo> --json` first and fails when `intact` is false.
- Appends one line per step to `logs/<runner>-<date>.log` and prints it: timestamp, model, mode, parameters, result.
- Catches every error per step, logs `FAIL <step> <error>`, carries on to the next step only when the steps are independent, and exits non-zero if anything failed.
- Writes a header line with `git rev-parse HEAD`, the model repo and snapshot revision, and the chip and memory.
- Takes the GPU lock before loading weights and releases it in `defer`: first verify GitHub Actions is idle on this self-hosted Mac (`gh run list -L 2 --workflow="Unit Tests"` has no `in_progress` or `queued` run), create the directory `/private/tmp/basalt-gpu.lock` (failing while it exists means another run holds the GPU, so wait and retry; only remove a stale lock after confirming the pid in `owner` is dead via `ps -p <pid>`), write the runner's pid into `owner` inside it, and on exit, including on error, remove it only if `owner` still holds that pid. Release exactly once: a second release (a `defer` plus a signal handler, or a wrapper that also cleans up) deletes the lock the next run has just taken, and two models then share the GPU. Hold it for one model, then release and take it again, so other runs can interleave.
- Wrap runs longer than 15 minutes in `caffeinate -dims` so macOS idle sleep never suspends an in-flight Metal command buffer (`kIOGPUCommandBufferCallbackErrorTimeout`, signal 5).
- A run that was killed or shared the GPU invalidates its numbers from that point; discard and rerun them.
- Speed numbers (tok/s, TTFT) come from a release build (`swift test -c release --filter <Suite>`, `swift run -c release`; do not use `swift build --build-tests -c release`, which omits `-enable-testing` for `@testable import`); a debug build is fine for memory, PPL and passkey.
## Every run records telemetry
A run that prints only tok/s hides what went wrong and what could be faster. Every real-model run, by any agent, saves the engine's telemetry next to its log and reads it before the numbers are reported (owner's rule, 2026-11-28).
- **Through the server** (the default for anything beyond a kernel microbenchmark): `basalt serve --rest --model <repo>`, send the requests, then save `GET /api/v1/stats` and `GET /v1/telemetry/frontier` as `<log>.stats.json` and `<log>.frontier.json`.
- **`PerformanceBenchmark` has no telemetry output.** Use it for the speed table, and pair it with one served run of the same model for the snapshots.
- **Check a headroom reading before acting on it.** A utilization well under 1 is an estimate; compare decode speed with `mlx_lm generate` on the same pack first (Hy-MT3-1.8B read 0.61 and was already at 96% of mlx-lm).
- **Read at least:** the compute regime and bandwidth utilization, prompt-cache hits against prefilled tokens, expert load balance and cache hit rate on a MoE, recurrent-state health on a hybrid, the health counters (NaN, OOM, fallbacks), TTFT against decode, and swapouts.
- **Act on it.** An anomaly (a utilization above 1, a prefix that was not reused, a collapsed expert, a fallback path taken, a counter that stays at zero when it should move) becomes an issue with the snapshot attached, or a fix in the same PR. A headroom finding (utilization well under 1, a cold cache, a slow first token) becomes a speed-up issue.
- **In the PR:** one line per model on what the telemetry showed, next to the speed table. "Telemetry: nothing unusual" is a valid line; no line is not.
Telemetry that costs speed stays off the measured path: flags such as `--expert-routing-telemetry` go into a second run, not into the one whose tok/s is reported.
## Which models
Cover at least two families for any speed or quality claim, plus one model the feature must refuse. Every model table includes a Gemma 4 of at least 12B (`gemma-4-12B-it-qat-4bit` or `gemma-4-26B-A4B-it-qat-4bit`); when the feature excludes Gemma 4, run it anyway and show the refusal or fallback. Llama is not used, neither for runs nor as the tiny test fixture:
| Class | Cached examples | Use for |
|---|---|---|
| Dense, all `KVCacheSimple` | `mlx-community/Qwen3-4B-4bit` | CacheBlend, prompt lookup, KV quantization |
| Sliding window + full attention, attention calls `cache.update` | `mlx-community/gemma-4-12B-it-qat-4bit` | KV cache layouts, fallback paths |
| Hybrid linear/full attention (qwen3_5) | `ornith-ai/Ornith-1.5-9B-MLX-4bit`, `lukaskremla/Qwen3.8-27B-3bit-MLX-TextOnly` | hybrid snapshots, fallback paths |
| Hybrid conv/SSM + attention | `LiquidAI/LFM2.5-8B-A1B-MLX-4bit`, `mlx-community/NVIDIA-Nemotron-3-Nano-4B-4bit` | hybrid snapshots, fallback paths |
Gemma 3 and Ministral 3 are out of scope. One model at a time on a 24 GB Mac.
## In the PR
A table per model with the numbers, the commit they were measured on, and the path or attachment of the runner's log. A model that wasn't run is listed as not measured, not left out.
## Related skills
All skills live in `.claude/skills/<name>/SKILL.md` (mirrored at `.agents/skills/`). Start from `swiftcoder` when unsure.
| Skill | Use it for |
|---|---|
| `swiftcoder` | the role and entry point: which skill to load, in what order, and the gates |
| `ponytail` | scope and the smallest complete change |
| `ponytail-review` | review of a change for correctness, safety, load, tests and need |
| `swift-64-architecture` | targets, boundaries, isolation domains, value core and actor shell |
| `swift-64-optimization-coding` | writing Swift 6.4 code: ownership, typed throws, size limits, Metal kernels |
| `swift-64-pr-review` | the 5-gate review of a Swift diff |
| `swift-concurrency-pro` | async/await, actors, tasks, streams and cancellation in depth |
| `swift-race-review` | races and deadlocks the compiler cannot see; MLX and Metal threading |
| `swift-testing-pro` | Swift Testing in depth: structure, async tests, new features |
| `xcode-mcp` | checking an API against Apple's documentation; Xcode workspace tools |
| `model-xray` | looking inside a running model and calling basalt's own MCP server |
| `model-surgery` | surgical, gated weight edits via MCP overlays or Swift `MLXNN.Module` updates |