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.

CUDA graph: up to 8 jobs per graphed decode step (8 sessions stay off the eager path) (#199)

Yaniss Amazouz6f78955635f3
diff --git a/exllamav3/model/cuda_graph.py b/exllamav3/model/cuda_graph.py
index a64584e..693901f 100644
--- a/exllamav3/model/cuda_graph.py
+++ b/exllamav3/model/cuda_graph.py
@@ -65,7 +65,7 @@ CUDA_GRAPH_ENABLED = os.environ.get("EXL3_CUDA_GRAPH", "0") == "1"
# EXL3_HIP_GRAPH=1 (experimental, default off): allow the whole-forward graph on ROCm (hipGraph through torch.cuda.CUDAGraph)
HIP_GRAPH = os.environ.get("EXL3_HIP_GRAPH", "0") == "1"
CUDA_GRAPH_WARMUPS = max(1, _env_int("EXL3_CUDA_GRAPH_WARMUPS", 2))
-# EXL3_CUDA_GRAPH_MULTI=1 (default off): several jobs per graph (B in 1..4, Q <= 16, B*Q <= 32), bigger LRU. Off =
+# EXL3_CUDA_GRAPH_MULTI=1 (default off): several jobs per graph (B in 1..8, Q <= 16, B*Q <= 32), bigger LRU. Off =
# the B=1, Q <= 8 behaviour above, unchanged. set_multi() flips the globals for harness arms (then call purge()).
CUDA_GRAPH_MULTI = False
CUDA_GRAPH_MAX = 6
@@ -79,7 +79,9 @@ def set_multi(on: bool):
CUDA_GRAPH_MULTI = bool(on)
CUDA_GRAPH_MAX = max(1, _env_int("EXL3_CUDA_GRAPH_MAX", 16 if on else 6))
CUDA_GRAPH_MAX_ROWS = 32 if on else 8
- CUDA_GRAPH_MAX_B = 4 if on else 1
+ # 8 jobs: a server with 8 sessions decodes 8 one-row jobs per step; at 4 the N8 step fell back to eager (host-bound, 3090 GPU busy ~53 %).
+ # EXL3_CUDA_GRAPH_MAX_B overrides (4 = the previous cap).
+ CUDA_GRAPH_MAX_B = max(1, _env_int("EXL3_CUDA_GRAPH_MAX_B", 8)) if on else 1
CUDA_GRAPH_MAX_Q = 16 if on else 8
diff --git a/tools/qwen/serve.py b/tools/qwen/serve.py
index f9a2315..e66b6ab 100644
--- a/tools/qwen/serve.py
+++ b/tools/qwen/serve.py
@@ -790,7 +790,7 @@ class QwenEngine:
if on_cuda:
for k, v in CUDA_SERVE_ENV:
os.environ.setdefault(k, v)
- if sessions > 1: # one graph per (jobs, rows) shape of the batched step; the LRU holds the 4 x 8 shapes
+ if sessions > 1: # one graph per (jobs, rows) shape of the batched step; the LRU holds the 8 x 4 shapes (jobs x rows)
os.environ.setdefault("EXL3_CUDA_GRAPH_MULTI", "1")
os.environ.setdefault("EXL3_CUDA_GRAPH_MAX", "32")
# several users: a big prompt prefills in 768-row steps beside the decoding users, which decode between two of its