From 6454855ae3359754659af9ee8e5ff507f7af8055 Mon Sep 17 00:00:00 2001 From: ostix360 <55257054+ostix360@users.noreply.github.com> Date: Tue, 25 Apr 2023 17:33:52 +0200 Subject: [PATCH] Update convert-lora-to-ggml.py Co-authored-by: Pavol Rusnak --- convert-lora-to-ggml.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/convert-lora-to-ggml.py b/convert-lora-to-ggml.py index 01c1665bb..3f37c597e 100644 --- a/convert-lora-to-ggml.py +++ b/convert-lora-to-ggml.py @@ -49,7 +49,12 @@ def translate_tensor_name(t: str) -> str: def write_file_header(fout: TextIO, params: Dict[str, Any]) -> None: fout.write(b"ggla"[::-1]) # magic (ggml lora) fout.write(struct.pack("i", 1)) # file version - fout.write(struct.pack("ii", params["r"], int(params["lora_alpha"]))) + fout.write(struct.pack("i", params["r"]) + # https://opendelta.readthedocs.io/en/latest/modules/deltas.html says that `lora_alpha` is an int + # but some models ship a float value instead + # let's convert to int, but fail if lossless conversion is not possible + assert int(lora_alpha) == lora_alpha, "cannot convert float to int losslessly" + fout.write(struct.pack("i", int(params["lora_alpha"]))) def write_tensor_header(