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.
Python amdapple-siliconcudadeepseekexl3exllamav3glminferencellmllm-inferencelocal-llmnvidiaopenai-apiquantizationqwenrocmstrix-halo
Discover serve flavors from tools/*/serve.py (#175)
Tristin Stagg4a749ba0e48d
diff --git a/doc/nix.md b/doc/nix.mdindex d3b3762..e1e8705 100644--- a/doc/nix.md+++ b/doc/nix.md@@ -34,13 +34,20 @@ metadata builds (`uv lock --check`, PEP 517 `get_requires`) keep working.```bashnix build .#exllamav3 # engine wheel + gfx1151 extensionnix build .#exllama-ext # native extension alone (narrowed sources)-nix build .#kyojin # serve wrappers (qwen/glm/mimo)+nix build .#kyojin # serve wrappers (one per tools/*/serve.py flavor)nix build .#torch-rocm # ROCm torch wheelnix build .#rocm-sdk # expanded SDK tree (headers, hipcc, libhsa)nix build .#docker # OCI image tarball, about 5 GB compressednix run .#kyojin-serve-glm -- --help```+Serve flavors are discovered from `tools/*/serve.py`: adding a server+directory adds its `kyojin-serve-<flavor>` wrapper and app, and makes the+container entrypoint accept that flavor, with no list to keep in sync. (Flake+sources only see tracked files, so `git add` the new directory first.) A new+flavor's Python dependencies must already be in `pyproject.toml`, since all+wrappers share the one locked environment.+The engine package is split for CI caching: `.#exllama-ext` compiles thenative extension from narrowed sources only (`setup.py`,`exllamav3/exllamav3_ext/`, `util/arch_list.py`, plus packaging metadata),@@ -144,8 +151,8 @@ 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 skipsthe download when a pack is already there. Both flavor and repo are requiredand 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+(`/models/<flavor>`, overridable with `KYOJIN_MODEL_DIR`), and a marker file+records which repo filled it, soswitching repos under the same flavor errors out instead of serving a stalepack. Tuning cache (`~/.cache/exllamav3`) lives under `HOME`, which theentrypoint points at `/models/home` (override with `KYOJIN_HOME`) so a freshdiff --git a/flake.nix b/flake.nixindex aed9567..ad9c1f6 100644--- a/flake.nix+++ b/flake.nix@@ -48,6 +48,23 @@inherit (pkgs) lib;python = pkgs.python312;+ # A flavor is any tools/<name>/serve.py. The full tools/ tree is+ # already shipped uncurated in kyojinServe, so this one discovery+ # rule drives the wrappers, the container entrypoint, the smoke+ # check and the apps: adding or removing a serve.py cannot leave+ # one of them behind.+ flavors =+ let+ entries = builtins.readDir ./tools;+ isFlavor = name: type: type == "directory" && builtins.pathExists (./tools + "/${name}/serve.py");+ found = builtins.attrNames (lib.filterAttrs isFlavor entries);+ in+ assert found != [ ];+ found;+ # The documented default; keep it explicit (not head flavors) so a+ # new flavor cannot silently become the default app.+ defaultFlavor = "glm";+# The package version, read from upstream's single source of truth# (exllamav3/version.py: `__version__ = "x.y.z"`). pyproject-nix# reports 0.0.0 for a setuptools-dynamic version, so the packages@@ -645,7 +662,7 @@# mirror the repo-root layout it expects.mkdir -p $out/share/exllamav3/utilcp $src/exllamav3/util/hip_compiler.py $out/share/exllamav3/util/- for flavor in glm mimo qwen; do+ for flavor in ${lib.concatStringsSep " " flavors}; domakeWrapper ${kyojinEnv}/bin/python $out/bin/kyojin-serve-$flavor \--add-flags "$out/share/kyojin/$flavor/serve.py" \--prefix PYTHONPATH : "${pythonSet.exllamav3}/lib/python3.12/site-packages:${rocmProviders}/lib/python3.12/site-packages:$out/share/kyojin" \@@ -660,7 +677,7 @@'';meta = {description = "kyojin exllamav3 inference server (AMD gfx1151)";- mainProgram = "kyojin-serve-glm";+ mainProgram = "kyojin-serve-${defaultFlavor}";};};@@ -713,9 +730,9 @@set -euo pipefailflavor="''${KYOJIN_FLAVOR:-}"case "$flavor" in- qwen | glm | mimo) ;;+ ${lib.concatStringsSep " | " flavors}) ;;*)- echo "kyojin-entrypoint: set KYOJIN_FLAVOR to one of: qwen glm mimo" >&2+ echo "kyojin-entrypoint: set KYOJIN_FLAVOR to one of: ${lib.concatStringsSep " " flavors}" >&2exit 2;;esac@@ -746,7 +763,7 @@printf '%s' "$repo" > "$marker"fiecho "kyojin-entrypoint: serving $flavor from $model_dir" >&2- exec "''${KYOJIN_BIN:-/bin/kyojin-serve-$flavor}" --model "$model_dir" "$@"+ exec "''${KYOJIN_BIN:-/bin/kyojin-serve-$flavor}" --host 0.0.0.0 --model "$model_dir" "$@"'';# huggingface-hub CLI (hf download for the entrypoint). nixpkgs'# anyio runs a networked TLS test suite in installCheck that fails@@ -910,7 +927,7 @@"${rocmSdk}/bin/hipcc" --genco --offload-arch=gfx1151 -O3 -ffp-contract=off \-o gr_mix.hsaco exllamav3/modules/gr_fn/gr_mix.hiptest -s gr_mix.hsaco- for flavor in glm mimo qwen; do+ for flavor in ${lib.concatStringsSep " " flavors}; dogrep -q HIP_DEVICE_LIB_PATH ${kyojinServe}/bin/kyojin-serve-$flavorgrep -q HIPCC_COMPILE_FLAGS_APPEND ${kyojinServe}/bin/kyojin-serve-$flavordone@@ -950,16 +967,21 @@type = "app";program = "${kyojinServe}/bin/kyojin-serve-${flavor}";};+ serveApps = builtins.listToAttrs (+ map (flavor: {+ name = "kyojin-serve-${flavor}";+ value = serveApp flavor;+ }) flavors+ );in- {- kyojin-serve-qwen = serveApp "qwen";- kyojin-serve-glm = serveApp "glm";- kyojin-serve-mimo = serveApp "mimo";+ assert lib.elem defaultFlavor flavors;+ serveApps+ // {kyojin-bench = {type = "app";program = "${kyojinBench}/bin/kyojin-bench";};- default = serveApp "glm";+ default = serveApp defaultFlavor;};};};