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.

qdec.hip TQ: fast path also for 4-column V runs (q_len 3..8); extra splits only for one q tile

YanissAmz5413e67b4169
diff --git a/exllamav3/modules/attention_fn/qdec.hip b/exllamav3/modules/attention_fn/qdec.hip
index 0bded11..50c3a70 100644
--- a/exllamav3/modules/attention_fn/qdec.hip
+++ b/exllamav3/modules/attention_fn/qdec.hip
@@ -118,13 +118,13 @@ template<int B> __device__ __forceinline__ u32 dequant2_tq(u32 raw_m, u32 s2, co
// TQ fast path (TQF): instead of rebuilding fp16 (1024 + raw) pairs from the bit planes, build for every 8 values a pair of index words
// ze / zo whose byte m is the LDS byte address (2 * raw) of the value at position 2m / 2m + 1, then one bfe + one u16 table read per
// value. Same values, same rounding (codebook entry * fp16 scale) as the generic TQ path, so the output is bit-identical.
-// Inputs: w = 4-bit plane word (value p at bits 4p), y = low plane field(s) of the same 8 values: B = 6 -> 2-bit fields, value p at
+// (DTW = 4 runs: only bytes 0, 1 of ze / zo are used.) Inputs: w = 4-bit plane word (value p at bits 4p), y = low plane field(s) of the same 8 values: B = 6 -> 2-bit fields, value p at
// bits 2p + 16 * KH (KH = 1 for the upper half of a 32-bit plane word); B = 5 -> 1-bit fields, value p at bit p + 8 * KK.
// raw = nib << (B - 4) | field, so address = nib << (B - 3) | field << 1.
#ifndef TQF_OFF
#define TQF_OFF 0
#endif
-#define TQF (TQ && !TQF_OFF && (KB == 5 || KB == 6) && (VB == 5 || VB == 6) && DTW == 8)
+#define TQF (TQ && !TQF_OFF && (KB == 5 || KB == 6) && (VB == 5 || VB == 6) && (DTW == 8 || DTW == 4))
template<int B, int K> __device__ __forceinline__ void zbuild(u32 w, u32 y, u32& ze, u32& zo)
{
if (B == 6) {
diff --git a/exllamav3/modules/attention_fn/qdec_hip.py b/exllamav3/modules/attention_fn/qdec_hip.py
index 636c1de..9ce5ff7 100644
--- a/exllamav3/modules/attention_fn/qdec_hip.py
+++ b/exllamav3/modules/attention_fn/qdec_hip.py
@@ -148,7 +148,7 @@ def cu_count(device):
def num_splits(cfg, device, programs, max_k_len):
if os.environ.get("EXL3_QDEC_HIP_SPL"):
return int(os.environ["EXL3_QDEC_HIP_SPL"])
- waves = int(os.environ.get("EXL3_QDEC_HIP_WAVES", "0")) or cu_count(device) * (16 if cfg.get("tq") else 12) # tq: 4 waves per SIMD, its decode keeps the V loads in flight
+ waves = int(os.environ.get("EXL3_QDEC_HIP_WAVES", "0")) or cu_count(device) * (16 if cfg.get("tq") and cfg["qlen"] * (cfg["nqh"] // cfg["nkv"]) <= 16 else 12) # tq, one q tile: 4 waves per SIMD (its V loads stay in flight)
return max(1, min(-(-waves // (programs * cfg["nw"])), -(-max_k_len // 16 // cfg["nw"]), 128))