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.

Test: qwen35moe GGUF decode through the generator, grouped vs per-expert MoE

YanissAmzbe120c3ac4c0
diff --git a/tests/test_gguf_qwen35moe_decode.py b/tests/test_gguf_qwen35moe_decode.py
new file mode 100644
index 0000000..90d76a0
--- /dev/null
+++ b/tests/test_gguf_qwen35moe_decode.py
@@ -0,0 +1,47 @@
+"""Decode a plain qwen35moe GGUF through the generator: grouped mixed-format MoE kernel vs per-expert path, tok/s each.
+Text is meaningless on a truncated cut; judge the kernel by token agreement and speed.
+
+ FMOE_GGUF=<file.gguf> python tests/test_gguf_qwen35moe_decode.py
+"""
+import json, os, sys, time
+import torch
+
+ENGINE = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
+sys.path.insert(0, ENGINE)
+from exllamav3 import Model, Config, Cache, Generator, Job, GreedySampler, Tokenizer
+from exllamav3.loader import gguf_tokenizer
+from exllamav3.loader.gguf_config import write_config_dir
+
+# Throughput test only: the qwen35 pre-tokenizer regex is not verified yet, so it is NOT mapped in the engine; the test borrows
+# qwen2's (token ids are meaningless on a 4-block cut anyway).
+gguf_tokenizer._PRE.setdefault("qwen35", gguf_tokenizer._PRE["qwen2"])
+
+src = os.environ["FMOE_GGUF"]
+d = write_config_dir(src, os.path.join(os.environ.get("FMOE_CFG", "/tmp"), "qwen35moe_cfg"))
+config = Config.from_directory(d)
+model = Model.from_config(config)
+cache = Cache(model, max_num_tokens=4096)
+model.load()
+tok = Tokenizer.from_config(config)
+gen = Generator(model=model, cache=cache, tokenizer=tok)
+ids = tok.encode("The capital of France is a city that")
+N = 64
+res = {}
+for grouped in ("0", "1", "0", "1"):
+ os.environ["MCPM_FQ_MOE_GROUPED"] = grouped
+ gen.generate("The capital of France", max_new_tokens=4, completion_only=True) # warm
+ torch.cuda.synchronize(); t = time.time()
+ job = Job(input_ids=ids, max_new_tokens=N, sampler=GreedySampler(), stop_conditions=[])
+ gen.enqueue(job)
+ toks = []
+ while gen.num_remaining_jobs():
+ for r in gen.iterate():
+ if r["stage"] == "streaming" and "token_ids" in r:
+ toks += r["token_ids"].flatten().tolist()
+ torch.cuda.synchronize(); dt = time.time() - t
+ res[grouped] = toks
+ print(("grouped " if grouped == "1" else "per-expert"), f"{len(toks)} tok in {dt:.2f}s = {len(toks) / dt:.1f} tok/s")
+n = min(len(res["1"]), len(res["0"]))
+agree = sum(a == b for a, b in zip(res["1"], res["0"]))
+print(f"token agreement {agree}/{n}")
+print("PASS")