From 4b3ae022a94f2bb4bedb5ff663501f30d7fd8f61 Mon Sep 17 00:00:00 2001 From: Richi <97880342+Hansehart@users.noreply.github.com> Date: Wed, 16 Apr 2025 09:17:25 +0200 Subject: [PATCH] fix: improved error handling when llama.cpp build fails --- unsloth/save.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/unsloth/save.py b/unsloth/save.py index b8da9c08d0..8280ed6529 100644 --- a/unsloth/save.py +++ b/unsloth/save.py @@ -887,11 +887,15 @@ def install_llama_cpp_old(version = -10): os.path.exists("llama.cpp/llama-quantize.exe") or os.path.exists("llama.cpp/llama-quantize") or os.path.exists("llama.cpp/quantize.exe") or - os.path.exists("llama.cpp/quantize") + os.path.exists("llama.cpp/quantize") or + os.path.exists("llama.cpp/build/bin/llama-quantize") or + os.path.exists("llama.cpp/build/bin/quantize") or + os.path.exists() ): raise RuntimeError( "Unsloth: The file 'llama.cpp/llama-quantize' or `llama.cpp/quantize` does not exist.\n"\ - "But we expect this file to exist! Maybe the llama.cpp developers changed the name or check extension of the llama-quantize file." + "We've also double checked the building directory under 'llama.cpp/build/bin/'.\n"\ + "But we expect this file to exist! Check if the file exists under llama.cp and investigate the building process of llama.cpp (make/cmake)" ) pass pass @@ -1081,11 +1085,16 @@ def save_to_gguf( quantize_location = "llama.cpp/llama-quantize.exe" elif os.path.exists("llama.cpp/llama-quantize"): quantize_location = "llama.cpp/llama-quantize" + elif os.path.exists("llama.cpp/build/bin/llama-quantize"): + quantize_location = "llama.cpp/build/bin/llama-quantize" + elif os.path.exists("llama.cpp/build/bin/quantize"): + quantize_location = "llama.cpp/build/bin/quantize" else: - raise RuntimeError( - "Unsloth: The file ('llama.cpp/llama-quantize' or 'llama.cpp/llama-quantize.exe' if you are on Windows WSL) or 'llama.cpp/quantize' does not exist.\n"\ - "But we expect this file to exist! Maybe the llama.cpp developers changed the name or check extension of the llama-quantize file." - ) + raise RuntimeError( + "Unsloth: The file 'llama.cpp/llama-quantize' or `llama.cpp/quantize` does not exist.\n"\ + "We've also double checked the building directory under 'llama.cpp/build/bin/'.\n"\ + "But we expect this file to exist! Check if the file exists under llama.cp and investigate the building process of llama.cpp (make/cmake)" + ) pass # See https://github.com/unslothai/unsloth/pull/730