From 9d0a0e317e999f79d3758b832ef04be0bb8a1346 Mon Sep 17 00:00:00 2001 From: City <125218114+city96@users.noreply.github.com> Date: Fri, 7 Mar 2025 22:37:17 +0100 Subject: [PATCH] ltxv bf16 fix scale shift table loads into nn.parameter, which can't work with BF16 --- tools/convert.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/convert.py b/tools/convert.py index 6a90960..480de37 100644 --- a/tools/convert.py +++ b/tools/convert.py @@ -17,6 +17,7 @@ class ModelTemplate: shape_fix = False # whether to reshape tensors keys_detect = [] # list of lists to match in state dict keys_banned = [] # list of keys that should mark model as invalid for conversion + keys_hiprec = [] # list of keys that need to be kept in fp32 for some reason def handle_nd_tensor(self, key, data): raise NotImplementedError(f"Tensor detected that exceeds dims supported by C++ code! ({key} @ {data.shape})") @@ -82,6 +83,9 @@ class ModelLTXV(ModelTemplate): "caption_projection.linear_2.weight", ) ] + keys_hiprec = [ + "scale_shift_table" # nn.parameter, can't load from BF16 base quant + ] class ModelSDXL(ModelTemplate): arch = "sdxl" @@ -227,6 +231,10 @@ def handle_tensors(writer, state_dict, model_arch): # very small tensors data_qtype = gguf.GGMLQuantizationType.F32 + elif any(x in key for x in model_arch.keys_hiprec): + # tensors that require max precision + data_qtype = gguf.GGMLQuantizationType.F32 + if (model_arch.shape_fix # NEVER reshape for models such as flux and n_dims > 1 # Skip one-dimensional tensors and n_params >= REARRANGE_THRESHOLD # Only rearrange tensors meeting the size requirement