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
Health helper: close the early socket in forked children, enter the GLM tuning stage unconditionally, load keyword tests
YanissAmz2ff0ec169a7b
diff --git a/tools/glm/serve.py b/tools/glm/serve.pyindex ca0918a..83f1de3 100644--- a/tools/glm/serve.py+++ b/tools/glm/serve.py@@ -401,6 +401,7 @@ def prime_dense_tune(budget_s: float = 600.0) -> tuple[int, float]:class (15 shapes). Warm-up has just logged every shape it met, so cross those shapes with allclasses 256..4096 and pay the tuning here. A cached key costs one GEMM. Tuned winners arebit-exact with the default path, so outputs do not change. Returns (keys, seconds)."""+ startup_health.stage("dense GEMM tuning") # entered even when nothing is left to tune: a clean stage listpath = dense_tune_path()if os.environ.get("EXL3_DENSE_GEMM_TUNE", "1") == "0" or not path.exists():return 0, 0.0@@ -418,7 +419,6 @@ def prime_dense_tune(budget_s: float = 600.0) -> tuple[int, float]:have.add((f[0], int(f[1]), int(f[2]), int(f[3]), int(f[4]), int(f[5])))tag = f[0] # the last line carries the running library's tag (the C++ side appends)# Keys the C++ tuner already holds cost nothing to skip: no buffers, no GEMM.- startup_health.stage("dense GEMM tuning")todo = [(n, k, ldn, f32, mc) for n, k, ldn, f32 in sorted(shapes) for mc in sorted(classes)if (tag, n, k, mc, ldn, f32) not in have]print(f"serve: dense GEMM prime: {len(todo)} of {len(shapes) * len(classes)} keys missing", flush=True)diff --git a/tools/startup_health.py b/tools/startup_health.pyindex 97a7c49..f195679 100644--- a/tools/startup_health.py+++ b/tools/startup_health.py@@ -171,6 +171,9 @@ class _EarlyServer:self.httpd = Server((host, port), Handler)self.port = self.httpd.server_address[1]+ # A fork-without-exec child would keep the listening socket open after close() and block the real bind.+ sock = self.httpd.socket+ os.register_at_fork(after_in_child=lambda: sock.close())self.thread = threading.Thread(target=self.httpd.serve_forever, daemon=True, name="startup-health")self.thread.start()diff --git a/tools/test_startup_health.py b/tools/test_startup_health.pyindex 458439f..de86637 100644--- a/tools/test_startup_health.py+++ b/tools/test_startup_health.py@@ -280,6 +280,44 @@ class ListenerTest(unittest.TestCase):self.assertEqual(codes, [503] * 8)+class ForkTest(unittest.TestCase):+ def test_forked_child_does_not_keep_the_port(self):+ import os+ import time+ t = tracker(["a"])+ t.serve("127.0.0.1", 0)+ port = t.server.port+ pid = os.fork()+ if pid == 0: # child: lives on while the parent hands the port over+ time.sleep(3)+ os._exit(0)+ try:+ t.release_port()+ s = socket.socket()+ s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)+ s.bind(("127.0.0.1", port))+ s.listen(1)+ s.close()+ finally:+ os.kill(pid, 9)+ os.waitpid(pid, 0)+++class LoadSignatureTest(unittest.TestCase):+ """The keyword the servers pass must exist on every load path they call (read from source: no torch here)."""++ def test_callback_reaches_load_paths(self):+ root = TOOLS.parent / "exllamav3"+ model = (root / "model" / "model.py").read_text()+ self.assertIn("callback: Callable[[int, int], None] | None = None", model)+ self.assertIn("self._load_single(progressbar, device, self.config, self.modules, verbose, callback)", model)+ self.assertIn("def load(self, *args, **kwargs):", model) # load() forwards to load_gen+ ls = (root / "model" / "model_ls.py").read_text()+ self.assertIn("verbose: bool,\n callback = None", ls)+ init = (root / "model_init.py").read_text()+ self.assertEqual(init.count("**kwargs\n"), 3) # signature + the two loads++class WiringTest(unittest.TestCase):"""The three servers call the same helper, in the right order, with stage names the lists declare."""