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.

Generator: restore EXL3_PREFILL_BIG_CHUNK_MAXPOS (plain prefill chunks beyond a set depth, lower peak memory at very long context)

YanissAmz878f2fd93b4d
diff --git a/exllamav3/generator/job.py b/exllamav3/generator/job.py
index 69f0369..32d0fe4 100644
--- a/exllamav3/generator/job.py
+++ b/exllamav3/generator/job.py
@@ -1243,6 +1243,15 @@ class Job:
big = int(os.environ.get("EXL3_PREFILL_BIG_CHUNK", "4096"))
if big > 65535:
raise ValueError(f"EXL3_PREFILL_BIG_CHUNK={big}: a forward is limited to 65535 rows (mixer kernel grid.y)")
+ # EXL3_PREFILL_BIG_CHUNK_MAXPOS (default 0 = off): from this kv position on, plain chunks again (smaller
+ # workspace, lower peak GPU/unified memory at very long context); the cached big-chunk workspace is
+ # released once per job at the switch
+ maxpos = int(os.environ.get("EXL3_PREFILL_BIG_CHUNK_MAXPOS", "0"))
+ if maxpos and big > chunk and seq.kv_position >= maxpos:
+ big = chunk
+ if not getattr(self, "_big_chunk_released", False):
+ self._big_chunk_released = True
+ torch.cuda.empty_cache()
remaining = len(seq.sequence_ids) - 1 - seq.kv_position
big_tail = big > chunk and big % chunk == 0 and self.big_tail_enabled()
if big_tail: