From 01f8845bf30d89fff293c7bd50187bc59d9d53ea Mon Sep 17 00:00:00 2001 From: City <125218114+city96@users.noreply.github.com> Date: Mon, 1 Dec 2025 01:32:43 +0100 Subject: [PATCH 1/2] Add VL version of Qwen3 4B as valid arch According to #361 the thinking/abliterated versions work even though the model wasn't trained with them, maybe the vision one does too. Does not have mmproj support, since nothing uses that atm. --- loader.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/loader.py b/loader.py index a81f37f..72dd010 100644 --- a/loader.py +++ b/loader.py @@ -10,7 +10,7 @@ from .ops import GGMLTensor from .dequant import is_quantized, dequantize_tensor IMG_ARCH_LIST = {"flux", "sd1", "sdxl", "sd3", "aura", "hidream", "cosmos", "ltxv", "hyvid", "wan", "lumina2", "qwen_image"} -TXT_ARCH_LIST = {"t5", "t5encoder", "llama", "qwen2vl", "qwen3"} +TXT_ARCH_LIST = {"t5", "t5encoder", "llama", "qwen2vl", "qwen3", "qwen3vl"} VIS_TYPE_LIST = {"clip-vision", "mmproj"} def get_orig_shape(reader, tensor_name): @@ -381,7 +381,7 @@ def gguf_clip_loader(path): logging.warning(f"Dequantizing {temb_key} to prevent runtime OOM.") sd[temb_key] = dequantize_tensor(sd[temb_key], dtype=torch.float16) sd = sd_map_replace(sd, T5_SD_MAP) - elif arch in {"llama", "qwen2vl", "qwen3"}: + elif arch in {"llama", "qwen2vl", "qwen3", "qwen3vl"}: # TODO: pass model_options["vocab_size"] to loader somehow temb_key = "token_embd.weight" if temb_key in sd and sd[temb_key].shape[0] >= (64 * 1024): From a57094a3d314e9a4e0c7e87fa7cca987e7bf081c Mon Sep 17 00:00:00 2001 From: City <125218114+city96@users.noreply.github.com> Date: Wed, 17 Dec 2025 15:52:16 +0100 Subject: [PATCH 2/2] Fix for scales being in BF16 The main conversion code shouldn't allow this, but apparently some models still end up with quantized 1D tensors, see #383 --- loader.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/loader.py b/loader.py index 72dd010..096ce9f 100644 --- a/loader.py +++ b/loader.py @@ -119,6 +119,10 @@ def gguf_sd_loader(path, handle_prefix="model.diffusion_model.", return_arch=Fal torch_tensor = torch_tensor.view(*shape) state_dict[sd_key] = GGMLTensor(torch_tensor, tensor_type=tensor.tensor_type, tensor_shape=shape) + # 1D tensors shouldn't be quantized, this is a fix for BF16 + if len(shape) <= 1 and is_quantized(state_dict[sd_key]): + state_dict[sd_key] = dequantize_tensor(state_dict[sd_key], dtype=torch.float32) + # keep track of loaded tensor types tensor_type_str = getattr(tensor.tensor_type, "name", repr(tensor.tensor_type)) qtype_dict[tensor_type_str] = qtype_dict.get(tensor_type_str, 0) + 1