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
Hy4 multi-session: plain rounds keep each session hcur and n-gram history current (a later speculative round started from stale state), CPU test
YanissAmzc2099f7147a9
diff --git a/tests/test_hy4_mu_plain_round.py b/tests/test_hy4_mu_plain_round.pynew file mode 100644index 0000000..eed9bf5--- /dev/null+++ b/tests/test_hy4_mu_plain_round.py@@ -0,0 +1,59 @@+"""CPU check of MuEngine.plain_round with a fake decoder: one token per session, and the per-session state a later speculative round starts from (hcur = trunk state of the+position just fed, n-gram history) stays current. Plain rounds run above HY4_MU_SPEC_MAXB sessions; when sessions finish, the same sessions go back to spec_round."""+import os+import sys+from types import SimpleNamespace++import torch++sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "tools", "hy4"))+import mu_engine as ME # noqa: E402+++class FakeNG:+ def __init__(self):+ self.seen = []++ def add(self, toks):+ self.seen += list(toks)+++def make(D=4):+ eng = object.__new__(ME.MuEngine)+ log = []++ def step_slots(rows):+ T = sum(len(t) for _, t in rows)+ log.append([(s.slot, list(t)) for s, t in rows])+ am = torch.arange(100, 100 + T)+ hv = torch.arange(T * D, dtype=torch.float32).reshape(T, D)+ return None, am, None, hv++ eng.GR = SimpleNamespace(step_slots=step_slots)+ return eng, log+++class Sess:+ def __init__(self, slot, y, ng=None):+ self.slot, self.y, self.ng, self.hcur = slot, y, ng, None+++def sess(slot, y, ng=None):+ return Sess(slot, y, ng)+++def test_plain_round_one_row_each_and_state_current():+ eng, log = make()+ a, b, c = sess(0, 7, FakeNG()), sess(1, 8), sess(2, 9, FakeNG())+ out = eng.plain_round([a, b, c])+ assert log == [[(0, [7]), (1, [8]), (2, [9])]]+ assert out == {a: [100], b: [101], c: [102]} and (a.y, b.y, c.y) == (100, 101, 102)+ assert torch.equal(b.hcur, torch.arange(4, 8, dtype=torch.float32)[None]) # the trunk state of ITS row, not of row 0+ assert a.ng.seen == [100] and c.ng.seen == [102] and b.ng is None+ eng.plain_round([c]) # single row: shapes of the T = 1 step+ assert c.y == 100 and c.ng.seen == [102, 100]+++if __name__ == "__main__":+ test_plain_round_one_row_each_and_state_current()+ print("ok")diff --git a/tools/hy4/mu_engine.py b/tools/hy4/mu_engine.pyindex a9072dc..61dbb98 100644--- a/tools/hy4/mu_engine.py+++ b/tools/hy4/mu_engine.py@@ -85,6 +85,9 @@ class MuEngine(Hy4Engine):out = {}for r, s in enumerate(sess):s.y = amh[r]+ s.hcur = hv[r:r + 1].clone() # a later spec_round (fewer sessions decode) drafts from the trunk state of the last fed position and the n-gram history+ if s.ng is not None:+ s.ng.add([s.y])out[s] = [s.y]return out