Skip to content

Commit

Permalink
add safetensors support to convert-lora-to-ggml.py (ggerganov#5062)
Browse files Browse the repository at this point in the history
* add safetensors support to convert-lora-to-ggml.py

* Update convert-lora-to-ggml.py

Remove white space in line 69.
  • Loading branch information
kuronekosaiko authored Jan 21, 2024
1 parent 6c5629d commit 05490fa
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion convert-lora-to-ggml.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,14 @@ def write_tensor_header(fout: BinaryIO, name: str, shape: Sequence[int], data_ty
input_model = os.path.join(sys.argv[1], "adapter_model.bin")
output_path = os.path.join(sys.argv[1], "ggml-adapter-model.bin")

model = torch.load(input_model, map_location="cpu")
if os.path.exists(input_model):
model = torch.load(input_model, map_location="cpu")
else:
input_model = os.path.join(sys.argv[1], "adapter_model.safetensors")
# lazy import load_file only if lora is in safetensors format.
from safetensors.torch import load_file
model = load_file(input_model, device="cpu")

arch_name = sys.argv[2] if len(sys.argv) == 3 else "llama"

if arch_name not in gguf.MODEL_ARCH_NAMES.values():
Expand Down

0 comments on commit 05490fa

Please sign in to comment.