From d09382fac7ec9eafa8b94c656ec55feb250e4bee Mon Sep 17 00:00:00 2001 From: Francis Couture-Harpin Date: Mon, 15 Jul 2024 11:39:42 -0400 Subject: [PATCH] convert_hf : move add_type to main() * convert_lora : use the GGUFWriter from Model instead of overwriting it --- convert_hf_to_gguf.py | 2 +- convert_lora_to_gguf.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/convert_hf_to_gguf.py b/convert_hf_to_gguf.py index ecf5aa234..a755b0a60 100755 --- a/convert_hf_to_gguf.py +++ b/convert_hf_to_gguf.py @@ -99,7 +99,6 @@ class Model: self.fname_out = fname_out.parent / fname_out.name.format(ftype_lw, outtype=ftype_lw, ftype=ftype_lw, OUTTYPE=ftype_up, FTYPE=ftype_up) self.gguf_writer = gguf.GGUFWriter(path=None, arch=gguf.MODEL_ARCH_NAMES[self.model_arch], endianess=self.endianess, use_temp_file=self.use_temp_file, split_max_tensors=split_max_tensors, split_max_size=split_max_size, dry_run=dry_run, small_first_shard=small_first_shard) - self.gguf_writer.add_type(gguf.GGUFType.MODEL) @classmethod def __init_subclass__(cls): @@ -3575,6 +3574,7 @@ def main() -> None: small_first_shard=args.no_tensor_first_split) logger.info("Set model parameters") + model_instance.gguf_writer.add_type(gguf.GGUFType.MODEL) model_instance.set_gguf_parameters() logger.info("Set model tokenizer") diff --git a/convert_lora_to_gguf.py b/convert_lora_to_gguf.py index bfd252d2e..4bb939d45 100755 --- a/convert_lora_to_gguf.py +++ b/convert_lora_to_gguf.py @@ -365,7 +365,6 @@ if __name__ == '__main__': alpha = lparams["lora_alpha"] - model_instance.gguf_writer = gguf.GGUFWriter(path=None, arch=gguf.MODEL_ARCH_NAMES[model_instance.model_arch]) model_instance.gguf_writer.add_string(gguf.Keys.General.TYPE, gguf.GGUFType.ADAPTER) model_instance.gguf_writer.add_string(gguf.Keys.Adapter.TYPE, "lora") model_instance.gguf_writer.add_float32(gguf.Keys.Adapter.LORA_ALPHA, float(alpha))