Skills von blackbook: software-development/local-llm-mac

This commit is contained in:
2026-11-18 14:02:16 +01:00
parent c0aa0952b3
commit 685d33f98a
3 changed files with 79 additions and 0 deletions
@@ -0,0 +1,56 @@
---
name: local-llm-mac
description: Use when running or wiring local LLMs on blackbook.
version: 1.0.0
author: Robert Rapp
license: MIT
platforms: [macos]
metadata:
hermes:
tags: [llm, ollama, llama.cpp, mlx, strata, fallback, benchmark]
related_skills: [hermes-agent, hermes-a2a]
---
# Lokale LLMs auf blackbook (M3 Pro, 36 GB)
## When to Use
For installing, checking, benchmarking, or using a local model on Robby's Mac as a fallback for when Claude is unavailable. This also covers adjusting the Hermes fallback and goal scripts that drive the local model. Requests often come relayed from the `android` peer on Robby's behalf.
## Gates (always)
- Default is **read-only**. Install, download, change config, or activate services/launchd/cron only after Robby explicitly says yes, and only for exactly the scope he approved (e.g. "one model at a time, nothing new to download").
- Ask before any multi-GB download, administrator password, or system setting. Send the exact question back with size, the remaining free disk space, and the exact command. Never guess.
- Only one model in RAM at a time: 36 GB does not fit two 20-GB models plus the system, and macOS then swaps.
- Use free disk space as a planning number (`df -h ~`). The disk is ~90% full.
## Procedure
1. **Inventory first** (read-only, batch it):
- `command -v ollama llama-server llama-cli mlx_lm.generate lms`
- `ollama list`
- list the model folders `~/models` and `~/.cache/huggingface/hub`
- `ps -axo pid,rss,command` filtered for llama-server, mlx_lm, ollama
- `lsof -nP -iTCP -sTCP:LISTEN`
- `GET /v1/models` for every listening server
- Real speed values are in `~/hermes/llama-server.log` (lines containing `eval time`): prompt eval = time to first token, eval = generation tok/s. Report measured numbers and label estimates as estimates.
2. **Before a third-party install script runs:** download it to scratch, read it completely, and check for elevated rights, writes outside its own directory, foreign downloads, and checksum/signature checks. Run it only if all is clean, and report what it does.
3. **Probing sizes without loading:** use the tool's plan/dry-run mode (e.g. `strata launch --plan --model X --no-tui`). Cross-check its claims against the source/docs. Details are in `references/strata.md`.
4. **Fallback in Hermes:** see the section below.
5. **Benchmark:** plan in `references/benchmark-plan.md`. Run it only with approval for each model.
## Changing the Hermes fallback config
- The `custom_providers` entry and the entry in `fallback_providers` must point to a server that actually serves the model. Read the model ID from `GET /v1/models` (llama-server: `--alias`) and set it identically in both places.
- The Hermes config is protected: the agent's write tools refuse it. Respect the guard and do not work around it with shell tricks. Instead:
1. Make a timestamped backup copy next to it (`config.yaml.bak-YYYYMMDD-HHMMSS`).
2. Write the new version via Python string replacement to `~/.hermes/cache/scratch/config-fallback/config.yaml.neu`. Assert that each old snippet occurs exactly once.
3. Save the diff (`diff -u`) and validate the YAML with a Python that has PyYAML. The system python3 may lack it; Strata's bundled Python under `~/.local/share/strata/terminal/*/python/bin/` has it.
4. Give Robby the diff and the one copy command, or tell him to use `hermes config edit`. The change takes effect from the next session.
- Test the server with a chat-completions request (the model ID plus `max_tokens:50`), which works regardless of the config.
## Idle goal script
`~/bin/idle-goal.sh` (not activated) sends `~/goals/next.md` to the local llama-server (:8081), but only when HIDIdleTime is above 15 min and no other model is loaded. Results go to `~/goals/done/`, there is a lockfile, timeout handling, `--dry-run`, and `--tts` (off by default). It only produces text and writes only under `~/goals`. After changing it, always run `bash -n` and `--dry-run`, plus a cross-check with a dummy process: start `exec -a llama-cli sleep 25` in the background; the dry run must then yield exit code 3.
## Pitfalls
- When detecting "another model running", match the **program name** (first word of the command, its basename via `${exe##*/}`, and for Python the first argument), not the full command line. Otherwise `tee …llama-server.log` and similar processes count as models.
- Do not use `basename` on arbitrary ps lines: process names like `-zsh` are parsed as options. Use parameter expansion instead.
- Server processes without a loaded model (`ollama serve`, `mlx_lm.server`, which here serves only Whisper/TTS on :8080) are allowed. Treat them as a model only when RSS > ~1 GB or `ollama ps` shows something.
- Strata and other tools default to port 8080, which is already used by `mlx_lm.server`. Always set `--port` explicitly.
- macOS has no `timeout` and no `pgrep -E`. Use curl `--max-time` and ps with grep instead.
@@ -0,0 +1,14 @@
# Benchmark plan for a local fallback model
Candidates for 36 GB: MoE with ~3B active parameters in Q4 (~19–23 GB, e.g. Nemotron 3.5 Lightning 30B-A3B IQ4_XS, already in `~/models`, ~35–38 tok/s; Qwen3.6-35B-A3B Q4) is fast. A dense ~27B Q4 (~17 GB) is smarter, but expect ~10–15 tok/s (an estimate based on ~150 GB/s bandwidth). Nothing ≥ ~30 GB.
Run each model alone (stop the other one first):
1. Speed: `llama-bench` / `mlx_lm.benchmark` with prompts of 512 / 8k / 32k tokens. The key figure is **time to first token at ~30k context** (the size of the Hermes system prompt).
2. Prompt cache: two Hermes requests in a row. With `--cache-reuse` the second must start noticeably faster.
3. Tool calls: ~10 typical Hermes tasks (read file, terminal, light curl, search notes). Measure the share of valid JSON with the correct tool and whether multi-step tasks succeed.
4. Quality: 5 German tasks plus 3 coding tasks, blind comparison against Claude.
5. Memory: `memory_pressure` / swap during the test, including with a browser open.
6. Sustained load: 10 min of generation to check for heat throttling, also on battery.
Knock-out criteria: tool calls ≥ 90% valid and TTFT at 30k < ~60 s. After that, quality and speed decide.
Report the result as a table plus a recommendation.
@@ -0,0 +1,9 @@
# Strata (Niko1221/Strata) auf dem Mac
- The release installer runs without elevated rights, writes only `~/.local/share/strata/terminal/<ver>` and the link `~/.local/bin/strata`, and checks SHA-256 and the signed feed. It installs no engine and no model; `strata launch` fetches those only when called.
- Read-only commands: `strata --version`, `strata doctor`, `strata models list`, `strata launch --plan --model X [--family F] --no-tui`. With `--plan` nothing is changed.
- `strata launch --plan --model nonexist` lists all model names.
- **On Apple silicon only Qwen3.8-Flash-Next (and the Swift 1.5 fine-tune) runs.** The smallest real size, Gyro-S, is ~58.5 GB plus a 1.2 GB drafter. All sizes are > 36 GB RAM, so you get the warning "may run slower".
- Qwen3.6-35B-A3B (`--family qwen36`, UD-Q4_K_XL 22.9 GB / UD-Q6_K_XL 32.6 GB / Q8_0 37.8 GB) only has CUDA/HIP engines. `docs/CAPABILITIES.md` in the repo says "Apple silicon: does not run".
- Do not trust `--plan`: for families/sizes not available on the Mac (qwen36, NVFP4, IQ2_XS …) it shows "Nothing to download: already on this computer" or no size at all. Read the real sizes from the `setup.py` of the installation (`QWEN36_FILES`, model tables).
- Custom GGUF/HF repo: `--model-path` / `strata models import --plan` accept only the Qwen3.8-Flash-Next architecture (`tools/strata_inspect.py`). For other models use llama.cpp / mlx-lm / Ollama.