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.

ROCm: build the foreign-quant dequant/GEMV kernels (Q8_0, K-quants, IQ2_XXS, NVFP4 rows); fused MoE/MLP tiers stay CUDA-only

YanissAmz1aa0f29f7aab
diff --git a/exllamav3/exllamav3_ext/bindings.cpp b/exllamav3/exllamav3_ext/bindings.cpp
index c6e7d2a..2b52c3e 100644
--- a/exllamav3/exllamav3_ext/bindings.cpp
+++ b/exllamav3/exllamav3_ext/bindings.cpp
@@ -87,6 +87,7 @@
#else
+#include "foreign_quant/fq_api.h"
#include "hgemm.cuh"
#include "rope.cuh"
#include "gdn.cuh"
@@ -560,7 +561,7 @@ PYBIND11_MODULE(TORCH_EXTENSION_NAME, m)
m.def("ngram_dequant", &ngram_dequant, "ngram_dequant");
#endif
-#if !defined(USE_ROCM)
+#if 1 // foreign-quant dequant/gemv: built on ROCm too (MoE/MLP fused tiers stay CUDA-only)
// Foreign-quant kernels (foreign_quant/*.cu): CUDA builds only (the ROCm build does not compile them).
// No env switch: they are additive (nothing upstream is replaced); Python falls back to torch when the ext
// predates them.
@@ -591,6 +592,7 @@ PYBIND11_MODULE(TORCH_EXTENSION_NAME, m)
m.def("fq_gemv_nvfp4", &fq_gemv_nvfp4, "fq_gemv_nvfp4",
py::arg("x"), py::arg("packed"), py::arg("scales"), py::arg("global_scale"), py::arg("out"),
py::arg("pair") = true);
+#if !defined(USE_ROCM)
m.def("fq_moe_iq2xxs_grouped", &fq_moe_iq2xxs_grouped, "fq_moe_iq2xxs_grouped",
py::arg("h"), py::arg("sel"), py::arg("wts"),
py::arg("up_ptrs"), py::arg("down_ptrs"),
@@ -598,6 +600,7 @@ PYBIND11_MODULE(TORCH_EXTENSION_NAME, m)
py::arg("partial"), py::arg("out"));
m.def("fq_mlp_shared_iq2xxs", &fq_mlp_shared_iq2xxs, "fq_mlp_shared_iq2xxs",
py::arg("x"), py::arg("up_packed"), py::arg("h"));
+#endif
m.def("fq_q8_scratch", &fq_q8_scratch, "fq_q8_scratch",
py::arg("dev"), py::arg("M"), py::arg("K"));
m.def("fq_quant_q8_1_rows", &fq_quant_q8_1_rows, "fq_quant_q8_1_rows",
@@ -616,6 +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)
m.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"),
@@ -637,4 +641,5 @@ PYBIND11_MODULE(TORCH_EXTENSION_NAME, m)
py::arg("gate_stride"), py::arg("up_stride"), py::arg("down_stride"),
py::arg("partial"), py::arg("out"));
#endif
+#endif
}
diff --git a/exllamav3/exllamav3_ext/build_config.py b/exllamav3/exllamav3_ext/build_config.py
index 4f705d6..1bfb3e5 100644
--- a/exllamav3/exllamav3_ext/build_config.py
+++ b/exllamav3/exllamav3_ext/build_config.py
@@ -11,6 +11,8 @@ ROCM_EXCLUDE_DIRS = {'parallel', 'comp_units', 'foreign_quant'}
# GEMV instances and EXL3 tile-quantizer K1..K8 instances are required by the HIP runtime/converter.
# 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',
'quant/comp_units/exl3_gemv_int8_inst_',
'quant/comp_units/quantize_tiles_inst_',
)