Skip to content

Commit 4bfe002

Browse files
committed
refactor: removed dead code from save_model_llama_cpp in save.py
1 parent 3535735 commit 4bfe002

2 files changed

Lines changed: 1 addition & 21 deletions

File tree

src/pruna/algorithms/llama_cpp.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,10 @@ def _load_quantized_model(self, llama_cpp: Any, quant_gguf_path: Path, smash_con
193193
n_gpu_layers=n_gpu_layers,
194194
main_gpu=smash_config["main_gpu"],
195195
)
196-
quantized_model._pruna_temp_dir = str(temp_dir)
197196
quantized_model.model_path = str(quant_gguf_path)
198197
quantized_model._pruna_device = smash_config["device"]
199198
return quantized_model
200199

201-
202200
def _get_cache_paths(
203201
self, model: Any, smash_config: SmashConfigPrefixWrapper, q_method: str
204202
) -> tuple[Path, Path, Path]:

src/pruna/engine/save.py

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -489,25 +489,7 @@ def save_model_llama_cpp(model: Any, model_path: str | Path, smash_config: Smash
489489
if gguf_file.exists():
490490
target_file = model_path / "model.gguf"
491491
if gguf_file.resolve() != target_file.resolve():
492-
if (
493-
hasattr(model, "_pruna_temp_dir")
494-
and Path(model._pruna_temp_dir).resolve() == gguf_file.parent.resolve()
495-
):
496-
try:
497-
shutil.move(gguf_file, target_file)
498-
shutil.rmtree(model._pruna_temp_dir)
499-
delattr(model, "_pruna_temp_dir")
500-
except PermissionError:
501-
pruna_logger.warning(
502-
f"Could not move GGUF file from {gguf_file} to {target_file} "
503-
"(likely memory-mapped on Windows). "
504-
"Copying instead, but the temporary directory will persist "
505-
"until process exit."
506-
)
507-
shutil.copy(gguf_file, target_file)
508-
else:
509-
shutil.copy(gguf_file, target_file)
510-
492+
shutil.copy(gguf_file, target_file)
511493
model.model_path = str(target_file)
512494
smash_config.load_fns.append(LOAD_FUNCTIONS.llama_cpp.name)
513495
else:

0 commit comments

Comments
 (0)