Skip to content

Kyojin: open-source engine that runs 100 GB-class open models (GLM-5.3, Qwen3.8, DeepSeek V4.1) on one desktop machine. AMD Strix Halo, NVIDIA RTX and Apple Mac. OpenAI API, built on ExLlamaV3.

feat(nix): per-flavor model slots with repo marker

Tristin Stagg9e537202dc5b
diff --git a/doc/nix.md b/doc/nix.md
index e0a6165..a78025c 100644
--- a/doc/nix.md
+++ b/doc/nix.md
@@ -99,11 +99,15 @@ with a raised memlock limit is the usual setup for GPU inference runtimes.
The entrypoint downloads the model into the volume on first start and skips
the download when a pack is already there. Both flavor and repo are required
-and fail fast; there are no silent 50 GB pulls. Tuning cache
-(`~/.cache/exllamav3`) lives under `HOME`, which the entrypoint points at
-`/models/home` (override with `KYOJIN_HOME`) so a fresh container does not
-re-tune. First start still tunes GEMM kernels (around 10 minutes with the
-port closed), same as bare metal. The servers answer `/health` from the
+and fail fast; there are no silent 50 GB pulls. Each flavor gets its own slot
+(`/models/qwen`, `/models/glm`, `/models/mimo`, overridable with
+`KYOJIN_MODEL_DIR`), and a marker file records which repo filled it, so
+switching repos under the same flavor errors out instead of serving a stale
+pack. Tuning cache (`~/.cache/exllamav3`) lives under `HOME`, which the
+entrypoint points at `/models/home` (override with `KYOJIN_HOME`) so a fresh
+container does not re-tune. First start still tunes GEMM kernels (around
+10 minutes with the port closed), same as bare metal. The servers answer
+`/health` from the
first second (503 while loading, 200 when ready), so it works as a
readiness check, and `/v1/models` answers once serving.
diff --git a/flake.nix b/flake.nix
index 71aea91..19a039c 100644
--- a/flake.nix
+++ b/flake.nix
@@ -625,16 +625,26 @@
echo "kyojin-entrypoint: set KYOJIN_MODEL_REPO (e.g. yamz-labs/GLM-5.3-Flash-EXL3-Yamz)" >&2
exit 2
fi
- model_dir="''${KYOJIN_MODEL_DIR:-/models/current}"
+ model_dir="''${KYOJIN_MODEL_DIR:-/models/$flavor}"
# Tuning cache (e.g. GLM's dense GEMM tune, ~8 min first launch)
# must survive container replacement: keep HOME on the volume.
export HOME="''${KYOJIN_HOME:-/models/home}"
mkdir -p "$HOME" "$model_dir"
+ # One slot per flavor; the marker records which repo filled it so
+ # switching repos under the same flavor fails loudly instead of
+ # serving a stale pack.
+ marker="$model_dir/.kyojin-repo"
if [ -f "$model_dir/config.json" ]; then
+ if [ -f "$marker" ] && [ "$(cat "$marker")" != "$repo" ]; then
+ echo "kyojin-entrypoint: $model_dir holds $(cat "$marker"), not $repo;" >&2
+ echo " set KYOJIN_MODEL_DIR or empty the directory" >&2
+ exit 2
+ fi
echo "kyojin-entrypoint: model present at $model_dir, skipping download" >&2
else
echo "kyojin-entrypoint: downloading $repo into $model_dir (first start is slow)" >&2
hf download "$repo" --local-dir "$model_dir"
+ printf '%s' "$repo" > "$marker"
fi
echo "kyojin-entrypoint: serving $flavor from $model_dir" >&2
exec "''${KYOJIN_BIN:-/bin/kyojin-serve-$flavor}" --model "$model_dir" "$@"
@@ -685,7 +695,6 @@
"/models" = { };
};
Env = [
- "KYOJIN_MODEL_DIR=/models/current"
"PATH=/bin:/usr/bin"
"SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"
"NIX_SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"