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
Build grouped KQ MoE kernels on ROCm; torch shared-gate fallback on HIP
YanissAmza3dbd132a987
diff --git a/exllamav3/exllamav3_ext/bindings.cpp b/exllamav3/exllamav3_ext/bindings.cppindex be6d31c..91ca080 100644--- a/exllamav3/exllamav3_ext/bindings.cpp+++ b/exllamav3/exllamav3_ext/bindings.cpp@@ -619,7 +619,7 @@ PYBIND11_MODULE(TORCH_EXTENSION_NAME, m)py::arg("qb"), py::arg("packed"), py::arg("out"));m.def("fq_gemv_iq4_xs_q8", &fq_gemv_iq4_xs_q8, "fq_gemv_iq4_xs_q8",py::arg("qb"), py::arg("packed"), py::arg("out"));-#if !defined(USE_ROCM)+// grouped KQ/IQ4_XS decode MoE (fq_moe_kq.cu): portable dp4a kernels, built on ROCm toom.def("fq_moe_q4k_grouped_q8", &fq_moe_q4k_grouped_q8, "fq_moe_q4k_grouped_q8",py::arg("h"), py::arg("sel"), py::arg("wts"),py::arg("gate_ptrs"), py::arg("up_ptrs"), py::arg("down_ptrs"),@@ -647,5 +647,4 @@ PYBIND11_MODULE(TORCH_EXTENSION_NAME, m)py::arg("fmt_ug"), py::arg("fmt_down"),py::arg("partial"), py::arg("out"));#endif-#endif}diff --git a/exllamav3/exllamav3_ext/build_config.py b/exllamav3/exllamav3_ext/build_config.pyindex 1bfb3e5..d5997bf 100644--- a/exllamav3/exllamav3_ext/build_config.py+++ b/exllamav3/exllamav3_ext/build_config.py@@ -12,7 +12,7 @@ ROCM_EXCLUDE_DIRS = {'parallel', 'comp_units', 'foreign_quant'}# Other comp_units remain excluded because they implement unported MoE/GEMM paths.ROCM_ALLOW_PREFIXES = ('foreign_quant/fq_dequant.cu', 'foreign_quant/fq_dequant_kq.cu', 'foreign_quant/fq_gemv.cu',- 'foreign_quant/fq_gemv_kq.cu', 'foreign_quant/fq_gemv_q8.cu', 'foreign_quant/fq_gemm.cu',+ 'foreign_quant/fq_gemv_kq.cu', 'foreign_quant/fq_gemv_q8.cu', 'foreign_quant/fq_moe_kq.cu', 'foreign_quant/fq_gemm.cu','quant/comp_units/exl3_gemv_int8_inst_','quant/comp_units/quantize_tiles_inst_',)diff --git a/exllamav3/modules/block_sparse_mlp.py b/exllamav3/modules/block_sparse_mlp.pyindex 2f8aa26..a945970 100644--- a/exllamav3/modules/block_sparse_mlp.py+++ b/exllamav3/modules/block_sparse_mlp.py@@ -1837,7 +1837,11 @@ class BlockSparseMLP(BlockSparseMLP_CPU, Module):if self.shared_experts is not None:se_params = {**params, "moe_valu": True} if _MOE_VALU else paramsse = self.shared_experts.forward(x, se_params)- if self.shared_gate is not None:+ if self.shared_gate is not None and torch.version.hip:+ # ROCm add_sigmoid_gate_proj takes a float shared-expert output: same math in torch+ g = torch.sigmoid((x.to(torch.float) @ self.shared_gate.inner.weight.to(torch.float)))+ final_hidden_states = final_hidden_states + se.to(torch.float) * g+ elif self.shared_gate is not None:ext.add_sigmoid_gate_proj(se, x, final_hidden_states,self.shared_gate.inner.weight)else: