support more t5 quants (#1482)

lets hope this is the last time that people randomly invent new state dict key formats
This commit is contained in:
lllyasviel
2024-08-24 12:47:49 -07:00
committed by GitHub
parent 0f3309eb3d
commit f82029c5cf
4 changed files with 73 additions and 33 deletions

View File

@@ -151,3 +151,18 @@ def get_state_dict_after_quant(model, prefix=''):
sd = model.state_dict()
sd = {(prefix + k): v.clone() for k, v in sd.items()}
return sd
def beautiful_print_gguf_state_dict_statics(state_dict):
from gguf.constants import GGMLQuantizationType
type_counts = {}
for k, v in state_dict.items():
gguf_type = getattr(v, 'gguf_type', None)
if gguf_type is not None:
type_name = GGMLQuantizationType(gguf_type).name
if type_name in type_counts:
type_counts[type_name] += 1
else:
type_counts[type_name] = 1
print(f'GGUF state dict: {type_counts}')
return