From a51a84f62d2f7cc2d3363ff20caad0580079e17e Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Sun, 20 Oct 2024 01:52:21 -0700 Subject: [PATCH] Update save.py --- unsloth/save.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/unsloth/save.py b/unsloth/save.py index 0381ab7ee2..ab30e0fea5 100644 --- a/unsloth/save.py +++ b/unsloth/save.py @@ -1181,7 +1181,10 @@ def save_to_gguf( pass pass - return all_saved_locations + # Finally check if first_conversion (f16, bf16 etc) was in the list of actual quant methods + full_precision_seen = first_conversion in frozenset(quantization_method) + + return all_saved_locations, full_precision_seen pass @@ -1659,7 +1662,8 @@ def unsloth_save_pretrained_gguf( is_sentencepiece_model = check_if_sentencepiece_model(self) # Save to GGUF - all_file_locations = save_to_gguf(model_type, model_dtype, is_sentencepiece_model, + all_file_locations, want_full_precision = save_to_gguf( + model_type, model_dtype, is_sentencepiece_model, new_save_directory, quantization_method, first_conversion, makefile, ) @@ -1684,6 +1688,9 @@ def unsloth_save_pretrained_gguf( if push_to_hub: print("Unsloth: Uploading GGUF to Huggingface Hub...") + # If not needing full precision, skip the first + if not want_full_precision: all_file_locations = all_file_locations[1:] + for file_location in all_file_locations: username = upload_to_huggingface( self, save_directory, token, @@ -1833,7 +1840,8 @@ def unsloth_push_to_hub_gguf( is_sentencepiece_model = check_if_sentencepiece_model(self) # Save to GGUF - all_file_locations = save_to_gguf(model_type, model_dtype, is_sentencepiece_model, + all_file_locations, want_full_precision = save_to_gguf( + model_type, model_dtype, is_sentencepiece_model, new_save_directory, quantization_method, first_conversion, makefile, ) @@ -1848,6 +1856,9 @@ def unsloth_push_to_hub_gguf( print(f"Unsloth: Saved Ollama Modelfile to {modelfile_location}") pass + # If not needing full precision, skip the first + if not want_full_precision: all_file_locations = all_file_locations[1:] + for file_location in all_file_locations: print("Unsloth: Uploading GGUF to Huggingface Hub...") username = upload_to_huggingface(