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.

GGUF dense: dequantize the token embedding on the GPU

YanissAmz44843778bc23
diff --git a/exllamav3/architecture/gguf_dense.py b/exllamav3/architecture/gguf_dense.py
index 5389f11..6be66a9 100644
--- a/exllamav3/architecture/gguf_dense.py
+++ b/exllamav3/architecture/gguf_dense.py
@@ -76,8 +76,11 @@ class GGUFDenseConfig(Config):
if fmt == "fp":
return
fl = ForeignLinear(self, "model.embed_tokens", K, N, fmt)
- fl.load(torch.device("cpu"))
- w = torch.cat([fl._dequant_rows(i, min(4096, N - i)) for i in range(0, N, 4096)])
+ # the K-quant / Q8_0 dequant kernels are device code: run them on the GPU, keep the table on the host
+ dev = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
+ fl.load(dev)
+ w = torch.cat([fl._dequant_rows(i, min(4096, N - i)).cpu() for i in range(0, N, 4096)])
+ fl.unload()
self.gguf.new_tensors = {"model.embed_tokens.weight": w}
def get_tensor_name_fixes(self):