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
GLM server: no dense GEMM screening by default (first start in about a minute); docs follow
YanissAmz585545ddea6f
diff --git a/doc/EXL3_CONV_GEMM.md b/doc/EXL3_CONV_GEMM.mdindex 21dd0c0..9ece110 100644--- a/doc/EXL3_CONV_GEMM.md+++ b/doc/EXL3_CONV_GEMM.md@@ -17,6 +17,11 @@ the first input of a resolution is slow for two unrelated reasons:Both disappear with environment variables. Nothing else in the server changes.+**Since Kyojin 1.5 the GLM server applies the recommended setup below by default** (`EXL3_CONV_GEMM=1`,+`EXL3_DENSE_GEMM_TUNE=0`, set by `tools/glm/serve.py` unless the variable is already in the environment).+The "default" columns and wording in this page describe the engine without those two values, which is+what `EXL3_CONV_GEMM=0 EXL3_DENSE_GEMM_TUNE=1` still gives.+## Recommended setup```bashdiff --git a/doc/env_vars.md b/doc/env_vars.mdindex 68efd6c..b9c8d91 100644--- a/doc/env_vars.md+++ b/doc/env_vars.md@@ -865,7 +865,8 @@ request then pays the kernel warm-up.#### `EXL3_SERVE_DTUNE_PRIME_S` (default: `600`)Seconds the GLM server spends pre-tuning dense GEMM shapes before it opens the port. `0` skips the-tuning and the matching `/health` stage.+tuning and the matching `/health` stage. Read only with `EXL3_DENSE_GEMM_TUNE=1`: the GLM server sets+`EXL3_DENSE_GEMM_TUNE=0` and `EXL3_CONV_GEMM=1` by default (see [EXL3_CONV_GEMM.md](EXL3_CONV_GEMM.md)).#### `EXL3_SERVE_EMPTY_CACHE` (default: `1`)diff --git a/tools/glm/SERVE.md b/tools/glm/SERVE.mdindex a37c6bf..ff7ab52 100644--- a/tools/glm/SERVE.md+++ b/tools/glm/SERVE.md@@ -36,7 +36,7 @@ call, a streamed call, a tool call, and two 400-token benchmark calls.| `--exact-prefix-cache` | off | a request resumed from the prompt cache gives the same greedy text as its cold prefill. Costs about 5-12 % of cold prefill speed at 7-14K tokens |Env vars the server sets for itself via `os.environ.setdefault` (so an external value-wins): `EXL3_MOE_UNION_V2=1`, `EXL3_MOE_CFG=2`, `EXL3_HIP_PREFILL_MIN_ROWS=2`,+wins): `EXL3_CONV_GEMM=1`, `EXL3_DENSE_GEMM_TUNE=0`, `EXL3_MOE_UNION_V2=1`, `EXL3_MOE_CFG=2`, `EXL3_HIP_PREFILL_MIN_ROWS=2`,`EXL3_BLOCK_GRAPH=1`, `EXL3_BLOCK_GRAPH_MLA=2`, plus the module-level`Generator.MTP_FUSE_CATCHUP = 2`. There is no `--temperature`/seed handling beyond therequest body.@@ -103,26 +103,17 @@ server does not fetch remote URLs). One image takes 40 to about 1,500 tokens depsent again in a later turn keeps the prompt cache. `--no-vision` skips the tower; an image request then gets HTTP 400,as do video and audio parts.-For image input, three environment variables before the start make the first image of a new size fast:+The first image of a new size costs seconds: the server runs the vision spatial-merge convolution as a GEMM+(`EXL3_CONV_GEMM=1`) and skips the dense GEMM screening (`EXL3_DENSE_GEMM_TUNE=0`). Both are server defaults+since 1.5; a value already in the environment wins. Measured on this model: start to ready 771 s -> 65 s, first+1024x1024 image 433 s -> 4 s, text prefill and decode unchanged, answers byte-identical.-```bash-export EXL3_CONV_GEMM=1 # vision spatial-merge convolution as a GEMM: no MIOpen solver search-export EXL3_DENSE_GEMM_TUNE=0 # no dense GEMM screening, at startup or per shape-export EXL3_SERVE_DTUNE_PRIME_S=0 # (implied by the line above; kept for explicitness)-python tools/glm/serve.py \- --model ~/models/glm53-exl3-td205 --port 18080-```--With the defaults, the first image of every new size pays two independent searches: a MIOpen convolution-solver search that grows with the vision token count (~0.3 s per token — about 68 s for a 400x400 image-and 416 s for 1024x1024, and a 1 % change in resolution pays it again), plus a dense GEMM screening on-the language and vision projections (up to 600 s at startup, 20-45 s for each new image size). The three-variables above remove both: a new size then costs seconds and the start is ~45 s.-`EXL3_DENSE_GEMM_TUNE=0` costs 0-7 % of prefill throughput, measured on this model (text is unaffected;-a large-image prefill is about 6 % slower), because the expert layers are EXL3-quantized and do not use-the tuned path.+`EXL3_DENSE_GEMM_TUNE=1` brings the tuner back, with up to 600 s of pre-tuning at the first start+(`EXL3_SERVE_DTUNE_PRIME_S`) and 20-45 s for each new image size. It buys about 6 % of prefill speed on a+large image and nothing on text, because the expert layers are EXL3-quantized and do not use the tuned path.+`EXL3_CONV_GEMM=0` brings the MIOpen convolution back (~0.3 s per vision token for the first image of each size).-Without the code change, `MIOPEN_FIND_MODE=FAST` alone removes the convolution half of that cost+With `EXL3_CONV_GEMM=0`, `MIOPEN_FIND_MODE=FAST` alone removes the convolution half of that cost(a first 1024x1024 goes from 431 s to 22 s) and leaves the GEMM side, and its 600 s of startuppre-tuning, exactly as the default has them. Measurements, the offline pre-generation alternative, andthe comparison with the default configuration: [doc/EXL3_CONV_GEMM.md](../../doc/EXL3_CONV_GEMM.md).diff --git a/tools/glm/serve.py b/tools/glm/serve.pyindex eec1e99..b8e62ea 100644--- a/tools/glm/serve.py+++ b/tools/glm/serve.py@@ -37,6 +37,10 @@ SPEED_ENV = {# Vision spatial-merge convolution as one GEMM: no MIOpen solver search, so the first image of a new# size costs seconds, not minutes (first 1024x1024: 433 s -> 4 s; answers byte-identical). "0" = F.conv2d."EXL3_CONV_GEMM": "1",+ # No dense GEMM screening: a first start takes about a minute instead of 13 (771 s -> 65 s) and a new image+ # size never stalls on it. Answers are byte-identical. "1" brings the tuner and its start-up pre-tuning+ # (EXL3_SERVE_DTUNE_PRIME_S) back; see doc/EXL3_CONV_GEMM.md for the offline pre-generation.+ "EXL3_DENSE_GEMM_TUNE": "0","EXL3_MOE_CFG": "2","EXL3_HIP_PREFILL_MIN_ROWS": "2","EXL3_BLOCK_GRAPH": "1",@@ -1196,7 +1200,7 @@ def main() -> None:os.environ.setdefault("EXL3_MOE_UNION_V2", "1")apply_eh_sidecar_default(args.model)warm = os.environ.get("EXL3_SERVE_WARMUP", "1") != "0"- tune = warm and float(os.environ.get("EXL3_SERVE_DTUNE_PRIME_S", "600")) > 0+ tune = warm and os.environ["EXL3_DENSE_GEMM_TUNE"] != "0" and float(os.environ.get("EXL3_SERVE_DTUNE_PRIME_S", "600")) > 0stages = ["target weights", "drafter weights"] + ([] if args.no_vision else ["vision tower"]) + (["warm-up"] if warm else []) + (["dense GEMM tuning"] if tune else [])startup_health.check_model_dir("serve", args.model, ("config.json",))# A start with the dense GEMM tuning already cached is much shorter than the first one: keep their timings apart.@@ -1230,7 +1234,7 @@ def main() -> None:mem_diag("warm")# EXL3_SERVE_DTUNE_PRIME_S: time budget for pre-tuning dense GEMM classes (0 = skip)budget = float(os.environ.get("EXL3_SERVE_DTUNE_PRIME_S", "600"))- if budget > 0:+ if budget > 0 and os.environ.get("EXL3_DENSE_GEMM_TUNE", "1") != "0":keys, secs = prime_dense_tune(budget)print(f"serve: dense GEMM prime {keys} keys {secs:.1f} s", flush=True)print(mem_line("primed"), flush=True)