Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Remove the no-op rmtree guard around the GGUF save (#7479)
Vineeth Sai Varikuntla274f5ff56928
diff --git a/unsloth/models/sentence_transformer.py b/unsloth/models/sentence_transformer.pyindex 990521677d1..1482c2a6f8a 100644--- a/unsloth/models/sentence_transformer.py+++ b/unsloth/models/sentence_transformer.py@@ -186,32 +186,23 @@ def _save_pretrained_gguf(if tokenizer is None:tokenizer = self.tokenizer- # 4. Patch environment so Unsloth treats this embedding model correctly- @contextlib.contextmanager- def patch_unsloth_gguf_save():- # Prevent deletion of the directory self.save_pretrained just created- original_rmtree = shutil.rmtree- try:- yield- finally:- shutil.rmtree = original_rmtree-- # 5. Call Unsloth's GGUF saver on the inner model targeting the transformer subdirectory- with patch_unsloth_gguf_save():- result = unsloth_save_pretrained_gguf(- inner_model,- save_directory = transformer_dir,- tokenizer = tokenizer,- quantization_method = quantization_method,- first_conversion = first_conversion,- push_to_hub = False, # Force local first to move files- token = token,- max_shard_size = max_shard_size,- temporary_location = temporary_location,- maximum_memory_usage = maximum_memory_usage,- )-- # 6. Move GGUF files from the subdirectory (0_Transformer) to the root save_directory+ # 4. Call Unsloth's GGUF saver on the inner model targeting the transformer subdirectory+ # No rmtree guard here: the merge cleanup that deletes save_directory is gated on+ # push_to_hub, which is forced False below.+ result = unsloth_save_pretrained_gguf(+ inner_model,+ save_directory = transformer_dir,+ tokenizer = tokenizer,+ quantization_method = quantization_method,+ first_conversion = first_conversion,+ push_to_hub = False, # Force local first to move files+ token = token,+ max_shard_size = max_shard_size,+ temporary_location = temporary_location,+ maximum_memory_usage = maximum_memory_usage,+ )++ # 5. Move GGUF files from the subdirectory (0_Transformer) to the root save_directorygguf_files = result.get("gguf_files", [])new_gguf_locations = []@@ -241,7 +232,7 @@ def _save_pretrained_gguf(result["gguf_files"] = new_gguf_locations- # 7. Add branding+ # 6. Add brandingtry:FastSentenceTransformer._add_unsloth_branding(save_directory)@@ -256,7 +247,7 @@ def _save_pretrained_gguf(except:pass- # 8. Handle Push to Hub if requested+ # 7. Handle Push to Hub if requestedif push_to_hub:if token is None:token = get_token()