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.

Experimental whole-forward graph on ROCm behind EXL3_HIP_GRAPH=1 (default off)

YanissAmz2aaeb8df0102
diff --git a/exllamav3/model/cuda_graph.py b/exllamav3/model/cuda_graph.py
index 33f05ad..a64584e 100644
--- a/exllamav3/model/cuda_graph.py
+++ b/exllamav3/model/cuda_graph.py
@@ -62,6 +62,8 @@ _env_int = lambda name, default: int(os.environ.get(name, default) or default)
# Module global: a harness may flip it between arms (then call purge()).
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 =
# the B=1, Q <= 8 behaviour above, unchanged. set_multi() flips the globals for harness arms (then call purge()).
@@ -641,7 +643,7 @@ def default_on_for_foreign():
def maybe_forward(model, ids: torch.Tensor, params: dict):
"""Hook for Model.forward (non-TP branch). Returns the logits, or None to run the eager path."""
- if not CUDA_GRAPH_ENABLED or torch.version.hip or not torch.cuda.is_available():
+ if not CUDA_GRAPH_ENABLED or (torch.version.hip and not HIP_GRAPH) or not torch.cuda.is_available():
return None
r = model.__dict__.get("_cuda_graph_runner")
if r is None:
diff --git a/exllamav3/model/model.py b/exllamav3/model/model.py
index a34ec29..8e6daad 100644
--- a/exllamav3/model/model.py
+++ b/exllamav3/model/model.py
@@ -318,7 +318,7 @@ class Model(Model_TPMixin, Model_LSMixin):
"""forward() for a decode step whose ids are a device tensor (lag-1 pipeline). CUDA with the whole-forward graph: only the
graph can take them (its GPU embedding table), a decline returns None. Otherwise the eager layers run from a device-side
embedding gather (lag_table). Same arithmetic as forward(): the table rows are the rows Embedding.forward reads."""
- if _cuda_graph.CUDA_GRAPH_ENABLED and not torch.version.hip:
+ if _cuda_graph.CUDA_GRAPH_ENABLED and (not torch.version.hip or _cuda_graph.HIP_GRAPH):
if self.loaded_tp or not torch.cuda.is_available():
return None
x = self.prepare_inputs(input_ids, params)