From bfd9b39080c44622c029239a1da964d7edc7d382 Mon Sep 17 00:00:00 2001 From: City <125218114+city96@users.noreply.github.com> Date: Wed, 27 Aug 2025 11:04:22 +0200 Subject: [PATCH] Blind fix for S2V --- tools/convert.py | 6 +++++- tools/lcpp.patch | 14 ++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/tools/convert.py b/tools/convert.py index a62403c..c0fe123 100644 --- a/tools/convert.py +++ b/tools/convert.py @@ -101,7 +101,11 @@ class ModelWan(ModelTemplate): ) ] keys_hiprec = [ - ".modulation" # nn.parameter, can't load from BF16 ver + ".modulation", # nn.parameter, can't load from BF16 ver + ".encoder.padding_tokens", # nn.parameter, specific to S2V + "trainable_cond_mask", # used directly w/ .weight + "casual_audio_encoder.weights", # nn.parameter, specific to S2V + "casual_audio_encoder.encoder.conv", # CausalConv1d doesn't use ops.py for now ] class ModelLTXV(ModelTemplate): diff --git a/tools/lcpp.patch b/tools/lcpp.patch index 49e5971..56e2f8d 100644 --- a/tools/lcpp.patch +++ b/tools/lcpp.patch @@ -39,7 +39,7 @@ index b16c462f..6d1568f1 100644 const int idx = gguf_find_tensor(ctx, name); if (idx < 0) { diff --git a/src/llama.cpp b/src/llama.cpp -index 24e1f1f0..19fdc5df 100644 +index 24e1f1f0..569778fd 100644 --- a/src/llama.cpp +++ b/src/llama.cpp @@ -205,6 +205,18 @@ enum llm_arch { @@ -348,7 +348,7 @@ index 24e1f1f0..19fdc5df 100644 } // Set split info if needed -@@ -18647,6 +18902,118 @@ static void llama_model_quantize_internal(const std::string & fname_inp, const s +@@ -18647,6 +18902,124 @@ static void llama_model_quantize_internal(const std::string & fname_inp, const s // do not quantize relative position bias (T5) quantize &= name.find("attn_rel_b.weight") == std::string::npos; @@ -423,6 +423,12 @@ index 24e1f1f0..19fdc5df 100644 + quantize &= name.find("time_embedding.") == std::string::npos; + quantize &= name.find("img_emb.") == std::string::npos; + quantize &= name.find("head.") == std::string::npos; ++ // S2V ++ quantize &= name.find("cond_encoder.") == std::string::npos; ++ quantize &= name.find("frame_packer.") == std::string::npos; ++ quantize &= name.find("audio_injector.") == std::string::npos; ++ quantize &= name.find("casual_audio_encoder.") == std::string::npos; ++ quantize &= name.find("trainable_cond_mask.") == std::string::npos; + } + if (model.arch == LLM_ARCH_HIDREAM) { + image_model = true; @@ -467,7 +473,7 @@ index 24e1f1f0..19fdc5df 100644 enum ggml_type new_type; void * new_data; size_t new_size; -@@ -18655,6 +19022,9 @@ static void llama_model_quantize_internal(const std::string & fname_inp, const s +@@ -18655,6 +19028,9 @@ static void llama_model_quantize_internal(const std::string & fname_inp, const s new_type = default_type; // get more optimal quantization type based on the tensor shape, layer, etc. @@ -477,7 +483,7 @@ index 24e1f1f0..19fdc5df 100644 if (!params->pure && ggml_is_quantized(default_type)) { new_type = llama_tensor_get_type(qs, new_type, tensor, ftype); } -@@ -18664,6 +19034,7 @@ static void llama_model_quantize_internal(const std::string & fname_inp, const s +@@ -18664,6 +19040,7 @@ static void llama_model_quantize_internal(const std::string & fname_inp, const s if (params->output_tensor_type < GGML_TYPE_COUNT && strcmp(tensor->name, "output.weight") == 0) { new_type = params->output_tensor_type; }