Python
fixes
DeepBeepMeepb7a3c9109832
diff --git a/models/flux/flux_handler.py b/models/flux/flux_handler.pyindex 7561480..beceafb 100644--- a/models/flux/flux_handler.py+++ b/models/flux/flux_handler.py@@ -279,13 +279,8 @@ class family_handler():else:text_encoder_folder = "qwen3_8b"text_encoder_repo = "DeepBeepMeep/Flux2"- text_encoder_name = get_text_encoder_name(base_model_type, None)- tokenizer_files = ["config.json", "generation_config.json", text_encoder_name, "added_tokens.json", "chat_template.jinja", "merges.txt", "special_tokens_map.json", "tokenizer.json", "tokenizer_config.json", "vocab.json"]- if base_model_type == "flux2_klein_4b":- tokenizer_files.append("qwen3_quanto_bf16_int8.safetensors")- if base_model_type == "flux2_klein_9b":- tokenizer_files.append("qwen3_8b_quanto_bf16_int8.safetensors")+ tokenizer_files = ["config.json", "generation_config.json", "added_tokens.json", "chat_template.jinja", "merges.txt", "special_tokens_map.json", "tokenizer.json", "tokenizer_config.json", "vocab.json"]ret = [{@@ -352,15 +347,6 @@ class family_handler():@staticmethoddef load_model(model_filename, model_type, base_model_type, model_def, quantizeTransformer = False, text_encoder_quantization = None, dtype = torch.bfloat16, VAE_dtype = torch.float32, mixed_precision_transformer = False, save_quantized = False, submodel_no_list = None, text_encoder_filename = None):from .flux_main import model_factory- if not text_encoder_filename:- text_encoder_folder = model_def.get("text_encoder_folder")- text_encoder_name = get_text_encoder_name(base_model_type, text_encoder_quantization)- if base_model_type in ["flux2_klein_4b", "flux2_klein_9b"] and text_encoder_folder:- text_encoder_filename = fl.locate_file(os.path.join(text_encoder_folder, text_encoder_name))- elif text_encoder_folder:- text_encoder_filename = fl.locate_file(os.path.join(text_encoder_folder, text_encoder_name))- else:- text_encoder_filename = fl.locate_file(text_encoder_name)flux_model = model_factory(checkpoint_dir="ckpts",diff --git a/models/z_image/z_image_main.py b/models/z_image/z_image_main.pyindex 42975bc..cef551c 100644--- a/models/z_image/z_image_main.py+++ b/models/z_image/z_image_main.py@@ -20,6 +20,8 @@ def conv_state_dict(sd: dict) -> dict:if "x_embedder.weight" not in sd and "model.diffusion_model.x_embedder.weight" not in sd:return sd+ from shared.qtypes.gguf import GGUFSourceTensor+inverse_replace = {"final_layer.": "all_final_layer.2-1.","x_embedder.": "all_x_embedder.2-1.",@@ -37,13 +39,23 @@ def conv_state_dict(sd: dict) -> dict:if key.endswith(".attention.qkv.weight"):base = key[: -len(".attention.qkv.weight")]- total_dim = tensor.shape[0]+ orig_shape = getattr(tensor, "tensor_shape", None)+ total_dim = orig_shape[0] if orig_shape is not None else tensor.shape[0]if total_dim % 3 != 0:raise ValueError(f"{key}: qkv first dimension ({total_dim}) not divisible by 3")d = total_dim // 3- q, k_w, v = torch.split(tensor, d, dim=0)+ if isinstance(tensor, GGUFSourceTensor) or getattr(tensor, "tensor_type", None) is not None:+ chunks = torch.split(tensor, d, dim=0)+ tensor_type = getattr(tensor, "tensor_type", None)+ tensor_shape = (d, orig_shape[1]) if orig_shape is not None else (d, tensor.shape[1])+ q, k_w, v = [+ GGUFSourceTensor.wrap(chunk, tensor_type=tensor_type, tensor_shape=tensor_shape)+ for chunk in chunks+ ]+ else:+ q, k_w, v = torch.split(tensor, d, dim=0)out_sd[base + ".attention.to_q.weight"] = qout_sd[base + ".attention.to_k.weight"] = k_wdiff --git a/shared/qtypes/gguf.py b/shared/qtypes/gguf.pyindex b374cac..6e5ab58 100644--- a/shared/qtypes/gguf.py+++ b/shared/qtypes/gguf.py@@ -903,7 +903,7 @@ class QLinearGGUF(QModuleMixin, torch.nn.Linear):self.weight = torch.nn.Parameter(gguf_weight, requires_grad=False)if bias is not None:- self.bias = torch.nn.Parameter(bias)+ self.bias = torch.nn.Parameter(bias, requires_grad=False)if torch.is_tensor(weight_raw):scale_device = weight_raw.device