Commit 522d6fdd4 for llama.cpp
commit 522d6fdd447c4dcf1169f918ae94481b1498be08
Author: Javier Argomedo <79397619+diabluz@users.noreply.github.com>
Date: Wed Nov 25 09:36:02 2026 +0100
deepseek41 : read quantized indexer K in place when fused_idx is set (#32795)
Indexer K is a strided view of the kv pool; with fused_idx the fused
indexer reads it through strides and supports quantized types, so the
F32 cast was a pure extra copy per ubatch: PP/TG +2..+15% by depth,
VRAM unchanged. Quantized K now scores through the MMA kernel (like
f16 caches); deep greedy A/B shows only 0.02-0.13-nat near-tie swaps,
paired PPL < 0.1% with no direction.
Co-authored-by: diabluz <diabluz@users.noreply.github.com>
diff --git a/src/models/deepseek41.cpp b/src/models/deepseek41.cpp
index e481cbd1d..c9c00b885 100644
--- a/src/models/deepseek41.cpp
+++ b/src/models/deepseek41.cpp
@@ -536,7 +536,7 @@ ggml_tensor * llama_model_deepseek41::graph::build_attention41(
comp_all->nb[1], comp_all->nb[2], comp_all->nb[3], ggml_row_size(comp_all->type, n_embd_head));
// the fused indexer reads the strided view in place, the unfused path needs it contiguous; CUDA has no same-type copy of quantized views, so dequantize them
const bool fused_idx = sparse && ci.kq_mask->type == GGML_TYPE_F16;
- if (ggml_is_quantized(ik->type)) {
+ if (ggml_is_quantized(ik->type) && !fused_idx) {
ik = ggml_cast(ctx0, ik, GGML_TYPE_F32);
} else if (!fused_idx) {
ik = ggml_cont(ctx0, ik);