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.

Qwen server: warm one full prefill chunk at load so the first request no longer pays ~1.3 s

YanissAmzdb6103b378ae
diff --git a/tools/qwen/serve.py b/tools/qwen/serve.py
index 6aaa80b..12434eb 100644
--- a/tools/qwen/serve.py
+++ b/tools/qwen/serve.py
@@ -890,6 +890,20 @@ class QwenEngine:
while self.generator.num_remaining_jobs():
list(self.generator.iterate())
self.torch.cuda.synchronize()
+ # The first full-size prefill chunk costs ~1.2 s more than every later one (one-time lazy init inside the
+ # forward at chunk size). Pay it at load, not on the first request: one chunk plus a short tail of ordinary text
+ # (EXL3_WARM_PREFILL=0 = off).
+ if os.environ.get("EXL3_WARM_PREFILL", "1") != "0":
+ chunk = int(self.generator.max_chunk_size)
+ text = "<|im_start|>user\n" + "The quick brown fox jumps over the lazy dog near the river bank. " * (chunk // 6 + 64)
+ ids = self.tokenizer.encode(text, add_bos=False, encode_special_tokens=True)
+ ids = ids[:, :chunk + 64].contiguous()
+ job = self.Job(input_ids=ids, max_new_tokens=2, sampler=self._sampler({"temperature": 0.0}),
+ stop_conditions=self.eos)
+ self.generator.enqueue(job)
+ while self.generator.num_remaining_jobs():
+ list(self.generator.iterate())
+ self.torch.cuda.synchronize()
def count_tokens(self, text: str) -> int:
return int(self.tokenizer.encode(text, add_bos=False, encode_special_tokens=True).numel())