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.

Block graph key includes the one-launch MoE switch; synth test fix

YanissAmz03a9007c7901
diff --git a/exllamav3/modules/block_graph.py b/exllamav3/modules/block_graph.py
index 5e5cec1..e8ccb93 100644
--- a/exllamav3/modules/block_graph.py
+++ b/exllamav3/modules/block_graph.py
@@ -72,6 +72,7 @@ BLOCK_GRAPH_DRAFT = _env_int("EXL3_BLOCK_GRAPH_DRAFT", 0)
# input already in place: no copy-in, no output clone (2 copyBuffer launches per block).
# Runtime-mutable; call purge() after toggling (captured graphs bake in the buffer address).
from .quant.exl3 import VERIFY_FUSE as _VF # fused and unfused verify never share a graph
+from .moe_fused import R8 as _R8 # one-launch and split 5..8-row MoE never share a graph
BG_KNOBS = {"shared_x": os.environ.get("EXL3_BG_SHARED_X", "1") != "0"}
_shared_x: dict = {}
@@ -206,7 +207,7 @@ class BlockGraphRunner:
history = bool(params.get("recurrent_history", False))
return (x.device.index, bsz, seqlen, history, id(rsg[0].cache),
params.get("layer_instance", 0),
- tuple(x.shape), str(x.dtype), bool(params.get("dflash_verify")), _VF["on"])
+ tuple(x.shape), str(x.dtype), bool(params.get("dflash_verify")), _VF["on"], _R8["on"])
def _mlp_io_ok(self, x: torch.Tensor, params: dict, draft: bool = False) -> bool:
"""Checks shared by every captured block type: MLP route, TP, device, io, rows. `draft`:
diff --git a/tests/moe_fused/moe8_synth.py b/tests/moe_fused/moe8_synth.py
index e353569..78004d5 100644
--- a/tests/moe_fused/moe8_synth.py
+++ b/tests/moe_fused/moe8_synth.py
@@ -44,7 +44,7 @@ def launch(x, variant=VAR):
R = x.shape[0]
buf = torch.full((R * H * D + 2 * PAD,), 12345.0, dtype=torch.float, device=dev)
xv = buf[PAD: PAD + R * H * D].view(1, R, H, D); xv.copy_(x.view(1, R, H, D))
- torch.ops.mf9.half(xv, fn, fn_scale, upt, up_scale, w_h, router, sgate, wt, svt, ws, 1e-6, 1, 0, variant | 0x1000, *SHAPE)
+ torch.ops.mf9.half(xv, fn, fn_scale, upt, up_scale, w_h, router, sgate, wt, svt, ws, 1e-6, 1, 0, variant, *SHAPE)
torch.cuda.synchronize()
assert bool((buf[:PAD] == 12345.0).all()) and bool((buf[PAD + R * H * D:] == 12345.0).all()), 'x canary overwritten'
assert bool((ws[off[-1]:] == 0xAB).all()), 'workspace tail canary overwritten'
@@ -101,7 +101,7 @@ if os.environ.get('BENCH', '0') != '0':
return best
def raw(x):
R = x.shape[0]; xv = x.clone().view(1, R, H, D)
- return lambda: torch.ops.mf9.half(xv, fn, fn_scale, upt, up_scale, w_h, router, sgate, wt, svt, ws, 1e-6, 1, 0, VAR | 0x1000, *SHAPE)
+ return lambda: torch.ops.mf9.half(xv, fn, fn_scale, upt, up_scale, w_h, router, sgate, wt, svt, ws, 1e-6, 1, 0, VAR, *SHAPE)
# real distinct rows (random inputs pick mostly different experts; a decode batch is similar)
for R in range(1, 9):
x = base[:R]