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.

Decode: K7 dense projections take the exl3_dec GEMV route

YanissAmz5dd15cd410dd
diff --git a/exllamav3/exllamav3_ext/quant/exl3_dec.cu b/exllamav3/exllamav3_ext/quant/exl3_dec.cu
index 151cbad..5a543d4 100644
--- a/exllamav3/exllamav3_ext/quant/exl3_dec.cu
+++ b/exllamav3/exllamav3_ext/quant/exl3_dec.cu
@@ -1941,7 +1941,7 @@ static int env_int(const char* name, int dflt)
inline int kb2_of(double K)
{
const int kb2 = (int) (K * 2.0 + 0.5);
- TORCH_CHECK(kb2 >= 4 && kb2 <= 12 && (double) kb2 == K * 2.0, "exl3_dec: unsupported K ", K);
+ TORCH_CHECK(kb2 >= 4 && kb2 <= 14 && (double) kb2 == K * 2.0, "exl3_dec: unsupported K ", K);
return kb2;
}
@@ -1954,6 +1954,7 @@ inline int kb2_of(double K)
case 8: { constexpr int KB2 = 8; __VA_ARGS__; } break; \
case 10: { constexpr int KB2 = 10; __VA_ARGS__; } break; \
case 12: { constexpr int KB2 = 12; __VA_ARGS__; } break; \
+ case 14: { constexpr int KB2 = 14; __VA_ARGS__; } break; \
default: TORCH_CHECK(false, "exl3_dec: unsupported K*2 ", kb2); \
}
@@ -1981,6 +1982,7 @@ inline void launch_gemv_cb(int kb2, int blocks, const half* xp, const Jobs& jobs
case 8: gemv_kernel<8, CB><<<blocks, THREADS, 0, stream>>>(xp, jobs, sp, cp); break;
case 10: gemv_kernel<10, CB><<<blocks, THREADS, 0, stream>>>(xp, jobs, sp, cp); break;
case 12: gemv_kernel<12, CB><<<blocks, THREADS, 0, stream>>>(xp, jobs, sp, cp); break;
+ case 14: gemv_kernel<14, CB><<<blocks, THREADS, 0, stream>>>(xp, jobs, sp, cp); break;
default: TORCH_CHECK(false, "exl3_dec_gemv: unsupported K*2 ", kb2);
}
}
diff --git a/exllamav3/modules/quant/exl3.py b/exllamav3/modules/quant/exl3.py
index 86ff6a3..f78e870 100644
--- a/exllamav3/modules/quant/exl3.py
+++ b/exllamav3/modules/quant/exl3.py
@@ -215,6 +215,8 @@ _hip_gemv_support_cache: dict[int, bool] = {}
# fused. EXL3_DEC=0 disables them (falls back to exl3_gemv / reconstruct).
EXL3_DEC = os.environ.get("EXL3_DEC", "1") != "0"
_DEC_KB2 = (4, 5, 6, 8, 10, 12)
+# dense projections also decode K7 (attention, linear-attention and shared-expert projections of 5 bpw packs); the routed-MoE kernels stop at K6
+_DEC_KB2_DENSE = _DEC_KB2 + (14,)
DEC_SCRATCH_FLOATS = 2 << 20
_dec_workspaces: dict = {}
@@ -252,7 +254,7 @@ def dec_supported(inner) -> bool:
"""True when a LinearEXL3 can run the exl3_dec kernels (mul1 codebook, supported K, shapes)."""
return (
EXL3_DEC and bool(torch.version.hip) and hasattr(ext, "exl3_dec_gemv") and
- inner.mul1 and not inner.mcg and int(round(inner.K * 2)) in _DEC_KB2 and
+ inner.mul1 and not inner.mcg and int(round(inner.K * 2)) in _DEC_KB2_DENSE and
inner.K * 2 == int(round(inner.K * 2)) and
inner.in_features % 512 == 0 and inner.out_features % 128 == 0 and
tuple(inner.trellis.shape[:2]) == (inner.in_features // 16, inner.out_features // 16) and