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.
Python amdapple-siliconcudadeepseekexl3exllamav3glminferencellmllm-inferencelocal-llmnvidiaopenai-apiquantizationqwenrocmstrix-halo
MoE decode gate/up k-split: opt-in (EXL3_MOE_COOP_KSPLIT_A=n), default is the unsplit unit
YanissAmza252200be0cd
diff --git a/doc/env_vars.md b/doc/env_vars.mdindex 01c631f..10520d6 100644--- a/doc/env_vars.md+++ b/doc/env_vars.md@@ -432,16 +432,17 @@ Split-k factor of the fused decode MoE kernels: `n` runs every column chunk as `disjoint k ranges whose partial sums the last-arriving block adds. Measured as neutral to harmfulon every GPU here, so the default is no split. Testing knob only.-### `EXL3_MOE_COOP_KSPLIT_A` (default: `3`, Ampere only)+### `EXL3_MOE_COOP_KSPLIT_A` (default: unset, no split; Ampere only)Gate/up stage of the fused decode MoE kernels at batch sizes whose (token, expert, projection,128-column) units fit one per SM (Flint at batch 1: 48 units on 82 SMs): every unit's k loop-is one block's serial chain, so it is shared by up to `n` blocks (while the grid stays-resident) and the last-arriving block of a chunk adds the fp32 partial rows in fixed order.-The pre-activation is then no longer rounded to fp16 before the output rotation, so results-differ from the unsplit unit in that rounding (teacher-forced NLL on Flint is lower at 4K, 32K-and 64K; greedy text flips at near-ties). `1` restores the unsplit unit, which is bit-identical-to the previous kernel. Other architectures and larger batches are not affected.+is one block's serial chain. `n` >= 2 (`3` is the measured choice) shares it over up to `n`+blocks (while the grid stays resident); the last-arriving block of a chunk adds the fp32 partial+rows in fixed order. The pre-activation is then no longer rounded to fp16 before the output+rotation, so results differ from the unsplit unit in that rounding (teacher-forced NLL on Flint+is lower at 4K, 32K and 64K; greedy text flips at near-ties). Unset, `0` or `1` keep the unsplit+unit, which is bit-identical to the previous kernel. Other architectures and larger batches are+not affected.### `EXL3_MOE_COOP_WIDE` (default: unset)diff --git a/exllamav3/exllamav3_ext/quant/exl3_moe_coop.cu b/exllamav3/exllamav3_ext/quant/exl3_moe_coop.cuindex ae79aad..574ff4e 100644--- a/exllamav3/exllamav3_ext/quant/exl3_moe_coop.cu+++ b/exllamav3/exllamav3_ext/quant/exl3_moe_coop.cu@@ -81,17 +81,17 @@ static int moe_coop_sk_mode()}// Gate/up k-split for batches whose units already fit one per SM (decode: 48 units for 82 SMs on Flint): every-// unit's k-slice loop is a latency chain of one block, so it is shared by this many blocks (as long as the grid-// stays resident), the last arrival summing the fp32 partial rows (d_out scratch) in fixed order. The sum is not-// rounded to fp16 before the output rotation as the unsplit unit's output is, so results differ from it by that-// rounding. EXL3_MOE_COOP_KSPLIT_A = 1 restores the unsplit unit, bit-identical to the previous kernel+// unit's k-slice loop is a latency chain of one block, so with EXL3_MOE_COOP_KSPLIT_A = n it is shared by up to n+// blocks (as long as the grid stays resident), the last arrival summing the fp32 partial rows (d_out scratch) in+// fixed order. The sum is not rounded to fp16 before the output rotation as the unsplit unit's output is, so results+// differ from it by that rounding. Off by default (unset, 0 or 1): the unsplit unit, bit-identical to the previous kernelstatic int moe_coop_ksplit_a_mode(){static int mode = -2;if (mode == -2){const char* env = std::getenv("EXL3_MOE_COOP_KSPLIT_A");- mode = env ? atoi(env) : 3;+ mode = env ? atoi(env) : 1;}return mode;}diff --git a/tests/test_moe_coop.py b/tests/test_moe_coop.pyindex 6fc755c..b78eabd 100644--- a/tests/test_moe_coop.py+++ b/tests/test_moe_coop.py@@ -245,8 +245,19 @@ def test_odd_shapes():def test_decode_k_split():- # Flint-like batch 1: 48 gate/up units fit one per SM, so the gate/up stage shares each unit's k loop over blocks- # (fp32 partial rows) on Ampere; shared-expert merge and mixed widths on top+ # Flint-like batch 1: 48 gate/up units fit one per SM. Default: unsplit unit (per-unit grid); with+ # EXL3_MOE_COOP_KSPLIT_A=3 (see test_decode_k_split_opt_in) the gate/up stage shares each unit's k loop over+ # blocks (fp32 partial rows) on Ampere; shared-expert merge and mixed widths on toprun_case(28, 3, 3, 3, 2, H = 2048, Hi = 2048, I = 512, Ho = 2048, H_out = 2048, E = 8, topk = 6, bsz = 1)run_case(29, 4, 4, 5, 2, H = 2048, Hi = 2048, I = 512, Ho = 2048, H_out = 2048, E = 8, topk = 6, bsz = 1, shared = "gated")++def test_decode_k_split_opt_in():+ # The mode is read once per process: rerun the shape test with the k-split enabled+ if os.environ.get("EXL3_MOE_COOP_KSPLIT_A") == "3":+ pytest.skip("already running with the k-split")+ import subprocess, sys+ env = dict(os.environ, EXL3_MOE_COOP_KSPLIT_A = "3")+ r = subprocess.run([sys.executable, "-m", "pytest", "-q", f"{__file__}::test_decode_k_split"],+ env = env, capture_output = True, text = True)+ assert r.returncode == 0, r.stdout[-2000:] + r.stderr[-2000:]