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.

QSA indexer: project the row-padded block input as a view

YanissAmz763e51c3f6a7
diff --git a/exllamav3/modules/qsa_indexer.py b/exllamav3/modules/qsa_indexer.py
index 29e2401..5bfab3e 100644
--- a/exllamav3/modules/qsa_indexer.py
+++ b/exllamav3/modules/qsa_indexer.py
@@ -601,7 +601,15 @@ class QSAIndexer(Module):
npr = bt.shape[1]
page_size = layer.raw_k.shape[1]
- xc = x.contiguous()
+ # the HC mix hands the attention site a row-padded view (hc_pad_ok); q/k/v read it as is, so the indexer
+ # projection does too instead of compacting the whole block input (same bytes into the GEMM, bit-exact).
+ # EXL3_QSA_IDX_PAD=0 (read per call) goes back to the copy
+ from .quant.exl3 import _pad_view_ok, _pad_eligible
+ if not x.is_contiguous() and os.environ.get("EXL3_QSA_IDX_PAD", "1") != "0" and _pad_view_ok(x) \
+ and _pad_eligible(self.index_qk_proj, x.shape[-1], R, params):
+ xc = x
+ else:
+ xc = x.contiguous()
qk = self.index_qk_proj.forward(xc, params).view(R, (H + 1) * dk)
if bsz == 1 and 1 < seqlen <= 8 and params.get("dflash_verify") and (VERIFY_QSA_PROJ["on"] or QSA_SHADOW["on"]):
qk = qk.clone()