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
Add opt-in wide launches for K6 and K8 MoE (#106)
razeth19d6fded97c3
diff --git a/exllamav3/exllamav3_ext/quant/exl3_moe_fused9.cu b/exllamav3/exllamav3_ext/quant/exl3_moe_fused9.cuindex c6da5e1..ee7fb56 100644--- a/exllamav3/exllamav3_ext/quant/exl3_moe_fused9.cu+++ b/exllamav3/exllamav3_ext/quant/exl3_moe_fused9.cu@@ -103,6 +103,16 @@ void mf9_half(at::Tensor& x, const at::Tensor& fn, const at::Tensor& fn_scale, cTORCH_CHECK(!timing, "mf9: wide launches (rows 5..8) have no timing build");const int64_t vv = variant & 0x1f0000;TORCH_CHECK(vv == 0x160000, "mf9: wide launches (rows 5..8) exist for the default variant 0x160000 (six stage launches) only");+ // K6/K8 wide experiment: native, six-stage, no ablations.+ if (Match7<mf::QwenK6S8>::eq(D, H, LR, NEXP, TOPK, INTER, RB, SB) ||+ Match7<mf::SmallK6S8>::eq(D, H, LR, NEXP, TOPK, INTER, RB, SB)) {+ TORCH_CHECK(native == 1 && (variant & ~0x1000LL) == 0x160000,+ "mf9: wide K6S8 requires native six-stage launches without ablations");+ if (Match7<mf::QwenK6S8>::eq(D, H, LR, NEXP, TOPK, INTER, RB, SB))+ L7(mf::Wide<mf::QwenK6S8>, false, 4, 1);+ else L7(mf::Wide<mf::SmallK6S8>, false, 4, 1);+ return;+ }#define XW(SH) if (Match7<mf::Wide<SH>>::eq(D, H, LR, NEXP, TOPK, INTER, RB, SB)) { L7(mf::Wide<SH>, false, 4, 1); return; }XW(mf::QwenShape) XW(mf::SmallTestShape) XW(mf::QwenK3S4) XW(mf::QwenK3S5) XW(mf::QwenK4S4) XW(mf::QwenK4S5)XW(mf::SmallK3S4) XW(mf::SmallK3S5) XW(mf::SmallK4S4) XW(mf::SmallK4S5)diff --git a/exllamav3/modules/moe_fused.py b/exllamav3/modules/moe_fused.pyindex 8a2104f..ae997c5 100644--- a/exllamav3/modules/moe_fused.py+++ b/exllamav3/modules/moe_fused.py@@ -73,6 +73,12 @@ def _rep(tr: torch.Tensor) -> torch.Tensor:return tr.reshape(kt, nt // 2, 2 * nw).permute(1, 0, 2).contiguous()+# (D, H, LR, NEXP, TOPK, INTER, RB, SB) of the wide K6S8 instantiations: QwenK6S8 and SmallK6S8 in exl3_moe_fused_idx.h.+# tests/test_moe_fused_wide_k6k8_cpu.py reads this constant and checks it against those two structs.+K6S8_WIDE_SHAPES = ((2560, 4, 320, 512, 10, 640, 6, 8),+ (256, 4, 32, 64, 4, 128, 6, 8))++def _route_trace(fh, rows: int) -> None:"""EXL3_ROUTE_TRACE (diagnostic, see block_sparse_mlp._RouteTrace): record the experts the fused half-layer selected this launch,read back from the kernel's own selection record (seldbg), so the trace is what the kernel really ran."""@@ -214,9 +220,14 @@ class FusedMoEHalf:return lim >= 8 and rows <= ROW_INV_MAX_ROWS and bool(params.get("dflash_verify"))def _wide_ok(self) -> bool:- """The one-launch 5..8 row path exists for this block: mf9 at the default variant 0x160000 (six stage launches), native layout, no timing. The wide instantiations cover K2..K5 only (the K6 drafter layer takes the split path)."""- v = MF9["variant"] & 0x1f0000- return bool(self.native and self.RB <= 5 and self.SB <= 5 and hasattr(torch.ops, "mf9") and hasattr(torch.ops.mf9, "half") and v == 0x160000 and not MF9["timing"])+ """Native wide launches; K6/K8 requires its own experimental opt-in."""+ v = MF9["variant"]+ k6s8 = (os.environ.get("EXL3_MOE_R8_K6S8", "0") == "1"+ and self.shape in K6S8_WIDE_SHAPES+ and (v & ~0x1000) == 0x160000)+ return bool(self.native and ((self.RB <= 5 and self.SB <= 5) or k6s8)+ and hasattr(torch.ops, "mf9") and hasattr(torch.ops.mf9, "half")+ and (v & 0x1f0000) == 0x160000 and not MF9["timing"])def __call__(self, x: torch.Tensor) -> torch.Tensor:"""x (b, s, H, D) fp32 residual stack, updated in place and returned."""diff --git a/tests/moe_fused/moe8_bounds.cpp b/tests/moe_fused/moe8_bounds.cppindex 01ce839..c1784a5 100644--- a/tests/moe_fused/moe8_bounds.cpp+++ b/tests/moe_fused/moe8_bounds.cpp@@ -183,6 +183,8 @@ template <class S> void prove(const char* name)int main(){prove<QwenShape>("Qwen"); prove<QwenK3S4>("QwenK3S4"); prove<QwenK4S5>("QwenK4S5"); prove<SmallTestShape>("SmallTest"); prove<SmallK4S4>("SmallK4S4"); prove<SmallK3S5>("SmallK3S5");+ prove<Wide<QwenK6S8>>("Wide QwenK6S8");+ prove<Wide<SmallK6S8>>("Wide SmallK6S8");printf("checks %lld fails %lld\n", checks, fails);return fails ? 1 : 0;}diff --git a/tests/moe_fused/moe8_k6k8_synth.py b/tests/moe_fused/moe8_k6k8_synth.pynew file mode 100644index 0000000..7c49b54--- /dev/null+++ b/tests/moe_fused/moe8_k6k8_synth.py@@ -0,0 +1,153 @@+"""Check K6/K8 wide launches on synthetic weights. Requires a ROCm GPU.++SHAPE=small or real; GS=0 or 1; SEED sets the random seed.+This check also measures wide and split launch times.+"""+import os, sys, torch+TREE = os.environ.get('EXL3_TREE', os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))); sys.path.insert(0, TREE)+import exllamav3+from exllamav3.ext import exllamav3_ext as ext+assert exllamav3.__file__.startswith(TREE)+RBSB = {'k6s8': (6, 8), 'k24': (2, 4), 'k3s4': (3, 4), 'k3s5': (3, 5), 'k4s4': (4, 4), 'k4s5': (4, 5)}[os.environ.get('SYNTH', 'k6s8')]+KIND = os.environ.get('SHAPE', 'small')+D, H, LR, NEXP, TOPK, INTER = (256, 4, 32, 64, 4, 128) if KIND == 'small' else (2560, 4, 320, 512, 10, 640)+RB, SB = RBSB+SHAPE = (D, H, LR, NEXP, TOPK, INTER, RB, SB)+assert ext.exl3_moe_fused_supported(*SHAPE), SHAPE+VAR = 0x161000+SEED = int(os.environ.get('SEED', '1234'))+GS = os.environ.get('GS', '1') == '1'+MR = LR + H; D4 = D // 4+dev = 'cuda'+g = torch.Generator(device='cpu'); g.manual_seed(SEED)+def ri(n): return torch.randint(-128, 128, (n,), dtype=torch.int8, generator=g).to(dev)+fn = ri(MR * H * D); upt = ri(H * D4 * LR * 4)+fn_scale = (torch.rand(MR * (H*D//128 if GS else 1), generator=g) * 0.02 + 0.001).to(dev); up_scale = (torch.rand(H * D * ((LR+63)//64 if GS else 1), generator=g) * 0.02 + 0.001).to(dev)+w_h = (torch.randn(H * D, generator=g) * 0.5 + 1).half().to(dev)+router = (torch.randn(NEXP * D, generator=g) * 0.1).half().to(dev); sgate = (torch.randn(D, generator=g) * 0.1).half().to(dev)+def mat(k, n, bits): return torch.randint(-32768, 32768, (k // 16, n // 16, 16 * bits), dtype=torch.int16, generator=g).to(dev)+def vec(n): return (torch.randn(n, generator=g) * 0.3 + 1).half().to(dev)+units = []+for u in range(NEXP + 1):+ b = SB if u == NEXP else RB+ units.append((mat(D, INTER, b), mat(D, INTER, b), mat(INTER, D, b), [vec(D), vec(INTER), vec(D), vec(INTER), vec(INTER), vec(D)]))+wt, keep = [], []+for gt, ut, dt, _ in units: wt += [gt.data_ptr(), ut.data_ptr(), dt.data_ptr()]+svt = [v.data_ptr() for *_, sv in units for v in sv]+wt = torch.tensor(wt, dtype=torch.int64, device=dev); svt = torch.tensor(svt, dtype=torch.int64, device=dev)+ro = [fn, upt, fn_scale, up_scale, w_h, router, sgate, wt, svt] + [m for u in units for m in u[:3]] + [v for u in units for v in u[3]]+ro_ref = [t.clone() for t in ro]+off = ext.exl3_moe_fused_ws_offsets(*SHAPE); TAIL = 1 << 20+ws = torch.full((off[-1] + TAIL,), 0xAB, dtype=torch.uint8, device=dev); ws[:256] = 0+print('shape', SHAPE, KIND, 'ws bytes', off[-1], flush=True)+PAD = 4096+def launch(x, variant=VAR):+ """x (R, H, D) fp32 -> output copy; checks canaries and ctl."""+ 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, *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'+ c = ws[:12].view(torch.int32).tolist(); assert c == [0, 0, 0], ('ctl after launch (bar, done, err)', c)+ return xv.view(R, H, D).clone()+def split(x):+ R = x.shape[0]+ return torch.cat([launch(x[lo:lo + 4]) for lo in range(0, R, 4)])+def ngroups_max(x): # largest number of rows sharing one expert (from the single-row selections) is not exported; report via seldbg of the wide launch instead+ return None+torch.manual_seed(SEED)+base = torch.randn(8, H, D, device=dev)+cases = {+ 'random': lambda R: base[:R].clone(),+ 'dup_all': lambda R: base[:1].repeat(R, 1, 1).contiguous(), # every group has R rows+ 'dup_pairs': lambda R: torch.stack([base[i // 2] for i in range(R)]).contiguous(),+ 'dup_5_of_R': lambda R: torch.stack([base[0] if i < 5 else base[i] for i in range(R)]).contiguous(),+}+nchecks = 0+for name, mk in cases.items():+ for R in range(5, 9):+ x = mk(R)+ w = launch(x)+ assert bool(torch.isfinite(w).all()), f'non-finite {name} R={R}'+ assert not torch.equal(w, x), 'output unchanged'+ s = split(x)+ assert torch.equal(w, s), f'{name} R={R}: wide != 4+{R-4} split ({(w - s).abs().max().item()})'+ singles = torch.cat([launch(x[i:i + 1]) for i in range(R)])+ assert torch.equal(w, singles), f'{name} R={R}: wide != single rows'+ # a prefix of the rows in a smaller wide launch / 4-row launch gives the same rows (row independence)+ if R > 5: assert torch.equal(launch(x[:R - 1])[:R - 1], w[:R - 1]), f'{name} R={R}: R-1 rows differ'+ assert torch.equal(launch(x[:4]), w[:4]), f'{name} R={R}: first 4 rows differ from the 4-row launch'+ nchecks += 1+ print(f'{name}: R=5..8 wide == 4-row split == single rows: IDENTICAL', flush=True)+for k in range(5): assert torch.equal(launch(base[:7]), launch(base[:7])), 'repeat differs'+print('repeats identical', flush=True)+xn = torch.full((8, H, D), float('nan'), device=dev); launch(xn); launch(xn[:5])+print('all-NaN rows: launched, canaries intact, ctl zero', flush=True)+# 1..4 rows still go through the unchanged kernels and match the base path+for R in (1, 2, 3, 4):+ a = launch(base[:R]); b = torch.cat([launch(base[i:i + 1]) for i in range(R)])+ assert torch.equal(a, b), 'small-row regression'+print('SYNTH8 OK', SHAPE, KIND, 'cases', nchecks, flush=True)++# Exercise the actual Python dispatcher, including two batches of four rows.+from types import SimpleNamespace+from exllamav3.modules import moe_fused as mf+obj = object.__new__(mf.FusedMoEHalf)+obj.native, obj.RB, obj.SB, obj.shape = True, RB, SB, SHAPE+obj.gr = SimpleNamespace(q8_set=lambda: (fn, fn_scale, upt, up_scale), w_h=w_h, rms_eps=1e-6)+obj.router, obj.sgate, obj.wt, obj.svt, obj.ws = router, sgate, wt, svt, ws+mf.R8['on'] = True+mf.MF9.update(variant=0x160000, timing=0, tk2=True)+for R in (5, 6, 7, 8):+ x = base[:R].view(2, 4, H, D) if R == 8 else base[:R].view(1, R, H, D)+ os.environ['EXL3_MOE_R8_K6S8'] = '0'+ assert not obj._wide_ok()+ a = obj(x.clone()).clone()+ os.environ['EXL3_MOE_R8_K6S8'] = '1'+ assert obj._wide_ok()+ before = mf.R8['calls']+ b = obj(x.clone())+ torch.cuda.synchronize()+ assert mf.R8['calls'] == before + 1 and torch.equal(a, b), 'dispatch parity failed'+for R in (5, 8):+ a = launch(base[:R], 0x160000)+ b = torch.cat([launch(base[i:min(i+4, R)], 0x160000) for i in range(0, R, 4)])+ assert torch.equal(a, b), 'plain top-k wide/split mismatch'+print('PASS: Python dispatch, batch shape, and both top-k modes', flush=True)++# Reset identical inputs BEFORE each timed interval; do not repeatedly feed+# the output back as the next input. Alternate arm order to reduce drift.+import statistics, json+for label in ('random', 'dup_all'):+ for R in (5, 6, 7, 8):+ x = cases[label](R).view(1, R, H, D)+ work = x.clone()+ def raw(z):+ torch.ops.mf9.half(z, fn, fn_scale, upt, up_scale, w_h, router,+ sgate, wt, svt, ws, 1e-6, 1, 0, VAR, *SHAPE)+ def measure(wide):+ work.copy_(x)+ torch.cuda.synchronize()+ a, b = torch.cuda.Event(enable_timing=True), torch.cuda.Event(enable_timing=True)+ a.record()+ if wide:+ raw(work)+ else:+ raw(work[:, :4]); raw(work[:, 4:])+ b.record(); b.synchronize()+ return a.elapsed_time(b)+ for _ in range(3):+ measure(False); measure(True)+ samples = {False: [], True: []}+ for repeat in range(16):+ for wide in ((False, True) if repeat % 2 == 0 else (True, False)):+ samples[wide].append(measure(wide))+ old, new = (statistics.median(samples[k]) for k in (False, True))+ print('BENCH:', json.dumps(dict(shape=KIND, gs=GS, seed=SEED, case=label,+ rows=R, split_ms=old, wide_ms=new, speedup=old/new)), flush=True)+for a, b in zip(ro, ro_ref):+ assert torch.equal(a, b), 'read-only input modified'+assert bool((ws[off[-1]:] == 0xAB).all()), 'workspace overrun'+print('PASS: wide K6/K8 synthetic parity, guards, repeatability, dispatch and timing', flush=True)diff --git a/tests/test_moe_fused_wide_k6k8_cpu.py b/tests/test_moe_fused_wide_k6k8_cpu.pynew file mode 100644index 0000000..b0e0175--- /dev/null+++ b/tests/test_moe_fused_wide_k6k8_cpu.py@@ -0,0 +1,92 @@+"""Check wide-launch eligibility without a GPU."""+import ast+import os+import re+import shutil+import subprocess+from pathlib import Path+from types import SimpleNamespace as NS++import pytest++ROOT = Path(__file__).resolve().parents[1]+++def _module_tree():+ return ast.parse((ROOT / "exllamav3/modules/moe_fused.py").read_text())+++def _shapes_constant():+ """The K6S8_WIDE_SHAPES assignment of moe_fused.py, evaluated without importing torch."""+ node = next(n for n in _module_tree().body+ if isinstance(n, ast.Assign) and any(getattr(t, "id", "") == "K6S8_WIDE_SHAPES" for t in n.targets))+ return ast.literal_eval(node.value)+++K6S8_WIDE_SHAPES = _shapes_constant()+++def policy():+ tree = _module_tree()+ cls = next(n for n in tree.body if isinstance(n, ast.ClassDef) and n.name == "FusedMoEHalf")+ fn = next(n for n in cls.body if isinstance(n, ast.FunctionDef) and n.name == "_wide_ok")+ state = {"variant": 0x160000, "timing": 0}+ ns = {"os": os, "MF9": state, "torch": NS(ops=NS(mf9=NS(half=True))), "K6S8_WIDE_SHAPES": K6S8_WIDE_SHAPES}+ exec(compile(ast.Module(body=[fn], type_ignores=[]), "wide-policy", "exec"), ns)+ return ns["_wide_ok"], state+++def test_shape_constant_matches_the_cpp_structs():+ """K6S8_WIDE_SHAPES must list exactly the shapes that exl3_moe_fused_idx.h instantiates as K6S8."""+ header = (ROOT / "exllamav3/exllamav3_ext/quant/exl3_moe_fused_idx.h").read_text()++ def fields(name):+ m = re.search(r"struct %s\s*(?::\s*(\w+)\s*)?\{([^}]*)\}" % name, header)+ assert m, name+ vals = dict((k, int(v)) for k, v in re.findall(r"\b(\w+)\s*=\s*(\d+)", m.group(2)))+ if m.group(1):+ vals = {**fields(m.group(1)), **vals}+ return vals++ keys = ("D", "H", "LR", "NEXP", "TOPK", "INTER", "RB", "SB")+ want = {tuple(fields(n)[k] for k in keys) for n in ("QwenK6S8", "SmallK6S8")}+ assert want == set(K6S8_WIDE_SHAPES)++[email protected](shutil.which("g++") is None, reason="needs g++")+def test_index_arithmetic_has_no_out_of_bounds_access(tmp_path):+ """Builds tests/moe_fused/moe8_bounds.cpp with ASan and UBSan in a temporary directory and runs it."""+ exe = tmp_path / "moe8-bounds"+ subprocess.run(["g++", "-O1", "-g", "-std=c++17", "-fsanitize=address,undefined", "-fno-sanitize-recover=all",+ f"-I{ROOT / 'exllamav3/exllamav3_ext/quant'}", str(ROOT / "tests/moe_fused/moe8_bounds.cpp"),+ "-o", str(exe)], check=True)+ subprocess.run([str(exe)], check=True)++[email protected]("shape", K6S8_WIDE_SHAPES)+def test_wide_k6k8_requires_supported_settings(monkeypatch, shape):+ fn, state = policy()+ obj = NS(native=True, RB=6, SB=8, shape=shape)+ monkeypatch.delenv("EXL3_MOE_R8_K6S8", raising=False)+ assert not fn(obj)+ monkeypatch.setenv("EXL3_MOE_R8_K6S8", "1")+ for variant in (0x160000, 0x161000):+ state["variant"] = variant+ assert fn(obj)+ for variant in (0, 0x60000, 0x160100):+ state["variant"] = variant+ assert not fn(obj)+ state.update(variant=0x160000, timing=1)+ assert not fn(obj)+ state["timing"] = 0+ obj.native = False+ assert not fn(obj)+ obj.native = True+ obj.shape = (512, 4, 32, 64, 4, 128, 6, 8)+ assert not fn(obj)+++def test_existing_low_bit_path_needs_no_new_setting(monkeypatch):+ fn, _ = policy()+ monkeypatch.delenv("EXL3_MOE_R8_K6S8", raising=False)+ assert fn(NS(native=True, RB=4, SB=5, shape=()))diff --git a/tools/qwen/WIDE_K6K8.md b/tools/qwen/WIDE_K6K8.mdnew file mode 100644index 0000000..fd6cc2d--- /dev/null+++ b/tools/qwen/WIDE_K6K8.md@@ -0,0 +1,115 @@+# Experimental wide K6/K8 launches++This change requires the K6/K8 fused MoE patch. It runs five to eight rows+in one launch. Without the setting, the dispatcher splits these rows into+groups of at most four. Existing low-bit paths do not change.++Use the settings in K6K8.md. Also set EXL3_MOE_R8_K6S8=1 before startup.+The path requires native layout and the six-stage variant, without timing+or other experimental variants. Rebuild the extension before use.++## Checks++Run from the repository root:++```sh+python -m pytest --noconftest -q tests/test_moe_fused_wide_k6k8_cpu.py+```++The test file also builds `tests/moe_fused/moe8_bounds.cpp` with ASan and+UBSan in a pytest temporary directory and runs it (it is skipped when g++ is+missing). It checks that `K6S8_WIDE_SHAPES` in `moe_fused.py` is the list of+K6S8 shapes in `exl3_moe_fused_idx.h`.++On an idle ROCm GPU, with the built extension:++```sh+for shape in small real; do+ for gs in 0 1; do+ for seed in 1234 5678; do+ SHAPE="$shape" GS="$gs" SEED="$seed" python tests/moe_fused/moe8_k6k8_synth.py+ done+ done+done+```++The synthetic check requires exact equality between wide and split outputs.+It checks repeated calls, duplicate rows, batch reshape, buffer bounds,+and both top-k modes. It also measures wide and split launch times.+It does not stop services or load a model.++## Measured on gfx1151 (this revision)++Synthetic weights, `tests/moe_fused/moe8_k6k8_synth.py`, two seeds and both+group-scale settings, mean launch time. Wide and split outputs were bit-identical in all 16 runs.+Real Qwen shape (2560 wide, 512 experts, top 10):++| Expert selection | Rows | Split (ms) | Wide (ms) | Wide speedup |+| --- | ---: | ---: | ---: | ---: |+| random | 5 | 1.177 | 1.056 | 1.11x |+| random | 6 | 1.361 | 1.234 | 1.10x |+| random | 7 | 1.536 | 1.403 | 1.09x |+| random | 8 | 1.713 | 1.574 | 1.09x |+| same for all rows | 5 | 0.667 | 0.444 | 1.50x |+| same for all rows | 6 | 0.684 | 0.475 | 1.44x |+| same for all rows | 7 | 0.703 | 0.508 | 1.39x |+| same for all rows | 8 | 0.720 | 0.496 | 1.45x |++Small test shape:++| Expert selection | Rows | Split (ms) | Wide (ms) | Wide speedup |+| --- | ---: | ---: | ---: | ---: |+| random | 5 | 0.084 | 0.059 | 1.41x |+| random | 6 | 0.088 | 0.064 | 1.38x |+| random | 7 | 0.094 | 0.069 | 1.35x |+| random | 8 | 0.098 | 0.073 | 1.34x |+| same for all rows | 5 | 0.078 | 0.054 | 1.45x |+| same for all rows | 6 | 0.081 | 0.057 | 1.42x |+| same for all rows | 7 | 0.085 | 0.059 | 1.43x |+| same for all rows | 8 | 0.087 | 0.062 | 1.40x |++Wide was faster than split in all 32 configurations, so nothing needs to be+excluded by row count. When the rows pick different experts, the gain on the+real shape is 7 to 13 percent; when they share their experts it is 39 to 51 percent.++Full model (6.05 bpw pack, 4K and 32K context, fused K6/K8 enabled, only+`EXL3_MOE_R8_K6S8` added): greedy text and every top-10 log-probability of 8+prompts are bit-identical to the split path (1843 positions), so the numerical+difference to the unfused path discussed in K6K8.md is the same with and without+this change. Decode median 16.6 against 16.4 tokens/s at 4K and 17.0 against+16.6 at 32K; at this sample size that is within noise.++Build: with its prerequisite the extension grows from 134.66 MB (base) to 137.29 MB,+of which this change adds about 1.1 MB over the prerequisite alone (136.20 MB); a full+build took 517 s against 469 s for the prerequisite alone (three parallel jobs, machine not idle).++Registers and spills (hipcc `-Rpass-analysis=kernel-resource-usage`, gfx1151).+The wide launch uses the six stage kernels (`moe_fused9s_kernel`, stage 0 to 5):++| Kernel | VGPRs per stage 0 to 5 | Spilled VGPRs | Waves/SIMD |+| --- | --- | ---: | ---: |+| `Wide<QwenK6S8>` | 183, 192, 163, 190, 179, 29 | 0 in all six | 8 |+| `Wide<SmallK6S8>` | 101, 154, 41, 135, 123, 29 | 0 in all six | 9 to 16 |+| for comparison `Wide<QwenShape>` (K4/K4) | 183, 192, 163, 187, 161, 29 | 0 | 8 |++The one-kernel variants are not used by the wide path (see the comment in+`exl3_moe_fused9.cu`). For the record, `moe_fused9_kernel<Wide<QwenK6S8>>`+uses 232 VGPRs without spills, and `moe_fused9o_kernel<Wide<QwenK6S8>>` uses+192 VGPRs and spills 20 (64 bytes per lane of scratch); the same variant for+K4/K4 spills 3. No kernel that existed before this change changed its+register or spill count.++## Earlier hardware results++The prototype ran on an EVO-X2 with 128 GB RAM and gfx1151, using the local+Qwen3.8 Flash-Next EXL3 pack labelled 6.05 bpw. The full-model comparison+changed only EXL3_MOE_R8_K6S8. Other local optimizations remained enabled.+Code throughput increased about 3.6%, explanation about 1%, and story+about 0.6%. Concurrent throughput increased about 5%.+A greedy code case changed from 45.72 to 48.61 tokens/s. Tested token IDs+matched. These are historical observations from the prototype, not GPU+validation of the rebased PR. They do not resolve the numerical differences+between fused and unfused MoE described in K6K8.md.++Repeat GPU and full-model checks on this revision before merge.+Use tools/bench.sh with the same machine and command for each comparison.