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.

Tests: the fake engines answer prompt_ids, as the real ones do

MangetsuC7d98ab6801f1
diff --git a/tools/glm/test_serve_glm_additional.py b/tools/glm/test_serve_glm_additional.py
index 3a30f7d..0478da0 100644
--- a/tools/glm/test_serve_glm_additional.py
+++ b/tools/glm/test_serve_glm_additional.py
@@ -47,6 +47,14 @@ class FakeEngine:
def count_tokens(self, text: str) -> int:
return len(text.split())
+ def prompt_ids(self, prompt: str):
+ """The ids the route counts tokens with; the real engine has an incremental encode cache here.
+
+ This double counts words, so the ids are placeholders of that length: the route asks the result for
+ `numel()` and puts the number in the log, which is the same value it got before."""
+ import torch
+ return torch.zeros(int(self.count_tokens(prompt)), dtype=torch.long)
+
async def generate(self, prompt: str, **kwargs):
self.prompts.append(prompt)
self.last_stats = {"cached_tokens": 8, "new_tokens": 4, "prompt_tokens": 20,
diff --git a/tools/test_serve_logging.py b/tools/test_serve_logging.py
index 49dd8e2..87b236d 100644
--- a/tools/test_serve_logging.py
+++ b/tools/test_serve_logging.py
@@ -69,6 +69,14 @@ class FakeEngine:
def count_tokens(self, text: str) -> int:
return len(text.split())
+ def prompt_ids(self, prompt: str):
+ """The ids the completion route counts tokens with; the real engines have an encode cache here.
+
+ This double counts words, so the ids are placeholders of that length - the route only asks the
+ result for `numel()`, and that number is what it puts in the log."""
+ import torch
+ return torch.zeros(int(self.count_tokens(prompt)), dtype=torch.long)
+
def spec_stats(self) -> dict:
return {}