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
Qwen serving: tier draft rule, ndt 7 and the verify rows 5..8 kernels (row split, one-launch MoE, 6-row GEMV) on by default
YanissAmzd6a9d9bbabbd
diff --git a/tools/qwen/serve.py b/tools/qwen/serve.pyindex 360f1ae..1767fe8 100644--- a/tools/qwen/serve.py+++ b/tools/qwen/serve.py@@ -525,6 +525,9 @@ SERVE_ENV = (("EXL3_HOST_LEAN", "1"), ("EXL3_HOST_CUTS", "1"), # batched verif# bit-identical prefill levers (hyper-connection apply folded into the next norm, MoE glue v2), served# +2.4 % / +1.6 % / +1.8 % (fuse) and +0.9 / -0.1 / +0.3 % (glue) at 4K / 16K / 32K on bal. 0 = off.("EXL3_PF_GR_FUSE", "1"), ("EXL3_MPW_GLUE", "1"),+ # verify of 5..8 rows (deep draft tier of spec_policy.TierRule): row split, one-launch fused MoE, one-launch 6-row dense GEMV;+ # bit-identical per row, rows <= 4 untouched. 0 = off.+ ("EXL3_VERIFY_ROW_SPLIT", "2"), ("EXL3_MOE_R8", "1"), ("EXL3_GEMV_R_RM6", "1"),# Fidelity first: int8 mixer weights with group scales (fn 128 along H*D, up 64# along rank) and, when <model_dir>/hc_gs_sidecar.safetensors exists, its GPTQ-rounded codes (decoded-token KLD 0.0504 -># 0.0455, plain decode +0.5-0.8 ms). A missing file means group scales with plain rounding. EXL3_GR_GS=0 = per-row scales.@@ -606,7 +609,7 @@ def check_latched_env() -> None:class QwenEngine:"""Target model + MTP drafter + (optional) vision tower + one Generator."""- def __init__(self, model_path: str, ctx: int, ndt: int = 3, draft_policy: str = "mix",+ def __init__(self, model_path: str, ctx: int, ndt: int = 7, draft_policy: str = "mix",vision: bool = True, max_chunk_size: int = 2048, cache_bits: int = 0, sessions: int = 1):# The measured Qwen serving configuration. Read at import time by the engine:# set before importing exllamav3. The caller's environment wins.@@ -1715,7 +1718,7 @@ def main() -> None:parser.add_argument("--ctx", "-c", type=int, default=65536, help="KV cache size in tokens (default 65536)")parser.add_argument("--cache-bits", type=int, default=0, choices=(0, 8),help="bits per K/V element of the attention cache pages (0 = fp16, the default; 8 = packed int8, about 40 %% smaller pages, saves 2.6 GiB at 256K, output not row-invariant for several rows)")- parser.add_argument("--ndt", type=int, default=3, help="max draft tokens per round (default 3)")+ parser.add_argument("--ndt", type=int, default=7, help="max draft tokens per round (default 7; the rule drafts up to 3 for most rounds, deeper only on confident chains)")parser.add_argument("--draft-policy", choices=("mix", "mtp", "off"), default="mix",help="mix = shipped rule (MTP + n-gram lookup, lossless), mtp = fixed MTP chain, off = plain decode")parser.add_argument("--no-vision", action="store_true", help="do not load the vision tower (saves memory)")diff --git a/tools/qwen/spec_policy.py b/tools/qwen/spec_policy.pyindex 7f42d95..b92eb6a 100644--- a/tools/qwen/spec_policy.py+++ b/tools/qwen/spec_policy.py@@ -312,9 +312,9 @@ def env_defaults(ndt):return _envf("QWSPEC_THF", 0.6), _envf("QWSPEC_THV", 0.3), _envf("QWSPEC_MAXD", int(ndt))def rule_from_env(thf, thv, maxd):- """QWSPEC_RULE = product (default) | tier (default thresholds below depth 4, stricter 5+ row tier: QWSPEC_THFD/THVD/DSPLIT) | cost | online | table (depth from the request's acceptance history, no probabilities); QWSPEC_GAMMA / QWSPEC_SCALE tune the calibrated reach.+ """QWSPEC_RULE = tier (default) | product (the former 0.6/0.3/3 rule when maxd=3) | tier (default thresholds below depth 4, stricter 5+ row tier: QWSPEC_THFD/THVD/DSPLIT) | cost | online | table (depth from the request's acceptance history, no probabilities); QWSPEC_GAMMA / QWSPEC_SCALE tune the calibrated reach.QWSPEC_FIXD = N: draft N depths with no host read and truncate once per round (rule applied on the stacked probabilities)."""- kind = os.environ.get("QWSPEC_RULE", "product")+ kind = os.environ.get("QWSPEC_RULE", "tier")if kind == "product": r = ProductRule(thf, thv, maxd)elif kind == "cost": r = CostRule(thf, thv, maxd, _envf("QWSPEC_GAMMA", 1.0), _envf("QWSPEC_SCALE", 1.0))elif kind == "tier": r = TierRule(thf, thv, maxd, _envf("QWSPEC_THFD", 0.9), _envf("QWSPEC_THVD", 0.5), _envf("QWSPEC_DSPLIT", 3))diff --git a/tools/qwen/test_spec_rule.py b/tools/qwen/test_spec_rule.pyindex 91be725..62c06e8 100644--- a/tools/qwen/test_spec_rule.py+++ b/tools/qwen/test_spec_rule.py@@ -127,8 +127,11 @@ class T(unittest.TestCase):def test_env_defaults(self):for k in ("QWSPEC_THF", "QWSPEC_THV", "QWSPEC_MAXD", "QWSPEC_RULE"): os.environ.pop(k, None)- self.assertEqual(sp.env_defaults(3), (0.6, 0.3, 3))- r = sp.rule_from_env(0.6, 0.3, 3); self.assertEqual((r.name, r.thf, r.thv, r.maxd), ("product", 0.6, 0.3, 3))+ self.assertEqual(sp.env_defaults(7), (0.6, 0.3, 7))+ r = sp.rule_from_env(0.6, 0.3, 7); self.assertEqual((r.name, r.thf, r.thv, r.maxd, r.thfd, r.thvd), ("tier", 0.6, 0.3, 7, 0.9, 0.5))+ os.environ["QWSPEC_RULE"] = "product"+ try: r = sp.rule_from_env(0.6, 0.3, 3); self.assertEqual((r.name, r.thf, r.thv, r.maxd), ("product", 0.6, 0.3, 3))+ finally: del os.environ["QWSPEC_RULE"]os.environ["QWSPEC_THF"] = "0.5"; os.environ["QWSPEC_MAXD"] = "5"try: self.assertEqual(sp.env_defaults(3), (0.5, 0.3, 5))finally: del os.environ["QWSPEC_THF"]; del os.environ["QWSPEC_MAXD"]