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.

Serve defaults for several sessions: GLM plain R-row steps and graph verify, Qwen draft depth cap

YanissAmzac87efc02a90
diff --git a/doc/env_vars.md b/doc/env_vars.md
index db23e92..e833d1b 100644
--- a/doc/env_vars.md
+++ b/doc/env_vars.md
@@ -972,6 +972,23 @@ With `EXL3_ROW_INV_GROUPS=1`: the most token rows one forward of a decode step m
job, which is the slowest plan and exact by construction. Values above 8 leave the range where the row-exact
kernels apply.
+#### `EXL3_PLAIN_ROWS_VERIFY` (default: `0`, off; the GLM server sets `1` with `--sessions` above 1)
+
+A decode step without drafted tokens that carries 2 to 8 rows (several sessions decoding together) is run like a verify
+forward: the union MoE on the device table, the R-row GEMV, the batched router and the per-sequence attention loops
+that `EXL3_ROW_INV` enables for verify forwards. Without it such a step fell to per-expert eager loops, thousands of
+host launches. Needs `EXL3_ROW_INV` on. One-row steps are untouched, so a single request decodes as before. GLM-5.3-Flash
+on the box (v1.7.2), 4 sessions, 4 greedy prompts: 26.1 to 40.7 tok/s aggregate. Qwen already has these paths, so it does
+not change there. The text of 4 concurrent plain streams still differs from the solo run at a near-tie word (the solo step
+uses the one-row kernels), as it did before the flag.
+
+#### `QWSPEC_LOAD_ROWS` (default: `EXL3_ROW_INV_GROUP_ROWS` (`8`) with `--sessions` above 1 in the Qwen server, else `0`)
+
+Qwen speculative decoding: with N requests decoding together the draft depth is capped at `R // N - 1`, so the verify rows
+of the step, `N * (depth + 1)`, stay within `R` rows (no draft when that is below 1). `0` turns the cap off.
+`QWSPEC_LOAD_CAPS="N:D,..."` sets the cap for chosen N. Qwen3.8-Flash-Next on the box (v1.7.2 with an equivalent cap), 4 sessions,
+4 greedy prompts: 54.9 tok/s aggregate without the cap, 71.2 with it.
+
#### `EXL3_MTP_EH_FP16` (default: unset, off)
Path of a safetensors sidecar holding an unquantized copy of the MTP `eh_proj`, which raises
diff --git a/tools/glm/serve.py b/tools/glm/serve.py
index 700169a..1f53a47 100644
--- a/tools/glm/serve.py
+++ b/tools/glm/serve.py
@@ -46,6 +46,14 @@ EH_SIDECAR_DEFAULT = "~/models/glm53-mtp-eh-proj-bf16.safetensors"
# Name inside the model folder. Not *.safetensors, so the weight loader never indexes it as model weights
# (same layout trick as uncensor_direction.st); the file is a normal safetensors file.
EH_SIDECAR_IN_PACK = "mtp_eh_proj.st"
+# --sessions > 1 (several requests decode in one step): plain steps take the R-row exact paths (union MoE on the device table, R-row
+# GEMV, batched router) instead of per-expert eager loops, and 2..8-row verify blocks replay as graphs. Box 4 requests, same prompts:
+# plain 26.1 -> 40.7 tok/s aggregate, speculative 38.1 -> 42.5; one request alone and speculative text equal to the solo run unchanged.
+MULTI_SESSION_ENV = {
+ "EXL3_PLAIN_ROWS_VERIFY": "1",
+ "EXL3_BLOCK_GRAPH_VERIFY": "1",
+ "EXL3_DEC_MOE_UNION_DEV": "1",
+}
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.
@@ -2113,6 +2121,9 @@ def main() -> None:
os.environ["EXL3_PREFILL_BIG_TAIL"] = "0"
for key, value in SPEED_ENV.items():
os.environ.setdefault(key, value)
+ if args.sessions > 1:
+ for key, value in MULTI_SESSION_ENV.items():
+ os.environ.setdefault(key, value)
os.environ.setdefault("EXL3_MOE_UNION_V2", "1")
apply_eh_sidecar_default(args.model)
apply_draft2s_default(args.model)
diff --git a/tools/qwen/serve.py b/tools/qwen/serve.py
index fcb6464..2b7893c 100644
--- a/tools/qwen/serve.py
+++ b/tools/qwen/serve.py
@@ -703,6 +703,8 @@ class QwenEngine:
if sessions > 1: # one graph per (jobs, rows) shape of the batched step; the LRU holds the 4 x 8 shapes
os.environ.setdefault("EXL3_CUDA_GRAPH_MULTI", "1")
os.environ.setdefault("EXL3_CUDA_GRAPH_MAX", "32")
+ if sessions > 1: # speculative rounds of N requests verify N * (depth + 1) rows: cap the depth so they stay in one 8-row forward
+ os.environ.setdefault("QWSPEC_LOAD_ROWS", os.environ.get("EXL3_ROW_INV_GROUP_ROWS") or "8")
from exllamav3 import Cache, Config, Generator, Job, Model, Tokenizer
torch.set_grad_enabled(False)
self.torch, self.Generator, self.Job = torch, Generator, Job