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.
Python amdapple-siliconcudadeepseekexl3exllamav3glminferencellmllm-inferencelocal-llmnvidiaopenai-apiquantizationqwenrocmstrix-halo
GGUF loader: per-expert slice names take the format of their stacked tensor
YanissAmzb712aa6e6a05
diff --git a/exllamav3/loader/gguf_collection.py b/exllamav3/loader/gguf_collection.pyindex 4e57d2a..632f52e 100644--- a/exllamav3/loader/gguf_collection.py+++ b/exllamav3/loader/gguf_collection.py@@ -314,3 +314,16 @@ class GGUFCollection:t = t.bfloat16()return _pad_to(t.to(dev), pad_to)raise ValueError(f"unsupported gguf type {ty} for {key}")+++def gguf_fmt(fm: dict, gname: str | None):+ """ggml format of a GGUF tensor name. A per-expert slice name 'blk.N.ffn_*_exps.eK.weight' is not in the+ file's tensor table: it takes the format of its stacked tensor 'blk.N.ffn_*_exps.weight'."""+ if not gname:+ return None+ fmt = fm.get(gname)+ if fmt is None and "_exps.e" in gname:+ base, e = (gname[:-7] if gname.endswith(".weight") else gname).rsplit(".e", 1)+ if e.isdigit():+ fmt = fm.get(base + ".weight")+ return fmtdiff --git a/exllamav3/modules/linear.py b/exllamav3/modules/linear.pyindex 7102be7..31ac6c3 100644--- a/exllamav3/modules/linear.py+++ b/exllamav3/modules/linear.py@@ -79,6 +79,7 @@ def apply_scale_grid(w: torch.Tensor, scale: torch.Tensor, block: tuple | None =+class _ForeignInner:"""Linear inner over a ForeignLinear payload (NVFP4 served as stored): the ForeignLinear kernels, Linear's interface."""@@ -682,7 +683,8 @@ class Linear(Module):return Falsegname = g.name_map.get(key + ".weight")gname = gname[0] if isinstance(gname, tuple) else gname- fmt = fm.get(gname) if gname else None+ from ..loader.gguf_collection import gguf_fmt as _gguf_fmt+ fmt = _gguf_fmt(fm, gname)if fmt is None or fmt == "fp" or fmt.startswith("unk"):return Falsefrom .foreign_linear import ForeignLineardiff --git a/tests/test_gguf_slice_format.py b/tests/test_gguf_slice_format.pynew file mode 100644index 0000000..0b99bc1--- /dev/null+++ b/tests/test_gguf_slice_format.py@@ -0,0 +1,29 @@+import importlib.util+import os++# Load the module by path: importing the exllamav3 package would build/load the CUDA extension (not needed here)+_p = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "exllamav3", "loader", "gguf_collection.py")+_spec = importlib.util.spec_from_file_location("gguf_collection_under_test_fmt", _p)+assert _spec is not None and _spec.loader is not None+_mod = importlib.util.module_from_spec(_spec)+_spec.loader.exec_module(_mod)+_gguf_fmt = _mod.gguf_fmt+++FM = {"blk.0.ffn_gate_exps.weight": "mxfp4", "blk.0.attn_q.weight": "q8_0"}+++def test_plain_name():+ assert _gguf_fmt(FM, "blk.0.attn_q.weight") == "q8_0"+++def test_expert_slice_takes_stack_format():+ assert _gguf_fmt(FM, "blk.0.ffn_gate_exps.e7.weight") == "mxfp4"+ assert _gguf_fmt(FM, "blk.0.ffn_gate_exps.e31.weight") == "mxfp4"+++def test_unknown_and_empty():+ assert _gguf_fmt(FM, "blk.0.ffn_up_exps.e3.weight") is None+ assert _gguf_fmt(FM, "blk.0.ffn_gate_exps.ex.weight") is None+ assert _gguf_fmt(FM, None) is None+ assert _gguf_fmt(FM, "") is None