Update save.py

This commit is contained in:
Daniel Han 2024-10-20 01:52:21 -07:00
commit 1f52468fa3

View file

@ -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(