From 909f6be291f6bb3acf6fc2a159b7b066c596e2af Mon Sep 17 00:00:00 2001 From: Jared Van Bortel Date: Thu, 4 Apr 2024 17:14:46 -0400 Subject: [PATCH] convert scripts : fix python 3.8 compatibility --- convert-hf-to-gguf.py | 3 ++- convert-persimmon-to-gguf.py | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/convert-hf-to-gguf.py b/convert-hf-to-gguf.py index cdb1122ac..5955ef739 100755 --- a/convert-hf-to-gguf.py +++ b/convert-hf-to-gguf.py @@ -2311,7 +2311,8 @@ class MambaModel(Model): data = data.astype(np.float32) # if f16 desired, convert big float32 2-dim weight tensors to float16 - if self.ftype == 1 and data_dtype == np.float32 and new_name.removesuffix(".weight").endswith((".ssm_in", ".ssm_out", "token_embd", "output")) and n_dims == 2: + new_weight_name = new_name[:-len(".weight")] if new_name.endswith(".weight") else "" + if self.ftype == 1 and data_dtype == np.float32 and new_weight_name.endswith((".ssm_in", ".ssm_out", "token_embd", "output")) and n_dims == 2: data = data.astype(np.float16) print(f"{new_name}, n_dims = {n_dims}, {old_dtype} --> {data.dtype}") diff --git a/convert-persimmon-to-gguf.py b/convert-persimmon-to-gguf.py index ccb99279e..69be17f94 100755 --- a/convert-persimmon-to-gguf.py +++ b/convert-persimmon-to-gguf.py @@ -1,4 +1,6 @@ #!/usr/bin/env python3 +from __future__ import annotations + import argparse import os import sys