From 242383371b9649081a5fd060277eed3ef054745f Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Fri, 28 Jun 2024 09:02:54 +0200 Subject: [PATCH 1/4] convert-hf : print output file name when completed This commit adds the output file name to the log message when the conversion is completed. The motivation for this change is that when `--outfile` option is not specified it migth not be obvious where the output file is written. With this change the output of running the script will be something like the following: ```console INFO:hf-to-gguf:Model successfully exported to models/gemma-2-9b-it.gguf. ``` Signed-off-by: Daniel Bevenius --- convert-hf-to-gguf.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/convert-hf-to-gguf.py b/convert-hf-to-gguf.py index 5bcc849db999d..3c974ae09056a 100755 --- a/convert-hf-to-gguf.py +++ b/convert-hf-to-gguf.py @@ -3128,11 +3128,11 @@ def main() -> None: if args.vocab_only: logger.info("Exporting model vocab...") model_instance.write_vocab() - logger.info("Model vocab successfully exported.") + logger.info(f"Model vocab successfully exported to {fname_out}.") else: logger.info("Exporting model...") model_instance.write() - logger.info("Model successfully exported.") + logger.info(f"Model successfully exported to {fname_out}.") if __name__ == '__main__': From 6879fb501f1816eecb78c7e1daf741d50f2a0e27 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Sat, 29 Jun 2024 06:26:29 +0200 Subject: [PATCH 2/4] squash! convert-hf : print output file name when completed Updates the output of to support printing the directory if the output is split into multiple files. Also the output file name is now retrieved from the model_instance object. Signed-off-by: Daniel Bevenius --- convert-hf-to-gguf.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/convert-hf-to-gguf.py b/convert-hf-to-gguf.py index 3c974ae09056a..985fbff5dea92 100755 --- a/convert-hf-to-gguf.py +++ b/convert-hf-to-gguf.py @@ -3091,7 +3091,8 @@ def main() -> None: "auto": gguf.LlamaFileType.GUESSED, } - if args.use_temp_file and (args.split_max_tensors > 0 or args.split_max_size != "0"): + is_split = args.split_max_tensors > 0 or args.split_max_size != "0" + if args.use_temp_file and is_split: logger.error("Error: Cannot use temp file when splitting") sys.exit(1) @@ -3128,11 +3129,12 @@ def main() -> None: if args.vocab_only: logger.info("Exporting model vocab...") model_instance.write_vocab() - logger.info(f"Model vocab successfully exported to {fname_out}.") + logger.info(f"Model vocab successfully exported to {model_instance.fname_out}") else: logger.info("Exporting model...") model_instance.write() - logger.info(f"Model successfully exported to {fname_out}.") + out_path = os.path.dirname(model_instance.fname_out) + '/' if is_split else model_instance.fname_out + logger.info(f"Model successfully exported to {out_path}") if __name__ == '__main__': From cd8c573edef93baeafa6f71afffdb310baa0c8f4 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Sat, 29 Jun 2024 09:14:56 +0200 Subject: [PATCH 3/4] squash! convert-hf : print output file name when completed Use parent attribute of Path object and string interpolation. Signed-off-by: Daniel Bevenius --- convert-hf-to-gguf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/convert-hf-to-gguf.py b/convert-hf-to-gguf.py index 985fbff5dea92..f82a7423f8de4 100755 --- a/convert-hf-to-gguf.py +++ b/convert-hf-to-gguf.py @@ -3133,7 +3133,7 @@ def main() -> None: else: logger.info("Exporting model...") model_instance.write() - out_path = os.path.dirname(model_instance.fname_out) + '/' if is_split else model_instance.fname_out + out_path = f"{model_instance.fname_out.parent}/" if is_split else model_instance.fname_out logger.info(f"Model successfully exported to {out_path}") From 49d31f7a626cc203feb5139e39d1e06d51d9d5e0 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Sun, 30 Jun 2024 06:49:30 +0200 Subject: [PATCH 4/4] squash! convert-hf : print output file name when completed Use os.sep instead of hardcoding the path separator. Signed-off-by: Daniel Bevenius --- convert-hf-to-gguf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/convert-hf-to-gguf.py b/convert-hf-to-gguf.py index f82a7423f8de4..b7cc94f63eec5 100755 --- a/convert-hf-to-gguf.py +++ b/convert-hf-to-gguf.py @@ -3133,7 +3133,7 @@ def main() -> None: else: logger.info("Exporting model...") model_instance.write() - out_path = f"{model_instance.fname_out.parent}/" if is_split else model_instance.fname_out + out_path = f"{model_instance.fname_out.parent}{os.sep}" if is_split else model_instance.fname_out logger.info(f"Model successfully exported to {out_path}")