Files
584811d86d Local models: ygg-models.sh, ygg-gpu.sh, and local roles in the proof and smoke scripts (#89)
* ygg-gpu.sh setup|check: the toolkit and the CDI spec in the Podman machine, repeatable (local-models LM-T15)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* ygg-models.sh start|stop|status|load, and the qwen scripts find the server through it (local-models LM-T12)

qwen-local.sh and its test are removed; qwen-lib.sh reads ygg-models.sh status.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* ygg-models.sh: --folder, exact names, reserved networks, load retry; qwen scripts tell engine errors from not running (local-models LM-T12)

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01H5rHSQVuXrzFdTaNXZdSde

* The proof and smoke scripts take opencode:local/<name> roles and --models FILE (local-models LM-T13)

A local role writes models.file into the config and, for the reviewer, no reasoning line. The OpenRouter
key and the usd caps are asked for only when a role is on OpenRouter. A local role without --models is
refused before anything is made. The default roles give the same config as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01H5rHSQVuXrzFdTaNXZdSde

* ygg-models.sh uses engine-side mount paths, a template step, and a hardened container (local-models review)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01H5rHSQVuXrzFdTaNXZdSde

* ygg-gpu.sh checks the engine before any wsl.exe -d and reads the state with one probe (local-models review)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01H5rHSQVuXrzFdTaNXZdSde

* Proof and smoke refuse two local models; the how-to uses the template step and the image (local-models review)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01H5rHSQVuXrzFdTaNXZdSde

* ygg-gpu.sh sends root scripts on stdin to sh -s, and the template step knows a fixed template (local-models review)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01H5rHSQVuXrzFdTaNXZdSde

* The example model list takes temp, top-k and top-p from the model file, and sets only min-p (local-models review)

The Qwen GGUF carries general.sampling.temp, top_k and top_p, which llama-server uses unless a
preset key overrides them. The founder uses the model's own values in most cases.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01H5rHSQVuXrzFdTaNXZdSde

---------

Co-authored-by: Bruno Guilhermo de Barros Valério <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-10-26 02:13:33 +01:00

48 lines
2.4 KiB
Bash

#!/usr/bin/env bash
# Shared defaults and helpers for the qwen-* scripts, which use the local model server
# (docs/5-research/2026-10-19-local-qwen-design.md; the server is scripts/ygg-models.sh, started from the
# operator's model list). Source this file; do not run it.
# The caller's values win over these defaults:
# QWEN_HOME logs and run state of the older measurement scripts ($HOME/.local/share/qwen-local)
# QWEN_CTX the context size in tokens (102400); keep it equal to `context` in the model list
# QWEN_ALIAS the model's name in the list (qwen3.8-27b); the name OpenCode and Claude Code ask for
# QWEN_MODELS_SH the script that reports the server (ygg-models.sh next to this file)
# QWEN_MODELS the model list, passed as --models (ygg-models.sh's default list when unset)
# QWEN_FOLDER the factory folder (factory.yaml), passed as --folder (ygg-models.sh's default, ~/ygg-it, when unset)
# The server's URL comes from `ygg-models.sh status`, which prints `running on <URL>, loaded: <name|none>`.
QWEN_HOME="${QWEN_HOME:-$HOME/.local/share/qwen-local}"
QWEN_CTX="${QWEN_CTX:-102400}"
QWEN_ALIAS="${QWEN_ALIAS:-qwen3.8-27b}"
QWEN_MODELS_SH="${QWEN_MODELS_SH:-$(dirname "${BASH_SOURCE[0]}")/ygg-models.sh}"
# qwen_status: run `ygg-models.sh status` (with --models "$QWEN_MODELS" and --folder "$QWEN_FOLDER" when set), print its line, pass its exit code on.
# Its stderr is not hidden: an engine that does not answer says why.
qwen_status() {
local args=()
[ -z "${QWEN_MODELS:-}" ] || args+=(--models "$QWEN_MODELS")
[ -z "${QWEN_FOLDER:-}" ] || args+=(--folder "$QWEN_FOLDER")
"$QWEN_MODELS_SH" "${args[@]}" status
}
# qwen_url: print the running server's URL; exit 1 when it does not run.
qwen_url() {
local line
line="$(qwen_status 2>/dev/null)" || return 1
case "$line" in "running on "*) ;; *) return 1 ;; esac
line="${line#running on }"
echo "${line%%,*}"
}
# qwen_require_server: exit 2 with a hint when the server is not running (status exit 3), and exit 2 with the
# status script's own message when the check itself failed (the engine does not answer, the list is wrong).
qwen_require_server() {
local rc=0
qwen_status >/dev/null || rc=$?
case "$rc" in
0) ;;
3) echo "the local model server is not running; start it with scripts/ygg-models.sh start" >&2; exit 2 ;;
*) echo "the local model server could not be checked (ygg-models.sh status exit $rc; see above)" >&2; exit 2 ;;
esac
}